Make sure to not propagate special height reflows too far. Bug 391901, r+sr+a=dbaron
authorbzbarsky@mit.edu
Mon, 08 Oct 2007 19:39:06 -0700
changeset 6738 97a9987555d3bb87115a6431ab272a06aa00a7ca
parent 6737 045596aeef0fe405597ef67a4a25a69204fe840d
child 6739 88da625014f956e14ace4f3d0e2538b2eb13ce28
push idunknown
push userunknown
push dateunknown
bugs391901
milestone1.9a9pre
Make sure to not propagate special height reflows too far. Bug 391901, r+sr+a=dbaron
layout/tables/nsTableCellFrame.cpp
layout/tables/nsTableFrame.cpp
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -834,16 +834,19 @@ NS_METHOD nsTableCellFrame::Reflow(nsPre
   }
 
   nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstKid,
                                    availSize);
   // mIPercentHeightObserver is for children of cells in quirks mode,
   // but only those than are tables in standards mode.  NeedsToObserve
   // will determine how far this is propagated to descendants.
   kidReflowState.mPercentHeightObserver = this;
+  // Don't propagate special height reflow state to our kids
+  kidReflowState.mFlags.mSpecialHeightReflow = PR_FALSE;
+  
   if (aReflowState.mFlags.mSpecialHeightReflow ||
       (GetFirstInFlow()->GetStateBits() & NS_TABLE_CELL_HAD_SPECIAL_REFLOW)) {
     // We need to force the kid to have mVResize set if we've had a
     // special reflow in the past, since the non-special reflow needs to
     // resize back to what it was without the special height reflow.
     kidReflowState.mFlags.mVResize = PR_TRUE;
   }
 
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -1878,20 +1878,18 @@ NS_METHOD nsTableFrame::Reflow(nsPresCon
       nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aReflowState);
       if ((tableSpecifiedHeight > 0) && 
           (tableSpecifiedHeight != NS_UNCONSTRAINEDSIZE)) {
         needToInitiateSpecialReflow = PR_TRUE;
       }
     }
     nsIFrame* lastChildReflowed = nsnull;
 
-    nsHTMLReflowState &mutable_rs =
-      const_cast<nsHTMLReflowState&>(aReflowState);
-    PRBool oldSpecialHeightReflow = mutable_rs.mFlags.mSpecialHeightReflow;
-    mutable_rs.mFlags.mSpecialHeightReflow = PR_FALSE;
+    NS_ASSERTION(!aReflowState.mFlags.mSpecialHeightReflow,
+                 "Shouldn't be in special height reflow here!");
 
     // do the pass 2 reflow unless this is a special height reflow and we will be 
     // initiating a special height reflow
     // XXXldb I changed this.  Should I change it back?
 
     // if we need to initiate a special height reflow, then don't constrain the 
     // height of the reflow before that
     nscoord availHeight = needToInitiateSpecialReflow 
@@ -1904,16 +1902,19 @@ NS_METHOD nsTableFrame::Reflow(nsPresCon
     // reevaluate special height reflow conditions
     if (GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT)
       needToInitiateSpecialReflow = PR_TRUE;
 
     // XXXldb Are all these conditions correct?
     if (needToInitiateSpecialReflow && NS_FRAME_IS_COMPLETE(aStatus)) {
       // XXXldb Do we need to set the mVResize flag on any reflow states?
 
+      nsHTMLReflowState &mutable_rs =
+        const_cast<nsHTMLReflowState&>(aReflowState);
+
       // distribute extra vertical space to rows
       CalcDesiredHeight(aReflowState, aDesiredSize); 
       mutable_rs.mFlags.mSpecialHeightReflow = PR_TRUE;
       // save the previous special height reflow initiator, install us as the new one
       nsIFrame* specialReflowInitiator = aReflowState.mPercentHeightReflowInitiator;
       mutable_rs.mPercentHeightReflowInitiator = this;
 
       ReflowTable(aDesiredSize, aReflowState, aReflowState.availableHeight, 
@@ -1924,19 +1925,19 @@ NS_METHOD nsTableFrame::Reflow(nsPresCon
       if (lastChildReflowed && NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
         // if there is an incomplete child, then set the desired height to include it but not the next one
         nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
         aDesiredSize.height = borderPadding.bottom + GetCellSpacingY() +
                               lastChildReflowed->GetRect().YMost();
       }
       haveDesiredHeight = PR_TRUE;
       reflowedChildren  = PR_TRUE;
-    }
-
-    mutable_rs.mFlags.mSpecialHeightReflow = oldSpecialHeightReflow;
+
+      mutable_rs.mFlags.mSpecialHeightReflow = PR_FALSE;
+    }
   }
 
   aDesiredSize.width = aReflowState.ComputedWidth() +
                        aReflowState.mComputedBorderPadding.LeftRight();
   if (!haveDesiredHeight) {
     CalcDesiredHeight(aReflowState, aDesiredSize); 
   }
   if (IsRowInserted()) {
@@ -6125,17 +6126,16 @@ nsTableFrame::PaintBCBorders(nsIRenderin
 
   RowGroupArray rowGroups;
   OrderRowGroups(rowGroups);
   PRBool done = PR_FALSE;
   PRBool haveIntersect = PR_FALSE;
   nsTableRowGroupFrame* inFlowRG  = nsnull;
   nsTableRowFrame*      inFlowRow = nsnull;
   // find startRowIndex, endRowIndex, startRowY
-  nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
   PRInt32 rowY = startRowY;
   for (PRUint32 rgX = 0; rgX < rowGroups.Length() && !done; rgX++) {
     nsTableRowGroupFrame* rgFrame = rowGroups[rgX];
     for (nsTableRowFrame* rowFrame = rgFrame->GetFirstRow(); rowFrame;
          rowFrame = rowFrame->GetNextRow()) {
       // conservatively estimate the half border widths outside the row
       nscoord topBorderHalf    = (GetPrevInFlow()) ? 0 : nsPresContext::CSSPixelsToAppUnits(rowFrame->GetTopBCBorderWidth() + 1); 
       nscoord bottomBorderHalf = (GetNextInFlow()) ? 0 : nsPresContext::CSSPixelsToAppUnits(rowFrame->GetBottomBCBorderWidth() + 1);