#ifndef CSSCrossfadeValue_h
#define CSSCrossfadeValue_h
#include "core/css/CSSImageGeneratorValue.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/fetch/ImageResource.h"
#include "core/fetch/ImageResourceClient.h"
#include "core/fetch/ResourcePtr.h"
#include "platform/graphics/Image.h"
namespace WebCore {
class ImageResource;
class CrossfadeSubimageObserverProxy;
class RenderObject;
class Document;
class CSSCrossfadeValue : public CSSImageGeneratorValue {
friend class CrossfadeSubimageObserverProxy;
public:
static PassRefPtrWillBeRawPtr<CSSCrossfadeValue> create(PassRefPtrWillBeRawPtr<CSSValue> fromValue, PassRefPtrWillBeRawPtr<CSSValue> toValue)
{
return adoptRefWillBeRefCountedGarbageCollected(new CSSCrossfadeValue(fromValue, toValue));
}
~CSSCrossfadeValue();
String customCSSText() const;
PassRefPtr<Image> image(RenderObject*, const IntSize&);
bool isFixedSize() const { return true; }
IntSize fixedSize(const RenderObject*);
bool isPending() const;
bool knownToBeOpaque(const RenderObject*) const;
void loadSubimages(ResourceFetcher*);
void setPercentage(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> percentageValue) { m_percentageValue = percentageValue; }
bool hasFailedOrCanceledSubresources() const;
bool equals(const CSSCrossfadeValue&) const;
void traceAfterDispatch(Visitor*);
private:
CSSCrossfadeValue(PassRefPtrWillBeRawPtr<CSSValue> fromValue, PassRefPtrWillBeRawPtr<CSSValue> toValue)
: CSSImageGeneratorValue(CrossfadeClass)
, m_fromValue(fromValue)
, m_toValue(toValue)
, m_cachedFromImage(0)
, m_cachedToImage(0)
, m_crossfadeSubimageObserver(this) { }
class CrossfadeSubimageObserverProxy FINAL : public ImageResourceClient {
public:
CrossfadeSubimageObserverProxy(CSSCrossfadeValue* ownerValue)
: m_ownerValue(ownerValue)
, m_ready(false) { }
virtual ~CrossfadeSubimageObserverProxy() { }
virtual void imageChanged(ImageResource*, const IntRect* = 0) OVERRIDE;
void setReady(bool ready) { m_ready = ready; }
private:
CSSCrossfadeValue* m_ownerValue;
bool m_ready;
};
void crossfadeChanged(const IntRect&);
RefPtrWillBeMember<CSSValue> m_fromValue;
RefPtrWillBeMember<CSSValue> m_toValue;
RefPtrWillBeMember<CSSPrimitiveValue> m_percentageValue;
ResourcePtr<ImageResource> m_cachedFromImage;
ResourcePtr<ImageResource> m_cachedToImage;
RefPtr<Image> m_generatedImage;
CrossfadeSubimageObserverProxy m_crossfadeSubimageObserver;
};
DEFINE_CSS_VALUE_TYPE_CASTS(CSSCrossfadeValue, isCrossfadeValue());
}
#endif