Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fixed position elements should layout relative to transformed container
https://bugs.webkit.org/show_bug.cgi?id=118635 Reviewed by Alan Bujtas. Layout code already handled `transform` and `will-change: transform` triggering containing block for `position: fixed`. However, compositing code would still treat the elements as fixed, registering them with the scrolling tree, so that scrolling would reposition them. Fix this by having `RenderLayerCompositor::isViewportConstrainedFixedOrStickyLayer()` consult the `behavesAsFixed()` flag on RenderLayer (rather than the position style). However, we also need to make `behavesAsFixed()` correct under a `will-change` ancestor, so have `RenderLayer::recursiveUpdateLayerPositions()` consult `canContainFixedPositionObjects()` and maintain a new `m_hasFixedContainingBlockAncestor` flag on RenderLayer (since the `m_hasTransformedAncestor`) one is used for other purposes. * LayoutTests/scrollingcoordinator/scrolling-tree/fixed-position-within-transformed-expected.txt: Added. * LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/fixed-position-within-transformed-expected.txt: Added. * LayoutTests/scrollingcoordinator/scrolling-tree/fixed-position-within-transformed.html: Added. * Source/WebCore/rendering/RenderLayer.cpp: (WebCore::RenderLayer::RenderLayer): (WebCore::RenderLayer::flagsForUpdateLayerPositions): (WebCore::RenderLayer::recursiveUpdateLayerPositions): * Source/WebCore/rendering/RenderLayer.h: (WebCore::RenderLayer::hasFixedContainingBlockAncestor const): * Source/WebCore/rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::isViewportConstrainedFixedOrStickyLayer const): Canonical link: https://commits.webkit.org/253809@main
- Loading branch information
Showing
6 changed files
with
109 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
(Frame scrolling node | ||
(scrollable area size 800 600) | ||
(contents size 800 3016) | ||
(scrollable area parameters | ||
(horizontal scroll elasticity 1) | ||
(vertical scroll elasticity 1) | ||
(horizontal scrollbar mode 0) | ||
(vertical scrollbar mode 0)) | ||
(layout viewport at (0,0) size 800x600) | ||
(min layout viewport origin (0,0)) | ||
(max layout viewport origin (0,2416)) | ||
(behavior for fixed 1) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
(Frame scrolling node | ||
(scrollable area size 785 600) | ||
(contents size 785 3016) | ||
(scrollable area parameters | ||
(horizontal scroll elasticity 2) | ||
(vertical scroll elasticity 2) | ||
(horizontal scrollbar mode 0) | ||
(vertical scrollbar mode 0) | ||
(allows vertical scrolling 1)) | ||
(layout viewport at (0,0) size 785x600) | ||
(min layout viewport origin (0,0)) | ||
(max layout viewport origin (0,2416)) | ||
(behavior for fixed 1) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
body { | ||
height: 3000px; | ||
} | ||
|
||
.container { | ||
position: relative; | ||
top: 500px; | ||
width: 200px; | ||
height: 200px; | ||
border: 1px solid black; | ||
} | ||
|
||
.not-fixed { | ||
position: fixed; | ||
width: 200px; | ||
height: 200px; | ||
background-color: green; | ||
} | ||
|
||
.compositing-trigger { | ||
position: absolute; | ||
left: 20px; | ||
top: 20px; | ||
width: 50px; | ||
height: 50px; | ||
background-color: gray; | ||
will-change: transform; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container" style="transform: translate(0, 0)"> | ||
<div class="compositing-trigger"></div> | ||
<div class="not-fixed"></div> | ||
</div> | ||
|
||
<div class="container" style="will-change: transform"> | ||
<div class="compositing-trigger"></div> | ||
<div class="not-fixed"></div> | ||
</div> | ||
|
||
<pre id="tree">Scrolling tree goes here</pre> | ||
<script> | ||
if (window.testRunner) | ||
testRunner.dumpAsText(); | ||
|
||
if (window.internals) | ||
document.getElementById('tree').innerText = internals.scrollingStateTreeAsText(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters