OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 virtual void canvasResized(HTMLCanvasElement*) = 0; | 58 virtual void canvasResized(HTMLCanvasElement*) = 0; |
59 virtual void canvasDestroyed(HTMLCanvasElement*) = 0; | 59 virtual void canvasDestroyed(HTMLCanvasElement*) = 0; |
60 }; | 60 }; |
61 | 61 |
62 class HTMLCanvasElement : public HTMLElement { | 62 class HTMLCanvasElement : public HTMLElement { |
63 public: | 63 public: |
64 static PassRefPtr<HTMLCanvasElement> create(Document*); | 64 static PassRefPtr<HTMLCanvasElement> create(Document*); |
65 static PassRefPtr<HTMLCanvasElement> create(const QualifiedName&, Document*)
; | 65 static PassRefPtr<HTMLCanvasElement> create(const QualifiedName&, Document*)
; |
66 virtual ~HTMLCanvasElement(); | 66 virtual ~HTMLCanvasElement(); |
67 | 67 |
68 void setObserver(CanvasObserver* observer) { m_observer = observer; } | 68 void addObserver(CanvasObserver* observer); |
| 69 void removeObserver(CanvasObserver* observer); |
69 | 70 |
70 // Attributes and functions exposed to script | 71 // Attributes and functions exposed to script |
71 int width() const { return size().width(); } | 72 int width() const { return size().width(); } |
72 int height() const { return size().height(); } | 73 int height() const { return size().height(); } |
73 | 74 |
74 const IntSize& size() const { return m_size; } | 75 const IntSize& size() const { return m_size; } |
75 | 76 |
76 void setWidth(int); | 77 void setWidth(int); |
77 void setHeight(int); | 78 void setHeight(int); |
78 | 79 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 132 |
132 virtual void recalcStyle(StyleChange); | 133 virtual void recalcStyle(StyleChange); |
133 | 134 |
134 void reset(); | 135 void reset(); |
135 | 136 |
136 void createImageBuffer() const; | 137 void createImageBuffer() const; |
137 | 138 |
138 void setSurfaceSize(const IntSize&); | 139 void setSurfaceSize(const IntSize&); |
139 bool hasCreatedImageBuffer() const { return m_hasCreatedImageBuffer; } | 140 bool hasCreatedImageBuffer() const { return m_hasCreatedImageBuffer; } |
140 | 141 |
141 CanvasObserver* m_observer; | 142 HashSet<CanvasObserver*> m_observers; |
142 | 143 |
143 IntSize m_size; | 144 IntSize m_size; |
144 | 145 |
145 OwnPtr<CanvasRenderingContext> m_context; | 146 OwnPtr<CanvasRenderingContext> m_context; |
146 | 147 |
147 bool m_rendererIsCanvas; | 148 bool m_rendererIsCanvas; |
148 | 149 |
149 bool m_ignoreReset; | 150 bool m_ignoreReset; |
150 FloatRect m_dirtyRect; | 151 FloatRect m_dirtyRect; |
151 | 152 |
152 float m_pageScaleFactor; | 153 float m_pageScaleFactor; |
153 bool m_originClean; | 154 bool m_originClean; |
154 | 155 |
155 // m_createdImageBuffer means we tried to malloc the buffer. We didn't nece
ssarily get it. | 156 // m_createdImageBuffer means we tried to malloc the buffer. We didn't nece
ssarily get it. |
156 mutable bool m_hasCreatedImageBuffer; | 157 mutable bool m_hasCreatedImageBuffer; |
157 mutable OwnPtr<ImageBuffer> m_imageBuffer; | 158 mutable OwnPtr<ImageBuffer> m_imageBuffer; |
158 | 159 |
159 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor
ms that have to copy the image buffer to render (and for CSSCanvasValue). | 160 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor
ms that have to copy the image buffer to render (and for CSSCanvasValue). |
160 }; | 161 }; |
161 | 162 |
162 } //namespace | 163 } //namespace |
163 | 164 |
164 #endif | 165 #endif |
OLD | NEW |