Index: WebCore/html/parser/HTMLDocumentParser.cpp |
=================================================================== |
--- WebCore/html/parser/HTMLDocumentParser.cpp (revision 69799) |
+++ WebCore/html/parser/HTMLDocumentParser.cpp (working copy) |
@@ -142,28 +142,6 @@ |
m_parserScheduler.clear(); // Deleting the scheduler will clear any timers. |
} |
-// This kicks off "Once the user agent stops parsing" as described by: |
-// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#the-end |
-void HTMLDocumentParser::prepareToStopParsing() |
-{ |
- ASSERT(!hasInsertionPoint()); |
- |
- // pumpTokenizer can cause this parser to be detached from the Document, |
- // but we need to ensure it isn't deleted yet. |
- RefPtr<HTMLDocumentParser> protect(this); |
- |
- // FIXME: Set the current document readiness to "interactive". |
- |
- // NOTE: This pump should only ever emit buffered character tokens, |
- // so ForceSynchronous vs. AllowYield should be meaningless. |
- pumpTokenizerIfPossible(ForceSynchronous); |
- |
- DocumentParser::prepareToStopParsing(); |
- if (m_scriptRunner && !m_scriptRunner->executeScriptsWaitingForParsing()) |
- return; |
- end(); |
-} |
- |
bool HTMLDocumentParser::processingData() const |
{ |
return isScheduledForResume() || inWrite(); |
@@ -171,7 +149,7 @@ |
void HTMLDocumentParser::pumpTokenizerIfPossible(SynchronousMode mode) |
{ |
- if (isStopped() || m_treeBuilder->isPaused()) |
+ if (m_parserStopped || m_treeBuilder->isPaused()) |
return; |
// Once a resume is scheduled, HTMLParserScheduler controls when we next pump. |
@@ -215,7 +193,8 @@ |
void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode) |
{ |
- ASSERT(!isStopped()); |
+ ASSERT(!isDetached()); |
+ ASSERT(!m_parserStopped); |
ASSERT(!m_treeBuilder->isPaused()); |
ASSERT(!isScheduledForResume()); |
// ASSERT that this object is both attached to the Document and protected. |
@@ -235,7 +214,7 @@ |
m_token.clear(); |
// JavaScript may have stopped or detached the parser. |
- if (isStopped()) |
+ if (isDetached() || m_parserStopped) |
return; |
// The parser will pause itself when waiting on a script to load or run. |
@@ -247,7 +226,7 @@ |
m_treeBuilder->setPaused(!shouldContinueParsing); |
// JavaScript may have stopped or detached the parser. |
- if (isStopped()) |
+ if (isDetached() || m_parserStopped) |
return; |
if (!shouldContinueParsing) |
@@ -296,7 +275,7 @@ |
void HTMLDocumentParser::insert(const SegmentedString& source) |
{ |
- if (isStopped()) |
+ if (m_parserStopped) |
return; |
// pumpTokenizer can cause this parser to be detached from the Document, |
@@ -317,7 +296,7 @@ |
void HTMLDocumentParser::append(const SegmentedString& source) |
{ |
- if (isStopped()) |
+ if (m_parserStopped) |
return; |
// pumpTokenizer can cause this parser to be detached from the Document, |
@@ -349,6 +328,14 @@ |
ASSERT(!isDetached()); |
ASSERT(!isScheduledForResume()); |
+ // pumpTokenizer can cause this parser to be detached from the Document, |
+ // but we need to ensure it isn't deleted yet. |
+ RefPtr<HTMLDocumentParser> protect(this); |
+ |
+ // NOTE: This pump should only ever emit buffered character tokens, |
+ // so ForceSynchronous vs. AllowYield should be meaningless. |
+ pumpTokenizerIfPossible(ForceSynchronous); |
+ |
// Informs the the rest of WebCore that parsing is really finished (and deletes this). |
m_treeBuilder->finished(); |
} |
@@ -362,7 +349,7 @@ |
m_endWasDelayed = true; |
return; |
} |
- prepareToStopParsing(); |
+ end(); |
} |
void HTMLDocumentParser::endIfDelayed() |
@@ -375,7 +362,7 @@ |
return; |
m_endWasDelayed = false; |
- prepareToStopParsing(); |
+ end(); |
} |
void HTMLDocumentParser::finish() |
@@ -460,11 +447,6 @@ |
void HTMLDocumentParser::notifyFinished(CachedResource* cachedResource) |
{ |
- if (isStopping()) { |
- prepareToStopParsing(); |
- return; |
- } |
- |
// pumpTokenizer can cause this parser to be detached from the Document, |
// but we need to ensure it isn't deleted yet. |
RefPtr<HTMLDocumentParser> protect(this); |