Bug 482921 part 0.5 - Restore support for using tree op queue to set document charset. r=bzbarsky.
authorHenri Sivonen <hsivonen@iki.fi>
Tue, 01 Nov 2011 13:33:11 +0200
changeset 79504 a6c58f76edb503841563570d6114f422a5f2f0b3
parent 79503 746e7c151de2ebc8e6ee635d75f244ea873c1c1e
child 79505 175a0afe3c436b9ac6fe84bab87b5ac8a808b732
push id21408
push userkhuey@mozilla.com
push dateTue, 01 Nov 2011 14:32:20 +0000
treeherdermozilla-central@cd9add22f090 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs482921
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 482921 part 0.5 - Restore support for using tree op queue to set document charset. r=bzbarsky.
parser/html/nsHtml5TreeBuilderCppSupplement.h
parser/html/nsHtml5TreeOperation.cpp
parser/html/nsHtml5TreeOperation.h
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -639,18 +639,23 @@ nsHtml5TreeBuilder::FlushLoads()
     mSpeculativeLoadStage->MoveSpeculativeLoadsFrom(mSpeculativeLoadQueue);
   }
 }
 
 void
 nsHtml5TreeBuilder::SetDocumentCharset(nsACString& aCharset, 
                                        PRInt32 aCharsetSource)
 {
-  mSpeculativeLoadQueue.AppendElement()->InitSetDocumentCharset(aCharset,
-                                                                aCharsetSource);
+  if (mSpeculativeLoadStage) {
+    mSpeculativeLoadQueue.AppendElement()->InitSetDocumentCharset(
+      aCharset, aCharsetSource);
+  } else {
+    mOpQueue.AppendElement()->Init(
+      eTreeOpSetDocumentCharset, aCharset, aCharsetSource);
+  }
 }
 
 void
 nsHtml5TreeBuilder::StreamEnded()
 {
   // The fragment mode calls DidBuildModel from nsHtml5Parser. 
   // Letting DidBuildModel be called from the executor in the fragment case
   // confuses the EndLoad logic of nsHTMLDocument, since nsHTMLDocument
--- a/parser/html/nsHtml5TreeOperation.cpp
+++ b/parser/html/nsHtml5TreeOperation.cpp
@@ -122,16 +122,17 @@ nsHtml5TreeOperation::~nsHtml5TreeOperat
       delete mTwo.stringPair;
       break;
     case eTreeOpFosterParentText:
     case eTreeOpAppendText:
     case eTreeOpAppendComment:
     case eTreeOpAppendCommentToDocument:
       delete[] mTwo.unicharPtr;
       break;
+    case eTreeOpSetDocumentCharset:
     case eTreeOpNeedsCharsetSwitchTo:
       delete[] mOne.charPtr;
       break;
     case eTreeOpProcessOfflineManifest:
       nsMemory::Free(mOne.unicharPtr);
       break;
     default: // keep the compiler happy
       break;
@@ -627,16 +628,23 @@ nsHtml5TreeOperation::Perform(nsHtml5Tre
       nsIContent* node = *(mOne.node);
       node->DoneCreatingElement();
       return rv;
     }
     case eTreeOpFlushPendingAppendNotifications: {
       aBuilder->FlushPendingAppendNotifications();
       return rv;
     }
+    case eTreeOpSetDocumentCharset: {
+      char* str = mOne.charPtr;
+      PRInt32 charsetSource = mInt;
+      nsDependentCString dependentString(str);
+      aBuilder->SetDocumentCharsetAndSource(dependentString, charsetSource);
+      return rv;
+    }
     case eTreeOpNeedsCharsetSwitchTo: {
       char* str = mOne.charPtr;
       PRInt32 charsetSource = mInt;
       aBuilder->NeedsCharsetSwitchTo(str, charsetSource);
       return rv;    
     }
     case eTreeOpUpdateStyleSheet: {
       nsIContent* node = *(mOne.node);
--- a/parser/html/nsHtml5TreeOperation.h
+++ b/parser/html/nsHtml5TreeOperation.h
@@ -69,16 +69,17 @@ enum eHtml5TreeOperation {
   eTreeOpAppendDoctypeToDocument,
   // Gecko-specific on-pop ops
   eTreeOpMarkAsBroken,
   eTreeOpRunScript,
   eTreeOpRunScriptAsyncDefer,
   eTreeOpDoneAddingChildren,
   eTreeOpDoneCreatingElement,
   eTreeOpFlushPendingAppendNotifications,
+  eTreeOpSetDocumentCharset,
   eTreeOpNeedsCharsetSwitchTo,
   eTreeOpUpdateStyleSheet,
   eTreeOpProcessMeta,
   eTreeOpProcessOfflineManifest,
   eTreeOpMarkMalformedIfScript,
   eTreeOpStreamEnded,
   eTreeOpSetStyleLineNumber,
   eTreeOpSetScriptLineNumberAndFreeze,