Bug 841363. Ensure padding-rect edges are included in scrollable area used to compute scrollWidth/scrollHeight for overflow:visible elements. r=matspal

--HG--
extra : rebase_source : 067c9577f797350274783d3c7cc682b5f74b998a
This commit is contained in:
Robert O'Callahan 2013-04-09 12:05:12 +12:00
parent 9ad50f5118
commit 332d038d07
3 changed files with 66 additions and 1 deletions

View File

@ -591,9 +591,17 @@ static nsSize GetScrollRectSizeForOverflowVisibleFrame(nsIFrame* aFrame)
nsRect paddingRect = aFrame->GetPaddingRectRelativeToSelf();
nsOverflowAreas overflowAreas(paddingRect, paddingRect);
// Add the scrollable overflow areas of children (if any) to the paddingRect.
// It's important to start with the paddingRect, otherwise if there are no
// children the overflow rect will be 0,0,0,0 which will force the point 0,0
// to be included in the final rect.
nsLayoutUtils::UnionChildOverflow(aFrame, overflowAreas);
// Make sure that an empty padding-rect's edges are included, by adding
// the padding-rect in again with UnionEdges.
nsRect overflowRect =
overflowAreas.ScrollableOverflow().UnionEdges(paddingRect);
return nsLayoutUtils::GetScrolledRect(aFrame,
overflowAreas.ScrollableOverflow(), paddingRect.Size(),
overflowRect, paddingRect.Size(),
aFrame->StyleVisibility()->mDirection).Size();
}

View File

@ -105,6 +105,7 @@ MOCHITEST_FILES = \
test_bug785324.html \
test_bug791616.html \
test_bug831780.html \
test_bug841361.html \
$(NULL)
MOCHITEST_CHROME_FILES = \

View File

@ -0,0 +1,56 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=841361
-->
<head>
<title>Test for Bug 841361</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=841361">Mozilla Bug 841361</a>
<p id="display">
<div style="width:500px; height:0;" id="a"></div>
<div style="width:0; height:500px;" id="b"></div>
<div style="width:500px;" id="c">
<div style="width:50px; height:50px; float:left; background:yellow"></div>
<div style="width:200px; height:50px; float:left; background:green"></div>
</div>
<div style="width:500px; height:0; overflow:hidden" id="d"></div>
<div style="width:0; height:500px; overflow:hidden" id="e"></div>
<div style="width:500px; overflow:hidden" id="f">
<div style="width:50px; height:50px; float:left; background:yellow"></div>
<div style="width:200px; height:50px; float:left; background:green"></div>
</div>
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
function doTest(id, w, h) {
var e = document.getElementById(id);
is(e.scrollWidth, w, "scrollWidth for element '" + id + "'");
is(e.scrollHeight, h, "scrollHeight for element '" + id + "'");
}
doTest("a", 500, 0);
doTest("b", 0, 500);
doTest("c", 500, 50);
doTest("d", 500, 0);
doTest("e", 0, 500);
doTest("f", 500, 50);
</script>
</pre>
</body>
</html>