PRBool didInitialReflow = PR_FALSE;  PRInt32 i, ns = mDocument->GetNumberOfShells(); for (i = 0; i < ns; i++) { nsCOMPtr<nsIPresShell> shell; mDocument->GetShellAt(i, getter_AddRefs(shell)); if (shell) { shell->GetDidInitialReflow(&didInitialReflow); if (didInitialReflow) break; } }  if (didInitialReflow && mCurrentContext->mStackPos > 1) { PRInt32 parentIndex    = mCurrentContext->mStackPos - 2; nsIHTMLContent *parent = mCurrentContext->mStack[parentIndex].mContent; PRInt32 numFlushed     = mCurrentContext->mStack[parentIndex].mNumFlushed; PRInt32 insertionPoint = mCurrentContext->mStack[parentIndex].mInsertionPoint;      if (insertionPoint != -1) { NotifyInsert(parent, mBody, insertionPoint - 1); } else {     NotifyAppend(parent, numFlushed); } }
HTMLContentSink::OpenBody(const nsIParserNode& aNode){  MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::OpenBody()\n"));  MOZ_TIMER_START(mWatch);  //NS_PRECONDITION(nsnull == mBody, "parser called OpenBody twice");  SINK_TRACE_NODE(SINK_TRACE_CALLS,                  "HTMLContentSink::OpenBody", aNode,                   mCurrentContext->mStackPos, this);  // Add attributes, if any, to the current BODY node  if(mBody != nsnull){    AddAttributes(aNode, mBody, PR_TRUE);    MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::OpenBody()\n"));    MOZ_TIMER_STOP(mWatch);    return NS_OK;  }  // Open body. Note that we pre-append the body to the root so that  // incremental reflow during document loading will work properly.  mCurrentContext->SetPreAppend(PR_TRUE);   nsresult rv = mCurrentContext->OpenContainer(aNode);  mCurrentContext->SetPreAppend(PR_FALSE);  if (NS_OK != rv) {    MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::OpenBody()\n"));    MOZ_TIMER_STOP(mWatch);    return rv;  }  mBody = mCurrentContext->mStack[mCurrentContext->mStackPos - 1].mContent;  NS_ADDREF(mBody);  MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::OpenBody()\n"));  MOZ_TIMER_STOP(mWatch);  StartLayout();  return NS_OK;}