Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #ifndef HTMLCanvasElement_h | 28 #ifndef HTMLCanvasElement_h |
| 29 #define HTMLCanvasElement_h | 29 #define HTMLCanvasElement_h |
| 30 | 30 |
| 31 #include "core/html/HTMLElement.h" | 31 #include "core/html/HTMLElement.h" |
| 32 #include "core/html/canvas/CanvasImageSource.h" | |
| 32 #include "platform/geometry/FloatRect.h" | 33 #include "platform/geometry/FloatRect.h" |
| 33 #include "platform/geometry/IntSize.h" | 34 #include "platform/geometry/IntSize.h" |
| 34 #include "platform/graphics/Canvas2DLayerBridge.h" | 35 #include "platform/graphics/Canvas2DLayerBridge.h" |
| 35 #include "wtf/Forward.h" | 36 #include "wtf/Forward.h" |
| 36 | 37 |
| 37 #define DefaultInterpolationQuality InterpolationMedium | 38 #define DefaultInterpolationQuality InterpolationMedium |
| 38 | 39 |
| 39 namespace WebCore { | 40 namespace WebCore { |
| 40 | 41 |
| 41 class AffineTransform; | 42 class AffineTransform; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 52 | 53 |
| 53 class CanvasObserver { | 54 class CanvasObserver { |
| 54 public: | 55 public: |
| 55 virtual ~CanvasObserver() { } | 56 virtual ~CanvasObserver() { } |
| 56 | 57 |
| 57 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect) = 0; | 58 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect) = 0; |
| 58 virtual void canvasResized(HTMLCanvasElement*) = 0; | 59 virtual void canvasResized(HTMLCanvasElement*) = 0; |
| 59 virtual void canvasDestroyed(HTMLCanvasElement*) = 0; | 60 virtual void canvasDestroyed(HTMLCanvasElement*) = 0; |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 class HTMLCanvasElement FINAL : public HTMLElement, public DocumentVisibilityObs erver { | 63 class HTMLCanvasElement FINAL : public HTMLElement, public DocumentVisibilityObs erver, public CanvasImageSource { |
| 63 public: | 64 public: |
| 64 static PassRefPtr<HTMLCanvasElement> create(Document&); | 65 static PassRefPtr<HTMLCanvasElement> create(Document&); |
| 65 virtual ~HTMLCanvasElement(); | 66 virtual ~HTMLCanvasElement(); |
| 66 | 67 |
| 67 void addObserver(CanvasObserver*); | 68 void addObserver(CanvasObserver*); |
| 68 void removeObserver(CanvasObserver*); | 69 void removeObserver(CanvasObserver*); |
| 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(); } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 void ensureUnacceleratedImageBuffer(); | 110 void ensureUnacceleratedImageBuffer(); |
| 110 ImageBuffer* buffer() const; | 111 ImageBuffer* buffer() const; |
| 111 Image* copiedImage() const; | 112 Image* copiedImage() const; |
| 112 void clearCopiedImage(); | 113 void clearCopiedImage(); |
| 113 PassRefPtr<ImageData> getImageData(); | 114 PassRefPtr<ImageData> getImageData(); |
| 114 void makePresentationCopy(); | 115 void makePresentationCopy(); |
| 115 void clearPresentationCopy(); | 116 void clearPresentationCopy(); |
| 116 | 117 |
| 117 SecurityOrigin* securityOrigin() const; | 118 SecurityOrigin* securityOrigin() const; |
| 118 void setOriginTainted() { m_originClean = false; } | 119 void setOriginTainted() { m_originClean = false; } |
| 119 bool originClean() const { return m_originClean; } | 120 virtual bool originClean() const { return m_originClean; } |
|
Stephen White
2014/03/06 16:06:17
Nit: is this still necessary?
| |
| 120 | 121 |
| 121 AffineTransform baseTransform() const; | 122 AffineTransform baseTransform() const; |
| 122 | 123 |
| 123 bool is3D() const; | 124 bool is3D() const; |
| 124 | 125 |
| 125 bool hasImageBuffer() const { return m_imageBuffer.get(); } | 126 bool hasImageBuffer() const { return m_imageBuffer.get(); } |
| 126 | 127 |
| 127 bool shouldAccelerate(const IntSize&) const; | 128 bool shouldAccelerate(const IntSize&) const; |
| 128 | 129 |
| 129 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; | 130 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; |
| 130 | 131 |
| 131 // DocumentVisibilityObserver implementation | 132 // DocumentVisibilityObserver implementation |
| 132 virtual void didChangeVisibilityState(PageVisibilityState) OVERRIDE; | 133 virtual void didChangeVisibilityState(PageVisibilityState) OVERRIDE; |
| 133 | 134 |
| 135 // CanvasImageSource implementation | |
| 136 virtual PassRefPtr<Image> getSourceImageForCanvas(ExceptionState&, CanvasIma geSourceUsage, bool* isVolatile) const OVERRIDE; | |
| 137 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE; | |
| 138 virtual FloatSize sourceSize() const OVERRIDE; | |
| 139 | |
| 134 protected: | 140 protected: |
| 135 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; | 141 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; |
| 136 | 142 |
| 137 private: | 143 private: |
| 138 explicit HTMLCanvasElement(Document&); | 144 explicit HTMLCanvasElement(Document&); |
| 139 | 145 |
| 140 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE; | 146 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE; |
| 141 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; | 147 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; |
| 142 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } | 148 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } |
| 143 | 149 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 OwnPtr<ImageBuffer> m_imageBuffer; | 183 OwnPtr<ImageBuffer> m_imageBuffer; |
| 178 mutable OwnPtr<GraphicsContextStateSaver> m_contextStateSaver; | 184 mutable OwnPtr<GraphicsContextStateSaver> m_contextStateSaver; |
| 179 | 185 |
| 180 mutable RefPtr<Image> m_presentedImage; | 186 mutable RefPtr<Image> m_presentedImage; |
| 181 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor ms that have to copy the image buffer to render (and for CSSCanvasValue). | 187 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor ms that have to copy the image buffer to render (and for CSSCanvasValue). |
| 182 }; | 188 }; |
| 183 | 189 |
| 184 } //namespace | 190 } //namespace |
| 185 | 191 |
| 186 #endif | 192 #endif |
| OLD | NEW |