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
This commit is contained in:
Brendan Dahl 2019-04-05 08:44:56 -07:00
parent eff829f752
commit 67a7d1d576

View File

@ -444,7 +444,7 @@ void nsHTMLDocument::TryFallback(int32_t& aCharsetSource,
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()) {
@ -455,9 +455,7 @@ bool ShouldUsePrototypeDocument(nsIChannel* aChannel, nsIDocShell* aDocShell) {
}
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,
@ -561,7 +559,7 @@ nsresult nsHTMLDocument::StartDocumentLoad(const char* aCommand,
} 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));