CSS Painting API should pass 'this' correctly to paint callback, and repaint when...
authorjustin_michaud@apple.com <justin_michaud@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 21:01:15 +0000 (21:01 +0000)
committerjustin_michaud@apple.com <justin_michaud@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 21:01:15 +0000 (21:01 +0000)
commit618b47141371c2af7cbe686f1816357892607560
treede8f1a0853a5558710113d261d5e3b111ecec984
parent3dd3f53178b6b2dd27224965246a08cc7dde50bc
CSS Painting API should pass 'this' correctly to paint callback, and repaint when properties change.
https://bugs.webkit.org/show_bug.cgi?id=191443

Reviewed by Dean Jackson.

Source/JavaScriptCore:

Export the simpler construct() method for use in WebCore.

* runtime/ConstructData.h:

Source/WebCore:

Instantiate a new instance of the paint class, and pass it as 'this' object when the paint callback is called.
Also, this patch makes sure that custom paint elements get repainted when properties that they care about get changed.
Finally, we fix two reference cycles that caused WorkletGlobalScope to never be destroyed.

Tests: fast/css-custom-paint/animate-repaint.html
       fast/css-custom-paint/animate.html

* bindings/js/JSDOMWrapper.cpp:
* bindings/js/JSPaintWorkletGlobalScopeCustom.cpp:
(WebCore::JSPaintWorkletGlobalScope::visitAdditionalChildren):
* bindings/js/JSWorkletGlobalScopeBase.cpp:
(WebCore::toJS):
* bindings/js/ScriptState.cpp:
(WebCore::execStateFromWorkletGlobalScope):
* css/CSSPaintCallback.h:
* css/CSSPaintCallback.idl:
* css/CSSPaintImageValue.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
* dom/Document.cpp:
(WebCore::Document::prepareForDestruction):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::vm):
* platform/graphics/CustomPaintImage.cpp:
(WebCore::CustomPaintImage::CustomPaintImage):
(WebCore::CustomPaintImage::doCustomPaint):
* platform/graphics/CustomPaintImage.h:
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::addCustomPaintWatchProperty):
(WebCore::RenderStyle::changeRequiresRepaint const):
* rendering/style/RenderStyle.h:
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator== const):
* rendering/style/StyleRareNonInheritedData.h:
* testing/Internals.cpp:
(WebCore::Internals::isAnyWorkletGlobalScopeAlive const):
* testing/Internals.h:
* testing/Internals.idl:
* worklets/PaintWorkletGlobalScope.cpp:
(WebCore::PaintWorkletGlobalScope::devicePixelRatio const):
(WebCore::PaintWorkletGlobalScope::PaintDefinition::PaintDefinition):
(WebCore::PaintWorkletGlobalScope::registerPaint):
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* worklets/WorkletGlobalScope.cpp:
(WebCore::WorkletGlobalScope::WorkletGlobalScope):
(WebCore::WorkletGlobalScope::~WorkletGlobalScope):
(WebCore::WorkletGlobalScope::prepareForDestruction):
(WebCore::WorkletGlobalScope::allWorkletGlobalScopesSet):
(WebCore::WorkletGlobalScope::isJSExecutionForbidden const):
(WebCore::WorkletGlobalScope::logExceptionToConsole):
(WebCore::WorkletGlobalScope::addConsoleMessage):
(WebCore::WorkletGlobalScope::addMessage):
* worklets/WorkletGlobalScope.h:
(WebCore::WorkletGlobalScope::script):
(WebCore::WorkletGlobalScope::responsibleDocument):
(WebCore::WorkletGlobalScope::responsibleDocument const):
(WebCore::WorkletGlobalScope::identifier const): Deleted.
(WebCore::WorkletGlobalScope::responsableDocument): Deleted.
(WebCore::WorkletGlobalScope::responsableDocument const): Deleted.
* worklets/WorkletScriptController.cpp:
(WebCore::WorkletScriptController::~WorkletScriptController):
(WebCore::WorkletScriptController::disableEval):
(WebCore::WorkletScriptController::disableWebAssembly):
(WebCore::WorkletScriptController::initScript):

LayoutTests:

* fast/css-custom-paint/animate-expected.html: Added.
* fast/css-custom-paint/animate-repaint-expected.txt: Added.
* fast/css-custom-paint/animate-repaint.html: Added.
* fast/css-custom-paint/animate.html: Added.
* fast/css-custom-paint/constructor-expected.html: Added.
* fast/css-custom-paint/constructor.html: Added.
* fast/css-custom-paint/leaks-expected.txt: Added.
* fast/css-custom-paint/leaks.html: Added.
* fast/css-custom-paint/properties.html:
* fast/css-custom-paint/resources/leaks-frame.html: Added.
* platform/mac/fast/css-custom-paint/raf-leak-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238686 268f45cc-cd09-0410-ab3c-d52691b4dbfc
39 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-custom-paint/animate-expected.html [new file with mode: 0644]
LayoutTests/fast/css-custom-paint/animate-repaint-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-custom-paint/animate-repaint.html [new file with mode: 0644]
LayoutTests/fast/css-custom-paint/animate.html [new file with mode: 0644]
LayoutTests/fast/css-custom-paint/constructor-expected.html [new file with mode: 0644]
LayoutTests/fast/css-custom-paint/constructor.html [new file with mode: 0644]
LayoutTests/fast/css-custom-paint/leaks-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-custom-paint/leaks.html [new file with mode: 0644]
LayoutTests/fast/css-custom-paint/properties.html
LayoutTests/fast/css-custom-paint/resources/leaks-frame.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-custom-paint/raf-leak-expected.txt [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/ConstructData.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMWrapper.cpp
Source/WebCore/bindings/js/JSPaintWorkletGlobalScopeCustom.cpp
Source/WebCore/bindings/js/JSWorkletGlobalScopeBase.cpp
Source/WebCore/bindings/js/ScriptState.cpp
Source/WebCore/css/CSSPaintCallback.h
Source/WebCore/css/CSSPaintCallback.idl
Source/WebCore/css/CSSPaintImageValue.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/platform/graphics/CustomPaintImage.cpp
Source/WebCore/platform/graphics/CustomPaintImage.h
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
Source/WebCore/rendering/style/StyleRareNonInheritedData.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebCore/worklets/PaintWorkletGlobalScope.cpp
Source/WebCore/worklets/PaintWorkletGlobalScope.h
Source/WebCore/worklets/WorkletGlobalScope.cpp
Source/WebCore/worklets/WorkletGlobalScope.h
Source/WebCore/worklets/WorkletScriptController.cpp