Chromium Code Reviews| 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 55c5ccd9fe0ea4fd6293e40e1b5a3c4f9f98d14d..0f3b3f7612ee27f0d72d0d18f6e233807a888608 100644 |
| --- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
| +++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
| @@ -398,6 +398,10 @@ void HTMLDocumentParser::didReceiveEncodingDataFromBackgroundParser( |
| void HTMLDocumentParser::validateSpeculations( |
| std::unique_ptr<TokenizedChunk> chunk) { |
| ASSERT(chunk); |
| + // TODO(kouhei): We should simplify codepath here by disallowing |
| + // validateSpeculations |
| + // while isWaitingForScripts, and m_lastChunkBeforeScript can simply be |
| + // pushed to m_speculations. |
| if (isWaitingForScripts()) { |
| // We're waiting on a network script, just save the chunk, we'll get a |
| // second validateSpeculations call after the script completes. This call |
| @@ -1061,9 +1065,11 @@ void HTMLDocumentParser::resumeParsingAfterScriptExecution() { |
| ASSERT(!isWaitingForScripts()); |
| if (m_haveBackgroundParser) { |
| - validateSpeculations(std::move(m_lastChunkBeforeScript)); |
| - ASSERT(!m_lastChunkBeforeScript); |
| - pumpPendingSpeculations(); |
| + if (m_lastChunkBeforeScript) { |
| + validateSpeculations(std::move(m_lastChunkBeforeScript)); |
| + DCHECK(!m_lastChunkBeforeScript); |
| + pumpPendingSpeculations(); |
| + } |
| return; |
| } |
| @@ -1098,14 +1104,11 @@ void HTMLDocumentParser::notifyScriptLoaded(Resource* cachedResource) { |
| } |
| void HTMLDocumentParser::executeScriptsWaitingForResources() { |
| + DCHECK(document()->isScriptExecutionReady()); |
| + |
| // Document only calls this when the Document owns the DocumentParser so this |
| // will not be called in the DocumentFragment case. |
| - ASSERT(m_scriptRunner); |
| - // Ignore calls unless we have a script blocking the parser waiting on a |
| - // stylesheet load. Otherwise we are currently parsing and this is a |
| - // re-entrant call from encountering a </ style> tag. |
| - if (!m_scriptRunner->hasScriptsWaitingForResources()) |
|
kouhei (in TOK)
2016/11/29 06:56:14
Actually, this is a bug as it refers to the stale
|
| - return; |
| + DCHECK(m_scriptRunner); |
| m_scriptRunner->executeScriptsWaitingForResources(); |
| if (!isWaitingForScripts()) |
| resumeParsingAfterScriptExecution(); |