#ifndef CSSCanvasValue_h
#define CSSCanvasValue_h
#include "CSSImageGeneratorValue.h"
#include "HTMLCanvasElement.h"
namespace WebCore {
class Document;
class CSSCanvasValue : public CSSImageGeneratorValue {
public:
static PassRefPtr<CSSCanvasValue> create(const String& name) { return adoptRef(new CSSCanvasValue(name)); }
~CSSCanvasValue();
String customCssText() const;
PassRefPtr<Image> image(RenderObject*, const IntSize&);
bool isFixedSize() const { return true; }
IntSize fixedSize(const RenderObject*);
bool isPending() const { return false; }
void loadSubimages(CachedResourceLoader*) { }
bool equals(const CSSCanvasValue&) const;
private:
CSSCanvasValue(const String& name)
: CSSImageGeneratorValue(CanvasClass)
, m_canvasObserver(this)
, m_name(name)
, m_element(0)
{
}
class CanvasObserverProxy : public CanvasObserver {
public:
CanvasObserverProxy(CSSCanvasValue* ownerValue) : m_ownerValue(ownerValue) { }
virtual ~CanvasObserverProxy() { }
virtual void canvasChanged(HTMLCanvasElement* canvas, const FloatRect& changedRect)
{
m_ownerValue->canvasChanged(canvas, changedRect);
}
virtual void canvasResized(HTMLCanvasElement* canvas)
{
m_ownerValue->canvasResized(canvas);
}
virtual void canvasDestroyed(HTMLCanvasElement* canvas)
{
m_ownerValue->canvasDestroyed(canvas);
}
private:
CSSCanvasValue* m_ownerValue;
};
void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect);
void canvasResized(HTMLCanvasElement*);
void canvasDestroyed(HTMLCanvasElement*);
HTMLCanvasElement* element(Document*);
CanvasObserverProxy m_canvasObserver;
String m_name;
HTMLCanvasElement* m_element;
};
}
#endif // CSSCanvasValue_h