Bug 1543245 - Use prototype document for all chrome XHTML pages. r=smaug
authorBrendan Dahl <bdahl@mozilla.com>
Wed, 10 Apr 2019 06:38:10 +0000
changeset 468826 a4d2565280511f4253d4fd2c5dfaa86bc537f381
parent 468825 426c8e0063416e851eb09473580fdd4962436911
child 468827 8e8da015fde18e4068f22f7f137ec9899b4310c8
push id112755
push userdvarga@mozilla.com
push dateWed, 10 Apr 2019 22:06:41 +0000
treeherdermozilla-inbound@606f85641d0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1543245
milestone68.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 1543245 - Use prototype document for all chrome XHTML pages. r=smaug Let all chrome privileged XHTML take advantage of the cache and faster document creation with the prototype document. Differential Revision: https://phabricator.services.mozilla.com/D26822
dom/html/nsHTMLDocument.cpp
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -438,30 +438,28 @@ void nsHTMLDocument::TryTLD(int32_t& aCh
 void nsHTMLDocument::TryFallback(int32_t& aCharsetSource,
                                  NotNull<const Encoding*>& aEncoding) {
   if (kCharsetFromFallback <= aCharsetSource) return;
 
   aCharsetSource = kCharsetFromFallback;
   aEncoding = FallbackEncoding::FromLocale();
 }
 
-// Using a prototype document is currently only allowed with browser.xhtml.
+// Using a prototype document is only allowed with chrome privilege.
 bool ShouldUsePrototypeDocument(nsIChannel* aChannel, nsIDocShell* aDocShell) {
   if (!aChannel || !aDocShell ||
       !StaticPrefs::dom_prototype_document_cache_enabled()) {
     return false;
   }
   if (aDocShell->ItemType() != nsIDocShellTreeItem::typeChrome) {
     return false;
   }
   nsCOMPtr<nsIURI> originalURI;
   aChannel->GetOriginalURI(getter_AddRefs(originalURI));
-  return IsChromeURI(originalURI) &&
-         originalURI->GetSpecOrDefault().EqualsLiteral(
-             BROWSER_CHROME_URL_QUOTED);
+  return IsChromeURI(originalURI);
 }
 
 nsresult nsHTMLDocument::StartDocumentLoad(const char* aCommand,
                                            nsIChannel* aChannel,
                                            nsILoadGroup* aLoadGroup,
                                            nsISupports* aContainer,
                                            nsIStreamListener** aDocListener,
                                            bool aReset, nsIContentSink* aSink) {
@@ -555,17 +553,17 @@ nsresult nsHTMLDocument::StartDocumentLo
       } else {
         mParser->MarkAsNotScriptCreated("plain-text");
       }
     } else if (viewSource && !html) {
       mParser->MarkAsNotScriptCreated("view-source-xml");
     } else {
       mParser->MarkAsNotScriptCreated(aCommand);
     }
-  } else if (ShouldUsePrototypeDocument(aChannel, docShell)) {
+  } else if (xhtml && ShouldUsePrototypeDocument(aChannel, docShell)) {
     loadWithPrototype = true;
     nsCOMPtr<nsIURI> originalURI;
     aChannel->GetOriginalURI(getter_AddRefs(originalURI));
     mParser = new mozilla::parser::PrototypeDocumentParser(originalURI, this);
   } else {
     mParser = do_CreateInstance(kCParserCID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
   }