Bug 234628 part 1 - Make the BOM take precedence over manual encoding overrides. r=smaug.
authorHenri Sivonen <hsivonen@iki.fi>
Fri, 18 Jan 2013 16:27:03 +0200
changeset 129917 b814f5638b20c2bdd44e135b22717026f269c901
parent 129916 9aad620031209b2abd17b8de5e324f0ddd266a4f
child 129918 010f52e1cf84d3d89faf3985c7e79c4ff06a33a7
push id317
push userbbajaj@mozilla.com
push dateTue, 07 May 2013 01:20:33 +0000
treeherdermozilla-release@159a10910249 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs234628
milestone21.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 234628 part 1 - Make the BOM take precedence over manual encoding overrides. r=smaug.
parser/html/nsHtml5StreamParser.cpp
parser/nsCharsetSource.h
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -933,27 +933,27 @@ nsHtml5StreamParser::OnStartRequest(nsIR
     mInitialEncodingWasFromParentFrame = true;
   }
 
   if (mCharsetSource >= kCharsetFromAutoDetection) {
     mFeedChardet = false;
   }
   
   nsCOMPtr<nsIWyciwygChannel> wyciwygChannel(do_QueryInterface(mRequest));
-  if (wyciwygChannel) {
-    mReparseForbidden = true;
-    mFeedChardet = false;
-    // If we are reloading a document.open()ed doc, fall through to converter
-    // instantiation here and avoid BOM sniffing.
-  } else if (mCharsetSource < kCharsetFromParentForced) {
+  if (!wyciwygChannel) {
     // we aren't ready to commit to an encoding yet
     // leave converter uninstantiated for now
     return NS_OK;
   }
-  
+
+  // We are reloading a document.open()ed doc.
+  mReparseForbidden = true;
+  mFeedChardet = false;
+
+  // Instantiate the converter here to avoid BOM sniffing.
   nsCOMPtr<nsICharsetConverterManager> convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = convManager->GetUnicodeDecoder(mCharset.get(), getter_AddRefs(mUnicodeDecoder));
   // if we failed to get a decoder, there will be fallback, so don't propagate
   //  the error.
   if (NS_FAILED(rv)) {
     mCharsetSource = kCharsetFromWeakDocTypeDefault;
   }
--- a/parser/nsCharsetSource.h
+++ b/parser/nsCharsetSource.h
@@ -14,15 +14,13 @@
 #define kCharsetFromParentFrame         5
 #define kCharsetFromAutoDetection       6
 #define kCharsetFromHintPrevDoc         7
 #define kCharsetFromMetaPrescan         8 // this one and smaller: HTML5 Tentative
 #define kCharsetFromMetaTag             9 // this one and greater: HTML5 Confident
 #define kCharsetFromIrreversibleAutoDetection 10
 #define kCharsetFromChannel            11
 #define kCharsetFromOtherComponent     12
-#define kCharsetFromByteOrderMark      13
-// Levels below here will be forced onto childframes too
-#define kCharsetFromParentForced       14
-#define kCharsetFromUserForced         15
-#define kCharsetFromPreviousLoading    16
+#define kCharsetFromParentForced       13 // propagates to child frames
+#define kCharsetFromUserForced         14 // propagates to child frames
+#define kCharsetFromByteOrderMark      15
 
 #endif /* nsCharsetSource_h_ */