aReflowState.reflowCommand->GetType(reflowType);
reflowState.reflowCommand->GetType(reflowType);
RootFrame::Reflow(nsIPresContext&          aPresContext,                  nsHTMLReflowMetrics&     aDesiredSize,                  const nsHTMLReflowState& aReflowState,                  nsReflowStatus&          aStatus){  NS_FRAME_TRACE_REFLOW_IN("RootFrame::Reflow");  aStatus = NS_FRAME_COMPLETE;  if (eReflowReason_Incremental == aReflowState.reason) {    // See if we're the target frame    nsIFrame* targetFrame;    aReflowState.reflowCommand->GetTarget(targetFrame);    if (this == targetFrame) {      nsIReflowCommand::ReflowType  reflowType;      nsIFrame*                     childFrame;      // Get the reflow type      aReflowState.reflowCommand->GetType(reflowType);      if ((nsIReflowCommand::FrameAppended == reflowType) ||          (nsIReflowCommand::FrameInserted == reflowType)) {        // Insert the frame into the child list        aReflowState.reflowCommand->GetChildFrame(childFrame);        if (nsnull == mFirstChild) {          mFirstChild = childFrame;        } else {          nsIFrame* lastChild = LastFrame(mFirstChild);          lastChild->SetNextSibling(childFrame);        }      } else if (nsIReflowCommand::FrameRemoved == reflowType) {        nsIFrame* deletedFrame;        // Get the child frame we should delete        aReflowState.reflowCommand->GetChildFrame(deletedFrame);        // Remove it from the child list        if (deletedFrame == mFirstChild) {          deletedFrame->GetNextSibling(mFirstChild);        } else {          nsIFrame* prevSibling = nsnull;          for (nsIFrame* f = mFirstChild; nsnull != f; f->GetNextSibling(f)) {            if (f == deletedFrame) {              break;            }            prevSibling = f;          }          if (nsnull != f) {            nsIFrame* nextSibling;            f->GetNextSibling(nextSibling);            NS_ASSERTION(nsnull != prevSibling, "null pointer");            prevSibling->SetNextSibling(nextSibling);          }        }        deletedFrame->SetNextSibling(nsnull);                  // Delete the frame        deletedFrame->DeleteFrame(aPresContext);      }    } else {      nsIFrame* nextFrame;      // Get the next frame in the reflow chain      aReflowState.reflowCommand->GetNext(nextFrame);      NS_ASSERTION(nextFrame == mFirstChild, "unexpected next reflow command frame");    }  }  // Reflow our child frame  if (nsnull != mFirstChild) {    // Compute how much space to reserve for our border and padding    const nsStyleSpacing* spacing =      (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);    nsMargin borderPadding;    spacing->CalcBorderPaddingFor(this, borderPadding);    nsSize  kidMaxSize(aReflowState.maxSize);    kidMaxSize.width -= borderPadding.left + borderPadding.right;    kidMaxSize.height -= borderPadding.top + borderPadding.bottom;    nsHTMLReflowMetrics desiredSize(nsnull);    nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState,                                     kidMaxSize);    // XXX HACK    kidReflowState.widthConstraint = eHTMLFrameConstraint_Fixed;    kidReflowState.minWidth = kidMaxSize.width;    kidReflowState.heightConstraint = eHTMLFrameConstraint_Fixed;    kidReflowState.minHeight = kidMaxSize.height;    nsIHTMLReflow* htmlReflow;    if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {      ReflowChild(mFirstChild, aPresContext, desiredSize, kidReflowState, aStatus);          // Place and size the child      nsRect  rect(borderPadding.left, borderPadding.top, desiredSize.width, desiredSize.height);      mFirstChild->SetRect(rect);      // XXX We should resolve the details of who/when DidReflow() notifications      // are sent...      htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);    }    // If this is a resize reflow and we have non-zero border or padding    // then do a repaint to make sure we repaint correctly.    // XXX We could be smarter about only damaging the border/padding area    // that was affected by the resize...    if ((eReflowReason_Resize == aReflowState.reason) &&        ((borderPadding.left != 0) || (borderPadding.top != 0) ||         (borderPadding.right != 0) || (borderPadding.bottom) != 0)) {      nsRect  damageRect(0, 0, aReflowState.maxSize.width, aReflowState.maxSize.height);      Invalidate(damageRect, PR_FALSE);    }  }  // Return the max size as our desired size  aDesiredSize.width = aReflowState.maxSize.width;  aDesiredSize.height = aReflowState.maxSize.height;  aDesiredSize.ascent = aDesiredSize.height;  aDesiredSize.descent = 0;  NS_FRAME_TRACE_REFLOW_OUT("RootFrame::Reflow", aStatus);  return NS_OK;}