Changeset 243820 in webkit
- Timestamp:
- Apr 3, 2019, 1:04:37 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
-
ChangeLog (modified) (1 diff)
-
html/CanvasBase.cpp (modified) (1 diff)
-
html/CanvasBase.h (modified) (3 diffs)
-
html/CustomPaintCanvas.cpp (modified) (1 diff)
-
html/CustomPaintCanvas.h (modified) (2 diffs)
-
html/HTMLCanvasElement.cpp (modified) (1 diff)
-
html/HTMLCanvasElement.h (modified) (1 diff)
-
html/OffscreenCanvas.cpp (modified) (1 diff)
-
html/OffscreenCanvas.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243819 r243820 1 2019-04-02 Ryosuke Niwa <rniwa@webkit.org> 2 3 Crash in HTMLCanvasElement::createContext2d after the element got adopted to a new document 4 https://bugs.webkit.org/show_bug.cgi?id=196527 5 6 Reviewed by Antti Koivisto. 7 8 We need to update CanvasBase::m_scriptExecutionContext when HTMLCanvasElement moves from 9 one document to another. Fixed the bug by making CanvasBase::scriptExecutionContext make 10 a virtual function call instead of directly storing a raw pointer. In HTMLCanvasElement, 11 we use Node::scriptExecutionContext(). Use ContextDestructionObserver in CustomPaintCanvas 12 and OffscreenCanvas instead of a raw pointer. 13 14 Unfortunately, no new tests since there is no reproducible test case. 15 16 * html/CanvasBase.cpp: 17 (WebCore::CanvasBase::CanvasBase): 18 * html/CanvasBase.h: 19 (WebCore::CanvasBase::scriptExecutionContext const): 20 * html/CustomPaintCanvas.cpp: 21 (WebCore::CustomPaintCanvas::CustomPaintCanvas): 22 * html/CustomPaintCanvas.h: 23 * html/HTMLCanvasElement.cpp: 24 (WebCore::HTMLCanvasElement::HTMLCanvasElement): 25 * html/HTMLCanvasElement.h: 26 * html/OffscreenCanvas.cpp: 27 (WebCore::OffscreenCanvas::OffscreenCanvas): 28 * html/OffscreenCanvas.h: 29 1 30 2019-04-03 Myles C. Maxfield <mmaxfield@apple.com> 2 31 -
trunk/Source/WebCore/html/CanvasBase.cpp
r243611 r243820 36 36 namespace WebCore { 37 37 38 CanvasBase::CanvasBase(ScriptExecutionContext* scriptExecutionContext) 39 : m_scriptExecutionContext(scriptExecutionContext) 38 CanvasBase::CanvasBase() 40 39 { 41 40 } -
trunk/Source/WebCore/html/CanvasBase.h
r237777 r243820 75 75 76 76 virtual SecurityOrigin* securityOrigin() const { return nullptr; } 77 ScriptExecutionContext* scriptExecutionContext() const { return m_scriptExecutionContext;}77 ScriptExecutionContext* scriptExecutionContext() const { return canvasBaseScriptExecutionContext(); } 78 78 79 79 CanvasRenderingContext* renderingContext() const; … … 99 99 100 100 protected: 101 CanvasBase(ScriptExecutionContext*); 101 CanvasBase(); 102 103 virtual ScriptExecutionContext* canvasBaseScriptExecutionContext() const = 0; 102 104 103 105 std::unique_ptr<CanvasRenderingContext> m_context; … … 108 110 bool m_didNotifyObserversCanvasDestroyed { false }; 109 111 #endif 110 ScriptExecutionContext* m_scriptExecutionContext;111 112 HashSet<CanvasObserver*> m_observers; 112 113 }; -
trunk/Source/WebCore/html/CustomPaintCanvas.cpp
r238839 r243820 40 40 41 41 CustomPaintCanvas::CustomPaintCanvas(ScriptExecutionContext& context, unsigned width, unsigned height) 42 : C anvasBase(&context)42 : ContextDestructionObserver(&context) 43 43 , m_size(width, height) 44 44 { -
trunk/Source/WebCore/html/CustomPaintCanvas.h
r238839 r243820 45 45 class PaintRenderingContext2D; 46 46 47 class CustomPaintCanvas final : public RefCounted<CustomPaintCanvas>, public CanvasBase {47 class CustomPaintCanvas final : public RefCounted<CustomPaintCanvas>, public CanvasBase, private ContextDestructionObserver { 48 48 WTF_MAKE_FAST_ALLOCATED; 49 49 public: … … 81 81 void refCanvasBase() final { ref(); } 82 82 void derefCanvasBase() final { deref(); } 83 ScriptExecutionContext* canvasBaseScriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); } 83 84 84 85 mutable GraphicsContext* m_destinationGraphicsContext = nullptr; -
trunk/Source/WebCore/html/HTMLCanvasElement.cpp
r243666 r243820 117 117 HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document& document) 118 118 : HTMLElement(tagName, document) 119 , CanvasBase(&document)120 119 , m_size(defaultWidth, defaultHeight) 121 120 { -
trunk/Source/WebCore/html/HTMLCanvasElement.h
r243666 r243820 180 180 void derefCanvasBase() final { HTMLElement::deref(); } 181 181 182 ScriptExecutionContext* canvasBaseScriptExecutionContext() const final { return HTMLElement::scriptExecutionContext(); } 183 182 184 FloatRect m_dirtyRect; 183 185 mutable IntSize m_size; -
trunk/Source/WebCore/html/OffscreenCanvas.cpp
r243163 r243820 39 39 40 40 OffscreenCanvas::OffscreenCanvas(ScriptExecutionContext& context, unsigned width, unsigned height) 41 : C anvasBase(&context)41 : ContextDestructionObserver(&context) 42 42 , m_size(width, height) 43 43 { -
trunk/Source/WebCore/html/OffscreenCanvas.h
r237344 r243820 46 46 #endif 47 47 48 class OffscreenCanvas final : public RefCounted<OffscreenCanvas>, public CanvasBase, public EventTargetWithInlineData {48 class OffscreenCanvas final : public RefCounted<OffscreenCanvas>, public CanvasBase, public EventTargetWithInlineData, private ContextDestructionObserver { 49 49 WTF_MAKE_FAST_ALLOCATED; 50 50 public: … … 95 95 bool isOffscreenCanvas() const final { return true; } 96 96 97 ScriptExecutionContext* scriptExecutionContext() const final { return CanvasBase::scriptExecutionContext(); } 97 ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); } 98 ScriptExecutionContext* canvasBaseScriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); } 98 99 99 100 EventTargetInterface eventTargetInterface() const final { return OffscreenCanvasEventTargetInterfaceType; }
Note:
See TracChangeset
for help on using the changeset viewer.