Index: third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
index 9c88682636e0ce6dd76d5c06fce08b40ab2a726c..757865f8d030cddb5b2dace698d91c364295a3f4 100644 |
--- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
+++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
@@ -89,14 +89,29 @@ static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem |
} |
HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, ParserSynchronizationPolicy syncPolicy) |
- : ScriptableDocumentParser(document) |
+ : HTMLDocumentParser(document, AllowScriptingContent, syncPolicy) |
+{ |
+ m_treeBuilder = HTMLTreeBuilder::create(this, &document, AllowScriptingContent, m_options); |
Yoav Weiss
2016/07/05 08:20:14
Doesn't this mean that we're creating m_treeBuilde
kouhei (in TOK)
2016/07/06 00:49:54
Yes. This does mean that m_treeBuilder Member smar
|
+} |
+ |
+HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* contextElement, ParserContentPolicy parserContentPolicy) |
Yoav Weiss
2016/07/05 08:20:14
Not critical, but It would've been easier to revie
kouhei (in TOK)
2016/07/06 00:49:54
I think we should have delegated ctor def either a
|
+ : HTMLDocumentParser(fragment->document(), parserContentPolicy, ForceSynchronousParsing) |
+{ |
+ m_treeBuilder = HTMLTreeBuilder::create(this, fragment, contextElement, parserContentPolicy, m_options); |
+ |
+ bool reportErrors = false; // For now document fragment parsing never reports errors. |
+ m_tokenizer->setState(tokenizerStateForContextElement(contextElement, reportErrors, m_options)); |
+ m_xssAuditor.initForFragment(); |
+} |
+ |
+HTMLDocumentParser::HTMLDocumentParser(Document& document, ParserContentPolicy contentPolicy, ParserSynchronizationPolicy syncPolicy) |
+ : ScriptableDocumentParser(document, contentPolicy) |
, m_options(&document) |
, m_token(syncPolicy == ForceSynchronousParsing ? wrapUnique(new HTMLToken) : nullptr) |
, m_tokenizer(syncPolicy == ForceSynchronousParsing ? HTMLTokenizer::create(m_options) : nullptr) |
- , m_scriptRunner(HTMLScriptRunner::create(&document, this)) |
- , m_treeBuilder(HTMLTreeBuilder::create(this, &document, getParserContentPolicy(), m_options)) |
+ , m_scriptRunner(scriptingContentIsAllowed(contentPolicy) ? HTMLScriptRunner::create(&document, this) : nullptr) |
tzik
2016/07/05 07:59:09
# As we chatted offline.
On old code, m_scriptRunn
|
, m_loadingTaskRunner(wrapUnique(document.loadingTaskRunner()->clone())) |
- , m_parserScheduler(HTMLParserScheduler::create(this, m_loadingTaskRunner.get())) |
+ , m_parserScheduler(syncPolicy == AllowAsynchronousParsing ? HTMLParserScheduler::create(this, m_loadingTaskRunner.get()) : nullptr) |
, m_xssAuditorDelegate(&document) |
, m_weakFactory(this) |
, m_preloader(HTMLResourcePreloader::create(document)) |
@@ -114,29 +129,6 @@ HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, ParserSynchroniza |
ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); |
} |
-// FIXME: Member variables should be grouped into self-initializing structs to |
-// minimize code duplication between these constructors. |
-HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* contextElement, ParserContentPolicy parserContentPolicy) |
- : ScriptableDocumentParser(fragment->document(), parserContentPolicy) |
- , m_options(&fragment->document()) |
- , m_token(wrapUnique(new HTMLToken)) |
- , m_tokenizer(HTMLTokenizer::create(m_options)) |
- , m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, this->getParserContentPolicy(), m_options)) |
- , m_loadingTaskRunner(wrapUnique(fragment->document().loadingTaskRunner()->clone())) |
- , m_xssAuditorDelegate(&fragment->document()) |
- , m_weakFactory(this) |
- , m_shouldUseThreading(false) |
- , m_endWasDelayed(false) |
- , m_haveBackgroundParser(false) |
- , m_tasksWereSuspended(false) |
- , m_pumpSessionNestingLevel(0) |
- , m_pumpSpeculationsSessionNestingLevel(0) |
-{ |
- bool reportErrors = false; // For now document fragment parsing never reports errors. |
- m_tokenizer->setState(tokenizerStateForContextElement(contextElement, reportErrors, m_options)); |
- m_xssAuditor.initForFragment(); |
-} |
- |
HTMLDocumentParser::~HTMLDocumentParser() |
{ |
// In Oilpan, HTMLDocumentParser can die together with Document, and |