nscoord y = cellSpacingY;
nscoord y = 0;
void nsTableFrame::DistributeSpaceToRows(nsIPresContext*   aPresContext,                                  const nsHTMLReflowState& aReflowState,                                  nsIFrame*                aRowGroupFrame,                                   nscoord                  aSumOfRowHeights,                                  nscoord                  aExcess,                                   nscoord&                 aExcessForRowGroup,                                   nscoord&                 aRowGroupYPos){  // the rows in rowGroupFrame need to be expanded by rowHeightDelta[i]  // and the rowgroup itself needs to be expanded by SUM(row height deltas)  nscoord cellSpacingY = GetCellSpacingY();  nsTableRowGroupFrame* rowGroupFrame = (nsTableRowGroupFrame*)aRowGroupFrame;  nsIFrame* rowFrame = rowGroupFrame->GetFirstFrame();  nscoord y = cellSpacingY;  while (rowFrame) {    const nsStyleDisplay *rowDisplay;    rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));    if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {      DistributeSpaceToRows(aPresContext, aReflowState, rowFrame, aSumOfRowHeights,                             aExcess, aExcessForRowGroup, y);    }    else if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {       // the row needs to be expanded by the proportion this row contributed to the original height      nsRect rowRect;      rowFrame->GetRect(rowRect);      float percent = ((float)(rowRect.height)) / (float)aSumOfRowHeights;      nscoord excessForRow = NSToCoordRound((float)aExcess * percent);      if (rowGroupFrame->RowsDesireExcessSpace()) {        nsRect newRowRect(rowRect.x, y, rowRect.width, excessForRow + rowRect.height);        rowFrame->SetRect(aPresContext, newRowRect);        if ((NS_STYLE_BORDER_COLLAPSE == GetBorderCollapseStyle()) && mBorderCollapser) {          PRInt32 rowIndex = ((nsTableRowFrame*)rowFrame)->GetRowIndex();          mBorderCollapser->SetBorderEdgeLength(NS_SIDE_LEFT,  rowIndex, newRowRect.height);          mBorderCollapser->SetBorderEdgeLength(NS_SIDE_RIGHT, rowIndex, newRowRect.height);        }        // better if this were part of an overloaded row::SetRect        y += excessForRow + rowRect.height;      }      y += cellSpacingY;      aExcessForRowGroup += excessForRow;    }    else { // XXX why      nsRect rowRect;      rowFrame->GetRect(rowRect);      y += rowRect.height;    }    rowGroupFrame->GetNextFrame(rowFrame, &rowFrame);  }  nsRect rowGroupRect;  aRowGroupFrame->GetRect(rowGroupRect);    if (rowGroupFrame->RowGroupDesiresExcessSpace()) {    nsRect newRowGroupRect(rowGroupRect.x, aRowGroupYPos, rowGroupRect.width,                            aExcessForRowGroup + rowGroupRect.height);    aRowGroupFrame->SetRect(aPresContext, newRowGroupRect);    aRowGroupYPos += aExcessForRowGroup + rowGroupRect.height;  }  else {    aRowGroupYPos += rowGroupRect.height;  }  DistributeSpaceToCells(aPresContext, aReflowState, aRowGroupFrame);}