Bug 424710. Make sizing of abs-pos frames whose container is the initial containing block sane and consistent with Firefox 2, while still incorrect. r+sr=dbaron

This commit is contained in:
roc+@cs.cmu.edu 2008-04-06 03:03:41 -07:00
parent 2c0ddfb82f
commit 8f556c16f9
4 changed files with 30 additions and 1 deletions

View File

@ -806,10 +806,14 @@ CalculateContainingBlockSizeForAbsolutes(const nsHTMLReflowState& aReflowState,
// content.
const nsHTMLReflowState* aLastRS = &aReflowState;
const nsHTMLReflowState* lastButOneRS = &aReflowState;
PRBool isCanvasBlock = PR_FALSE;
while (aLastRS->parentReflowState &&
aLastRS->parentReflowState->frame->GetContent() == frame->GetContent()) {
lastButOneRS = aLastRS;
aLastRS = aLastRS->parentReflowState;
if (aLastRS->frame->GetType() == nsGkAtoms::canvasFrame) {
isCanvasBlock = PR_TRUE;
}
}
if (aLastRS != &aReflowState) {
// Scrollbars need to be specifically excluded, if present, because they are outside the
@ -830,11 +834,23 @@ CalculateContainingBlockSizeForAbsolutes(const nsHTMLReflowState& aReflowState,
}
// We found a reflow state for the outermost wrapping frame, so use
// its computed metrics if available
if (aLastRS->ComputedWidth() != NS_UNCONSTRAINEDSIZE) {
// XXX grotesque hack for Firefox 2 compatibility until we can
// properly fix abs-pos containers! If this is the block for
// the root element, don't adjust the width here, just use the block's
// width. We have to do this because the abs-pos frame will be
// positioned relative to the block, not the canvas frame, and the
// block might have borders and margin which will throw things off
// if we use the canvas frame width.
// Positioning abs-pos frames relative to the canvas is bug 425432.
if (aLastRS->ComputedWidth() != NS_UNCONSTRAINEDSIZE && !isCanvasBlock) {
cbSize.width = PR_MAX(0,
aLastRS->ComputedWidth() + aLastRS->mComputedPadding.LeftRight() - scrollbars.LeftRight());
}
if (aLastRS->ComputedHeight() != NS_UNCONSTRAINEDSIZE) {
// XXX This can be terribly wrong if we're the root element's block,
// because our margin and borders will be included in the height
// here but the abs-pos element(s) are positioned relative to
// our content rect...
cbSize.height = PR_MAX(0,
aLastRS->ComputedHeight() + aLastRS->mComputedPadding.TopBottom() - scrollbars.TopBottom());
}

View File

@ -0,0 +1,5 @@
<!DOCTYPE HTML>
<html style="border:2px dotted blue; margin:3px;">
<body>
</body>
</html>

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html style="border:2px dotted blue; margin:3px;">
<body>
<div style="position:absolute; top:0; right:0px; width:100px; height:100px;"></div>
</body>
</html>

View File

@ -785,3 +785,5 @@ fails == 413027-3.html 413027-3-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 424074-1-ref2.xul 424074-1-ref3.xul
== 424236-10.html 424236-10-ref.html
== 424631-1.html 424631-1-ref.html
== 424710-1.html 424710-1-ref.html