if (((nsTableRowGroupFrame*)rgFrame)->RowGroupReceivesExcessSpace()) { ((nsTableRowGroupFrame*)rgFrame)->GetHeightOfRows(aPresContext, sumOfRowHeights); } if (!firstRowGroupFrame) { nsMargin borderPadding = aReflowState.mComputedBorderPadding; rowGroupYPos = borderPadding.top; firstRowGroupFrame = childFrame;
if (rgFrame->RowGroupReceivesExcessSpace()) { rgFrame->GetHeightOfRows(aPresContext, sumOfRowHeights);
nscoord nsTableFrame::ComputeDesiredHeight(nsIPresContext*          aPresContext,                                           const nsHTMLReflowState& aReflowState,                                            nscoord                  aDefaultHeight) {  nsTableCellMap* cellMap = GetCellMap();  if (!cellMap) {    NS_ASSERTION(PR_FALSE, "never ever call me until the cell map is built!");    return 0;  }  nscoord result = aDefaultHeight;  nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aPresContext, aReflowState);  if ((tableSpecifiedHeight > 0) && (tableSpecifiedHeight != NS_UNCONSTRAINEDSIZE)) {    if (tableSpecifiedHeight > aDefaultHeight) {      result = tableSpecifiedHeight;      if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) {         // proportionately distribute the excess height to each row. Note that we        // don't need to do this if it's an unconstrained reflow        nscoord excess = tableSpecifiedHeight - aDefaultHeight;        nscoord sumOfRowHeights = 0;        nscoord rowGroupYPos = 0;        nsIFrame* childFrame = mFrames.FirstChild();        nsIFrame* firstRowGroupFrame = nsnull;        while (nsnull != childFrame) {          nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(childFrame);          if (rgFrame) {            if (((nsTableRowGroupFrame*)rgFrame)->RowGroupReceivesExcessSpace()) {               ((nsTableRowGroupFrame*)rgFrame)->GetHeightOfRows(aPresContext, sumOfRowHeights);            }            if (!firstRowGroupFrame) {              nsMargin borderPadding = aReflowState.mComputedBorderPadding;              rowGroupYPos = borderPadding.top;              firstRowGroupFrame = childFrame;            }          }          childFrame->GetNextSibling(&childFrame);        }          childFrame = mFrames.FirstChild();        while (childFrame) {          nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(childFrame);          if (rgFrame) {            if (((nsTableRowGroupFrame*)rgFrame)->RowGroupReceivesExcessSpace()) {              nscoord excessForGroup = 0;              const nsStyleTable* tableStyle;              GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);              DistributeSpaceToRows(aPresContext, aReflowState, rgFrame, sumOfRowHeights,                                     excess, excessForGroup, rowGroupYPos);                // Make sure child views are properly positioned              // XXX what happens if childFrame is a scroll frame and this gets skipped?              nsIView*  view;              rgFrame->GetView(aPresContext, &view);              if (view) {                nsContainerFrame::PositionFrameView(aPresContext, rgFrame, view);              } else {                nsContainerFrame::PositionChildViews(aPresContext, rgFrame);              }            }            else {              nsRect rowGroupRect;              rgFrame->GetRect(rowGroupRect);              rowGroupYPos += rowGroupRect.height;            }          }          childFrame->GetNextSibling(&childFrame);        }      }    }  }  return result;}