PRBool firstReflow = PR_FALSE;  NS_ASSERTION(mViewManager, "Must have view manager"); mViewManager->BeginUpdateViewBatch();  WillCauseReflow();  if (mCaret) mCaret->EraseCaret();     nsIFrame* rootFrame = FrameManager()->GetRootFrame();  if (!rootFrame && (aWidth == NS_UNCONSTRAINEDSIZE || aHeight == NS_UNCONSTRAINEDSIZE)) { return NS_ERROR_NOT_AVAILABLE; }  if (mPresContext) { nsRect r(0, 0, aWidth, aHeight); mPresContext->SetVisibleArea(r); }  if (rootFrame) {  NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("enter nsPresShell::ResizeReflow: %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(); 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;  nsHTMLReflowState reflowState(mPresContext, rootFrame, eReflowReason_Resize, rcx, maxSize);  rootFrame->WillReflow(mPresContext); nsContainerFrame::PositionFrameView(rootFrame); rootFrame->Reflow(mPresContext, desiredSize, reflowState, status); rootFrame->SetSize(nsSize(desiredSize.width, desiredSize.height)); mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));  nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, rootFrame->GetView(), 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::ResizeReflow"));   } else { firstReflow = PR_TRUE; #ifdef NOISY printf("PresShell::ResizeReflow: null root frame\n"); #endif } DidCauseReflow();  #ifdef NS_DEBUG if (GetVerifyReflowEnable() && (VERIFY_REFLOW_DURING_RESIZE_REFLOW & gVerifyReflowFlags)) { mInVerifyReflow = PR_TRUE; VerifyIncrementalReflow(); mInVerifyReflow = PR_FALSE; } #endif  DidDoReflow();  mViewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);  if (!firstReflow) {  CreateResizeEventTimer(); }  return NS_OK;
return ResizeReflow(aWidth, aHeight);
PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight){  PRBool firstReflow = PR_FALSE;  NS_ASSERTION(mViewManager, "Must have view manager");  mViewManager->BeginUpdateViewBatch();  WillCauseReflow();  if (mCaret)    mCaret->EraseCaret();  // If we don't have a root frame yet, that means we haven't had our initial  // reflow... If that's the case, and aWidth or aHeight is unconstrained,  // ignore them altogether.  nsIFrame* rootFrame = FrameManager()->GetRootFrame();  if (!rootFrame &&      (aWidth == NS_UNCONSTRAINEDSIZE || aHeight == NS_UNCONSTRAINEDSIZE)) {    return NS_ERROR_NOT_AVAILABLE;  }    if (mPresContext) {    nsRect r(0, 0, aWidth, aHeight);    mPresContext->SetVisibleArea(r);  }  if (rootFrame) {    // Kick off a top-down reflow    NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,                 ("enter nsPresShell::ResizeReflow: %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();    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;    nsHTMLReflowState reflowState(mPresContext, rootFrame,                                  eReflowReason_Resize, rcx, maxSize);    rootFrame->WillReflow(mPresContext);    nsContainerFrame::PositionFrameView(rootFrame);    rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);    rootFrame->SetSize(nsSize(desiredSize.width, desiredSize.height));    mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));    nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, rootFrame->GetView(),                                               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::ResizeReflow"));    // XXX if debugging then we should assert that the cache is empty  } else {    firstReflow = PR_TRUE;#ifdef NOISY    printf("PresShell::ResizeReflow: null root frame\n");#endif  }  DidCauseReflow();  // if the proper flag is set, VerifyReflow now#ifdef NS_DEBUG  if (GetVerifyReflowEnable() && (VERIFY_REFLOW_DURING_RESIZE_REFLOW & gVerifyReflowFlags))  {    mInVerifyReflow = PR_TRUE;    /*PRBool ok = */VerifyIncrementalReflow();    mInVerifyReflow = PR_FALSE;  }#endif    DidDoReflow();  mViewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);  if (!firstReflow) {    //Set resize event timer    CreateResizeEventTimer();  }    return NS_OK; //XXX this needs to be real. MMP}