Chromium Code Reviews| Index: Source/core/html/parser/HTMLDocumentParser.cpp |
| diff --git a/Source/core/html/parser/HTMLDocumentParser.cpp b/Source/core/html/parser/HTMLDocumentParser.cpp |
| index 1d349669659c14a25a20a5e5a2b2e425478d756a..6a17e7c80cb379c9d906820b5ee4ba075a24189f 100644 |
| --- a/Source/core/html/parser/HTMLDocumentParser.cpp |
| +++ b/Source/core/html/parser/HTMLDocumentParser.cpp |
| @@ -102,18 +102,18 @@ private: |
| WeakPtr<BackgroundHTMLParser> m_backgroundParser; |
| }; |
| -HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors) |
| +HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors, ParserSynchronizationPolicy backgroundParsingPolicy) |
| : ScriptableDocumentParser(document) |
| , m_options(&document) |
| - , m_token(nullptr) |
| - , m_tokenizer(nullptr) |
| + , m_token(backgroundParsingPolicy == ForceSynchronousParsing ? adoptPtr(new HTMLToken) : nullptr) |
| + , m_tokenizer(backgroundParsingPolicy == ForceSynchronousParsing ? HTMLTokenizer::create(m_options) : nullptr) |
| , m_scriptRunner(HTMLScriptRunner::create(&document, this)) |
| , m_treeBuilder(HTMLTreeBuilder::create(this, &document, parserContentPolicy(), reportErrors, m_options)) |
| , m_parserScheduler(HTMLParserScheduler::create(this)) |
| , m_xssAuditorDelegate(&document) |
| , m_weakFactory(this) |
| , m_preloader(HTMLResourcePreloader::create(document)) |
| - , m_isPinnedToMainThread(false) |
| + , m_shouldUseThreading(backgroundParsingPolicy == AllowAsynchronousParsing) |
| , m_endWasDelayed(false) |
| , m_haveBackgroundParser(false) |
| , m_tasksWereSuspended(false) |
| @@ -133,14 +133,13 @@ HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont |
| , m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, this->parserContentPolicy(), m_options)) |
| , m_xssAuditorDelegate(&fragment->document()) |
| , m_weakFactory(this) |
| - , m_isPinnedToMainThread(true) |
| + , m_shouldUseThreading(false) |
| , m_endWasDelayed(false) |
| , m_haveBackgroundParser(false) |
| , m_tasksWereSuspended(false) |
| , m_pumpSessionNestingLevel(0) |
| , m_pumpSpeculationsSessionNestingLevel(0) |
| { |
| - ASSERT(!shouldUseThreading()); |
| bool reportErrors = false; // For now document fragment parsing never reports errors. |
| m_tokenizer->setState(tokenizerStateForContextElement(contextElement, reportErrors, m_options)); |
| m_xssAuditor.initForFragment(); |
| @@ -175,18 +174,6 @@ void HTMLDocumentParser::trace(Visitor* visitor) |
| HTMLScriptRunnerHost::trace(visitor); |
| } |
| -void HTMLDocumentParser::pinToMainThread() |
| -{ |
| - ASSERT(!m_haveBackgroundParser); |
| - ASSERT(!m_isPinnedToMainThread); |
| - m_isPinnedToMainThread = true; |
| - if (!m_tokenizer) { |
| - ASSERT(!m_token); |
| - m_token = adoptPtr(new HTMLToken); |
| - m_tokenizer = HTMLTokenizer::create(m_options); |
| - } |
| -} |
| - |
| void HTMLDocumentParser::detach() |
| { |
| if (m_haveBackgroundParser) |
| @@ -277,7 +264,7 @@ bool HTMLDocumentParser::isScheduledForResume() const |
| // Used by HTMLParserScheduler |
| void HTMLDocumentParser::resumeParsingAfterYield() |
| { |
| - ASSERT(!m_isPinnedToMainThread); |
| + ASSERT(shouldUseThreading()); |
| ASSERT(m_haveBackgroundParser); |
| // pumpPendingSpeculations can cause this parser to be detached from the Document, |
| @@ -797,14 +784,7 @@ void HTMLDocumentParser::append(PassRefPtr<StringImpl> inputSource) |
| return; |
| } |
| - // A couple pinToMainThread() callers require synchronous parsing, but can't |
| - // easily use the insert() method, so we hack append() for them to be synchronous. |
| - // javascript: url handling is one such caller. |
| - // FIXME: This is gross, and we should separate the concept of synchronous parsing |
| - // from insert() so that only document.write() uses insert. |
|
kbalazs
2014/12/05 23:42:04
This comment was pretty confusing also. No one els
|
| - ASSERT(m_isPinnedToMainThread); |
| pumpTokenizerIfPossible(); |
| - |
| endIfDelayed(); |
| } |