Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1007)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.h

Issue 1416793004: Remove support for -webkit-canvas and Document.getCSSCanvasContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 class CanvasRenderingContext; 54 class CanvasRenderingContext;
55 class CanvasRenderingContextFactory; 55 class CanvasRenderingContextFactory;
56 class GraphicsContext; 56 class GraphicsContext;
57 class HTMLCanvasElement; 57 class HTMLCanvasElement;
58 class Image; 58 class Image;
59 class ImageBuffer; 59 class ImageBuffer;
60 class ImageBufferSurface; 60 class ImageBufferSurface;
61 class ImageData; 61 class ImageData;
62 class IntSize; 62 class IntSize;
63 63
64 class CORE_EXPORT CanvasObserver : public WillBeGarbageCollectedMixin { 64 class CORE_EXPORT CanvasObserver : public WillBeGarbageCollectedMixin {
Justin Novosad 2015/10/23 18:21:12 Nuke this.
65 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(CanvasObserver); 65 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(CanvasObserver);
66 public: 66 public:
67 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect) = 0; 67 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect) = 0;
68 virtual void canvasResized(HTMLCanvasElement*) = 0; 68 virtual void canvasResized(HTMLCanvasElement*) = 0;
69 #if !ENABLE(OILPAN) 69 #if !ENABLE(OILPAN)
70 virtual void canvasDestroyed(HTMLCanvasElement*) = 0; 70 virtual void canvasDestroyed(HTMLCanvasElement*) = 0;
71 #endif 71 #endif
72 72
73 DEFINE_INLINE_VIRTUAL_TRACE() { } 73 DEFINE_INLINE_VIRTUAL_TRACE() { }
74 }; 74 };
75 75
76 class CORE_EXPORT HTMLCanvasElement final : public HTMLElement, public DocumentV isibilityObserver, public CanvasImageSource, public ImageBufferClient { 76 class CORE_EXPORT HTMLCanvasElement final : public HTMLElement, public DocumentV isibilityObserver, public CanvasImageSource, public ImageBufferClient {
77 DEFINE_WRAPPERTYPEINFO(); 77 DEFINE_WRAPPERTYPEINFO();
78 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLCanvasElement); 78 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLCanvasElement);
79 public: 79 public:
80 DECLARE_NODE_FACTORY(HTMLCanvasElement); 80 DECLARE_NODE_FACTORY(HTMLCanvasElement);
81 ~HTMLCanvasElement() override; 81 ~HTMLCanvasElement() override;
82 82
83 static WebThread* getToBlobThreadInstance(); 83 static WebThread* getToBlobThreadInstance();
84 84
85 void addObserver(CanvasObserver*);
86 void removeObserver(CanvasObserver*);
87
88 // Attributes and functions exposed to script 85 // Attributes and functions exposed to script
89 int width() const { return size().width(); } 86 int width() const { return size().width(); }
90 int height() const { return size().height(); } 87 int height() const { return size().height(); }
91 88
92 const IntSize& size() const { return m_size; } 89 const IntSize& size() const { return m_size; }
93 90
94 void setWidth(int); 91 void setWidth(int);
95 void setHeight(int); 92 void setHeight(int);
96 void setAccelerationDisabled(bool accelerationDisabled) { m_accelerationDisa bled = accelerationDisabled; }
97 bool accelerationDisabled() const { return m_accelerationDisabled; }
98 93
99 void setSize(const IntSize& newSize) 94 void setSize(const IntSize& newSize)
100 { 95 {
101 if (newSize == size()) 96 if (newSize == size())
102 return; 97 return;
103 m_ignoreReset = true; 98 m_ignoreReset = true;
104 setWidth(newSize.width()); 99 setWidth(newSize.width());
105 setHeight(newSize.height()); 100 setHeight(newSize.height());
106 m_ignoreReset = false; 101 m_ignoreReset = false;
107 reset(); 102 reset();
108 } 103 }
109 104
110 // Called by HTMLCanvasElement's V8 bindings. 105 // Called by HTMLCanvasElement's V8 bindings.
111 ScriptValue getContext(ScriptState*, const String&, const CanvasContextCreat ionAttributes&); 106 ScriptValue getContext(ScriptState*, const String&, const CanvasContextCreat ionAttributes&);
112 // Called by Document::getCSSCanvasContext as well as above getContext(). 107 // Called by Document::getCSSCanvasContext as well as above getContext().
113 CanvasRenderingContext* getCanvasRenderingContext(const String&, const Canva sContextCreationAttributes&); 108 CanvasRenderingContext* getCanvasRenderingContext(const String&, const Canva sContextCreationAttributes&);
114 109
115 bool isPaintable() const; 110 bool isPaintable() const;
116 111
117 static String toEncodingMimeType(const String& mimeType); 112 static String toEncodingMimeType(const String& mimeType);
118 String toDataURL(const String& mimeType, const ScriptValue& qualityArgument, ExceptionState&) const; 113 String toDataURL(const String& mimeType, const ScriptValue& qualityArgument, ExceptionState&) const;
119 String toDataURL(const String& mimeType, ExceptionState& exceptionState) con st { return toDataURL(mimeType, ScriptValue(), exceptionState); } 114 String toDataURL(const String& mimeType, ExceptionState& exceptionState) con st { return toDataURL(mimeType, ScriptValue(), exceptionState); }
120 115
121 void toBlob(FileCallback*, const String& mimeType, const ScriptValue& qualit yArgument, ExceptionState&); 116 void toBlob(FileCallback*, const String& mimeType, const ScriptValue& qualit yArgument, ExceptionState&);
122 void toBlob(FileCallback* callback, const String& mimeType, ExceptionState& exceptionState) { return toBlob(callback, mimeType, ScriptValue(), exceptionStat e); } 117 void toBlob(FileCallback* callback, const String& mimeType, ExceptionState& exceptionState) { return toBlob(callback, mimeType, ScriptValue(), exceptionStat e); }
123 118
124 // Used for rendering 119 // Used for rendering
125 void didDraw(const FloatRect&); 120 void didDraw(const FloatRect&);
126 void notifyObserversCanvasChanged(const FloatRect&);
Justin Novosad 2015/10/23 18:21:12 This was so fragile. Glad to see it go!
chrishtr 2015/10/23 19:47:06 ACK!
127 121
128 void paint(GraphicsContext*, const LayoutRect&); 122 void paint(GraphicsContext*, const LayoutRect&);
129 123
130 SkCanvas* drawingCanvas() const; 124 SkCanvas* drawingCanvas() const;
131 void disableDeferral() const; 125 void disableDeferral() const;
132 SkCanvas* existingDrawingCanvas() const; 126 SkCanvas* existingDrawingCanvas() const;
133 127
134 void setRenderingContext(PassOwnPtrWillBeRawPtr<CanvasRenderingContext>); 128 void setRenderingContext(PassOwnPtrWillBeRawPtr<CanvasRenderingContext>);
135 CanvasRenderingContext* renderingContext() const { return m_context.get(); } 129 CanvasRenderingContext* renderingContext() const { return m_context.get(); }
136 130
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 void setSurfaceSize(const IntSize&); 207 void setSurfaceSize(const IntSize&);
214 208
215 bool paintsIntoCanvasBuffer() const; 209 bool paintsIntoCanvasBuffer() const;
216 210
217 ImageData* toImageData(SourceDrawingBuffer) const; 211 ImageData* toImageData(SourceDrawingBuffer) const;
218 String toDataURLInternal(const String& mimeType, const double& quality, Sour ceDrawingBuffer) const; 212 String toDataURLInternal(const String& mimeType, const double& quality, Sour ceDrawingBuffer) const;
219 213
220 static void encodeImageAsync(DOMUint8ClampedArray* imagedata, IntSize imageS ize, FileCallback*, const String& mimeType, double quality); 214 static void encodeImageAsync(DOMUint8ClampedArray* imagedata, IntSize imageS ize, FileCallback*, const String& mimeType, double quality);
221 static void createBlobAndCall(PassOwnPtr<Vector<char>> encodedImage, const S tring& mimeType, FileCallback*); 215 static void createBlobAndCall(PassOwnPtr<Vector<char>> encodedImage, const S tring& mimeType, FileCallback*);
222 216
223 WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver>> m_observers;
224
225 IntSize m_size; 217 IntSize m_size;
226 218
227 OwnPtrWillBeMember<CanvasRenderingContext> m_context; 219 OwnPtrWillBeMember<CanvasRenderingContext> m_context;
228 220
229 bool m_ignoreReset; 221 bool m_ignoreReset;
230 bool m_accelerationDisabled;
231 FloatRect m_dirtyRect; 222 FloatRect m_dirtyRect;
232 223
233 mutable intptr_t m_externallyAllocatedMemory; 224 mutable intptr_t m_externallyAllocatedMemory;
234 225
235 bool m_originClean; 226 bool m_originClean;
236 227
237 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t o allocate an imageBuffer 228 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t o allocate an imageBuffer
238 // after the first attempt failed. 229 // after the first attempt failed.
239 mutable bool m_didFailToCreateImageBuffer; 230 mutable bool m_didFailToCreateImageBuffer;
240 bool m_imageBufferIsClear; 231 bool m_imageBufferIsClear;
241 OwnPtr<ImageBuffer> m_imageBuffer; 232 OwnPtr<ImageBuffer> m_imageBuffer;
242 233
243 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor ms that have to copy the image buffer to render (and for CSSCanvasValue). 234 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor ms that have to copy the image buffer to render (and for CSSCanvasValue).
244 }; 235 };
245 236
246 } // namespace blink 237 } // namespace blink
247 238
248 #endif // HTMLCanvasElement_h 239 #endif // HTMLCanvasElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698