Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (293208 => 293209)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-04-22 05:21:54 UTC (rev 293208)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-04-22 05:35:33 UTC (rev 293209)
@@ -1,3 +1,14 @@
+2022-04-21 Rob Buis <rb...@igalia.com>
+
+ `contain: layout` on the html element should change position:fixed behavior
+ https://bugs.webkit.org/show_bug.cgi?id=238560
+
+ Reviewed by Simon Fraser.
+
+ * web-platform-tests/css/css-contain/contain-layout-021-expected.html: Added.
+ * web-platform-tests/css/css-contain/contain-layout-021.html: Added.
+ * web-platform-tests/css/css-contain/reference/contain-layout-021-ref.html: Added.
+
2022-04-21 Chris Dumez <cdu...@apple.com>
No-op, instead of throwing, on dataTransfer.items.remove()
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-layout-021-expected.html (0 => 293209)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-layout-021-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-layout-021-expected.html 2022-04-22 05:35:33 UTC (rev 293209)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Containment Test: Layout containment fixed positioned descendants</title>
+<style>
+#green {
+ background: green;
+ width: 100px;
+ height: 100px;
+}
+body {
+ height: 3000px;
+ margin: 0px;
+}
+#spacer {
+ height: 200px;
+}
+</style>
+<script>
+function runTest() {
+ document.documentElement.scrollTop += 200;
+}
+</script>
+<body _onload_="runTest()">
+<div id="spacer"></div>
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<div id="green"></div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-layout-021.html (0 => 293209)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-layout-021.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-layout-021.html 2022-04-22 05:35:33 UTC (rev 293209)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Containment Test: Layout containment fixed positioned descendants</title>
+<link rel="help" href=""
+<link rel="match" href=""
+<meta name=assert content="Layout containment makes an element to act as containing block for fixed positioned descendants.">
+<style>
+html {
+ contain: layout;
+}
+#fixed {
+ position: fixed;
+ background: green;
+ width: 100px;
+ height: 100px;
+}
+body {
+ height: 3000px;
+ margin: 0px;
+}
+#spacer {
+ height: 200px;
+}
+</style>
+<script>
+function runTest() {
+ document.documentElement.scrollTop += 200;
+}
+</script>
+<body _onload_="runTest()">
+<div id="spacer"></div>
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<div id="fixed"></div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/reference/contain-layout-021-ref.html (0 => 293209)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/reference/contain-layout-021-ref.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/reference/contain-layout-021-ref.html 2022-04-22 05:35:33 UTC (rev 293209)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Containment Test: Layout containment fixed positioned descendants</title>
+<style>
+#green {
+ background: green;
+ width: 100px;
+ height: 100px;
+}
+body {
+ height: 3000px;
+ margin: 0px;
+}
+#spacer {
+ height: 200px;
+}
+</style>
+<script>
+function runTest() {
+ document.documentElement.scrollTop += 200;
+}
+</script>
+<body _onload_="runTest()">
+<div id="spacer"></div>
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<div id="green"></div>
+</body>
Modified: trunk/Source/WebCore/ChangeLog (293208 => 293209)
--- trunk/Source/WebCore/ChangeLog 2022-04-22 05:21:54 UTC (rev 293208)
+++ trunk/Source/WebCore/ChangeLog 2022-04-22 05:35:33 UTC (rev 293209)
@@ -1,3 +1,23 @@
+2022-04-21 Rob Buis <rb...@igalia.com>
+
+ `contain: layout` on the html element should change position:fixed behavior
+ https://bugs.webkit.org/show_bug.cgi?id=238560
+
+ Reviewed by Simon Fraser.
+
+ The mapLocalToContainer/mapAbsoluteToLocalPoint methods need to not only consider boxes
+ having transforms but need to include all checks in canContainFixedPositionObjects to
+ determine if the box acts as a fixed position containing block.
+
+ Tests: imported/w3c/web-platform-tests/css/css-contain/contain-layout-021.html
+ imported/w3c/web-platform-tests/css/css-contain/reference/contain-layout-021-ref.html
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::mapLocalToContainer const):
+ (WebCore::RenderBox::mapAbsoluteToLocalPoint const):
+ * rendering/svg/RenderSVGRoot.cpp:
+ (WebCore::RenderSVGRoot::mapLocalToContainer const):
+
2022-04-21 Chris Dumez <cdu...@apple.com>
No-op, instead of throwing, on dataTransfer.items.remove()
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (293208 => 293209)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2022-04-22 05:21:54 UTC (rev 293208)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2022-04-22 05:35:33 UTC (rev 293209)
@@ -2320,10 +2320,10 @@
bool isFixedPos = isFixedPositioned();
// If this box has a transform, it acts as a fixed position container for fixed descendants,
// and may itself also be fixed position. So propagate 'fixed' up only if this box is fixed position.
- if (hasTransform() && !isFixedPos)
+ if (isFixedPos)
+ mode.add(IsFixed);
+ else if (canContainFixedPositionObjects())
mode.remove(IsFixed);
- else if (isFixedPos)
- mode.add(IsFixed);
if (wasFixed)
*wasFixed = mode.contains(IsFixed);
@@ -2394,12 +2394,13 @@
void RenderBox::mapAbsoluteToLocalPoint(OptionSet<MapCoordinatesMode> mode, TransformState& transformState) const
{
bool isFixedPos = isFixedPositioned();
- if (hasTransform() && !isFixedPos) {
+ if (isFixedPos)
+ mode.add(IsFixed);
+ else if (canContainFixedPositionObjects()) {
// If this box has a transform, it acts as a fixed position container for fixed descendants,
// and may itself also be fixed position. So propagate 'fixed' up only if this box is fixed position.
mode.remove(IsFixed);
- } else if (isFixedPos)
- mode.add(IsFixed);
+ }
RenderBoxModelObject::mapAbsoluteToLocalPoint(mode, transformState);
}
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp (293208 => 293209)
--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp 2022-04-22 05:21:54 UTC (rev 293208)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp 2022-04-22 05:35:33 UTC (rev 293209)
@@ -512,10 +512,10 @@
bool isFixedPos = isFixedPositioned();
// If this box has a transform, it acts as a fixed position container for fixed descendants,
// and may itself also be fixed position. So propagate 'fixed' up only if this box is fixed position.
- if (hasTransform() && !isFixedPos)
+ if (isFixedPos)
+ mode.add(IsFixed);
+ else if (canContainFixedPositionObjects())
mode.remove(IsFixed);
- else if (isFixedPos)
- mode.add(IsFixed);
if (wasFixed)
*wasFixed = mode.contains(IsFixed);