Bug 733875: If you're a nsFrame inside a box, be sure to reflow your absolute children after box layout gives you your size. r=bz

This commit is contained in:
Daniel Holbert 2012-03-10 14:50:51 -08:00
parent 9c55e83277
commit c743f28bca
6 changed files with 141 additions and 0 deletions

View File

@ -7560,6 +7560,20 @@ nsFrame::DoLayout(nsBoxLayoutState& aState)
desiredSize.width = size.width;
desiredSize.height = size.height;
desiredSize.UnionOverflowAreasWithDesiredBounds();
if (HasAbsolutelyPositionedChildren()) {
// Set up a |reflowState| to pass into ReflowAbsoluteFrames
nsHTMLReflowState reflowState(aState.PresContext(), this,
aState.GetRenderingContext(),
nsSize(size.width, NS_UNCONSTRAINEDSIZE));
// Set up a |reflowStatus| to pass into ReflowAbsoluteFrames
// (just a dummy value; hopefully that's OK)
nsReflowStatus reflowStatus = NS_FRAME_COMPLETE;
ReflowAbsoluteFrames(aState.PresContext(), desiredSize,
reflowState, reflowStatus);
}
FinishAndStoreOverflow(desiredSize.mOverflowAreas, size);
SyncLayout(aState);

View File

@ -0,0 +1,29 @@
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<html>
<head>
<style>
.relpos_parent {
position: relative;
width: 100px;
height: 100px;
background: lightblue;
}
.abspos_child {
position: absolute;
left: 30px;
bottom: 10px;
width: 20px;
height: 20px;
background: purple;
}
</style>
</head>
<body>
<div>
<div class="relpos_parent">
<div class="abspos_child"></div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,32 @@
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<!-- This testcase has a -moz-box element with a block as its only child, which
forms a containing block for an absolutely positioned grandchild. -->
<html>
<head>
<style>
.box { display: -moz-box }
.relpos_parent {
position: relative;
width: 100px;
height: 100px;
background: lightblue;
}
.abspos_child {
position: absolute;
left: 30px;
bottom: 10px;
width: 20px;
height: 20px;
background: purple;
}
</style>
</head>
<body>
<div class="box">
<div class="relpos_parent">
<div class="abspos_child"></div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,30 @@
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<html>
<head>
<style>
body { margin-top: 50px }
.relpos_parent {
position: relative;
width: 100px;
height: 100px;
background: lightblue;
}
.abspos_child {
position: absolute;
left: 30px;
bottom: 10px;
width: 20px;
height: 130px;
background: purple;
}
</style>
</head>
<body>
<div>
<div class="relpos_parent">
<div class="abspos_child"></div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,34 @@
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<!-- This testcase has a -moz-box element with a block as its only child, which
forms a containing block for an absolutely positioned grandchild. Also, in
this case, the grandchild is taller than its parent and grandparent. -->
<html>
<head>
<style>
body { margin-top: 50px }
.box { display: -moz-box }
.relpos_parent {
position: relative;
width: 100px;
height: 100px;
background: lightblue;
}
.abspos_child {
position: absolute;
left: 30px;
bottom: 10px;
width: 20px;
height: 130px;
background: purple;
}
</style>
</head>
<body>
<div class="box">
<div class="relpos_parent">
<div class="abspos_child"></div>
</div>
</div>
</body>
</html>

View File

@ -7,3 +7,5 @@
== flexbox-attributes-no-box-vertical.xhtml flexbox-attributes-no-box-vertical-ref.xhtml
== flexbox-attributes-no-input-horizontal.xhtml flexbox-attributes-no-input-horizontal-ref.xhtml
== flexbox-attributes-no-input-vertical.xhtml flexbox-attributes-no-input-vertical-ref.xhtml
== flexbox-child-is-abspos-container-1.html flexbox-child-is-abspos-container-1-ref.html
== flexbox-child-is-abspos-container-2.html flexbox-child-is-abspos-container-2-ref.html