MOZ_TIMER_DEBUGLOG(("Reset and start: Frame Creation: PresShell::InitialReflow(), this=%p\n", this));
MOZ_TIMER_DEBUGLOG(("Reset and start: Frame Creation: PresShell::InitialReflow(), this=%p\n", (void*)this));
PresShell::InitialReflow(nscoord aWidth, nscoord aHeight){  nsCOMPtr<nsIContent> root;  mDidInitialReflow = PR_TRUE;#ifdef NS_DEBUG  if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {    nsCOMPtr<nsIURI> uri;    if (mDocument) {      mDocument->GetDocumentURL(getter_AddRefs(uri));      if (uri) {        nsCAutoString url;        uri->GetSpec(url);        printf("*** PresShell::InitialReflow (this=%p, url='%s')\n", (void*)this, url.get());      }    }  }#endif  // notice that we ignore the result  NotifyReflowObservers(NS_PRESSHELL_INITIAL_REFLOW);  mCaret->EraseCaret();  //StCaretHider  caretHider(mCaret);			// stack-based class hides caret until dtor.    WillCauseReflow();  if (mPresContext) {    nsRect r(0, 0, aWidth, aHeight);    mPresContext->SetVisibleArea(r);  }  if (mDocument) {    mDocument->GetRootContent(getter_AddRefs(root));  }  // Get the root frame from the frame manager  nsIFrame* rootFrame;  mFrameManager->GetRootFrame(&rootFrame);    if (root) {    MOZ_TIMER_DEBUGLOG(("Reset and start: Frame Creation: PresShell::InitialReflow(), this=%p\n", this));    MOZ_TIMER_RESET(mFrameCreationWatch);    MOZ_TIMER_START(mFrameCreationWatch);    CtlStyleWatch(kStyleWatchEnable,mStyleSet);    if (!rootFrame) {      // Have style sheet processor construct a frame for the      // precursors to the root content object's frame      mStyleSet->ConstructRootFrame(mPresContext, root, rootFrame);      mFrameManager->SetRootFrame(rootFrame);    }    // Have the style sheet processor construct frame for the root    // content object down    mStyleSet->ContentInserted(mPresContext, nsnull, root, 0);    VERIFY_STYLE_TREE;    MOZ_TIMER_DEBUGLOG(("Stop: Frame Creation: PresShell::InitialReflow(), this=%p\n", this));    MOZ_TIMER_STOP(mFrameCreationWatch);    CtlStyleWatch(kStyleWatchDisable,mStyleSet);  }  if (rootFrame) {    MOZ_TIMER_DEBUGLOG(("Reset and start: Reflow: PresShell::InitialReflow(), this=%p\n", this));    MOZ_TIMER_RESET(mReflowWatch);    MOZ_TIMER_START(mReflowWatch);    // Kick off a top-down reflow    NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,                 ("enter nsPresShell::InitialReflow: %d,%d", aWidth, aHeight));#ifdef NS_DEBUG    if (nsIFrameDebug::GetVerifyTreeEnable()) {      nsIFrameDebug*  frameDebug;      if (NS_SUCCEEDED(rootFrame->QueryInterface(NS_GET_IID(nsIFrameDebug),                                                (void**)&frameDebug))) {        frameDebug->VerifyTree();      }    }#endif#ifdef DEBUG_kipp    nsPresShell_ReflowStackPointerTop = (char*) &aWidth;#endif    nsRect                bounds;    mPresContext->GetVisibleArea(bounds);    nsSize                maxSize(bounds.width, bounds.height);    nsHTMLReflowMetrics   desiredSize(nsnull);    nsReflowStatus        status;    nsIRenderingContext*  rcx = nsnull;    nsresult rv=CreateRenderingContext(rootFrame, &rcx);	if (NS_FAILED(rv)) return rv;    mIsReflowing = PR_TRUE;    nsHTMLReflowState reflowState(mPresContext, rootFrame,                                  eReflowReason_Initial, rcx, maxSize);    rootFrame->WillReflow(mPresContext);    nsContainerFrame::PositionFrameView(mPresContext, rootFrame);    rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);    rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);    mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));    nsIView* view;    rootFrame->GetView(mPresContext, &view);    if (view) {      nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,                                                 nsnull);    }    rootFrame->DidReflow(mPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);      #ifdef NS_DEBUG    if (nsIFrameDebug::GetVerifyTreeEnable()) {      nsIFrameDebug*  frameDebug;      if (NS_SUCCEEDED(rootFrame->QueryInterface(NS_GET_IID(nsIFrameDebug),                                                 (void**)&frameDebug))) {        frameDebug->VerifyTree();      }    }#endif    VERIFY_STYLE_TREE;    NS_IF_RELEASE(rcx);    NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::InitialReflow"));    MOZ_TIMER_DEBUGLOG(("Stop: Reflow: PresShell::InitialReflow(), this=%p\n", this));    MOZ_TIMER_STOP(mReflowWatch);    mIsReflowing = PR_FALSE;  }  DidCauseReflow();  if (mViewManager && mCaret && !mViewEventListener) {    nsIScrollableView* scrollingView = nsnull;    mViewManager->GetRootScrollableView(&scrollingView);    if (scrollingView) {      mViewEventListener = new PresShellViewEventListener;      if (!mViewEventListener)        return NS_ERROR_OUT_OF_MEMORY;      NS_ADDREF(mViewEventListener);      mViewEventListener->SetPresShell(this);      scrollingView->AddScrollPositionListener((nsIScrollPositionListener *)mViewEventListener);      mViewManager->AddCompositeListener((nsICompositeListener *)mViewEventListener);    }  }  // For printing, we just immediately unsuppress.  PRBool isPaginated = PR_FALSE;  mPresContext->IsPaginated(&isPaginated);  if (!isPaginated) {    // Kick off a one-shot timer based off our pref value.  When this timer    // fires, if painting is still locked down, then we will go ahead and    // trigger a full invalidate and allow painting to proceed normally.    mPaintingSuppressed = PR_TRUE;    mPaintSuppressionTimer = do_CreateInstance("@mozilla.org/timer;1");    if (!mPaintSuppressionTimer)      // Uh-oh.  We must be out of memory.  No point in keeping painting locked down.      mPaintingSuppressed = PR_FALSE;    else {      // Initialize the timer.      PRInt32 delay = PAINTLOCK_EVENT_DELAY; // Use this value if we fail to get the pref value.      nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));      if (prefs)        prefs->GetIntPref("nglayout.initialpaint.delay", &delay);      mPaintSuppressionTimer->Init(sPaintSuppressionCallback, this, delay, PR_FALSE);    }  }  return NS_OK; //XXX this needs to be real. MMP}