HTMLCanvasElement.h [plain text]
#ifndef HTMLCanvasElement_h
#define HTMLCanvasElement_h
#include "CanvasSurface.h"
#include "FloatRect.h"
#include "HTMLElement.h"
#if ENABLE(3D_CANVAS)
#include "GraphicsContext3D.h"
#endif
#include "IntSize.h"
namespace WebCore {
class CanvasContextAttributes;
class CanvasRenderingContext;
class GraphicsContext;
class HTMLCanvasElement;
class IntSize;
class CanvasObserver {
public:
virtual ~CanvasObserver() { }
virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect) = 0;
virtual void canvasResized(HTMLCanvasElement*) = 0;
virtual void canvasDestroyed(HTMLCanvasElement*) = 0;
};
class HTMLCanvasElement : public HTMLElement, public CanvasSurface {
public:
HTMLCanvasElement(const QualifiedName&, Document*);
virtual ~HTMLCanvasElement();
void setWidth(int);
void setHeight(int);
CanvasRenderingContext* getContext(const String&, CanvasContextAttributes* attributes = 0);
void setSize(const IntSize& newSize)
{
if (newSize == size())
return;
m_ignoreReset = true;
setWidth(newSize.width());
setHeight(newSize.height());
m_ignoreReset = false;
reset();
}
virtual void willDraw(const FloatRect&);
void paint(GraphicsContext*, const IntRect&);
void addObserver(CanvasObserver*);
void removeObserver(CanvasObserver*);
CanvasRenderingContext* renderingContext() const { return m_context.get(); }
RenderBox* renderBox() const { return HTMLElement::renderBox(); }
RenderStyle* computedStyle() { return HTMLElement::computedStyle(); }
#if ENABLE(3D_CANVAS)
bool is3D() const;
#endif
private:
#if ENABLE(DASHBOARD_SUPPORT)
virtual HTMLTagStatus endTagRequirement() const;
virtual int tagPriority() const;
#endif
virtual void parseMappedAttribute(MappedAttribute*);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual void attach();
virtual void recalcStyle(StyleChange);
virtual void createdImageBuffer(size_t) const;
void reset();
bool m_rendererIsCanvas;
OwnPtr<CanvasRenderingContext> m_context;
HashSet<CanvasObserver*> m_observers;
bool m_ignoreReset;
FloatRect m_dirtyRect;
};
}
#endif