nsTableRowGroupFrame *   aStartingFrame,
NS_METHOD nsTableFrame::ResizeReflowPass1(nsIPresContext*          aPresContext,                                          nsHTMLReflowMetrics&     aDesiredSize,                                          const nsHTMLReflowState& aReflowState,                                          nsReflowStatus&          aStatus,                                          nsTableRowGroupFrame *   aStartingFrame,                                          nsReflowReason           aReason,                                          PRBool                   aDoSiblingFrames){  NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");  NS_PRECONDITION(aReflowState.parentReflowState->frame == mParent,                  "bad parent reflow state");  NS_ASSERTION(nsnull==mPrevInFlow, "illegal call, cannot call pass 1 on a continuing frame.");  NS_ASSERTION(nsnull != mContent, "null content");  nsresult rv = NS_OK;  // set out params  aStatus = NS_FRAME_COMPLETE;  nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); // availSize is the space available at any given time in the process  nsSize maxSize(0, 0);       // maxSize is the size of the largest child so far in the process  nsSize kidMaxSize(0,0);  nsHTMLReflowMetrics kidSize(&kidMaxSize);  nscoord y = 0;  nscoord cellSpacingY = GetCellSpacingY();  // Compute the insets (sum of border and padding)  // XXX: since this is pass1 reflow and where we place the rowgroup frames is irrelevant, insets are probably a waste  if (IsAutoLayout(&aReflowState)) {    nsIFrame* kidFrame = aStartingFrame;    if (nsnull==kidFrame)      kidFrame = mFrames.FirstChild();       for ( ; nsnull != kidFrame; kidFrame->GetNextSibling(&kidFrame)) {      const nsStyleDisplay *childDisplay;      kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));      if ((NS_STYLE_DISPLAY_TABLE_HEADER_GROUP != childDisplay->mDisplay) &&          (NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP != childDisplay->mDisplay) &&          (NS_STYLE_DISPLAY_TABLE_ROW_GROUP    != childDisplay->mDisplay) ) {         // it's an unknown frame type, give it a generic reflow and ignore the results        nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,                                          availSize, aReason);        // rv intentionally not set here        ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, 0, 0, 0, aStatus);        kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);        continue;      }      // Get the table's border padding      nsMargin borderPadding;      GetTableBorderForRowGroup(GetRowGroupFrameFor(kidFrame, childDisplay), borderPadding);      const nsStyleSpacing* tableSpacing;      GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)tableSpacing));      nsMargin padding;      tableSpacing->GetPadding(padding);      borderPadding += padding;      y += cellSpacingY;      if (kidFrame == mFrames.FirstChild()) {        y += borderPadding.top;      }            // Reflow the child      nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,                                       availSize, aReason);      // Note: we don't bother checking here for whether we should clear the      // isTopOfPage reflow state flag, because we're dealing with an unconstrained      // height and it isn't an issue...      ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, borderPadding.left,                  y, 0, aStatus);      // Place the child since some of its content fit in us.      FinishReflowChild(kidFrame, aPresContext, kidSize, borderPadding.left,                        borderPadding.top + y, 0);      if (NS_UNCONSTRAINEDSIZE == kidSize.height)        // XXX This is very suspicious. Why would a row group frame want        // such a large height?        y = NS_UNCONSTRAINEDSIZE;      else        y += kidSize.height;      if (kidMaxSize.width > maxSize.width) {        maxSize.width = kidMaxSize.width;      }      if (kidMaxSize.height > maxSize.height) {        maxSize.height = kidMaxSize.height;      }      if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {        // If the child didn't finish layout then it means that it used        // up all of our available space (or needs us to split).        break;      }      if (!aDoSiblingFrames)        break;    }    // if required, give the colgroups their initial reflows    if (aDoSiblingFrames) {      kidFrame=mColGroups.FirstChild();         for ( ; nsnull != kidFrame; kidFrame->GetNextSibling(&kidFrame)) {        nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,                                         availSize, aReason);        ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, 0, 0, 0, aStatus);        FinishReflowChild(kidFrame, aPresContext, kidSize, 0, 0, 0);      }    }  }  // Get the table's border/padding  const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)    mStyleContext->GetStyleData(eStyleStruct_Spacing);  nsMargin tableBorderPadding;  GetTableBorder (tableBorderPadding);   // this gets the max border thickness at each edge  nsMargin tablePadding;  mySpacing->GetPadding(tablePadding);  tableBorderPadding += tablePadding;  aDesiredSize.width = kidSize.width;  nscoord defaultHeight = y + tableBorderPadding.top + tableBorderPadding.bottom;  aDesiredSize.height = ComputeDesiredHeight(aPresContext, aReflowState, defaultHeight);  mBits.mFirstPassValid = PR_TRUE;  return rv;}