Changeset 122168 in webkit


Ignore:
Timestamp:
Jul 9, 2012 4:48:14 PM (12 years ago)
Author:
eric@webkit.org
Message:

document.write of scripts that also document.write sometimes writes async
https://bugs.webkit.org/show_bug.cgi?id=89102

Reviewed by Adam Barth.

Source/WebCore:

When a script tag is first encountered, the TreeBuilder holds the element and returns
out to the outer HTMLDocumentParser parse loop. The HTMLDocumentParser then takes
the script element and passes it to the HTMLScriptRunner for execution. However, if the
script is an "external script" the HTMLScriptRunner may have to wait for that parser
blocking script to load, and may store the script in its own m_parserBlockingScript member.

While the HTMLScriptRunner has this not-yet-loaded-script the parser is also blocked.
Because the "paused" state of the parser was held as a separate bool on the TreeBuilder
we'd have to be careful to update it to reflect the current state of this pending script
on the HTMLScriptRunner.

This patch removes this separate "paused" bool and makes the HTMLDocumentParser responsible
for the "paused" state of the parser through the isWaitingForScripts() function which
knows how to check both the TreeBuilder and the ScriptRunner for possible parser-blocking scripts.

I suspect this change may actually fix a bunch of edge cases where we were not
checking for the HTMLScriptRunner's parser blocking script and thus incorrectly ending
the parser, or not starting the pre-load scanner, etc.

As part of this change I also renamed m_haveParsingBlockingScript in HTMLScriptRunner to match
the naming style used elsewhere in the parser, as well as removed all the "bool" return values
for these parse/execute functions as they are no longer useful (or correct). The correct way
is always to check HTMLDocumentParser::isWaitingForScripts().

Test: fast/parser/cached-script-document-write.html

  • html/parser/HTMLDocumentParser.cpp:

(WebCore::HTMLDocumentParser::pumpTokenizerIfPossible):
(WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder):
(WebCore::HTMLDocumentParser::canTakeNextToken):
(WebCore::HTMLDocumentParser::isWaitingForScripts):
(WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution):
(WebCore::HTMLDocumentParser::notifyFinished):
(WebCore::HTMLDocumentParser::executeScriptsWaitingForStylesheets):

  • html/parser/HTMLScriptRunner.cpp:

(WebCore::HTMLScriptRunner::~HTMLScriptRunner):
(WebCore::HTMLScriptRunner::executeParsingBlockingScript):
(WebCore::HTMLScriptRunner::execute):
(WebCore::HTMLScriptRunner::hasParserBlockingScript):
(WebCore::HTMLScriptRunner::executeParsingBlockingScripts):
(WebCore::HTMLScriptRunner::executeScriptsWaitingForLoad):
(WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing):
(WebCore::HTMLScriptRunner::requestParsingBlockingScript):
(WebCore::HTMLScriptRunner::runScript):

  • html/parser/HTMLScriptRunner.h:

(HTMLScriptRunner):

  • html/parser/HTMLTreeBuilder.cpp:

(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::takeScriptToProcess):
(WebCore::HTMLTreeBuilder::processEndTag):
(WebCore::HTMLTreeBuilder::processTokenInForeignContent):

  • html/parser/HTMLTreeBuilder.h:

(HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::hasParserBlockingScript):

LayoutTests:

  • fast/parser/cached-script-document-write-expected.txt: Added.
  • fast/parser/cached-script-document-write.html: Added.
  • fast/parser/resources/cached-script-document-write.js: Added.
Location:
trunk
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r122167 r122168  
     12012-07-09  Eric Seidel  <eric@webkit.org>
     2
     3        document.write of scripts that also document.write sometimes writes async
     4        https://bugs.webkit.org/show_bug.cgi?id=89102
     5
     6        Reviewed by Adam Barth.
     7
     8        * fast/parser/cached-script-document-write-expected.txt: Added.
     9        * fast/parser/cached-script-document-write.html: Added.
     10        * fast/parser/resources/cached-script-document-write.js: Added.
     11
    1122012-07-09  Filip Pizlo  <fpizlo@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r122163 r122168  
     12012-07-09  Eric Seidel  <eric@webkit.org>
     2
     3        document.write of scripts that also document.write sometimes writes async
     4        https://bugs.webkit.org/show_bug.cgi?id=89102
     5
     6        Reviewed by Adam Barth.
     7
     8        When a script tag is first encountered, the TreeBuilder holds the element and returns
     9        out to the outer HTMLDocumentParser parse loop.  The HTMLDocumentParser then takes
     10        the script element and passes it to the HTMLScriptRunner for execution. However, if the
     11        script is an "external script" the HTMLScriptRunner may have to wait for that parser
     12        blocking script to load, and may store the script in its own m_parserBlockingScript member.
     13
     14        While the HTMLScriptRunner has this not-yet-loaded-script the parser is also blocked.
     15        Because the "paused" state of the parser was held as a separate bool on the TreeBuilder
     16        we'd have to be careful to update it to reflect the current state of this pending script
     17        on the HTMLScriptRunner.
     18
     19        This patch removes this separate "paused" bool and makes the HTMLDocumentParser responsible
     20        for the "paused" state of the parser through the isWaitingForScripts() function which
     21        knows how to check both the TreeBuilder and the ScriptRunner for possible parser-blocking scripts.
     22
     23        I suspect this change may actually fix a bunch of edge cases where we were not
     24        checking for the HTMLScriptRunner's parser blocking script and thus incorrectly ending
     25        the parser, or not starting the pre-load scanner, etc.
     26
     27        As part of this change I also renamed m_haveParsingBlockingScript in HTMLScriptRunner to match
     28        the naming style used elsewhere in the parser, as well as removed all the "bool" return values
     29        for these parse/execute functions as they are no longer useful (or correct). The correct way
     30        is always to check HTMLDocumentParser::isWaitingForScripts().
     31
     32        Test: fast/parser/cached-script-document-write.html
     33
     34        * html/parser/HTMLDocumentParser.cpp:
     35        (WebCore::HTMLDocumentParser::pumpTokenizerIfPossible):
     36        (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder):
     37        (WebCore::HTMLDocumentParser::canTakeNextToken):
     38        (WebCore::HTMLDocumentParser::isWaitingForScripts):
     39        (WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution):
     40        (WebCore::HTMLDocumentParser::notifyFinished):
     41        (WebCore::HTMLDocumentParser::executeScriptsWaitingForStylesheets):
     42        * html/parser/HTMLScriptRunner.cpp:
     43        (WebCore::HTMLScriptRunner::~HTMLScriptRunner):
     44        (WebCore::HTMLScriptRunner::executeParsingBlockingScript):
     45        (WebCore::HTMLScriptRunner::execute):
     46        (WebCore::HTMLScriptRunner::hasParserBlockingScript):
     47        (WebCore::HTMLScriptRunner::executeParsingBlockingScripts):
     48        (WebCore::HTMLScriptRunner::executeScriptsWaitingForLoad):
     49        (WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing):
     50        (WebCore::HTMLScriptRunner::requestParsingBlockingScript):
     51        (WebCore::HTMLScriptRunner::runScript):
     52        * html/parser/HTMLScriptRunner.h:
     53        (HTMLScriptRunner):
     54        * html/parser/HTMLTreeBuilder.cpp:
     55        (WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
     56        (WebCore::HTMLTreeBuilder::takeScriptToProcess):
     57        (WebCore::HTMLTreeBuilder::processEndTag):
     58        (WebCore::HTMLTreeBuilder::processTokenInForeignContent):
     59        * html/parser/HTMLTreeBuilder.h:
     60        (HTMLTreeBuilder):
     61        (WebCore::HTMLTreeBuilder::hasParserBlockingScript):
     62
    1632012-07-09  Ryosuke Niwa  <rniwa@webkit.org>
    264
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp

    r121858 r122168  
    166166void HTMLDocumentParser::pumpTokenizerIfPossible(SynchronousMode mode)
    167167{
    168     if (isStopped() || m_treeBuilder->isPaused())
     168    if (isStopped() || isWaitingForScripts())
    169169        return;
    170170
     
    196196}
    197197
    198 bool HTMLDocumentParser::runScriptsForPausedTreeBuilder()
    199 {
    200     ASSERT(m_treeBuilder->isPaused());
    201 
     198void HTMLDocumentParser::runScriptsForPausedTreeBuilder()
     199{
    202200    TextPosition scriptStartPosition = TextPosition::belowRangePosition();
    203201    RefPtr<Element> scriptElement = m_treeBuilder->takeScriptToProcess(scriptStartPosition);
    204202    // We will not have a scriptRunner when parsing a DocumentFragment.
    205     if (!m_scriptRunner)
    206         return true;
    207     return m_scriptRunner->execute(scriptElement.release(), scriptStartPosition);
     203    if (m_scriptRunner)
     204        m_scriptRunner->execute(scriptElement.release(), scriptStartPosition);
    208205}
    209206
     
    213210        return false;
    214211
    215     // The parser will pause itself when waiting on a script to load or run.
    216     if (m_treeBuilder->isPaused()) {
     212    if (isWaitingForScripts()) {
    217213        if (mode == AllowYield)
    218214            m_parserScheduler->checkForYieldBeforeScript(session);
     
    223219
    224220        // If we're paused waiting for a script, we try to execute scripts before continuing.
    225         bool shouldContinueParsing = runScriptsForPausedTreeBuilder();
    226         m_treeBuilder->setPaused(!shouldContinueParsing);
    227         if (!shouldContinueParsing || isStopped())
     221        runScriptsForPausedTreeBuilder();
     222        if (isWaitingForScripts() || isStopped())
    228223            return false;
    229224    }
     
    386381    ASSERT(isStopping());
    387382    ASSERT(!hasInsertionPoint());
    388     if (m_scriptRunner && !m_scriptRunner->executeScriptsWaitingForParsing())
    389         return;
     383    if (m_scriptRunner) {
     384        m_scriptRunner->executeScriptsWaitingForParsing();
     385        if (isWaitingForScripts())
     386            return;
     387    }
    390388    end();
    391389}
     
    463461bool HTMLDocumentParser::isWaitingForScripts() const
    464462{
    465     return m_treeBuilder->isPaused();
     463    // When the TreeBuilder encounters a </script> tag, it returns to the HTMLDocumentParser
     464    // where the script is transfered from the treebuilder to the script runner.
     465    // The script runner will hold the script until its loaded and run. During
     466    // any of this time, we want to count ourselves as "waiting for a script" and thus
     467    // run the preload scanner, as well as delay completion of parsing.
     468    bool treeBuilderHasBlockingScript = m_treeBuilder->hasParserBlockingScript();
     469    bool scriptRunnerHasBlockingScript = m_scriptRunner && m_scriptRunner->hasParserBlockingScript();
     470    // Since the parser is paused while a script runner has a blocking script, it should
     471    // never be possible to end up with both objects holding a blocking script.
     472    ASSERT(!(treeBuilderHasBlockingScript && scriptRunnerHasBlockingScript));
     473    // If either object has a blocking script, the parser should be paused.
     474    return treeBuilderHasBlockingScript || scriptRunnerHasBlockingScript;
    466475}
    467476
     
    469478{
    470479    ASSERT(!isExecutingScript());
    471     ASSERT(!m_treeBuilder->isPaused());
     480    ASSERT(!isWaitingForScripts());
    472481
    473482    m_insertionPreloadScanner.clear();
     
    510519    }
    511520
    512     ASSERT(m_treeBuilder->isPaused());
    513     // Note: We only ever wait on one script at a time, so we always know this
    514     // is the one we were waiting on and can un-pause the tree builder.
    515     m_treeBuilder->setPaused(false);
    516     bool shouldContinueParsing = m_scriptRunner->executeScriptsWaitingForLoad(cachedResource);
    517     m_treeBuilder->setPaused(!shouldContinueParsing);
    518     if (shouldContinueParsing)
     521    m_scriptRunner->executeScriptsWaitingForLoad(cachedResource);
     522    if (!isWaitingForScripts())
    519523        resumeParsingAfterScriptExecution();
    520524}
     
    534538    // but we need to ensure it isn't deleted yet.
    535539    RefPtr<HTMLDocumentParser> protect(this);
    536 
    537     ASSERT(!m_scriptRunner->isExecutingScript());
    538     ASSERT(m_treeBuilder->isPaused());
    539     // Note: We only ever wait on one script at a time, so we always know this
    540     // is the one we were waiting on and can un-pause the tree builder.
    541     m_treeBuilder->setPaused(false);
    542     bool shouldContinueParsing = m_scriptRunner->executeScriptsWaitingForStylesheets();
    543     m_treeBuilder->setPaused(!shouldContinueParsing);
    544     if (shouldContinueParsing)
     540    m_scriptRunner->executeScriptsWaitingForStylesheets();
     541    if (!isWaitingForScripts())
    545542        resumeParsingAfterScriptExecution();
    546543}
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.h

    r121623 r122168  
    125125    void pumpTokenizerIfPossible(SynchronousMode);
    126126
    127     bool runScriptsForPausedTreeBuilder();
     127    void runScriptsForPausedTreeBuilder();
    128128    void resumeParsingAfterScriptExecution();
    129129
  • trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp

    r95901 r122168  
    5858{
    5959    // FIXME: Should we be passed a "done loading/parsing" callback sooner than destruction?
    60     if (m_parsingBlockingScript.cachedScript() && m_parsingBlockingScript.watchingForLoad())
    61         stopWatchingForLoad(m_parsingBlockingScript);
     60    if (m_parserBlockingScript.cachedScript() && m_parserBlockingScript.watchingForLoad())
     61        stopWatchingForLoad(m_parserBlockingScript);
    6262
    6363    while (!m_scriptsToExecuteAfterParsing.isEmpty()) {
     
    113113    ASSERT(!m_scriptNestingLevel);
    114114    ASSERT(m_document->haveStylesheetsLoaded());
    115     ASSERT(isPendingScriptReady(m_parsingBlockingScript));
     115    ASSERT(isPendingScriptReady(m_parserBlockingScript));
    116116
    117117    InsertionPointRecord insertionPointRecord(m_host->inputStream());
    118     executePendingScriptAndDispatchEvent(m_parsingBlockingScript);
     118    executePendingScriptAndDispatchEvent(m_parserBlockingScript);
    119119}
    120120
     
    160160// This function should match 10.2.5.11 "An end tag whose tag name is 'script'"
    161161// Script handling lives outside the tree builder to keep the each class simple.
    162 bool HTMLScriptRunner::execute(PassRefPtr<Element> scriptElement, const TextPosition& scriptStartPosition)
     162void HTMLScriptRunner::execute(PassRefPtr<Element> scriptElement, const TextPosition& scriptStartPosition)
    163163{
    164164    ASSERT(scriptElement);
    165     // FIXME: If scripting is disabled, always just return true;
     165    // FIXME: If scripting is disabled, always just return.
    166166
    167167    bool hadPreloadScanner = m_host->hasPreloadScanner();
     
    170170    runScript(scriptElement.get(), scriptStartPosition);
    171171
    172     if (haveParsingBlockingScript()) {
     172    if (hasParserBlockingScript()) {
    173173        if (m_scriptNestingLevel)
    174             return false; // Block the parser. Unwind to the outermost HTMLScriptRunner::execute before continuing parsing.
     174            return; // Unwind to the outermost HTMLScriptRunner::execute before continuing parsing.
    175175        // If preload scanner got created, it is missing the source after the current insertion point. Append it and scan.
    176176        if (!hadPreloadScanner && m_host->hasPreloadScanner())
    177177            m_host->appendCurrentInputStreamToPreloadScannerAndScan();
    178         if (!executeParsingBlockingScripts())
    179             return false; // We still have a parsing blocking script, block the parser.
    180     }
    181     return true; // Scripts executed as expected, continue parsing.
    182 }
    183 
    184 bool HTMLScriptRunner::haveParsingBlockingScript() const
    185 {
    186     return !!m_parsingBlockingScript.element();
    187 }
    188 
    189 bool HTMLScriptRunner::executeParsingBlockingScripts()
    190 {
    191     while (haveParsingBlockingScript()) {
    192         // We only really need to check once.
    193         if (!isPendingScriptReady(m_parsingBlockingScript))
    194             return false;
     178        executeParsingBlockingScripts();
     179    }
     180}
     181
     182bool HTMLScriptRunner::hasParserBlockingScript() const
     183{
     184    return !!m_parserBlockingScript.element();
     185}
     186
     187void HTMLScriptRunner::executeParsingBlockingScripts()
     188{
     189    while (hasParserBlockingScript() && isPendingScriptReady(m_parserBlockingScript))
    195190        executeParsingBlockingScript();
    196     }
    197     return true;
    198 }
    199 
    200 bool HTMLScriptRunner::executeScriptsWaitingForLoad(CachedResource* cachedScript)
     191}
     192
     193void HTMLScriptRunner::executeScriptsWaitingForLoad(CachedResource* cachedScript)
    201194{
    202195    ASSERT(!m_scriptNestingLevel);
    203     ASSERT(haveParsingBlockingScript());
    204     ASSERT_UNUSED(cachedScript, m_parsingBlockingScript.cachedScript() == cachedScript);
    205     ASSERT(m_parsingBlockingScript.cachedScript()->isLoaded());
    206     return executeParsingBlockingScripts();
    207 }
    208 
    209 bool HTMLScriptRunner::executeScriptsWaitingForStylesheets()
     196    ASSERT(hasParserBlockingScript());
     197    ASSERT_UNUSED(cachedScript, m_parserBlockingScript.cachedScript() == cachedScript);
     198    ASSERT(m_parserBlockingScript.cachedScript()->isLoaded());
     199    executeParsingBlockingScripts();
     200}
     201
     202void HTMLScriptRunner::executeScriptsWaitingForStylesheets()
    210203{
    211204    ASSERT(m_document);
     
    215208    ASSERT(!m_scriptNestingLevel);
    216209    ASSERT(m_document->haveStylesheetsLoaded());
    217     return executeParsingBlockingScripts();
    218 }
    219 
    220 bool HTMLScriptRunner::executeScriptsWaitingForParsing()
     210    executeParsingBlockingScripts();
     211}
     212
     213void HTMLScriptRunner::executeScriptsWaitingForParsing()
    221214{
    222215    while (!m_scriptsToExecuteAfterParsing.isEmpty()) {
    223216        ASSERT(!m_scriptNestingLevel);
    224         ASSERT(!haveParsingBlockingScript());
     217        ASSERT(!hasParserBlockingScript());
    225218        ASSERT(m_scriptsToExecuteAfterParsing.first().cachedScript());
    226219        if (!m_scriptsToExecuteAfterParsing.first().cachedScript()->isLoaded()) {
    227220            watchForLoad(m_scriptsToExecuteAfterParsing.first());
    228             return false;
     221            return;
    229222        }
    230223        PendingScript first = m_scriptsToExecuteAfterParsing.takeFirst();
    231224        executePendingScriptAndDispatchEvent(first);
     225        // FIXME: What is this m_document check for?
    232226        if (!m_document)
    233             return false;
    234     }
    235     return true;
     227            return;
     228    }
    236229}
    237230
    238231void HTMLScriptRunner::requestParsingBlockingScript(Element* element)
    239232{
    240     if (!requestPendingScript(m_parsingBlockingScript, element))
     233    if (!requestPendingScript(m_parserBlockingScript, element))
    241234        return;
    242235
    243     ASSERT(m_parsingBlockingScript.cachedScript());
     236    ASSERT(m_parserBlockingScript.cachedScript());
    244237
    245238    // We only care about a load callback if cachedScript is not already
    246     // in the cache.  Callers will attempt to run the m_parsingBlockingScript
     239    // in the cache. Callers will attempt to run the m_parserBlockingScript
    247240    // if possible before returning control to the parser.
    248     if (!m_parsingBlockingScript.cachedScript()->isLoaded())
    249         watchForLoad(m_parsingBlockingScript);
     241    if (!m_parserBlockingScript.cachedScript()->isLoaded())
     242        watchForLoad(m_parserBlockingScript);
    250243}
    251244
     
    279272{
    280273    ASSERT(m_document);
    281     ASSERT(!haveParsingBlockingScript());
     274    ASSERT(!hasParserBlockingScript());
    282275    {
    283276        InsertionPointRecord insertionPointRecord(m_host->inputStream());
     
    303296        else if (scriptElement->readyToBeParserExecuted()) {
    304297            if (m_scriptNestingLevel == 1) {
    305                 m_parsingBlockingScript.setElement(script);
    306                 m_parsingBlockingScript.setStartingPosition(scriptStartPosition);
     298                m_parserBlockingScript.setElement(script);
     299                m_parserBlockingScript.setStartingPosition(scriptStartPosition);
    307300            } else {
    308301                ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), scriptStartPosition);
  • trunk/Source/WebCore/html/parser/HTMLScriptRunner.h

    r95901 r122168  
    5454
    5555    // Processes the passed in script and any pending scripts if possible.
    56     bool execute(PassRefPtr<Element> scriptToProcess, const TextPosition& scriptStartPosition);
     56    void execute(PassRefPtr<Element> scriptToProcess, const TextPosition& scriptStartPosition);
    5757
    58     bool executeScriptsWaitingForLoad(CachedResource*);
     58    void executeScriptsWaitingForLoad(CachedResource*);
    5959    bool hasScriptsWaitingForStylesheets() const { return m_hasScriptsWaitingForStylesheets; }
    60     bool executeScriptsWaitingForStylesheets();
    61     bool executeScriptsWaitingForParsing();
     60    void executeScriptsWaitingForStylesheets();
     61    void executeScriptsWaitingForParsing();
    6262
     63    bool hasParserBlockingScript() const;
    6364    bool isExecutingScript() const { return !!m_scriptNestingLevel; }
    6465
     
    7071    void executeParsingBlockingScript();
    7172    void executePendingScriptAndDispatchEvent(PendingScript&);
    72     bool haveParsingBlockingScript() const;
    73     bool executeParsingBlockingScripts();
     73    void executeParsingBlockingScripts();
    7474
    7575    void requestParsingBlockingScript(Element*);
     
    8787    Document* m_document;
    8888    HTMLScriptRunnerHost* m_host;
    89     PendingScript m_parsingBlockingScript;
     89    PendingScript m_parserBlockingScript;
    9090    Deque<PendingScript> m_scriptsToExecuteAfterParsing; // http://www.whatwg.org/specs/web-apps/current-work/#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing
    9191    unsigned m_scriptNestingLevel;
  • trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp

    r122081 r122168  
    352352    , m_tree(document, maximumDOMTreeDepth)
    353353    , m_reportErrors(reportErrors)
    354     , m_isPaused(false)
    355354    , m_insertionMode(InitialMode)
    356355    , m_originalInsertionMode(InitialMode)
     
    370369    , m_tree(fragment, scriptingPermission, maximumDOMTreeDepth)
    371370    , m_reportErrors(false) // FIXME: Why not report errors in fragments?
    372     , m_isPaused(false)
    373371    , m_insertionMode(InitialMode)
    374372    , m_originalInsertionMode(InitialMode)
     
    426424PassRefPtr<Element> HTMLTreeBuilder::takeScriptToProcess(TextPosition& scriptStartPosition)
    427425{
     426    ASSERT(m_scriptToProcess);
    428427    // Unpause ourselves, callers may pause us again when processing the script.
    429428    // The HTML5 spec is written as though scripts are executed inside the tree
    430429    // builder.  We pause the parser to exit the tree builder, and then resume
    431430    // before running scripts.
    432     m_isPaused = false;
    433431    scriptStartPosition = m_scriptToProcessStartPosition;
    434432    m_scriptToProcessStartPosition = uninitializedPositionValue1();
     
    21282126        if (token.name() == scriptTag) {
    21292127            // Pause ourselves so that parsing stops until the script can be processed by the caller.
    2130             m_isPaused = true;
    21312128            ASSERT(m_tree.currentElement()->hasTagName(scriptTag));
    21322129            m_scriptToProcess = m_tree.currentElement();
     
    27512748
    27522749        if (token.name() == SVGNames::scriptTag && m_tree.currentNode()->hasTagName(SVGNames::scriptTag)) {
    2753             m_isPaused = true;
    27542750            m_scriptToProcess = m_tree.currentElement();
    27552751            m_tree.openElements()->pop();
  • trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h

    r122081 r122168  
    7171    void detach();
    7272
    73     void setPaused(bool paused) { m_isPaused = paused; }
    74     bool isPaused() const { return m_isPaused; }
    75 
    7673    // The token really should be passed as a const& since it's never modified.
    7774    void constructTreeFromToken(HTMLToken&);
    7875    void constructTreeFromAtomicToken(AtomicHTMLToken&);
    7976
    80     // Must be called when parser is paused before calling the parser again.
     77    bool hasParserBlockingScript() const { return !!m_scriptToProcess; }
     78    // Must be called to take the parser-blocking script before calling the parser again.
    8179    PassRefPtr<Element> takeScriptToProcess(TextPosition& scriptStartPosition);
    8280
     
    217215
    218216    bool m_reportErrors;
    219     bool m_isPaused;
    220217
    221218    // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#insertion-mode
Note: See TracChangeset for help on using the changeset viewer.