kidFrame->SetRect(kidRect); Invalidate(kidRect);
kidFrame->SetRect(aPresContext, kidRect); Invalidate(aPresContext, kidRect);
nsTableFrame::ReflowChildren(nsIPresContext*     aPresContext,                             nsTableReflowState& aReflowState,                             PRBool              aDoColGroups,                             PRBool              aDirtyOnly,                             nsReflowStatus&     aStatus,                             nsIFrame*&          aLastChildReflowed,                             nsRect&             aOverflowArea,                             PRBool*             aReflowedAtLeastOne){  aStatus = NS_FRAME_COMPLETE;  aLastChildReflowed = nsnull;  nsIFrame* prevKidFrame = nsnull;  nsresult  rv = NS_OK;  nscoord   cellSpacingY = GetCellSpacingY();  PRBool isPaginated = aPresContext->IsPaginated();  aOverflowArea = nsRect (0, 0, 0, 0);    nsAutoVoidArray rowGroups;  PRUint32 numRowGroups;  nsTableRowGroupFrame *thead, *tfoot;  OrderRowGroups(rowGroups, numRowGroups, &aReflowState.firstBodySection, &thead, &tfoot);  PRBool haveReflowedRowGroup = PR_FALSE;  PRBool pageBreak = PR_FALSE;  for (PRUint32 childX = 0; ((PRInt32)childX) < rowGroups.Count(); childX++) {    nsIFrame* kidFrame = (nsIFrame*)rowGroups.ElementAt(childX);    // Get the frame state bits    // See if we should only reflow the dirty child frames    PRBool doReflowChild = PR_TRUE;    if (aDirtyOnly && ((kidFrame->GetStateBits() & NS_FRAME_IS_DIRTY) == 0)) {      doReflowChild = PR_FALSE;    }    if (doReflowChild) {      if (pageBreak) {        PushChildren(aPresContext, kidFrame, prevKidFrame);        aStatus = NS_FRAME_NOT_COMPLETE;        break;      }      nsSize kidAvailSize(aReflowState.availSize);      // if the child is a tbody in paginated mode reduce the height by a repeated footer      nsIFrame* repeatedFooter = nsnull;      nscoord repeatedFooterHeight = 0;      if (isPaginated && (NS_UNCONSTRAINEDSIZE != kidAvailSize.height)) {        if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == kidFrame->GetStyleDisplay()->mDisplay) { // the child is a tbody          nsIFrame* lastChild = (nsIFrame*)rowGroups.ElementAt(numRowGroups - 1);          if (NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == lastChild->GetStyleDisplay()->mDisplay) { // the last child is a tfoot            if (((nsTableRowGroupFrame*)lastChild)->IsRepeatable()) {              repeatedFooterHeight = lastChild->GetSize().height;              if (repeatedFooterHeight + cellSpacingY < kidAvailSize.height) {                repeatedFooter = lastChild;                kidAvailSize.height -= repeatedFooterHeight + cellSpacingY;              }            }          }        }      }      nsHTMLReflowMetrics desiredSize(PR_FALSE);      desiredSize.width = desiredSize.height = desiredSize.ascent = desiredSize.descent = 0;        if (childX < numRowGroups) {          // Reflow the child into the available space        nsHTMLReflowState  kidReflowState(aPresContext, aReflowState.reflowState, kidFrame,                                           kidAvailSize, aReflowState.reason);        InitChildReflowState(*aPresContext, kidReflowState);        // XXX fix up bad mComputedWidth for scroll frame        kidReflowState.mComputedWidth = PR_MAX(kidReflowState.mComputedWidth, 0);          // If this isn't the first row group, then we can't be at the top of the page        if (childX > 0) {          kidReflowState.mFlags.mIsTopOfPage = PR_FALSE;        }        aReflowState.y += cellSpacingY;                // record the next in flow in case it gets destroyed and the row group array        // needs to be recomputed.        nsIFrame* kidNextInFlow;        kidFrame->GetNextInFlow(&kidNextInFlow);          rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,                         aReflowState.x, aReflowState.y, 0, aStatus);        haveReflowedRowGroup = PR_TRUE;        aLastChildReflowed   = kidFrame;        pageBreak = PR_FALSE;        // see if there is a page break after this row group or before the next one        if (NS_FRAME_IS_COMPLETE(aStatus) && isPaginated &&             (NS_UNCONSTRAINEDSIZE != kidReflowState.availableHeight)) {          nsIFrame* nextKid = (childX + 1 < numRowGroups) ? (nsIFrame*)rowGroups.ElementAt(childX + 1) : nsnull;          pageBreak = PageBreakAfter(*kidFrame, nextKid);        }        // Place the child        PlaceChild(aPresContext, aReflowState, kidFrame, desiredSize);          // 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)) {                   kidFrame->GetNextInFlow(&kidNextInFlow);          if (!kidNextInFlow) {            // The child doesn't have a next-in-flow so create a continuing            // frame. This hooks the child into the flow            nsIFrame*     continuingFrame;            aPresContext->PresShell()->FrameConstructor()->              CreateContinuingFrame(aPresContext, kidFrame, this,                                    &continuingFrame);              // Add the continuing frame to the sibling list            continuingFrame->SetNextSibling(kidFrame->GetNextSibling());            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();          if (nsnull != nextSibling) {            PushChildren(aPresContext, nextSibling, kidFrame);          }          if (repeatedFooter) {            kidAvailSize.height = repeatedFooterHeight;            nsHTMLReflowState footerReflowState(aPresContext, aReflowState.reflowState, repeatedFooter,                                                 kidAvailSize, aReflowState.reason);            InitChildReflowState(*aPresContext, footerReflowState);            aReflowState.y += cellSpacingY;            nsReflowStatus footerStatus;            rv = ReflowChild(repeatedFooter, aPresContext, desiredSize, footerReflowState,                             aReflowState.x, aReflowState.y, 0, footerStatus);            PlaceChild(aPresContext, aReflowState, repeatedFooter, desiredSize);          }          break;        }      }    }    else if (childX < numRowGroups) { // it is a row group but isn't being reflowed      nsRect kidRect = kidFrame->GetRect();      if (haveReflowedRowGroup) {         if (kidRect.y != aReflowState.y) {          Invalidate(kidRect); // invalidate the old position          kidRect.y = aReflowState.y;          kidFrame->SetRect(kidRect);        // move to the new position          Invalidate(kidRect); // invalidate the new position        }      }      aReflowState.y += cellSpacingY + kidRect.height;    }    ConsiderChildOverflow(aPresContext, aOverflowArea, kidFrame);  }    // if required, give the colgroups their initial reflows  if (aDoColGroups) {    nsHTMLReflowMetrics kidMet(PR_FALSE);    for (nsIFrame* kidFrame = mColGroups.FirstChild(); kidFrame;         kidFrame = kidFrame->GetNextSibling()) {      nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState, kidFrame,                                       aReflowState.availSize, aReflowState.reason);      nsReflowStatus cgStatus;      ReflowChild(kidFrame, aPresContext, kidMet, kidReflowState, 0, 0, 0, cgStatus);      FinishReflowChild(kidFrame, aPresContext, nsnull, kidMet, 0, 0, 0);    }    SetHaveReflowedColGroups(PR_TRUE);  }  // set the repeatablility of headers and footers in the original table during its first reflow  // the repeatability of header and footers on continued tables is handled when they are created  if (isPaginated && !mPrevInFlow && (NS_UNCONSTRAINEDSIZE == aReflowState.availSize.height)) {    nsRect actualRect;    nsRect adjRect;    aPresContext->GetPageDim(&actualRect, &adjRect);    // don't repeat the thead or tfoot unless it is < 25% of the page height    if (thead) {      thead->SetRepeatable(IsRepeatable(*thead, actualRect.height));    }    if (tfoot) {      tfoot->SetRepeatable(IsRepeatable(*tfoot, actualRect.height));    }  }  if (aReflowedAtLeastOne) {    *aReflowedAtLeastOne = haveReflowedRowGroup;  }  return rv;}