Title: [295715] trunk
Revision
295715
Author
za...@apple.com
Date
2022-06-21 19:41:14 -0700 (Tue, 21 Jun 2022)

Log Message

RenderBox::hasHorizontalLayoutOverflow/hasVerticalLayoutOverflow use incorrect coordinate space
https://bugs.webkit.org/show_bug.cgi?id=241796

Reviewed by Simon Fraser.

RenderBox::x() and y() are in the coordinate space of the containing block while layoutOverflowRect is relative to the box's border box. These functions would compute overflow true if the box happens to have some offset (through margin or positioning) even without actual overflow.

* LayoutTests/fast/overflow/horizontal-overflow-with-offset-expected.txt: Added.
* LayoutTests/fast/overflow/horizontal-overflow-with-offset.html: Added.
* LayoutTests/fast/overflow/vertical-overflow-with-offset-expected.txt: Added.
* LayoutTests/fast/overflow/vertical-overflow-with-offset.html: Added.
* Source/WebCore/rendering/RenderBox.h:
(WebCore::RenderBox::hasHorizontalLayoutOverflow const):
(WebCore::RenderBox::hasVerticalLayoutOverflow const):

Canonical link: https://commits.webkit.org/251720@main

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/fast/overflow/horizontal-overflow-with-offset-expected.txt (0 => 295715)


--- trunk/LayoutTests/fast/overflow/horizontal-overflow-with-offset-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/overflow/horizontal-overflow-with-offset-expected.txt	2022-06-22 02:41:14 UTC (rev 295715)
@@ -0,0 +1 @@
+PASS

Added: trunk/LayoutTests/fast/overflow/horizontal-overflow-with-offset.html (0 => 295715)


--- trunk/LayoutTests/fast/overflow/horizontal-overflow-with-offset.html	                        (rev 0)
+++ trunk/LayoutTests/fast/overflow/horizontal-overflow-with-offset.html	2022-06-22 02:41:14 UTC (rev 295715)
@@ -0,0 +1,38 @@
+<style>
+#container {
+  position: absolute;
+  top: 100px;
+  left: 100px;
+
+  width: 100px;
+  height: 100px;
+  overflow: hidden;
+
+  background-color: green;
+}
+
+#child {
+  width: 10px;
+  height: 10px;
+  background-color: blue;
+}
+</style>
+<div id=container><div id=child></div></div>
+<pre id=result></pre>
+<script>
+if (window.testRunner) {
+  testRunner.dumpAsText();
+  testRunner.waitUntilDone();
+}
+
+function overflowChanged(event) {
+  result.innerText = !event.horizontalOverflow ? "PASS" : "FAIL";
+  if (window.testRunner)
+    testRunner.notifyDone();
+}
+container.addEventListener('overflowchanged', overflowChanged, false);
+
+document.body.offsetHeight;
+// This should not trigger horizontal overflow change.
+child.style.height = "120px";
+</script>
\ No newline at end of file

Added: trunk/LayoutTests/fast/overflow/vertical-overflow-with-offset-expected.txt (0 => 295715)


--- trunk/LayoutTests/fast/overflow/vertical-overflow-with-offset-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/overflow/vertical-overflow-with-offset-expected.txt	2022-06-22 02:41:14 UTC (rev 295715)
@@ -0,0 +1 @@
+PASS

Added: trunk/LayoutTests/fast/overflow/vertical-overflow-with-offset.html (0 => 295715)


--- trunk/LayoutTests/fast/overflow/vertical-overflow-with-offset.html	                        (rev 0)
+++ trunk/LayoutTests/fast/overflow/vertical-overflow-with-offset.html	2022-06-22 02:41:14 UTC (rev 295715)
@@ -0,0 +1,38 @@
+<style>
+#container {
+  position: absolute;
+  top: 100px;
+  left: 100px;
+
+  width: 100px;
+  height: 100px;
+  overflow: hidden;
+
+  background-color: green;
+}
+
+#child {
+  width: 10px;
+  height: 10px;
+  background-color: blue;
+}
+</style>
+<div id=container><div id=child></div></div>
+<pre id=result></pre>
+<script>
+if (window.testRunner) {
+  testRunner.dumpAsText();
+  testRunner.waitUntilDone();
+}
+
+function overflowChanged(event) {
+  result.innerText = !event.verticalOverflow ? "PASS" : "FAIL";
+  if (window.testRunner)
+    testRunner.notifyDone();
+}
+container.addEventListener('overflowchanged', overflowChanged, false);
+
+document.body.offsetHeight;
+// This should not trigger vertical overflow change.
+child.style.width = "120px";
+</script>
\ No newline at end of file

Modified: trunk/Source/WebCore/rendering/RenderBox.h (295714 => 295715)


--- trunk/Source/WebCore/rendering/RenderBox.h	2022-06-22 02:38:43 UTC (rev 295714)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2022-06-22 02:41:14 UTC (rev 295715)
@@ -625,9 +625,9 @@
         if (!m_overflow)
             return false;
 
-        LayoutRect layoutOverflowRect = m_overflow->layoutOverflowRect();
-        flipForWritingMode(layoutOverflowRect);
-        return layoutOverflowRect.x() < x() || layoutOverflowRect.maxX() > x() + logicalWidth();
+        auto layoutOverflowRect = m_overflow->layoutOverflowRect();
+        auto paddingBoxRect = flippedClientBoxRect();
+        return layoutOverflowRect.x() < paddingBoxRect.x() || layoutOverflowRect.maxX() > paddingBoxRect.maxX();
     }
 
     bool hasVerticalLayoutOverflow() const
@@ -635,9 +635,9 @@
         if (!m_overflow)
             return false;
 
-        LayoutRect layoutOverflowRect = m_overflow->layoutOverflowRect();
-        flipForWritingMode(layoutOverflowRect);
-        return layoutOverflowRect.y() < y() || layoutOverflowRect.maxY() > y() + logicalHeight();
+        auto layoutOverflowRect = m_overflow->layoutOverflowRect();
+        auto paddingBoxRect = flippedClientBoxRect();
+        return layoutOverflowRect.y() < paddingBoxRect.y() || layoutOverflowRect.maxY() > paddingBoxRect.maxY();
     }
 
     virtual RenderPtr<RenderBox> createAnonymousBoxWithSameTypeAs(const RenderBox&) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to