WebKit Bugzilla
Attachment 356779 Details for
Bug 192335
: CS Painting API should support multiple worklets.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192335-20181206194839.patch (text/plain), 10.44 KB, created by
Justin Michaud
on 2018-12-06 19:48:44 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Justin Michaud
Created:
2018-12-06 19:48:44 PST
Size:
10.44 KB
patch
obsolete
>Subversion Revision: 238944 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 92d946d6ef02f6cc2e0ff8596dae119a560e03dc..5a7f2f6aa43803970bb269ba7f1a013fb15e52f0 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,29 @@ >+2018-12-06 Justin Michaud <justin_michaud@apple.com> >+ >+ CS Painting API should support multiple worklets. >+ https://bugs.webkit.org/show_bug.cgi?id=192335 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adds a new map to support separate paint worklet global scopes (one for each worklet). >+ >+ Test: fast/css-custom-paint/multiple-worklets.html >+ >+ * css/CSSPaintImageValue.cpp: >+ (WebCore::CSSPaintImageValue::image): >+ * css/StyleResolver.cpp: >+ (WebCore::StyleResolver::applyProperty): >+ * dom/Document.cpp: >+ (WebCore::Document::prepareForDestruction): >+ (WebCore::Document::paintWorkletGlobalScope): >+ (WebCore::Document::setPaintWorkletGlobalScope): >+ * dom/Document.h: >+ (WebCore::Document::paintWorkletGlobalScope): Deleted. >+ * worklets/Worklet.cpp: >+ (WebCore::Worklet::addModule): >+ * worklets/WorkletGlobalScope.cpp: >+ (WebCore::WorkletGlobalScope::prepareForDestruction): >+ > 2018-12-06 Adrian Perez de Castro <aperez@igalia.com> > > Content Extensions: Misc fixes to debugging / perf testing code >diff --git a/Source/WebCore/css/CSSPaintImageValue.cpp b/Source/WebCore/css/CSSPaintImageValue.cpp >index 796846e6471f57e49c1f5bf9f6f762698bbfc152..811c1f6948c392a18388f9ae1f7af5de4b40a510 100644 >--- a/Source/WebCore/css/CSSPaintImageValue.cpp >+++ b/Source/WebCore/css/CSSPaintImageValue.cpp >@@ -51,7 +51,7 @@ RefPtr<Image> CSSPaintImageValue::image(RenderElement& renderElement, const Floa > { > if (size.isEmpty()) > return nullptr; >- auto* selectedGlobalScope = renderElement.document().paintWorkletGlobalScope(); >+ auto* selectedGlobalScope = renderElement.document().paintWorkletGlobalScope(m_name); > if (!selectedGlobalScope) > return nullptr; > auto locker = holdLock(selectedGlobalScope->paintDefinitionLock()); >diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp >index 6a1ce49d0c4079f990ab0f998be65572526e00e8..13fcbbe83a3e2af3884a5d5f7fa50a0d31411859 100644 >--- a/Source/WebCore/css/StyleResolver.cpp >+++ b/Source/WebCore/css/StyleResolver.cpp >@@ -1720,13 +1720,15 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value, ApplyCascad > state.style()->setHasExplicitlyInheritedProperties(); > > #if ENABLE(CSS_PAINTING_API) >- if (is<CSSPaintImageValue>(*valueToApply) && document().paintWorkletGlobalScope()) { >- // FIXME: This should use the "document paint registration map" from the spec, once it is implemented. >- auto& paintWorklet = *document().paintWorkletGlobalScope(); >- auto locker = holdLock(paintWorklet.paintDefinitionLock()); >- if (auto* registration = paintWorklet.paintDefinitionMap().get(downcast<CSSPaintImageValue>(*valueToApply).name())) { >- for (auto& property : registration->inputProperties) >- state.style()->addCustomPaintWatchProperty(property); >+ if (is<CSSPaintImageValue>(*valueToApply)) { >+ auto& name = downcast<CSSPaintImageValue>(*valueToApply).name(); >+ if (document().paintWorkletGlobalScope(name)) { >+ auto& paintWorklet = *document().paintWorkletGlobalScope(name); >+ auto locker = holdLock(paintWorklet.paintDefinitionLock()); >+ if (auto* registration = paintWorklet.paintDefinitionMap().get(name)) { >+ for (auto& property : registration->inputProperties) >+ state.style()->addCustomPaintWatchProperty(property); >+ } > } > } > #endif >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index e334adbeaeb02add8a305829c9b6f2eeb4e5fae2..b681676272319e59781e1612abff38fef75c870d 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -2564,10 +2564,10 @@ void Document::prepareForDestruction() > #endif > > #if ENABLE(CSS_PAINTING_API) >- if (m_paintWorkletGlobalScope) { >- m_paintWorkletGlobalScope->prepareForDestruction(); >- m_paintWorkletGlobalScope = nullptr; >+ for (auto& scope : m_paintWorkletGlobalScopes.values()) { >+ scope->prepareForDestruction(); > } >+ m_paintWorkletGlobalScopes.clear(); > #endif > > m_hasPreparedForDestruction = true; >@@ -8519,9 +8519,15 @@ Worklet& Document::ensurePaintWorklet() > return *m_paintWorklet; > } > >-void Document::setPaintWorkletGlobalScope(Ref<PaintWorkletGlobalScope>&& scope) >+PaintWorkletGlobalScope* Document::paintWorkletGlobalScope(const String& name) > { >- m_paintWorkletGlobalScope = WTFMove(scope); >+ return m_paintWorkletGlobalScopes.get(name); >+} >+ >+void Document::setPaintWorkletGlobalScope(const String& name, Ref<PaintWorkletGlobalScope>&& scope) >+{ >+ auto addResult = m_paintWorkletGlobalScopes.add(name, WTFMove(scope)); >+ ASSERT_UNUSED(addResult, addResult); > } > #endif > >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index 5b5ff49b7f136c672245fe5bb924fafd8ae34e0b..7856774c9cb8ecfc187cc256685979907bec8c0d 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -1522,8 +1522,8 @@ public: > > #if ENABLE(CSS_PAINTING_API) > Worklet& ensurePaintWorklet(); >- PaintWorkletGlobalScope* paintWorkletGlobalScope() { return m_paintWorkletGlobalScope.get(); } >- void setPaintWorkletGlobalScope(Ref<PaintWorkletGlobalScope>&&); >+ PaintWorkletGlobalScope* paintWorkletGlobalScope(const String& name); >+ void setPaintWorkletGlobalScope(const String& name, Ref<PaintWorkletGlobalScope>&&); > #endif > > void setAsRunningUserScripts() { m_isRunningUserScripts = true; } >@@ -2072,7 +2072,7 @@ private: > > #if ENABLE(CSS_PAINTING_API) > RefPtr<Worklet> m_paintWorklet; >- RefPtr<PaintWorkletGlobalScope> m_paintWorkletGlobalScope; >+ HashMap<String, Ref<PaintWorkletGlobalScope>> m_paintWorkletGlobalScopes; > #endif > > bool m_isRunningUserScripts { false }; >diff --git a/Source/WebCore/worklets/Worklet.cpp b/Source/WebCore/worklets/Worklet.cpp >index 38f2c5896f2cbd9ff86cd58001219e1894467772..3164579cd7e4a35031bab55889d0831fbddc6c37 100644 >--- a/Source/WebCore/worklets/Worklet.cpp >+++ b/Source/WebCore/worklets/Worklet.cpp >@@ -49,9 +49,10 @@ void Worklet::addModule(Document& document, const String& moduleURL) > // https://bugs.webkit.org/show_bug.cgi?id=191136 > auto context = PaintWorkletGlobalScope::create(document, ScriptSourceCode(moduleURL)); > context->evaluate(); >- // FIXME: We should store multiple global scopes and choose between them >- // This will not function correctly if multiple modules are added. >- document.setPaintWorkletGlobalScope(WTFMove(context)); >+ >+ auto locker = holdLock(context->paintDefinitionLock()); >+ for (auto& name : context->paintDefinitionMap().keys()) >+ document.setPaintWorkletGlobalScope(name, makeRef(context.get())); > } > > } // namespace WebCore >diff --git a/Source/WebCore/worklets/WorkletGlobalScope.cpp b/Source/WebCore/worklets/WorkletGlobalScope.cpp >index 3c56196803e1bcb42a89e20187728fe6a694108e..7234031570fe305e8e934c75a57d66d487e28853 100644 >--- a/Source/WebCore/worklets/WorkletGlobalScope.cpp >+++ b/Source/WebCore/worklets/WorkletGlobalScope.cpp >@@ -74,7 +74,8 @@ WorkletGlobalScope::~WorkletGlobalScope() > > void WorkletGlobalScope::prepareForDestruction() > { >- ASSERT(m_script); >+ if (!m_script) >+ return; > stopActiveDOMObjects(); > removeRejectedPromiseTracker(); > removeAllEventListeners(); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 565ab81a36f340067e5fae7069d9d15a171e0082..c0ec5a5df55934f80b6d828c8408b224e6ade3c2 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+2018-12-06 Justin Michaud <justin_michaud@apple.com> >+ >+ CS Painting API should support multiple worklets. >+ https://bugs.webkit.org/show_bug.cgi?id=192335 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/css-custom-paint/multiple-worklets-expected.html: Added. >+ * fast/css-custom-paint/multiple-worklets.html: Added. >+ > 2018-12-06 Wenson Hsieh <wenson_hsieh@apple.com> > > [iOS] WKWebView should match UITextView behavior when editing text with an RTL keyboard >diff --git a/LayoutTests/fast/css-custom-paint/multiple-worklets-expected.html b/LayoutTests/fast/css-custom-paint/multiple-worklets-expected.html >new file mode 100644 >index 0000000000000000000000000000000000000000..e90e880b1d2e8b4e87ab4fbb555f81b18ec555cd >--- /dev/null >+++ b/LayoutTests/fast/css-custom-paint/multiple-worklets-expected.html >@@ -0,0 +1,3 @@ >+<!DOCTYPE html> >+<div id="paint" style="width: 150px; height: 150px; background-color: purple;" ></div> >+<div id="paint2" style="width: 150px; height: 150px; background-color: green;" ></div> >diff --git a/LayoutTests/fast/css-custom-paint/multiple-worklets.html b/LayoutTests/fast/css-custom-paint/multiple-worklets.html >new file mode 100644 >index 0000000000000000000000000000000000000000..6596df456966c7fbe0e888a6a95eef3f83fac424 >--- /dev/null >+++ b/LayoutTests/fast/css-custom-paint/multiple-worklets.html >@@ -0,0 +1,47 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSPaintingAPIEnabled=true ] --> >+<script src="resources/testharness.js"></script> >+<meta name="author" title="Justin Michaud" href="mailto:justin_michaud@webkit.org"> >+<meta name="assert" content="test hidpi scaling"> >+<link rel="help" content="https://drafts.css-houdini.org/css-paint-api-1/"> >+ >+<style> >+ #paint { >+ background-image: paint(my-paint2); >+ width: 150px; >+ height: 150px; >+ } >+ >+ #paint2 { >+ background-image: paint(my-paint); >+ width: 150px; >+ height: 150px; >+ } >+</style> >+ >+<div id="paint"></div> >+<div id="paint2"></div> >+ >+<script id="code1" type="text/worklet"> >+registerPaint('my-paint', class { >+ paint(ctx, geom, properties) { >+ ctx.fillStyle = 'purple'; >+ ctx.fillRect(0, 0, geom.width, geom.height); >+ } >+}); >+</script> >+ >+<script id="code2" type="text/worklet"> >+registerPaint('my-paint2', class { >+ paint(ctx, geom, properties) { >+ ctx.fillStyle = 'green'; >+ ctx.fillRect(0, 0, geom.width, geom.height); >+ } >+}); >+</script> >+ >+<script> >+importWorklet(CSS.paintWorklet, document.getElementById('code1').textContent); >+importWorklet(CSS.paintWorklet, document.getElementById('code2').textContent); >+paint.style.backgroundImage = "paint(my-paint)"; >+paint2.style.backgroundImage = "paint(my-paint2)"; >+</script>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192335
:
356779
|
356973
|
357018