PRBool enableInterruptParsing = PR_FALSE;
PRBool enableInterruptParsing = PR_TRUE;  mDynamicIntervalSwitchThreshold = 750000;
HTMLContentSink::Init(nsIDocument* aDoc,                      nsIURI* aURL,                      nsIWebShell* aContainer,                      nsIChannel* aChannel){    MOZ_TIMER_DEBUGLOG(("Reset and start: nsHTMLContentSink::Init(), this=%p\n", this));  MOZ_TIMER_RESET(mWatch);  MOZ_TIMER_START(mWatch);  NS_PRECONDITION(nsnull != aDoc, "null ptr");  NS_PRECONDITION(nsnull != aURL, "null ptr");  NS_PRECONDITION(nsnull != aContainer, "null ptr");  if ((nsnull == aDoc) || (nsnull == aURL) || (nsnull == aContainer)) {    MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::Init()\n"));    MOZ_TIMER_STOP(mWatch);    return NS_ERROR_NULL_POINTER;  }  nsresult rv;  mDocument = aDoc;  NS_ADDREF(aDoc);  aDoc->AddObserver(this);  aDoc->QueryInterface(NS_GET_IID(nsIHTMLDocument), (void**)&mHTMLDocument);  rv = mDocument->GetNodeInfoManager(*getter_AddRefs(mNodeInfoManager));  NS_ENSURE_SUCCESS(rv, rv);  mDocumentURI = aURL;  NS_ADDREF(aURL);  mDocumentBaseURL = aURL;  NS_ADDREF(aURL);  mWebShell = aContainer;  NS_ADDREF(aContainer);  nsCOMPtr<nsIScriptLoader> loader;  rv = mDocument->GetScriptLoader(getter_AddRefs(loader));  NS_ENSURE_SUCCESS(rv, rv);  loader->AddObserver(this);    PRBool enabled = PR_TRUE;  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));  NS_ASSERTION(docShell,"oops no docshell!");  if (docShell) {    docShell->GetAllowSubframes(&enabled);    if (enabled) {      mFlags |= NS_SINK_FLAG_FRAMES_ENABLED;    }  }  // Find out if scripts are enabled, if not, show <noscript> content  if (IsScriptEnabled(aDoc, aContainer)) {    mFlags |= NS_SINK_FLAG_SCRIPT_ENABLED;  }  nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));  mNotifyOnTimer = PR_TRUE;  if (prefs) {    prefs->GetBoolPref("content.notify.ontimer", &mNotifyOnTimer);  }  mBackoffCount = -1; // never  if (prefs) {    prefs->GetIntPref("content.notify.backoffcount", &mBackoffCount);  }  // The mNotificationInterval has a dramatic effect on how long it   // takes to initially display content for slow connections.  // The current value provides good   // incremental display of content without causing an increase  // in page load time. If this value is set below 1/10 of second  // it starts to impact page load performance.  // see bugzilla bug 72138 for more info.  mNotificationInterval = 120000;  if (prefs) {    prefs->GetIntPref("content.notify.interval", &mNotificationInterval);  }  // The mMaxTokenProcessingTime controls how long we stay away from  // the event loop when processing token. A lower value  // makes the app more responsive, but may increase page load time.  // The content sink mNotificationInterval gates how frequently the content  // is processed so it will also affect how interactive the app is during  // page load also. The mNotification prevents contents flushes from happening   // too frequently. while mMaxTokenProcessingTime prevents flushes from happening   // too infrequently.  // The current ratio of 3 to 1 was determined to be the lowest mMaxTokenProcessingTime  // which does not impact page load performance.  // See bugzilla bug 76722 for details.  mMaxTokenProcessingTime = mNotificationInterval * 3;    PRBool enableInterruptParsing = PR_FALSE;    if (prefs) {    prefs->GetBoolPref("content.interrupt.parsing", &enableInterruptParsing);    prefs->GetIntPref("content.max.tokenizing.time", &mMaxTokenProcessingTime);  }  if (enableInterruptParsing) {    mFlags |= NS_SINK_FLAG_CAN_INTERRUPT_PARSER;  }  // Changed from 8192 to greatly improve page loading performance on large  // pages.  See bugzilla bug 77540.  mMaxTextRun = 8191;  if (prefs) {    prefs->GetIntPref("content.maxtextrun", &mMaxTextRun);  }  nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(aDoc));  if (htmlContainer) {    htmlContainer->GetCSSLoader(mCSSLoader);  }  // XXX this presumes HTTP header info is alread set in document  // XXX if it isn't we need to set it here...  ProcessHTTPHeaders(aChannel);  nsCOMPtr<nsINodeInfo> nodeInfo;  rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::html, nsnull,                                     kNameSpaceID_None,                                     *getter_AddRefs(nodeInfo));  NS_ENSURE_SUCCESS(rv, rv);  // Make root part  nsCOMPtr<nsIContent> doc_root;  mDocument->GetRootContent(getter_AddRefs(doc_root));  if (doc_root) {    // If the document already has a root we'll use it. This will    // happen when we do document.open()/.write()/.close()...    CallQueryInterface(doc_root, &mRoot);  } else {    rv = NS_NewHTMLHtmlElement(&mRoot, nodeInfo);    if (NS_OK != rv) {      MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::Init()\n"));      MOZ_TIMER_STOP(mWatch);      return rv;    }    mRoot->SetDocument(mDocument, PR_FALSE, PR_TRUE);    mDocument->SetRootContent(mRoot);  }  // Make head part  rv = mNodeInfoManager->GetNodeInfo(NS_LITERAL_STRING("head"),                                     nsnull, kNameSpaceID_None,                                     *getter_AddRefs(nodeInfo));  NS_ENSURE_SUCCESS(rv, rv);  rv = NS_NewHTMLHeadElement(&mHead, nodeInfo);  if (NS_OK != rv) {    MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::Init()\n"));    MOZ_TIMER_STOP(mWatch);    return rv;  }  mRoot->AppendChildTo(mHead, PR_FALSE, PR_FALSE);  mCurrentContext = new SinkContext(this);  NS_ENSURE_TRUE(mCurrentContext, NS_ERROR_OUT_OF_MEMORY);  mCurrentContext->Begin(eHTMLTag_html, mRoot, 0, -1);  mContextStack.AppendElement(mCurrentContext);#ifdef NS_DEBUG  char* spec;  (void)aURL->GetSpec(&spec);  SINK_TRACE(SINK_TRACE_CALLS,             ("HTMLContentSink::Init: this=%p url='%s'",              this, spec));  nsCRT::free(spec);#endif  MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::Init()\n"));  MOZ_TIMER_STOP(mWatch);  return NS_OK;}