Index: Source/core/html/parser/HTMLDocumentParser.cpp |
diff --git a/Source/core/html/parser/HTMLDocumentParser.cpp b/Source/core/html/parser/HTMLDocumentParser.cpp |
index 6550314ea84dcfcda1d5c7d343b5027dd2216d9a..e599417a30d3716d66c28d0b6c69d8c0283aece9 100644 |
--- a/Source/core/html/parser/HTMLDocumentParser.cpp |
+++ b/Source/core/html/parser/HTMLDocumentParser.cpp |
@@ -116,6 +116,7 @@ HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors |
, m_isPinnedToMainThread(false) |
, m_endWasDelayed(false) |
, m_haveBackgroundParser(false) |
+ , m_tasksWereSuspended(false) |
, m_pumpSessionNestingLevel(0) |
{ |
ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); |
@@ -134,6 +135,7 @@ HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont |
, m_isPinnedToMainThread(true) |
, m_endWasDelayed(false) |
, m_haveBackgroundParser(false) |
+ , m_tasksWereSuspended(false) |
, m_pumpSessionNestingLevel(0) |
{ |
ASSERT(!shouldUseThreading()); |
@@ -281,14 +283,15 @@ void HTMLDocumentParser::resumeParsingAfterYield() |
// but we need to ensure it isn't deleted yet. |
RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); |
- if (m_haveBackgroundParser) { |
+ if (m_haveBackgroundParser || !m_speculations.isEmpty()) { |
João Eiras
2014/10/06 12:14:30
I'm a bit unsure about how these two variables rel
eseidel
2014/10/06 18:07:08
Speculations are parsed chunks sent to us from the
João Eiras
2014/10/07 13:25:07
OK, line reverted.
|
pumpPendingSpeculations(); |
return; |
} |
// We should never be here unless we can pump immediately. Call pumpTokenizer() |
// directly so that ASSERTS will fire if we're wrong. |
- pumpTokenizer(AllowYield); |
+ if (m_tokenizer) |
João Eiras
2014/10/06 12:14:31
As consequence of forcing a call to this method wh
eseidel
2014/10/06 18:07:08
This seems wrong. We should just be more careful
João Eiras
2014/10/07 13:25:07
Ok, added a couple extra checks in HTMLDocumentPar
|
+ pumpTokenizer(AllowYield); |
endIfDelayed(); |
} |
@@ -349,7 +352,7 @@ void HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<Pa |
// 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) { |
+ if (isWaitingForScripts() || !m_speculations.isEmpty() || document()->activeParserCount() > 0 || m_tasksWereSuspended) { |
m_preloader->takeAndPreload(chunk->preloads); |
m_speculations.append(chunk); |
return; |
@@ -1029,14 +1032,18 @@ void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFra |
void HTMLDocumentParser::suspendScheduledTasks() |
{ |
+ ASSERT(!m_tasksWereSuspended); |
+ m_tasksWereSuspended = true; |
if (m_parserScheduler) |
m_parserScheduler->suspend(); |
} |
void HTMLDocumentParser::resumeScheduledTasks() |
{ |
+ ASSERT(m_tasksWereSuspended); |
+ m_tasksWereSuspended = false; |
if (m_parserScheduler) |
- m_parserScheduler->resume(); |
+ m_parserScheduler->scheduleForResume(); |
} |
void HTMLDocumentParser::appendBytes(const char* data, size_t length) |