PRBool haveTHead, haveTBody, haveTFoot, tHeadBeforeTFoot; GetSectionInfo(mFrames, haveTHead, haveTBody, haveTFoot, tHeadBeforeTFoot);
nsVoidArray rowGroups; PRUint32 numRowGroups; OrderRowGroups(rowGroups, numRowGroups, &aReflowState.firstBodySection); PRUint32 numChildren = rowGroups.Count();
NS_METHOD nsTableFrame::ReflowMappedChildren(nsIPresContext*        aPresContext,                                             nsHTMLReflowMetrics&   aDesiredSize,                                             InnerTableReflowState& aReflowState,                                             nsReflowStatus&        aStatus){  NS_PRECONDITION(mFrames.NotEmpty(), "no children");  nsIFrame* prevKidFrame = nsnull;  nsSize    kidMaxElementSize(0,0);  nsSize*   pKidMaxElementSize = (nsnull != aDesiredSize.maxElementSize) ? &kidMaxElementSize : nsnull;  nsresult  rv = NS_OK;  nscoord   cellSpacingY = GetCellSpacingY();  nsReflowReason reason;  if (!IsAutoLayout(&aReflowState.reflowState)) {    reason = aReflowState.reflowState.reason;    if (eReflowReason_Incremental==reason) {      reason = eReflowReason_Resize;      if (aDesiredSize.maxElementSize) {        aDesiredSize.maxElementSize->width = 0;        aDesiredSize.maxElementSize->height = 0;      }    }  }  else {    reason = eReflowReason_Resize;  }  // determine what section elements are present  PRBool haveTHead, haveTBody, haveTFoot, tHeadBeforeTFoot;  GetSectionInfo(mFrames, haveTHead, haveTBody, haveTFoot, tHeadBeforeTFoot);  // this never passes reflows down to colgroups  nsIFrame* kidFrame = mFrames.FirstChild();  while (kidFrame) {    nsSize              kidAvailSize(aReflowState.availSize);    nsHTMLReflowMetrics desiredSize(pKidMaxElementSize);    desiredSize.width = desiredSize.height = desiredSize.ascent = desiredSize.descent = 0;    const nsStyleDisplay* childDisplay;    kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));    if (IsRowGroup(childDisplay->mDisplay)) {      // Keep track of the first body section row group      if (!aReflowState.firstBodySection) {        if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay) {          aReflowState.firstBodySection = kidFrame;        }      }      nsMargin borderPadding;      GetTableBorderForRowGroup(GetRowGroupFrameFor(kidFrame, childDisplay), borderPadding);      const nsStyleSpacing* tableSpacing;      GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)tableSpacing));      borderPadding += aReflowState.reflowState.mComputedPadding;      // Reflow the child into the available space      nsHTMLReflowState  kidReflowState(aPresContext, aReflowState.reflowState,                                        kidFrame, kidAvailSize, reason);      // XXX fix up bad mComputedWidth for scroll frame      kidReflowState.mComputedWidth = PR_MAX(kidReflowState.mComputedWidth, 0);      if (aReflowState.firstBodySection && (kidFrame != aReflowState.firstBodySection)) {        // If this isn't the first row group frame or the header or footer, then        // we can't be at the top of the page anymore...        kidReflowState.isTopOfPage = PR_FALSE;      }      aReflowState.y += cellSpacingY;      nscoord x = borderPadding.left;      nscoord y = aReflowState.y;            if (RowGroupsShouldBeConstrained()) {        // Only applies to the tree widget.        nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aPresContext, aReflowState.reflowState);        if ((tableSpecifiedHeight != NS_UNCONSTRAINEDSIZE)) {          kidReflowState.availableHeight = tableSpecifiedHeight - y;          if (kidReflowState.availableHeight < 0)            kidReflowState.availableHeight = 0;        }      }      rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,                       x, y, 0, aStatus);      // Did the child fit?      if (desiredSize.height > kidAvailSize.height) {        if (aReflowState.firstBodySection && (kidFrame != aReflowState.firstBodySection)) {          // The child is too tall to fit at all in the available space, and it's          // not a header/footer or our first row group frame          PushChildren(aPresContext, kidFrame, prevKidFrame);          aStatus = NS_FRAME_NOT_COMPLETE;          break;        }      }      // Place the child      if (IsRowGroup(childDisplay->mDisplay)) {        // we don't want to adjust the maxElementSize if this is an initial reflow        // it was set by the TableLayoutStrategy and shouldn't be changed.        nsSize* requestedMaxElementSize = nsnull;        if (eReflowReason_Initial != aReflowState.reflowState.reason)          requestedMaxElementSize = aDesiredSize.maxElementSize;        PlaceChild(aPresContext, aReflowState, kidFrame, desiredSize,                   x, y, requestedMaxElementSize, kidMaxElementSize);      } else {        kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);      }      // Remember where we just were in case we end up pushing children      prevKidFrame = kidFrame;      // Special handling for incomplete children      if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {        nsIFrame* kidNextInFlow;                 kidFrame->GetNextInFlow(&kidNextInFlow);        if (nsnull == kidNextInFlow) {          // The child doesn't have a next-in-flow so create a continuing          // frame. This hooks the child into the flow          nsIFrame*     continuingFrame;          nsIPresShell* presShell;          nsIStyleSet*  styleSet;          aPresContext->GetShell(&presShell);          presShell->GetStyleSet(&styleSet);          NS_RELEASE(presShell);          styleSet->CreateContinuingFrame(aPresContext, kidFrame, this, &continuingFrame);          NS_RELEASE(styleSet);          // Add the continuing frame to the sibling list          nsIFrame* nextSib;                     kidFrame->GetNextSibling(&nextSib);          continuingFrame->SetNextSibling(nextSib);          kidFrame->SetNextSibling(continuingFrame);        }        // We've used up all of our available space so push the remaining        // children to the next-in-flow        nsIFrame* nextSibling;                 kidFrame->GetNextSibling(&nextSibling);        if (nsnull != nextSibling) {          PushChildren(aPresContext, nextSibling, kidFrame);        }        break;      }    }    else {// it's an unknown frame type, give it a generic reflow and ignore the results      nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState, kidFrame,                                       nsSize(0,0), eReflowReason_Resize);      nsHTMLReflowMetrics unusedDesiredSize(nsnull);      nsReflowStatus status;      ReflowChild(kidFrame, aPresContext, unusedDesiredSize, kidReflowState,                  0, 0, 0, status);      kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);    }    // Get the next child    kidFrame->GetNextSibling(&kidFrame);  }  return rv;}