PRInt64 maxTime; while (0 != mReflowCommands.Count()) { ProcessReflowCommand(mReflowCommands, aInterruptible, desiredSize, maxSize, *rcx); if (aInterruptible) { LL_I2L(maxTime, gMaxRCProcessingTime); PRInt64 temp; LL_I2L(temp, mAccumulatedReflowTime); if (LL_CMP(temp, >, maxTime)) break;
do {  IncrementalReflow reflow; for (PRInt32 i = mReflowCommands.Count() - 1; i >= 0; --i) { nsHTMLReflowCommand *command = NS_STATIC_CAST(nsHTMLReflowCommand *, mReflowCommands[i]);  if (reflow.AddCommand(mPresContext, command)) {  mReflowCommands.RemoveElementAt(i); ReflowCommandRemoved(command); } else {   }
PresShell::ProcessReflowCommands(PRBool aInterruptible){  MOZ_TIMER_DEBUGLOG(("Start: Reflow: PresShell::ProcessReflowCommands(), this=%p\n", this));  MOZ_TIMER_START(mReflowWatch);    if (0 != mReflowCommands.Count()) {    nsHTMLReflowMetrics   desiredSize(nsnull);    nsIRenderingContext*  rcx;    nsIFrame*             rootFrame;            mFrameManager->GetRootFrame(&rootFrame);    nsSize          maxSize;    rootFrame->GetSize(maxSize);    nsresult rv=CreateRenderingContext(rootFrame, &rcx);	  if (NS_FAILED(rv)) return rv;#ifdef DEBUG    if (GetVerifyReflowEnable()) {      if (VERIFY_REFLOW_ALL & gVerifyReflowFlags) {        printf("ProcessReflowCommands: begin incremental reflow\n");      }    }    if (VERIFY_REFLOW_DUMP_COMMANDS & gVerifyReflowFlags) {         PRInt32 i, n = mReflowCommands.Count();      printf("\nPresShell::ProcessReflowCommands: this=%p, count=%d\n", (void*)this, n);      for (i = 0; i < n; i++) {        nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*)          mReflowCommands.ElementAt(i);        rc->List(stdout);      }    }#endif        mIsReflowing = PR_TRUE;    PRInt64 maxTime;    while (0 != mReflowCommands.Count()) {      ProcessReflowCommand(mReflowCommands, aInterruptible, desiredSize, maxSize, *rcx);      if (aInterruptible) {        LL_I2L(maxTime, gMaxRCProcessingTime);        PRInt64 temp;        LL_I2L(temp, mAccumulatedReflowTime);        if (LL_CMP(temp, >, maxTime))          break;                }    }    mIsReflowing = PR_FALSE;    if (aInterruptible) {      // process the timeout reflow commands completely      // printf("timeout reflows=%d \n", mTimeoutReflowCommands.Count());      while (0 != mTimeoutReflowCommands.Count()) {        ProcessReflowCommand(mTimeoutReflowCommands, PR_TRUE, desiredSize, maxSize, *rcx);      }      if (mReflowCommands.Count() > 0) { // Reflow Commands are still queued up.        // Schedule a reflow event to handle the remaining reflow commands asynchronously.        PostReflowEvent();      }#ifdef DEBUG      if (VERIFY_REFLOW_DUMP_COMMANDS & gVerifyReflowFlags) {                printf("Time spent in PresShell::ProcessReflowCommands(), this=%p, time=%d micro seconds\n",                (void*)this, mAccumulatedReflowTime);      }#endif      mAccumulatedReflowTime = 0;    }    NS_IF_RELEASE(rcx);    #ifdef DEBUG    if (VERIFY_REFLOW_DUMP_COMMANDS & gVerifyReflowFlags) {      printf("\nPresShell::ProcessReflowCommands() finished: this=%p\n", (void*)this);    }    if (nsIFrameDebug::GetVerifyTreeEnable()) {      nsIFrameDebug*  frameDebug;      if (NS_SUCCEEDED(rootFrame->QueryInterface(NS_GET_IID(nsIFrameDebug),                                                 (void**)&frameDebug))) {        frameDebug->VerifyTree();      }    }    if (GetVerifyReflowEnable()) {      // First synchronously render what we have so far so that we can      // see it.      nsIView* rootView;      mViewManager->GetRootView(rootView);      mViewManager->UpdateView(rootView, NS_VMREFRESH_IMMEDIATE);      mInVerifyReflow = PR_TRUE;      PRBool ok = VerifyIncrementalReflow();      mInVerifyReflow = PR_FALSE;      if (VERIFY_REFLOW_ALL & gVerifyReflowFlags) {        printf("ProcessReflowCommands: finished (%s)\n",               ok ? "ok" : "failed");      }      if (0 != mReflowCommands.Count()) {        printf("XXX yikes! reflow commands queued during verify-reflow\n");      }    }#endif    // If there are no more reflow commands in the queue, we'll want    // to remove the ``dummy request''.    DoneRemovingReflowCommands();  }    MOZ_TIMER_DEBUGLOG(("Stop: Reflow: PresShell::ProcessReflowCommands(), this=%p\n", this));  MOZ_TIMER_STOP(mReflowWatch);    HandlePostedDOMEvents();  HandlePostedAttributeChanges();  HandlePostedReflowCallbacks();  if (mShouldUnsuppressPainting && mReflowCommands.Count() == 0) {    // We only unlock if we're out of reflows.  It's pointless    // to unlock if reflows are still pending, since reflows    // are just going to thrash the frames around some more.  By    // waiting we avoid an overeager "jitter" effect.    mShouldUnsuppressPainting = PR_FALSE;    UnsuppressAndInvalidate();  }  return NS_OK;}