Title: [276562] trunk
Revision
276562
Author
timothy_hor...@apple.com
Date
2021-04-24 19:12:07 -0700 (Sat, 24 Apr 2021)

Log Message

Changing the source of a model element with clipping applied does not update the model
https://bugs.webkit.org/show_bug.cgi?id=224917

Reviewed by Simon Fraser.

Source/WebCore:

Tests: model-element/model-element-contents-layer-updates-with-clipping.html
       model-element/model-element-contents-layer-updates.html

Previously, a <model> with a contents clipping layer (e.g. border-radius)
would not reparent its contents layer in the right place when setContentsToModel
was called again (because the source changed), leaving the old model
contents layer in place.

* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::updateSublayerList):
Ensure that updateSublayerList always parents contentsLayer in one of its two homes:
under contentsClippingLayer, if it exists; otherwise, directly under the primary layer.

(WebCore::GraphicsLayerCA::setContentsToModel):
Drive-by fix a bug revealed by the tests for this patch: when swapping out the
contents layer in setContentsToModel, we also need to mark ContentsRectsChanged,
or the new contents layer will not get its bounds set during the subsequent flush.

(WebCore::GraphicsLayerCA::setContentsToPlatformLayer):
Remove special-case code that was added to fix this bug just for setContentsToPlatformLayer;
this case is now correctly handled for all contents layers by updateSublayerList.

(WebCore::GraphicsLayerCA::dumpInnerLayer const):
* platform/graphics/GraphicsLayerClient.h:
* platform/graphics/ca/PlatformCALayer.cpp:
(WebCore::PlatformCALayer::dumpAdditionalProperties):
* platform/graphics/ca/PlatformCALayer.h:
* testing/Internals.cpp:
(WebCore::toPlatformLayerTreeFlags):
* testing/Internals.h:
* testing/Internals.idl:
Add a bit to platformLayerTreeAsText() that makes PlatformCALayerRemoteModelHosting
dump the size of the model that it is hosting, which is used in the test for this bug.

Remove the IncludeOpacity bit since we can just always log opacity if it's not the default.

Source/WebKit:

* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.h:
* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.mm:
(WebKit::PlatformCALayerRemoteModelHosting::dumpAdditionalProperties):
Add a bit to platformLayerTreeAsText() that makes PlatformCALayerRemoteModelHosting
dump the size of the model that it is hosting, which is used in the test for this bug.

LayoutTests:

* model-element/model-element-contents-layer-updates-expected.txt: Added.
* model-element/model-element-contents-layer-updates-with-clipping-expected.txt: Added.
* model-element/model-element-contents-layer-updates-with-clipping.html: Added.
* model-element/model-element-contents-layer-updates.html: Added.
* model-element/resources/cube.usdz: Added.
* platform/ios-wk2/TestExpectations:
* platform/mac/TestExpectations:
Add tests that ensure that adding a <model> with one source, then changing
it to another, correctly updates the content layer. Test this both
with and without clipping (the without-clipping case passed before this change,
with-clipping failed).

These tests only work on Cocoa ports with UI-side compositing enabled
because they depend on the PlatformCALayer subclass holding on to the model
data (and logging its size) in order to distinguish between the two models.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (276561 => 276562)


--- trunk/LayoutTests/ChangeLog	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/LayoutTests/ChangeLog	2021-04-25 02:12:07 UTC (rev 276562)
@@ -1,3 +1,26 @@
+2021-04-24  Tim Horton  <timothy_hor...@apple.com>
+
+        Changing the source of a model element with clipping applied does not update the model
+        https://bugs.webkit.org/show_bug.cgi?id=224917
+
+        Reviewed by Simon Fraser.
+
+        * model-element/model-element-contents-layer-updates-expected.txt: Added.
+        * model-element/model-element-contents-layer-updates-with-clipping-expected.txt: Added.
+        * model-element/model-element-contents-layer-updates-with-clipping.html: Added.
+        * model-element/model-element-contents-layer-updates.html: Added.
+        * model-element/resources/cube.usdz: Added.
+        * platform/ios-wk2/TestExpectations:
+        * platform/mac/TestExpectations:
+        Add tests that ensure that adding a <model> with one source, then changing
+        it to another, correctly updates the content layer. Test this both
+        with and without clipping (the without-clipping case passed before this change,
+        with-clipping failed).
+
+        These tests only work on Cocoa ports with UI-side compositing enabled
+        because they depend on the PlatformCALayer subclass holding on to the model
+        data (and logging its size) in order to distinguish between the two models.
+
 2021-04-24  Julian Gonzalez  <julian_a_gonza...@apple.com>
 
         Crash in BreakBlockquoteCommand::doApply()

Added: trunk/LayoutTests/model-element/model-element-contents-layer-updates-expected.txt (0 => 276562)


--- trunk/LayoutTests/model-element/model-element-contents-layer-updates-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/model-element/model-element-contents-layer-updates-expected.txt	2021-04-25 02:12:07 UTC (rev 276562)
@@ -0,0 +1,25 @@
+ Before Changing Source:
+(platform layer
+  (position 158.00 83.00)
+  (bounds 300.00 150.00)
+  (children
+    (contents layer (model)
+      (position 0.00 0.00)
+      (bounds 300.00 150.00)
+      (model data size 395126)
+    )
+  )
+)
+After Changing Source:
+(platform layer
+  (position 158.00 83.00)
+  (bounds 300.00 150.00)
+  (children
+    (contents layer (model)
+      (position 0.00 0.00)
+      (bounds 300.00 150.00)
+      (model data size 3248)
+    )
+  )
+)
+

Added: trunk/LayoutTests/model-element/model-element-contents-layer-updates-with-clipping-expected.txt (0 => 276562)


--- trunk/LayoutTests/model-element/model-element-contents-layer-updates-with-clipping-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/model-element/model-element-contents-layer-updates-with-clipping-expected.txt	2021-04-25 02:12:07 UTC (rev 276562)
@@ -0,0 +1,37 @@
+ Before Changing Source:
+(platform layer
+  (position 158.00 83.00)
+  (bounds 300.00 150.00)
+  (children
+    (contents clipping layer
+      (position 0.00 0.00)
+      (bounds 300.00 150.00)
+      (children
+        (contents layer (model)
+          (position 0.00 0.00)
+          (bounds 300.00 150.00)
+          (model data size 395126)
+        )
+      )
+    )
+  )
+)
+After Changing Source:
+(platform layer
+  (position 158.00 83.00)
+  (bounds 300.00 150.00)
+  (children
+    (contents clipping layer
+      (position 0.00 0.00)
+      (bounds 300.00 150.00)
+      (children
+        (contents layer (model)
+          (position 0.00 0.00)
+          (bounds 300.00 150.00)
+          (model data size 3248)
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/model-element/model-element-contents-layer-updates-with-clipping.html (0 => 276562)


--- trunk/LayoutTests/model-element/model-element-contents-layer-updates-with-clipping.html	                        (rev 0)
+++ trunk/LayoutTests/model-element/model-element-contents-layer-updates-with-clipping.html	2021-04-25 02:12:07 UTC (rev 276562)
@@ -0,0 +1,44 @@
+<!DOCTYPE html><!-- webkit-test-runner [ ModelElementEnabled=true ] -->
+<html>
+<body>
+<model id="model" style="border-radius: 5px">
+    <source src=""
+</model>
+<pre id="layers"></pre>
+<script>
+    let layers = document.getElementById("layers");
+    let source = document.getElementsByTagName("source")[0];
+
+    if (window.testRunner) {
+        testRunner.waitUntilDone();
+        testRunner.dumpAsText();
+    } else
+        layers.textContent = "This test requires testRunner.";
+
+    let model = document.getElementById("model");
+
+    model.ready.then(value => {
+        layers.textContent = "Before Changing Source:\n";
+        layers.textContent += window.internals.platformLayerTreeAsText(model, window.internals.PLATFORM_LAYER_TREE_INCLUDE_MODELS);
+
+        source.src = ""
+        model.ready.then(value => {
+            if (window.testRunner) {
+                layers.textContent += "After Changing Source:\n";
+                layers.textContent += window.internals.platformLayerTreeAsText(model, window.internals.PLATFORM_LAYER_TREE_INCLUDE_MODELS);
+            }
+        }, reason => {
+            layers.textContent = `Failed. Second model did not load: ${reason}`;
+        }).finally(() => { 
+            if (window.testRunner)
+                testRunner.notifyDone();
+        });
+        
+    }, reason => {
+        layers.textContent = `Failed. First model did not load: ${reason}`;
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/model-element/model-element-contents-layer-updates.html (0 => 276562)


--- trunk/LayoutTests/model-element/model-element-contents-layer-updates.html	                        (rev 0)
+++ trunk/LayoutTests/model-element/model-element-contents-layer-updates.html	2021-04-25 02:12:07 UTC (rev 276562)
@@ -0,0 +1,44 @@
+<!DOCTYPE html><!-- webkit-test-runner [ ModelElementEnabled=true ] -->
+<html>
+<body>
+<model id="model">
+    <source src=""
+</model>
+<pre id="layers"></pre>
+<script>
+    let layers = document.getElementById("layers");
+    let source = document.getElementsByTagName("source")[0];
+
+    if (window.testRunner) {
+        testRunner.waitUntilDone();
+        testRunner.dumpAsText();
+    } else
+        layers.textContent = "This test requires testRunner.";
+
+    let model = document.getElementById("model");
+
+    model.ready.then(value => {
+        layers.textContent = "Before Changing Source:\n";
+        layers.textContent += window.internals.platformLayerTreeAsText(model, window.internals.PLATFORM_LAYER_TREE_INCLUDE_MODELS);
+
+        source.src = ""
+        model.ready.then(value => {
+            if (window.testRunner) {
+                layers.textContent += "After Changing Source:\n";
+                layers.textContent += window.internals.platformLayerTreeAsText(model, window.internals.PLATFORM_LAYER_TREE_INCLUDE_MODELS);
+            }
+        }, reason => {
+            layers.textContent = `Failed. Second model did not load: ${reason}`;
+        }).finally(() => { 
+            if (window.testRunner)
+                testRunner.notifyDone();
+        });
+        
+    }, reason => {
+        layers.textContent = `Failed. First model did not load: ${reason}`;
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/model-element/model-element-graphics-layers-opacity.html (276561 => 276562)


--- trunk/LayoutTests/model-element/model-element-graphics-layers-opacity.html	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/LayoutTests/model-element/model-element-graphics-layers-opacity.html	2021-04-25 02:12:07 UTC (rev 276562)
@@ -25,7 +25,7 @@
 
     model.ready.then(value => {
         if (window.testRunner)
-            layers.innerText = window.internals.platformLayerTreeAsText(model, window.internals.PLATFORM_LAYER_TREE_INCLUDE_OPACITY);
+            layers.innerText = window.internals.platformLayerTreeAsText(model);
         model.remove();
     }, reason => {
         layers.textContent = `Failed. Model did not load: ${reason}`;

Added: trunk/LayoutTests/model-element/resources/cube.usdz (0 => 276562)


--- trunk/LayoutTests/model-element/resources/cube.usdz	                        (rev 0)
+++ trunk/LayoutTests/model-element/resources/cube.usdz	2021-04-25 02:12:07 UTC (rev 276562)
@@ -0,0 +1,17 @@
+PK
+i|\x95Rn54
+
+untitled.imported.usdc\x86PXR-USDCB
+@
+@ !"#$%&')'*+,()'$0\xF0UEUUQUUPU+\xED\xF3\xFC+\xF7	\xFE\xFD\xFA	\xF7\xF3\xF9+\xEF\xFD\xFD\xFC\xF3\xEF\xCD\xCCL?\xCD\xCCL?\xCD\xCCL?	\x80\xBF\x80?\x80\x80?\x80\x80\xBF\x80\x80\xBF\x80?\x80\x80?\x80?\x80\x80?\x80\x80\xBF\x80
 \x80?\x80?\x80\x80\xBF\x80\x80\xBF\x80?\x80\x80\xBF\x80\x80\xBF\x80\x80\xBF\x80\xBF\x80\x80?\x80?\x80\x80\xBF\x80\x80\xBF\x80\x80?\x80?\x80?\x80\xBF\x80?\x80?\x80\xBF\x80?\x
 80?\x80\xBF\x80?\x80\xBF\x80\xBF\x80?\x80\xBF\x80\xBF\x80?\x80\xBF\x80\xBF\x80?\x80?\x80?\x80?\x80?\x80?\x80?\x80?\x80?\x80?\x80\xBF\x80?\x80?\x80\xBF\x80?\x80?\x80\xBF\x80?\x80\xBF\x80?\x80\xBF\x80\xBF\x80?\x80\xBF\x80\xBF\x80?\x80\xBF\x80\xBF\x80\xBF\x80\xBF\x80\xBF\x80\xBF\x80\xBF\x80\xBF\x80\xBF\x80\xBF\x80\xBF\x80?\x80?\x80\xBF\x80?\x80?\x80\xBF\x80?\x80?\x80\xBF\x80\xBF\x80?\x80\xBF\x80\xBF\x80?\x80\xBF\x80\xBF\x80? ?? ?? ??\xC0>?\xC0>?\xC0>? ?@? ?@? ?@?\xC0>@?\xC0>@?\xC0>@? ?\x80> ?\x80>`??\xC0>\x80>>?\xC0>\x80> €À€ ?À€À€À€À€À€À€ ?À€À€\x80?À€À€`?À€À€@?À€À€\xC0>À€À€À€À€À€À€À€>À€À€@?À€À€\xC0>À€À€\x80?	\x92\xF7>oz\xAC>f\xB6U\xBE\xB7\xCDG?2"->`\x81A?Z\x8B\xBE\x9E)?À€À€À€@\x81o@À€À€À€À€O\xD5@À€À€À€\x80\xB4@À€À€À€@N@À€À€À€À€\x8E\x9D@À€À€À€\xE0V\x
 F0\xBF@\xABM\xF3\xAEupAxisYprimChildrenuntitleddefaultPrimmetersPerUnitcustomLayerDatacreatorusdzconvert preview 0.62specifiertypeNameXformassetInfonamekindcomponentMaterialsGeompropertiesm\xF4#:bindingScopeCubeLightCameraxformOp:translateTOrder+A:oriq\xA1eshpoints\xC0vars:stnorm\x87\xF8faceVertexIndice0Cou7\xF5subdivisionSchemedoubleSided\xD2]C.%er0surf0Sha\xA0\x83outputs:\xA1info:idin\xB0diffuseColo\x84metallic$\xF4roughnessboolvariability\x8C\xF2int[]tokenUsdP\xC2S\x91 c^\xF33ffloattargetPaths@3f[]C\xC1erpolationv+pconnec0a/7@ord2<\xA3nonequatf3\xA03token[]	9AR$U\xF1UTEQ\xF4\xF8\xF8\xF8\xF0\xF0	\xF8#\xDC\xDC\xDC\xDC\xD6\xD2\x
 DC\xDC\xDC\xDC5 0@XA)\xB1@\x80?	@dP*@A@\x8011@\x9C3)\xAC1@\xB83)\xCC1@\xE0
 @)	0)$D@(0LX- #,3@0h2\x80\xA0#\xA0123\xE0 34\xC1@\xCD\xCC\xCC>@\xEC 3"\xF96!1@A3\x808 0	3"=:A@P3\x80;xi3\x80<= @	3P>A@`3x?\x80\x90\x80s~\xF0lEUTTUUPTUEQUUAUUQUUTEU\xFB\xF5\xF3\xF2	\xF0\xEF\xEC\xEA\xFB\xEC\xE8\xE5\xE3\xE2\xFB\xE0!\xDE#\xDC#\xDB\xDA+\xD9(\xD6\xE1\xD5+\xD4-\xD2/\xFB\xD0\xFB\xCF2\xCD2\xCC5\xCA5\xC98\xE2\xC7##%\xF0UAUAAD\xE3\xE9\xE4\xF2	\xFB-\xF0UQQQEEUU\xCD\xFF0\xC7\xF5\xFF\xFC9\xCE\xFF+\xB1\xFF\xFF\xFFL\xAF$\xF0QQ@EU@T\xFF\xF2\xFC\xFE\xF7\xFE\xFE\xFA\xFE\xFA\xFE\xFD\xFE#\xE0&
 \xF0UUUAP\xFC\xFE\xF0@@\xFF\xFB\xF9TOKENS\xA0eSTRINGS
 FIELDS\x8EFIELDSETS\xAB	\x8EPATHS9
+\x9ESPECS\xD7
+kPK
+i|\x95Rn54
+
+untitled.imported.usdc\x86PKPJ
\ No newline at end of file

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (276561 => 276562)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-04-25 02:12:07 UTC (rev 276562)
@@ -46,6 +46,9 @@
 fast/visual-viewport/rubberbanding-viewport-rects.html [ Pass ]
 fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html  [ Pass ]
 
+model-element/model-element-contents-layer-updates-with-clipping.html [ Pass ]
+model-element/model-element-contents-layer-updates.html [ Pass ]
+
 # Pending SDK changes, re-skip these tests that are un-skipped above.
 fast/viewport/ios/viewport-fit-contain.html [ Skip ]
 fast/viewport/ios/viewport-fit-cover.html [ Skip ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (276561 => 276562)


--- trunk/LayoutTests/platform/mac/TestExpectations	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2021-04-25 02:12:07 UTC (rev 276562)
@@ -67,6 +67,10 @@
 fast/dom/Window/slow-unload-handler.html
 fast/dom/Window/slow-unload-handler-only-frame-is-stopped.html
 
+# This test only works with UI-side compositing
+model-element/model-element-contents-layer-updates-with-clipping.html [ Skip ]
+model-element/model-element-contents-layer-updates.html [ Skip ]
+
 # Accessibility tests for notifications that don't exist or aren't needed on Mac OS X.
 accessibility/aria-checkbox-sends-notification.html
 accessibility/aria-switch-sends-notification.html

Modified: trunk/Source/WebCore/ChangeLog (276561 => 276562)


--- trunk/Source/WebCore/ChangeLog	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/Source/WebCore/ChangeLog	2021-04-25 02:12:07 UTC (rev 276562)
@@ -1,3 +1,46 @@
+2021-04-24  Tim Horton  <timothy_hor...@apple.com>
+
+        Changing the source of a model element with clipping applied does not update the model
+        https://bugs.webkit.org/show_bug.cgi?id=224917
+
+        Reviewed by Simon Fraser.
+
+        Tests: model-element/model-element-contents-layer-updates-with-clipping.html
+               model-element/model-element-contents-layer-updates.html
+
+        Previously, a <model> with a contents clipping layer (e.g. border-radius)
+        would not reparent its contents layer in the right place when setContentsToModel
+        was called again (because the source changed), leaving the old model
+        contents layer in place.
+        
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::updateSublayerList):
+        Ensure that updateSublayerList always parents contentsLayer in one of its two homes:
+        under contentsClippingLayer, if it exists; otherwise, directly under the primary layer.
+
+        (WebCore::GraphicsLayerCA::setContentsToModel):
+        Drive-by fix a bug revealed by the tests for this patch: when swapping out the
+        contents layer in setContentsToModel, we also need to mark ContentsRectsChanged,
+        or the new contents layer will not get its bounds set during the subsequent flush.
+
+        (WebCore::GraphicsLayerCA::setContentsToPlatformLayer):
+        Remove special-case code that was added to fix this bug just for setContentsToPlatformLayer;
+        this case is now correctly handled for all contents layers by updateSublayerList.
+
+        (WebCore::GraphicsLayerCA::dumpInnerLayer const):
+        * platform/graphics/GraphicsLayerClient.h:
+        * platform/graphics/ca/PlatformCALayer.cpp:
+        (WebCore::PlatformCALayer::dumpAdditionalProperties):
+        * platform/graphics/ca/PlatformCALayer.h:
+        * testing/Internals.cpp:
+        (WebCore::toPlatformLayerTreeFlags):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        Add a bit to platformLayerTreeAsText() that makes PlatformCALayerRemoteModelHosting
+        dump the size of the model that it is hosting, which is used in the test for this bug.
+
+        Remove the IncludeOpacity bit since we can just always log opacity if it's not the default.
+
 2021-04-24  Julian Gonzalez  <julian_a_gonza...@apple.com>
 
         Crash in BreakBlockquoteCommand::doApply()

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h (276561 => 276562)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2021-04-25 02:12:07 UTC (rev 276562)
@@ -90,7 +90,7 @@
 enum class PlatformLayerTreeAsTextFlags : uint8_t {
     Debug = 1 << 0,
     IgnoreChildren = 1 << 1,
-    IncludeOpacity = 1 << 2,
+    IncludeModels = 1 << 2,
 };
 
 enum GraphicsLayerPaintFlags {

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (276561 => 276562)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2021-04-25 02:12:07 UTC (rev 276562)
@@ -1240,7 +1240,7 @@
     if (contentsLayerChanged)
         noteSublayersChanged();
 
-    noteLayerPropertyChanged(OpacityChanged);
+    noteLayerPropertyChanged(ContentsRectsChanged | OpacityChanged);
 }
 #endif
 
@@ -1249,9 +1249,6 @@
     if (m_contentsLayer && platformLayer == m_contentsLayer->platformLayer())
         return;
 
-    if (m_contentsClippingLayer && m_contentsLayer)
-        m_contentsLayer->removeFromSuperlayer();
-
     // FIXME: The passed in layer might be a raw layer or an externally created
     // PlatformCALayer. To determine this we attempt to get the
     // PlatformCALayer pointer. If this returns a null pointer we assume it's
@@ -1270,9 +1267,6 @@
 
     m_contentsLayerPurpose = platformLayer ? purpose : ContentsLayerPurpose::None;
 
-    if (m_contentsClippingLayer && m_contentsLayer)
-        m_contentsClippingLayer->appendSublayer(*m_contentsLayer);
-
     noteSublayersChanged();
     noteLayerPropertyChanged(ContentsPlatformLayerChanged);
 }
@@ -2030,17 +2024,14 @@
         list.append(m_layer);
     };
 
+    auto appendContentsLayer = [&](PlatformCALayerList& list) {
+        if (m_contentsVisible && m_contentsLayer)
+            list.append(m_contentsLayer);
+    };
+
     auto appendClippingLayers = [&](PlatformCALayerList& list) {
-        if (!m_contentsVisible)
-            return;
-
-        if (m_contentsClippingLayer) {
+        if (m_contentsVisible && m_contentsClippingLayer)
             list.append(m_contentsClippingLayer);
-            return;
-        }
-
-        if (m_contentsLayer)
-            list.append(m_contentsLayer);
     };
 
     auto appendCustomAndClippingLayers = [&](PlatformCALayerList& list) {
@@ -2047,7 +2038,10 @@
         if (auto* customSublayers = m_layer->customSublayers())
             list.appendVector(*customSublayers);
 
-        appendClippingLayers(list);
+        if (m_contentsClippingLayer)
+            appendClippingLayers(list);
+        else
+            appendContentsLayer(list);
     };
 
     auto appendLayersFromChildren = [&](PlatformCALayerList& list) {
@@ -2076,9 +2070,11 @@
     appendCustomAndClippingLayers(primaryLayerChildren);
 
     bool clippingLayerHostsChildren = m_contentsRectClipsDescendants && m_contentsClippingLayer;
-    if (clippingLayerHostsChildren) {
+    if (m_contentsClippingLayer) {
         PlatformCALayerList clippingChildren;
-        buildChildLayerList(clippingChildren);
+        if (clippingLayerHostsChildren)
+            buildChildLayerList(clippingChildren);
+        appendContentsLayer(clippingChildren);
         m_contentsClippingLayer->setSublayers(clippingChildren);
     }
 
@@ -3981,12 +3977,14 @@
         ts << indent << "(position " << layer->position().x() << " " << layer->position().y() << ")\n";
         ts << indent << "(bounds " << layer->bounds().width() << " " << layer->bounds().height() << ")\n";
         
-        if (flags.contains(PlatformLayerTreeAsTextFlags::IncludeOpacity))
+        if (layer->opacity() != 1)
             ts << indent << "(opacity " << layer->opacity() << ")\n";
 
         if (layer->isHidden())
             ts << indent << "(hidden)\n";
 
+        layer->dumpAdditionalProperties(ts, flags);
+
         if (!flags.contains(PlatformLayerTreeAsTextFlags::IgnoreChildren)) {
             auto sublayers = layer->sublayersForLogging();
             if (sublayers.size()) {

Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp (276561 => 276562)


--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp	2021-04-25 02:12:07 UTC (rev 276562)
@@ -198,6 +198,10 @@
     return *sharedPool;
 }
 
+void PlatformCALayer::dumpAdditionalProperties(TextStream&, OptionSet<PlatformLayerTreeAsTextFlags>)
+{
+}
+
 TextStream& operator<<(TextStream& ts, PlatformCALayer::LayerType layerType)
 {
     switch (layerType) {

Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h (276561 => 276562)


--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h	2021-04-25 02:12:07 UTC (rev 276562)
@@ -300,6 +300,8 @@
     static CGRect frameForLayer(const PlatformLayer*);
 
     void moveToLayerPool();
+    
+    virtual void dumpAdditionalProperties(TextStream&, OptionSet<PlatformLayerTreeAsTextFlags>);
 
 protected:
     PlatformCALayer(LayerType, PlatformCALayerClient* owner);

Modified: trunk/Source/WebCore/testing/Internals.cpp (276561 => 276562)


--- trunk/Source/WebCore/testing/Internals.cpp	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/Source/WebCore/testing/Internals.cpp	2021-04-25 02:12:07 UTC (rev 276562)
@@ -2861,8 +2861,8 @@
         platformLayerTreeFlags.add(PlatformLayerTreeAsTextFlags::Debug);
     if (flags & Internals::PLATFORM_LAYER_TREE_IGNORES_CHILDREN)
         platformLayerTreeFlags.add(PlatformLayerTreeAsTextFlags::IgnoreChildren);
-    if (flags & Internals::PLATFORM_LAYER_TREE_INCLUDE_OPACITY)
-        platformLayerTreeFlags.add(PlatformLayerTreeAsTextFlags::IncludeOpacity);
+    if (flags & Internals::PLATFORM_LAYER_TREE_INCLUDE_MODELS)
+        platformLayerTreeFlags.add(PlatformLayerTreeAsTextFlags::IncludeModels);
     return platformLayerTreeFlags;
 }
 

Modified: trunk/Source/WebCore/testing/Internals.h (276561 => 276562)


--- trunk/Source/WebCore/testing/Internals.h	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/Source/WebCore/testing/Internals.h	2021-04-25 02:12:07 UTC (rev 276562)
@@ -425,7 +425,7 @@
         // Values need to be kept in sync with Internals.idl.
         PLATFORM_LAYER_TREE_DEBUG = 1,
         PLATFORM_LAYER_TREE_IGNORES_CHILDREN = 2,
-        PLATFORM_LAYER_TREE_INCLUDE_OPACITY = 4,
+        PLATFORM_LAYER_TREE_INCLUDE_MODELS = 4,
     };
     ExceptionOr<String> platformLayerTreeAsText(Element&, unsigned short flags) const;
 

Modified: trunk/Source/WebCore/testing/Internals.idl (276561 => 276562)


--- trunk/Source/WebCore/testing/Internals.idl	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/Source/WebCore/testing/Internals.idl	2021-04-25 02:12:07 UTC (rev 276562)
@@ -504,7 +504,7 @@
     // Flags for platformLayerTreeAsText.
     const unsigned short PLATFORM_LAYER_TREE_DEBUG = 1;
     const unsigned short PLATFORM_LAYER_TREE_IGNORES_CHILDREN = 2;
-    const unsigned short PLATFORM_LAYER_TREE_INCLUDE_OPACITY = 4;
+    const unsigned short PLATFORM_LAYER_TREE_INCLUDE_MODELS = 4;
     DOMString platformLayerTreeAsText(Element element, optional unsigned short flags = 0);
 
     DOMString scrollbarOverlayStyle(optional Node? node = null);

Modified: trunk/Source/WebKit/ChangeLog (276561 => 276562)


--- trunk/Source/WebKit/ChangeLog	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/Source/WebKit/ChangeLog	2021-04-25 02:12:07 UTC (rev 276562)
@@ -1,3 +1,16 @@
+2021-04-24  Tim Horton  <timothy_hor...@apple.com>
+
+        Changing the source of a model element with clipping applied does not update the model
+        https://bugs.webkit.org/show_bug.cgi?id=224917
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.h:
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.mm:
+        (WebKit::PlatformCALayerRemoteModelHosting::dumpAdditionalProperties):
+        Add a bit to platformLayerTreeAsText() that makes PlatformCALayerRemoteModelHosting
+        dump the size of the model that it is hosting, which is used in the test for this bug.
+
 2021-04-23  Kate Cheney  <katherine_che...@apple.com>
 
         PCM: debug mode should send the second report on a 10 second delay after the first

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.h (276561 => 276562)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.h	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.h	2021-04-25 02:12:07 UTC (rev 276562)
@@ -42,6 +42,8 @@
     Ref<WebCore::PlatformCALayer> clone(WebCore::PlatformCALayerClient* owner) const override;
     
     void populateCreationProperties(RemoteLayerTreeTransaction::LayerCreationProperties&, const RemoteLayerTreeContext&, WebCore::PlatformCALayer::LayerType) override;
+    
+    void dumpAdditionalProperties(TextStream&, OptionSet<PlatformLayerTreeAsTextFlags>) final;
 
     Ref<Model> m_model;
 };

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.mm (276561 => 276562)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.mm	2021-04-25 00:50:32 UTC (rev 276561)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.mm	2021-04-25 02:12:07 UTC (rev 276562)
@@ -66,4 +66,10 @@
     properties.model = m_model.ptr();
 }
 
+void PlatformCALayerRemoteModelHosting::dumpAdditionalProperties(TextStream& ts, OptionSet<PlatformLayerTreeAsTextFlags> flags)
+{
+    if (flags.contains(PlatformLayerTreeAsTextFlags::IncludeModels))
+        ts << indent << "(model data size " << m_model->data()->size() << ")\n";
+}
+
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to