Call SetGeometryDirty if we need to call DistributeHeightToRows, since DistributeHeightToRows can't deal with rows that have already had height distributed to them. Patch by Daniel Holbert <dholbert@mozilla.com>. b=380227 r+sr=dbaron

This commit is contained in:
dbaron@dbaron.org 2007-05-17 23:04:43 -07:00
parent 3cfbaf7cc5
commit 5b75544077
6 changed files with 60 additions and 9 deletions

View File

@ -0,0 +1,8 @@
<html>
<body>
<iframe id="myFrame"
style="height: 200px"
src="380227-iframe.html"/>
</body>
</html>

View File

@ -0,0 +1,17 @@
<html class="reftest-wait">
<body onload="HandleLoad()">
<script>
function HandleLoad() {
setTimeout(function() {
var myFrame = document.getElementById("myFrame");
myFrame.style.height = "200px";
document.documentElement.className = "";
}, 0);
}
</script>
<iframe id="myFrame"
style="height: 300px"
src="380227-iframe.html"/>
</body>
</html>

View File

@ -0,0 +1,9 @@
<html>
<body>
<table height="50%">
<tr><td bgcolor="blue">
x
</td></tr>
</table>
</body>
</html>

View File

@ -236,4 +236,5 @@ fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 372037-1.html 372037-1-ref.html # bug 3
random-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 379316-2.html 379316-2-ref.html # bug 379786
== 379328-1.html 379328-1-ref.html
== 380004-1.html 380004-1-ref.html
== 380227-1.html 380227-1-ref.html
== 380842-1.html 380842-1-ref.html

View File

@ -1871,6 +1871,17 @@ NS_METHOD nsTableFrame::Reflow(nsPresContext* aPresContext,
PRBool haveDesiredHeight = PR_FALSE;
PRBool reflowedChildren = PR_FALSE;
if (aReflowState.mComputedHeight != NS_UNCONSTRAINEDSIZE) {
// XXX Eventually, we should modify DistributeHeightToRows to use
// nsTableRowFrame::GetHeight instead of nsIFrame::GetSize().height.
// That way, it will make its calculations based on internal table
// frame heights as they are before they ever had any extra height
// distributed to them. In the meantime, this reflows all the
// internal table frames, which restores them to their state before
// DistributeHeightToRows was called.
SetGeometryDirty();
}
// Reflow the entire table (pass 2 and possibly pass 3). This phase is necessary during a
// constrained initial reflow and other reflows which require either a strategy init or balance.
// This isn't done during an unconstrained reflow, because it will occur later when the parent
@ -2728,7 +2739,8 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
aOverflowArea = nsRect (0, 0, 0, 0);
PRBool reflowAllKids = aReflowState.reflowState.ShouldReflowAllKids() ||
mBits.mResizedColumns;
mBits.mResizedColumns ||
IsGeometryDirty();
nsAutoVoidArray rowGroups;
PRUint32 numRowGroups;
@ -3016,14 +3028,12 @@ nsTableFrame::CalcDesiredHeight(const nsHTMLReflowState& aReflowState, nsHTMLRef
(tableSpecifiedHeight != NS_UNCONSTRAINEDSIZE) &&
(tableSpecifiedHeight > desiredHeight)) {
// proportionately distribute the excess height to unconstrained rows in each
// unconstrained row group.We don't need to do this if it's an unconstrained reflow
if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) {
DistributeHeightToRows(aReflowState, tableSpecifiedHeight - desiredHeight);
// this might have changed the overflow area incorporate the childframe overflow area.
for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame; kidFrame = kidFrame->GetNextSibling()) {
ConsiderChildOverflow(aDesiredSize.mOverflowArea, kidFrame);
}
}
// unconstrained row group.
DistributeHeightToRows(aReflowState, tableSpecifiedHeight - desiredHeight);
// this might have changed the overflow area incorporate the childframe overflow area.
for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame; kidFrame = kidFrame->GetNextSibling()) {
ConsiderChildOverflow(aDesiredSize.mOverflowArea, kidFrame);
}
desiredHeight = tableSpecifiedHeight;
}
}

View File

@ -606,6 +606,12 @@ public:
PRBool NeedColSpanExpansion() const;
void SetNeedColSpanExpansion(PRBool aValue);
/** The GeometryDirty bit is similar to the NS_FRAME_IS_DIRTY frame
* state bit, which implies that all descendants are dirty. The
* GeometryDirty still implies that all the parts of the table are
* dirty, but resizing optimizations should still apply to the
* contents of the individual cells.
*/
void SetGeometryDirty() { mBits.mGeometryDirty = PR_TRUE; }
void ClearGeometryDirty() { mBits.mGeometryDirty = PR_FALSE; }
PRBool IsGeometryDirty() const { return mBits.mGeometryDirty; }