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..6cc075f65e96951c156dc0cb91c14dc6432e219a 100644 |
| --- a/Source/core/html/parser/HTMLDocumentParser.cpp |
| +++ b/Source/core/html/parser/HTMLDocumentParser.cpp |
| @@ -328,25 +328,28 @@ void HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<Pa |
| { |
| TRACE_EVENT0("blink", "HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser"); |
| - // alert(), runModalDialog, and the JavaScript Debugger all run nested event loops |
| - // which can cause this method to be re-entered. We detect re-entry using |
| - // hasActiveParser(), save the chunk as a speculation, and return. |
| - if (isWaitingForScripts() || !m_speculations.isEmpty() || document()->activeParserCount() > 0 || m_tasksWereSuspended || isScheduledForResume()) { |
| - if (m_tasksWereSuspended) |
| - m_parserScheduler->forceResumeAfterYield(); |
| - m_preloader->takeAndPreload(chunk->preloads); |
| - m_speculations.append(chunk); |
| + if (!isParsing()) |
| return; |
| - } |
| - // processParsedChunkFromBackgroundParser can cause this parser to be detached from the Document, |
| - // but we need to ensure it isn't deleted yet. |
| - RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); |
| + // ApplicationCache needs to be initialized before issuing preloads. |
| + // We suspend preload until HTMLHTMLElement is inserted and |
| + // ApplicationCache is initialized. |
| + if (!document()->documentElement()) { |
| + for (auto& request : chunk->preloads) |
| + m_queuedPreloads.append(request.release()); |
| + } else { |
| + ASSERT(m_queuedPreloads.isEmpty()); |
|
tyoshino (SeeGerritForStatus)
2014/12/04 06:48:21
please write the reason that we're sure that m_que
|
| + m_preloader->takeAndPreload(chunk->preloads); |
| + } |
| - ASSERT(m_speculations.isEmpty()); |
| - chunk->preloads.clear(); // We don't need to preload because we're going to parse immediately. |
| m_speculations.append(chunk); |
| - pumpPendingSpeculations(); |
| + |
| + if (!isWaitingForScripts() && !isScheduledForResume()) { |
| + if (m_tasksWereSuspended) |
| + m_parserScheduler->forceResumeAfterYield(); |
| + else |
| + m_parserScheduler->scheduleForResume(); |
| + } |
| } |
| void HTMLDocumentParser::didReceiveEncodingDataFromBackgroundParser(const DocumentEncodingData& data) |
| @@ -463,6 +466,9 @@ size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(PassOwnPtr<Par |
| constructTreeFromCompactHTMLToken(*it); |
| + if (!m_queuedPreloads.isEmpty() && document()->documentElement()) |
| + m_preloader->takeAndPreload(m_queuedPreloads); |
| + |
|
tyoshino (SeeGerritForStatus)
2014/12/04 06:48:21
before this CL we were calling chunk->preloads.cle
|
| if (isStopped()) |
| break; |