nsTableFrame::RePositionViews(presContext, rowFrame);
nsTableFrame::RePositionViews(aPresContext, rowFrame);
nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,                                     nscoord                  aAmount){   nsIPresContext *presContext = GetPresContext();  float p2t;  p2t = presContext->PixelsToTwips();  nscoord cellSpacingY = GetCellSpacingY();  nsMargin borderPadding = GetChildAreaOffset(&aReflowState);    nsVoidArray rowGroups;  PRUint32 numRowGroups;  OrderRowGroups(rowGroups, numRowGroups, nsnull);  nscoord amountUsed = 0;  // distribute space to each pct height row whose row group doesn't have a computed   // height, and base the pct on the table height. If the row group had a computed   // height, then this was already done in nsTableRowGroupFrame::CalculateRowHeights  nscoord pctBasis = aReflowState.mComputedHeight - (GetCellSpacingY() * (GetRowCount() + 1));  nscoord yOriginRG = borderPadding.top + GetCellSpacingY();  nscoord yEndRG = yOriginRG;  PRUint32 rgX;  for (rgX = 0; (rgX < numRowGroups); rgX++) {    nsTableRowGroupFrame* rgFrame = GetRowGroupFrame((nsIFrame*)rowGroups.ElementAt(rgX));    nscoord amountUsedByRG = 0;    nscoord yOriginRow = 0;    nsRect rgRect = rgFrame->GetRect();    if (rgFrame && !rgFrame->HasStyleHeight()) {      nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();      while (rowFrame) {        nsRect rowRect = rowFrame->GetRect();        if ((amountUsed < aAmount) && rowFrame->HasPctHeight()) {          nscoord pctHeight = nsTableFrame::RoundToPixel(rowFrame->GetHeight(pctBasis), p2t);          nscoord amountForRow = PR_MIN(aAmount - amountUsed, pctHeight - rowRect.height);          if (amountForRow > 0) {            rowRect.height += amountForRow;            rowFrame->SetRect(rowRect);            yOriginRow += rowRect.height + cellSpacingY;            yEndRG += rowRect.height + cellSpacingY;            amountUsed += amountForRow;            amountUsedByRG += amountForRow;            //rowFrame->DidResize(aPresContext, aReflowState);                    nsTableFrame::RePositionViews(presContext, rowFrame);          }        }        else {          if (amountUsed > 0) {            rowFrame->SetPosition(nsPoint(rowRect.x, yOriginRow));            nsTableFrame::RePositionViews(presContext, rowFrame);          }          yOriginRow += rowRect.height + cellSpacingY;          yEndRG += rowRect.height + cellSpacingY;        }        rowFrame = rowFrame->GetNextRow();      }      if (amountUsed > 0) {        rgRect.y = yOriginRG;        rgRect.height += amountUsedByRG;        rgFrame->SetRect(rgRect);      }    }    else if (amountUsed > 0) {      rgFrame->SetPosition(nsPoint(0, yOriginRG));      // Make sure child views are properly positioned      nsTableFrame::RePositionViews(presContext, rgFrame);    }    yOriginRG = yEndRG;  }  if (amountUsed >= aAmount) {    ResizeCells(*this, presContext, aReflowState);    return;  }  // get the first row without a style height where its row group has an unconstrianed height  nsTableRowGroupFrame* firstUnStyledRG  = nsnull;  nsTableRowFrame*      firstUnStyledRow = nsnull;  for (rgX = 0; (rgX < numRowGroups) && !firstUnStyledRG; rgX++) {    nsTableRowGroupFrame* rgFrame = GetRowGroupFrame((nsIFrame*)rowGroups.ElementAt(rgX));    if (rgFrame && !rgFrame->HasStyleHeight()) {      nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();      while (rowFrame) {        if (!rowFrame->HasStyleHeight()) {          firstUnStyledRG = rgFrame;          firstUnStyledRow = rowFrame;          break;        }        rowFrame = rowFrame->GetNextRow();      }    }  }  nsTableRowFrame* lastElligibleRow = nsnull;  // accumulate the correct divisor. This will be the total of all unstyled rows inside   // unstyled row groups, unless there are none, in which case, it will be all rows  nscoord divisor = 0;  for (rgX = 0; rgX < numRowGroups; rgX++) {    nsTableRowGroupFrame* rgFrame = GetRowGroupFrame((nsIFrame*)rowGroups.ElementAt(rgX));    if (rgFrame && (!firstUnStyledRG || !rgFrame->HasStyleHeight())) {      nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();      while (rowFrame) {        if (!firstUnStyledRG || !rowFrame->HasStyleHeight()) {          divisor += rowFrame->GetSize().height;          lastElligibleRow = rowFrame;        }        rowFrame = rowFrame->GetNextRow();      }    }  }  if (divisor <= 0) {    NS_ERROR("invalid divisor");    return;  }  // allocate the extra height to the unstyled row groups and rows  pctBasis = aAmount - amountUsed;  yOriginRG = borderPadding.top + cellSpacingY;  yEndRG = yOriginRG;  for (rgX = 0; rgX < numRowGroups; rgX++) {    nsTableRowGroupFrame* rgFrame = GetRowGroupFrame((nsIFrame*)rowGroups.ElementAt(rgX));    if (!rgFrame) continue;     nscoord amountUsedByRG = 0;    nscoord yOriginRow = 0;    nsRect rgRect = rgFrame->GetRect();    // see if there is an eligible row group    if (!firstUnStyledRG || !rgFrame->HasStyleHeight()) {      nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();      while (rowFrame) {        nsRect rowRect = rowFrame->GetRect();        // see if there is an eligible row        if (!firstUnStyledRow || !rowFrame->HasStyleHeight()) {          // The amount of additional space each row gets is proportional to its height          float percent = rowRect.height / ((float)divisor);          // give rows their percentage, except for the last row which gets the remainder          nscoord amountForRow = (rowFrame == lastElligibleRow)                                  ? aAmount - amountUsed : NSToCoordRound(((float)(pctBasis)) * percent);          amountForRow = PR_MIN(nsTableFrame::RoundToPixel(amountForRow, p2t), aAmount - amountUsed);          // update the row height          nsRect newRowRect(rowRect.x, yOriginRow, rowRect.width, rowRect.height + amountForRow);          rowFrame->SetRect(newRowRect);          yOriginRow += newRowRect.height + cellSpacingY;          yEndRG += newRowRect.height + cellSpacingY;          amountUsed += amountForRow;          amountUsedByRG += amountForRow;          NS_ASSERTION((amountUsed <= aAmount), "invalid row allocation");          //rowFrame->DidResize(aPresContext, aReflowState);                  nsTableFrame::RePositionViews(presContext, rowFrame);        }        else {          if (amountUsed > 0) {            rowFrame->SetPosition(nsPoint(rowRect.x, yOriginRow));            nsTableFrame::RePositionViews(presContext, rowFrame);          }          yOriginRow += rowRect.height + cellSpacingY;          yEndRG += rowRect.height + cellSpacingY;        }        rowFrame = rowFrame->GetNextRow();      }      if (amountUsed > 0) {        rgRect.y = yOriginRG;        rgRect.height += amountUsedByRG;        rgFrame->SetRect(rgRect);      }      // Make sure child views are properly positioned      // XXX what happens if childFrame is a scroll frame and this gets skipped? see also below    }    else if (amountUsed > 0) {      rgFrame->SetPosition(nsPoint(0, yOriginRG));      // Make sure child views are properly positioned      nsTableFrame::RePositionViews(presContext, rgFrame);    }    yOriginRG = yEndRG;  }  ResizeCells(*this, presContext, aReflowState);}