Changeset 239067 in webkit
- Timestamp:
- Dec 10, 2018 7:55:49 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 11 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r239064 r239067 1 2018-12-10 Justin Michaud <justin_michaud@apple.com> 2 3 CS Painting API should support multiple worklets. 4 https://bugs.webkit.org/show_bug.cgi?id=192335 5 6 Reviewed by Dean Jackson. 7 8 * fast/css-custom-paint/animate-repaint-expected.txt: 9 * fast/css-custom-paint/animate-repaint.html: 10 * fast/css-custom-paint/delay-expected.html: Added. 11 * fast/css-custom-paint/delay-repaint-expected.txt: Copied from LayoutTests/fast/css-custom-paint/animate-repaint-expected.txt. 12 * fast/css-custom-paint/delay-repaint.html: Copied from LayoutTests/fast/css-custom-paint/animate-repaint.html. 13 * fast/css-custom-paint/delay.html: Copied from LayoutTests/fast/css-custom-paint/animate-repaint.html. 14 * fast/css-custom-paint/multiple-worklets-expected.html: Added. 15 * fast/css-custom-paint/multiple-worklets.html: Added. 16 1 17 2018-12-10 Youenn Fablet <youenn@apple.com> 2 18 -
trunk/LayoutTests/fast/css-custom-paint/animate-repaint-expected.txt
r238686 r239067 1 1 (repaint rects 2 (rect 0 0 800 600)3 (rect 0 0 150 150)4 (rect 8 8 784 150)5 (rect 0 0 800 166)6 2 (rect 0 0 800 600) 7 3 (rect 8 8 150 150) -
trunk/LayoutTests/fast/css-custom-paint/animate-repaint.html
r238686 r239067 23 23 24 24 <script type="text/javascript"> 25 if (window.testRunner && window.internals) { 26 window.testRunner.dumpAsText(false); 27 window.internals.startTrackingRepaints(); 25 function onload() { 26 if (window.testRunner && window.internals) { 27 window.testRunner.dumpAsText(false); 28 window.internals.startTrackingRepaints(); 29 } 30 importWorklet(CSS.paintWorklet, document.getElementById('code').textContent); 31 32 // FIXME: Once importWorklet returns a promise, these setTimeouts should go away. 33 setTimeout(function() { 34 document.getElementById('paint').style.setProperty('--my-prop', 'goodbye'); 35 }, 500); 36 37 setTimeout(function() { 38 var repaintRects = "No test runner"; 39 if (window.testRunner && window.internals) { 40 // force a style recalc. 41 var dummy = document.body.offsetTop; 42 repaintRects = window.internals.repaintRectsAsText(); 43 window.internals.stopTrackingRepaints(); 44 } 45 46 var pre = document.createElement('pre'); 47 document.body.appendChild(pre); 48 pre.innerHTML = repaintRects; 49 }, 1000); 28 50 } 29 importWorklet(CSS.paintWorklet, document.getElementById('code').textContent);30 31 // FIXME: Once importWorklet returns a promise, these setTimeouts should go away.32 setTimeout(function() {33 document.getElementById('paint').style.setProperty('--my-prop', 'goodbye');34 }, 500);35 36 setTimeout(function() {37 var repaintRects = "No test runner";38 if (window.testRunner && window.internals) {39 window.internals.startTrackingRepaints();40 41 // force a style recalc.42 var dummy = document.body.offsetTop;43 44 repaintRects = window.internals.repaintRectsAsText();45 46 window.internals.stopTrackingRepaints();47 }48 49 var pre = document.createElement('pre');50 document.body.appendChild(pre);51 pre.innerHTML = repaintRects;52 }, 1000);53 51 </script> 54 52 … … 62 60 </style> 63 61 64 <body >62 <body onload="onload()"> 65 63 <div id="paint"></div> 66 64 </body> -
trunk/LayoutTests/fast/css-custom-paint/delay-repaint-expected.txt
r239066 r239067 1 1 (repaint rects 2 (rect 0 0 800 600)3 (rect 0 0 150 150)4 (rect 8 8 784 150)5 (rect 0 0 800 166)6 2 (rect 0 0 800 600) 7 3 (rect 8 8 150 150) -
trunk/LayoutTests/fast/css-custom-paint/delay-repaint.html
r239066 r239067 1 1 <!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSPaintingAPIEnabled=true ] --> 2 2 <meta name="author" title="Justin Michaud" href="mailto:justin_michaud@webkit.org"> 3 <meta name="assert" content="Test that paint worklets repaint when properties change">3 <meta name="assert" content="Test that paint worklets repaint when modules are added, and correctly watch properties"> 4 4 <link rel="help" content="https://drafts.css-houdini.org/css-paint-api-1/"> 5 5 <script src="resources/testharness.js"></script> … … 10 10 11 11 paint(ctx, geom, properties) { 12 if (properties.get('--my-prop').toString() != "goodbye") { 12 if (properties.get('--my-prop') == 5) { 13 ctx.fillStyle = "green"; 14 } else { 13 15 ctx.fillStyle = "red"; 14 } else {15 ctx.fillStyle = "green";16 16 } 17 18 17 ctx.fillRect(0, 0, geom.width, geom.height); 19 18 } … … 23 22 24 23 <script type="text/javascript"> 24 function onload() { 25 25 if (window.testRunner && window.internals) { 26 26 window.testRunner.dumpAsText(false); 27 27 window.internals.startTrackingRepaints(); 28 28 } 29 importWorklet(CSS.paintWorklet, document.getElementById('code').textContent);30 29 31 30 // FIXME: Once importWorklet returns a promise, these setTimeouts should go away. 32 31 setTimeout(function() { 33 document.getElementById('paint').style.setProperty('--my-prop', 'goodbye');32 importWorklet(CSS.paintWorklet, document.getElementById('code').textContent); 34 33 }, 500); 34 35 setTimeout(function() { 36 paint.style.setProperty('--my-prop', 5); 37 }, 2000); 35 38 36 39 setTimeout(function() { 37 40 var repaintRects = "No test runner"; 38 41 if (window.testRunner && window.internals) { 39 window.internals.startTrackingRepaints();40 41 42 // force a style recalc. 42 43 var dummy = document.body.offsetTop; 43 44 44 repaintRects = window.internals.repaintRectsAsText(); 45 46 45 window.internals.stopTrackingRepaints(); 47 46 } … … 50 49 document.body.appendChild(pre); 51 50 pre.innerHTML = repaintRects; 52 }, 1000); 51 }, 2500); 52 } 53 53 </script> 54 54 … … 56 56 #paint { 57 57 background-image: paint(my-paint); 58 --my-prop: hello;59 58 width: 150px; 60 59 height: 150px; … … 62 61 </style> 63 62 64 <body >63 <body onload="onload()"> 65 64 <div id="paint"></div> 66 65 </body> -
trunk/LayoutTests/fast/css-custom-paint/delay.html
r239066 r239067 1 1 <!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSPaintingAPIEnabled=true ] --> 2 2 <meta name="author" title="Justin Michaud" href="mailto:justin_michaud@webkit.org"> 3 <meta name="assert" content="Test that paint worklets repaint when properties change">3 <meta name="assert" content="Test that paint worklets repaint when modules are added, and correctly watch properties"> 4 4 <link rel="help" content="https://drafts.css-houdini.org/css-paint-api-1/"> 5 5 <script src="resources/testharness.js"></script> … … 10 10 11 11 paint(ctx, geom, properties) { 12 if (properties.get('--my-prop').toString() != "goodbye") { 12 if (properties.get('--my-prop') == 5) { 13 ctx.fillStyle = "green"; 14 } else { 13 15 ctx.fillStyle = "red"; 14 } else {15 ctx.fillStyle = "green";16 16 } 17 18 17 ctx.fillRect(0, 0, geom.width, geom.height); 19 18 } … … 23 22 24 23 <script type="text/javascript"> 25 if (window.testRunner && window.internals) {26 window.testRunner.dumpAsText(false);27 window.internals.startTrackingRepaints();28 }29 importWorklet(CSS.paintWorklet, document.getElementById('code').textContent);30 31 // FIXME: Once importWorklet returns a promise, these setTimeouts should go away.32 24 setTimeout(function() { 33 document.getElementById('paint').style.setProperty('--my-prop', 'goodbye');25 importWorklet(CSS.paintWorklet, document.getElementById('code').textContent); 34 26 }, 500); 35 27 // FIXME: This should use a promise once addModule supports it. 36 28 setTimeout(function() { 37 var repaintRects = "No test runner"; 38 if (window.testRunner && window.internals) { 39 window.internals.startTrackingRepaints(); 40 41 // force a style recalc. 42 var dummy = document.body.offsetTop; 43 44 repaintRects = window.internals.repaintRectsAsText(); 45 46 window.internals.stopTrackingRepaints(); 47 } 48 49 var pre = document.createElement('pre'); 50 document.body.appendChild(pre); 51 pre.innerHTML = repaintRects; 52 }, 1000); 29 paint.style.setProperty('--my-prop', 5); 30 }, 2000); 53 31 </script> 54 32 … … 56 34 #paint { 57 35 background-image: paint(my-paint); 58 --my-prop: hello;59 36 width: 150px; 60 37 height: 150px; -
trunk/Source/WebCore/ChangeLog
r239065 r239067 1 2018-12-10 Justin Michaud <justin_michaud@apple.com> 2 3 CS Painting API should support multiple worklets. 4 https://bugs.webkit.org/show_bug.cgi?id=192335 5 6 Reviewed by Dean Jackson. 7 8 Adds a new map to support separate paint worklet global scopes (one for each worklet). Also 9 adds some tests and a fix for a repaint bug that this oncovered, where changing a custom property required 10 for paint would not trigger a repaint if there had not been a valid value set before. 11 12 Test: fast/css-custom-paint/multiple-worklets.html 13 14 * css/CSSPaintImageValue.cpp: 15 (WebCore::CSSPaintImageValue::image): 16 * css/StyleResolver.cpp: 17 (WebCore::StyleResolver::applyProperty): 18 * dom/Document.cpp: 19 (WebCore::Document::prepareForDestruction): 20 (WebCore::Document::paintWorkletGlobalScope): 21 (WebCore::Document::setPaintWorkletGlobalScope): 22 * dom/Document.h: 23 (WebCore::Document::paintWorkletGlobalScope): Deleted. 24 * rendering/style/RenderStyle.cpp: 25 (WebCore::changedCustomPaintWatchedProperty): 26 * worklets/Worklet.cpp: 27 (WebCore::Worklet::addModule): 28 * worklets/WorkletGlobalScope.cpp: 29 (WebCore::WorkletGlobalScope::prepareForDestruction): 30 1 31 2018-12-10 Youenn Fablet <youenn@apple.com> 2 32 -
trunk/Source/WebCore/css/CSSPaintImageValue.cpp
r238872 r239067 52 52 if (size.isEmpty()) 53 53 return nullptr; 54 auto* selectedGlobalScope = renderElement.document().paintWorkletGlobalScope ();54 auto* selectedGlobalScope = renderElement.document().paintWorkletGlobalScopeForName(m_name); 55 55 if (!selectedGlobalScope) 56 56 return nullptr; -
trunk/Source/WebCore/css/StyleResolver.cpp
r238686 r239067 1721 1721 1722 1722 #if ENABLE(CSS_PAINTING_API) 1723 if (is<CSSPaintImageValue>(*valueToApply) && document().paintWorkletGlobalScope()) { 1724 // FIXME: This should use the "document paint registration map" from the spec, once it is implemented. 1725 auto& paintWorklet = *document().paintWorkletGlobalScope(); 1726 auto locker = holdLock(paintWorklet.paintDefinitionLock()); 1727 if (auto* registration = paintWorklet.paintDefinitionMap().get(downcast<CSSPaintImageValue>(*valueToApply).name())) { 1728 for (auto& property : registration->inputProperties) 1729 state.style()->addCustomPaintWatchProperty(property); 1723 if (is<CSSPaintImageValue>(*valueToApply)) { 1724 auto& name = downcast<CSSPaintImageValue>(*valueToApply).name(); 1725 if (auto* paintWorklet = document().paintWorkletGlobalScopeForName(name)) { 1726 auto locker = holdLock(paintWorklet->paintDefinitionLock()); 1727 if (auto* registration = paintWorklet->paintDefinitionMap().get(name)) { 1728 for (auto& property : registration->inputProperties) 1729 state.style()->addCustomPaintWatchProperty(property); 1730 } 1730 1731 } 1731 1732 } -
trunk/Source/WebCore/dom/Document.cpp
r239057 r239067 2563 2563 2564 2564 #if ENABLE(CSS_PAINTING_API) 2565 if (m_paintWorkletGlobalScope) { 2566 m_paintWorkletGlobalScope->prepareForDestruction(); 2567 m_paintWorkletGlobalScope = nullptr; 2568 } 2565 for (auto& scope : m_paintWorkletGlobalScopes.values()) 2566 scope->prepareForDestruction(); 2567 m_paintWorkletGlobalScopes.clear(); 2569 2568 #endif 2570 2569 … … 8518 8517 } 8519 8518 8520 void Document::setPaintWorkletGlobalScope(Ref<PaintWorkletGlobalScope>&& scope) 8521 { 8522 m_paintWorkletGlobalScope = WTFMove(scope); 8519 PaintWorkletGlobalScope* Document::paintWorkletGlobalScopeForName(const String& name) 8520 { 8521 return m_paintWorkletGlobalScopes.get(name); 8522 } 8523 8524 void Document::setPaintWorkletGlobalScopeForName(const String& name, Ref<PaintWorkletGlobalScope>&& scope) 8525 { 8526 auto addResult = m_paintWorkletGlobalScopes.add(name, WTFMove(scope)); 8527 ASSERT_UNUSED(addResult, addResult); 8523 8528 } 8524 8529 #endif -
trunk/Source/WebCore/dom/Document.h
r239057 r239067 1523 1523 #if ENABLE(CSS_PAINTING_API) 1524 1524 Worklet& ensurePaintWorklet(); 1525 PaintWorkletGlobalScope* paintWorkletGlobalScope () { return m_paintWorkletGlobalScope.get(); }1526 void setPaintWorkletGlobalScope (Ref<PaintWorkletGlobalScope>&&);1525 PaintWorkletGlobalScope* paintWorkletGlobalScopeForName(const String& name); 1526 void setPaintWorkletGlobalScopeForName(const String& name, Ref<PaintWorkletGlobalScope>&&); 1527 1527 #endif 1528 1528 … … 2073 2073 #if ENABLE(CSS_PAINTING_API) 2074 2074 RefPtr<Worklet> m_paintWorklet; 2075 RefPtr<PaintWorkletGlobalScope> m_paintWorkletGlobalScope;2075 HashMap<String, Ref<PaintWorkletGlobalScope>> m_paintWorkletGlobalScopes; 2076 2076 #endif 2077 2077 -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r238968 r239067 990 990 RefPtr<CSSValue> valueA; 991 991 RefPtr<CSSValue> valueB; 992 if (isCustomPropertyName(name) && a.getCustomProperty(name) && b.getCustomProperty(name)) { 993 valueA = CSSCustomPropertyValue::create(*a.getCustomProperty(name)); 994 valueB = CSSCustomPropertyValue::create(*b.getCustomProperty(name)); 992 if (isCustomPropertyName(name)) { 993 if (a.getCustomProperty(name)) 994 valueA = CSSCustomPropertyValue::create(*a.getCustomProperty(name)); 995 if (b.getCustomProperty(name)) 996 valueB = CSSCustomPropertyValue::create(*b.getCustomProperty(name)); 995 997 } else { 996 998 CSSPropertyID propertyID = cssPropertyID(name); -
trunk/Source/WebCore/worklets/Worklet.cpp
r237766 r239067 50 50 auto context = PaintWorkletGlobalScope::create(document, ScriptSourceCode(moduleURL)); 51 51 context->evaluate(); 52 // FIXME: We should store multiple global scopes and choose between them 53 // This will not function correctly if multiple modules are added. 54 document.setPaintWorkletGlobalScope(WTFMove(context)); 52 53 auto locker = holdLock(context->paintDefinitionLock()); 54 for (auto& name : context->paintDefinitionMap().keys()) 55 document.setPaintWorkletGlobalScopeForName(name, makeRef(context.get())); 55 56 } 56 57 -
trunk/Source/WebCore/worklets/WorkletGlobalScope.cpp
r238686 r239067 75 75 void WorkletGlobalScope::prepareForDestruction() 76 76 { 77 ASSERT(m_script); 77 if (!m_script) 78 return; 78 79 stopActiveDOMObjects(); 79 80 removeRejectedPromiseTracker();
Note: See TracChangeset
for help on using the changeset viewer.