Bug 708062. Root view bounds should not include viewport frame overflow area. r=tn

This commit is contained in:
Robert O'Callahan 2011-12-08 17:17:42 +13:00
parent 5bc052a4bd
commit 79009dc7eb
3 changed files with 60 additions and 10 deletions

View File

@ -7288,34 +7288,36 @@ PresShell::DoReflow(nsIFrame* target, bool aInterruptible)
// root frame, then its desired size had better not change! If it's
// initiated at the root, then the size better not change unless its
// height was unconstrained to start with.
nsRect boundsRelativeToTarget = nsRect(0, 0, desiredSize.width, desiredSize.height);
NS_ASSERTION((target == rootFrame && size.height == NS_UNCONSTRAINEDSIZE) ||
(desiredSize.width == size.width &&
desiredSize.height == size.height),
"non-root frame's desired size changed during an "
"incremental reflow");
NS_ASSERTION(target == rootFrame || desiredSize.VisualOverflow().IsEqualInterior(
nsRect(nsPoint(0, 0),
nsSize(desiredSize.width, desiredSize.height))),
NS_ASSERTION(target == rootFrame ||
desiredSize.VisualOverflow().IsEqualInterior(boundsRelativeToTarget),
"non-root reflow roots must not have visible overflow");
NS_ASSERTION(target == rootFrame || desiredSize.ScrollableOverflow().IsEqualEdges(
nsRect(nsPoint(0, 0),
nsSize(desiredSize.width, desiredSize.height))),
NS_ASSERTION(target == rootFrame ||
desiredSize.ScrollableOverflow().IsEqualEdges(boundsRelativeToTarget),
"non-root reflow roots must not have scrollable overflow");
NS_ASSERTION(status == NS_FRAME_COMPLETE,
"reflow roots should never split");
target->SetSize(nsSize(desiredSize.width, desiredSize.height));
target->SetSize(boundsRelativeToTarget.Size());
// Always use boundsRelativeToTarget here, not desiredSize.GetVisualOverflowArea(),
// because for root frames (where they could be different, since root frames
// are allowed to have overflow) the root view bounds need to match the
// viewport bounds; the view manager "window dimensions" code depends on it.
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, target,
target->GetView(),
desiredSize.VisualOverflow());
boundsRelativeToTarget);
nsContainerFrame::SyncWindowProperties(mPresContext, target,
target->GetView());
target->DidReflow(mPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
if (target == rootFrame && size.height == NS_UNCONSTRAINEDSIZE) {
mPresContext->SetVisibleArea(nsRect(0, 0, desiredSize.width,
desiredSize.height));
mPresContext->SetVisibleArea(boundsRelativeToTarget);
}
#ifdef DEBUG

View File

@ -55,6 +55,7 @@ _CHROME_FILES = \
test_bug533845.xul \
test_bug551434.html \
bug551434_childframe.html \
test_bug708062.html \
test_chrome_content_integration.xul \
chrome_content_integration_window.xul \
test_chrome_over_plugin.xul \

View File

@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=708062
-->
<head>
<title>Test for Bug 708062</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body onload="doTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=708062">Mozilla Bug 708062</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<iframe id="f" style="width:100px;"
src="data:text/html,A<div id='d' style='position:fixed;width:170px;top:0;right:0;height:1px;background:yellow;'>"></iframe>
<pre id="test">
<script>
function isBoundingClientRect(e, r, msg) {
var BCR = e.getBoundingClientRect();
is([BCR.left, BCR.top, BCR.right, BCR.bottom].join(','), r, msg);
}
function doTest() {
var f = document.getElementById('f');
var navigator1 = f.contentWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebNavigation);
var docShell = navigator1.QueryInterface(Components.interfaces.nsIDocShell);
var docviewer = docShell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
var d = f.contentDocument.getElementById('d');
isBoundingClientRect(d, "-70,0,100,1", "initial rect");
docviewer.fullZoom = 2;
isBoundingClientRect(d, "-120,0,50,1", "after zooming in");
docviewer.fullZoom = 1;
isBoundingClientRect(d, "-70,0,100,1", "after zooming back out");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>