haikuwebkit/LayoutTests/model-element/model-element-contents-laye...

45 lines
1.5 KiB
HTML
Raw Permalink Normal View History

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. Canonical link: https://commits.webkit.org/236998@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276562 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-25 02:12:07 +00:00
<!DOCTYPE html><!-- webkit-test-runner [ ModelElementEnabled=true ] -->
<html>
<body>
<model id="model" style="border-radius: 5px">
<source src="resources/heart.usdz">
</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 = "resources/cube.usdz";
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>