зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1550524 part 1. Make NewHtml5Parser() return an nsHtml5Parser. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D30750 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
55a63d1520
Коммит
0c6443c5e8
|
@ -542,18 +542,20 @@ nsresult nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
|
||||
|
||||
bool loadWithPrototype = false;
|
||||
RefPtr<nsHtml5Parser> html5Parser;
|
||||
if (loadAsHtml5) {
|
||||
mParser = nsHtml5Module::NewHtml5Parser();
|
||||
html5Parser = nsHtml5Module::NewHtml5Parser();
|
||||
mParser = html5Parser;
|
||||
if (mIsPlainText) {
|
||||
if (viewSource) {
|
||||
mParser->MarkAsNotScriptCreated("view-source-plain");
|
||||
html5Parser->MarkAsNotScriptCreated("view-source-plain");
|
||||
} else {
|
||||
mParser->MarkAsNotScriptCreated("plain-text");
|
||||
html5Parser->MarkAsNotScriptCreated("plain-text");
|
||||
}
|
||||
} else if (viewSource && !html) {
|
||||
mParser->MarkAsNotScriptCreated("view-source-xml");
|
||||
html5Parser->MarkAsNotScriptCreated("view-source-xml");
|
||||
} else {
|
||||
mParser->MarkAsNotScriptCreated(aCommand);
|
||||
html5Parser->MarkAsNotScriptCreated(aCommand);
|
||||
}
|
||||
} else if (xhtml && ShouldUsePrototypeDocument(aChannel, this)) {
|
||||
loadWithPrototype = true;
|
||||
|
@ -691,7 +693,7 @@ nsresult nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
}
|
||||
} else {
|
||||
if (loadAsHtml5) {
|
||||
nsHtml5Module::Initialize(mParser, this, uri, docShell, aChannel);
|
||||
html5Parser->Initialize(this, uri, docShell, aChannel);
|
||||
} else {
|
||||
// about:blank *only*
|
||||
nsCOMPtr<nsIHTMLContentSink> htmlsink;
|
||||
|
@ -1178,8 +1180,9 @@ Document* nsHTMLDocument::Open(const Optional<nsAString>& /* unused */,
|
|||
// Step 14 -- create a new parser associated with document. This also does
|
||||
// step 16 implicitly.
|
||||
mParserAborted = false;
|
||||
mParser = nsHtml5Module::NewHtml5Parser();
|
||||
nsHtml5Module::Initialize(mParser, this, GetDocumentURI(), shell, nullptr);
|
||||
RefPtr<nsHtml5Parser> parser = nsHtml5Module::NewHtml5Parser();
|
||||
mParser = parser;
|
||||
parser->Initialize(this, GetDocumentURI(), shell, nullptr);
|
||||
if (mReferrerPolicySet) {
|
||||
// CSP may have set the referrer policy, so a speculative parser should
|
||||
// start with the new referrer policy.
|
||||
|
|
|
@ -60,21 +60,12 @@ void nsHtml5Module::ReleaseStatics() {
|
|||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<nsIParser> nsHtml5Module::NewHtml5Parser() {
|
||||
already_AddRefed<nsHtml5Parser> nsHtml5Module::NewHtml5Parser() {
|
||||
MOZ_ASSERT(sNsHtml5ModuleInitialized, "nsHtml5Module not initialized.");
|
||||
nsCOMPtr<nsIParser> rv = new nsHtml5Parser();
|
||||
RefPtr<nsHtml5Parser> rv = new nsHtml5Parser();
|
||||
return rv.forget();
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult nsHtml5Module::Initialize(nsIParser* aParser, dom::Document* aDoc,
|
||||
nsIURI* aURI, nsISupports* aContainer,
|
||||
nsIChannel* aChannel) {
|
||||
MOZ_ASSERT(sNsHtml5ModuleInitialized, "nsHtml5Module not initialized.");
|
||||
nsHtml5Parser* parser = static_cast<nsHtml5Parser*>(aParser);
|
||||
return parser->Initialize(aDoc, aURI, aContainer, aChannel);
|
||||
}
|
||||
|
||||
class nsHtml5ParserThreadTerminator final : public nsIObserver {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
|
|
@ -5,17 +5,15 @@
|
|||
#ifndef nsHtml5Module_h
|
||||
#define nsHtml5Module_h
|
||||
|
||||
#include "nsIParser.h"
|
||||
#include "nsIThread.h"
|
||||
|
||||
class nsHtml5Parser;
|
||||
|
||||
class nsHtml5Module {
|
||||
public:
|
||||
static void InitializeStatics();
|
||||
static void ReleaseStatics();
|
||||
static already_AddRefed<nsIParser> NewHtml5Parser();
|
||||
static nsresult Initialize(nsIParser* aParser, mozilla::dom::Document* aDoc,
|
||||
nsIURI* aURI, nsISupports* aContainer,
|
||||
nsIChannel* aChannel);
|
||||
static already_AddRefed<nsHtml5Parser> NewHtml5Parser();
|
||||
static nsIThread* GetStreamParserThread();
|
||||
|
||||
private:
|
||||
|
|
Загрузка…
Ссылка в новой задаче