if (mDocument) {
PRUint32 delayBeforeLoweringThreshold = NS_STATIC_CAST(PRUint32, ((2 * mDynamicIntervalSwitchThreshold) + NS_DELAY_FOR_WINDOW_CREATION)); if (((currentTime - mBeginLoadTime) > delayBeforeLoweringThreshold) && mDocument) {
HTMLContentSink::DidProcessAToken(void) {  if (mFlags & NS_SINK_FLAG_CAN_INTERRUPT_PARSER) {#ifdef NS_DEBUGPRInt32 oldMaxTokenProcessingTime = GetMaxTokenProcessingTime();#endif    PRUint32 currentTime = PR_IntervalToMicroseconds(PR_IntervalNow());       // Get the last user event time and compare it with    // the current time to determine if the lower value    // for content notification and max token processing     // should be used.    if (mDocument) {      nsCOMPtr<nsIPresShell> shell;      mDocument->GetShellAt(0, getter_AddRefs(shell));      if (shell) {        nsCOMPtr<nsIViewManager> vm;        shell->GetViewManager(getter_AddRefs(vm));        PRUint32 eventTime;        nsresult rv = vm->GetLastUserEventTime(eventTime);        if (NS_SUCCEEDED(rv)) {                             if ((currentTime - eventTime) < NS_STATIC_CAST(PRUint32, mDynamicIntervalSwitchThreshold)) {            // lower the dynamic values to favor            // application responsiveness over page load            // time.            mFlags |= NS_SINK_FLAG_DYNAMIC_LOWER_VALUE;          }          else {            // raise the content notification and            // MaxTokenProcessing time to favor overall             // page load speed over responsiveness            mFlags &= ~NS_SINK_FLAG_DYNAMIC_LOWER_VALUE;          }        }      }    }#ifdef NS_DEBUGPRInt32 newMaxTokenProcessingTime = GetMaxTokenProcessingTime();   if (newMaxTokenProcessingTime != oldMaxTokenProcessingTime) {//     printf("Changed dynamic interval : MaxTokenProcessingTime %d\n", GetMaxTokenProcessingTime());   }#endif   if ((currentTime - mDelayTimerStart) > NS_STATIC_CAST(PRUint32, GetMaxTokenProcessingTime())) {     return NS_ERROR_HTMLPARSER_INTERRUPTED;   }    }  return NS_OK;}