Skip to content
Permalink
Browse files
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
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Jun 22, 2022
1 parent 6d01e0a commit d5e81d932ffb11c1f29c2992c7dbf9b7815e8237
Showing 5 changed files with 84 additions and 6 deletions.
@@ -0,0 +1 @@
PASS
@@ -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>
@@ -0,0 +1 @@
PASS
@@ -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>
@@ -625,19 +625,19 @@ override;
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
{
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

0 comments on commit d5e81d9

Please sign in to comment.