Skip to content

Commit

Permalink
This ensures that the viewport anchor layer will be updated when upda…
Browse files Browse the repository at this point in the history
…ting compositing layers upon style change

https://bugs.webkit.org/show_bug.cgi?id=246890
rdar://99568474

Reviewed by Simon Fraser.

* LayoutTests/compositing/scrolling/fixed-style-with-rotation.html: Added.
* LayoutTests/compositing/scrolling/sticky-style-with-rotation.html: Added.
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::layerStyleChanged):

Canonical link: https://commits.webkit.org/256025@main
  • Loading branch information
arunsundarapple authored and smfr committed Oct 26, 2022
1 parent c4f1f9c commit 67c0ccb
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
@@ -0,0 +1 @@
The HTML page loads as expected
20 changes: 20 additions & 0 deletions LayoutTests/compositing/scrolling/fixed-style-with-rotation.html
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<style>
body {
rotate: y 1turn;
}
</style>
<body>
<p>The HTML page loads as expected</p>
</body>
<script>
if (window.testRunner)
testRunner.dumpAsText();

onload = () => {
document.body.offsetTop;
document.body.style.position = 'fixed';
scrollBy(0, 0);
};
</script>

@@ -0,0 +1 @@
The HTML page loads as expected
20 changes: 20 additions & 0 deletions LayoutTests/compositing/scrolling/sticky-style-with-rotation.html
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<style>
body {
rotate: y 1turn;
}
</style>
<body>
<p>The HTML page loads as expected</p>
</body>
<script>
if (window.testRunner)
testRunner.dumpAsText();

onload = () => {
document.body.offsetTop;
document.body.style.position = 'sticky';
scrollBy(0, 0);
};
</script>

11 changes: 11 additions & 0 deletions Source/WebCore/rendering/RenderLayerCompositor.cpp
Expand Up @@ -1727,6 +1727,17 @@ void RenderLayerCompositor::layerStyleChanged(StyleDifference diff, RenderLayer&
}
}

// This ensures that the viewport anchor layer will be updated when updating compositing layers upon style change
auto styleChangeAffectsAnchorLayer = [](const RenderStyle* oldStyle, const RenderStyle& newStyle) {
if (!oldStyle)
return false;

return oldStyle->hasViewportConstrainedPosition() != newStyle.hasViewportConstrainedPosition();
};

if (styleChangeAffectsAnchorLayer(oldStyle, newStyle))
layer.setNeedsCompositingConfigurationUpdate();

// These properties trigger compositing if some descendant is composited.
if (oldStyle && styleChangeMayAffectIndirectCompositingReasons(*oldStyle, newStyle))
layer.setNeedsPostLayoutCompositingUpdate();
Expand Down

0 comments on commit 67c0ccb

Please sign in to comment.