Changeset 61608 in webkit


Ignore:
Timestamp:
Jun 22, 2010 1:14:46 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-06-22 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Follow the HTML5 spec more closely w.r.t. when to save the insertion point
https://bugs.webkit.org/show_bug.cgi?id=40976

This test no longer asserts. The output is incorrect, however. I'll
fix the output in the next patch.

  • fast/tokenizer/write-on-load-expected.txt: Added.
  • fast/tokenizer/write-on-load.html: Added.

2010-06-22 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Follow the HTML5 spec more closely w.r.t. when to save the insertion point
https://bugs.webkit.org/show_bug.cgi?id=40976

The spec always increments the nesting level and saves the insertion
point at the same time. In this patch, we now do those operations
packaged as a RAII.

As a side effect, the test case below no longer ASSERTs. (The output
is wrong, but we'll get to that next.)

Test: fast/tokenizer/write-on-load.html

  • html/HTML5ScriptRunner.cpp: (WebCore::NestScript::NestScript): (WebCore::NestScript::~NestScript): (WebCore::HTML5ScriptRunner::executePendingScript): (WebCore::HTML5ScriptRunner::executeScript): (WebCore::HTML5ScriptRunner::requestScript): (WebCore::HTML5ScriptRunner::runScript):
  • html/HTMLInputStream.h:
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r61605 r61608  
     12010-06-22  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Follow the HTML5 spec more closely w.r.t. when to save the insertion point
     6        https://bugs.webkit.org/show_bug.cgi?id=40976
     7
     8        This test no longer asserts.  The output is incorrect, however.  I'll
     9        fix the output in the next patch.
     10
     11        * fast/tokenizer/write-on-load-expected.txt: Added.
     12        * fast/tokenizer/write-on-load.html: Added.
     13
    1142010-06-21  Julien Chaffraix  <jchaffraix@webkit.org>
    215
  • trunk/WebCore/ChangeLog

    r61607 r61608  
     12010-06-22  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Follow the HTML5 spec more closely w.r.t. when to save the insertion point
     6        https://bugs.webkit.org/show_bug.cgi?id=40976
     7
     8        The spec always increments the nesting level and saves the insertion
     9        point at the same time.  In this patch, we now do those operations
     10        packaged as a RAII.
     11
     12        As a side effect, the test case below no longer ASSERTs.  (The output
     13        is wrong, but we'll get to that next.)
     14
     15        Test: fast/tokenizer/write-on-load.html
     16
     17        * html/HTML5ScriptRunner.cpp:
     18        (WebCore::NestScript::NestScript):
     19        (WebCore::NestScript::~NestScript):
     20        (WebCore::HTML5ScriptRunner::executePendingScript):
     21        (WebCore::HTML5ScriptRunner::executeScript):
     22        (WebCore::HTML5ScriptRunner::requestScript):
     23        (WebCore::HTML5ScriptRunner::runScript):
     24        * html/HTMLInputStream.h:
     25
    1262010-06-22  Adam Barth  <abarth@webkit.org>
    227
  • trunk/WebCore/html/HTML5ScriptRunner.cpp

    r61607 r61608  
    4444using namespace HTMLNames;
    4545
     46class NestScript : public Noncopyable {
     47public:
     48    NestScript(unsigned& nestingLevel, HTMLInputStream& inputStream)
     49        : m_nestingLevel(&nestingLevel)
     50        , m_savedInsertionPoint(inputStream)
     51    {
     52        ++(*m_nestingLevel);
     53    }
     54
     55    ~NestScript()
     56    {
     57        --(*m_nestingLevel);
     58    }
     59
     60private:
     61    unsigned* m_nestingLevel;
     62    InsertionPointRecord m_savedInsertionPoint;
     63};
     64
    4665HTML5ScriptRunner::HTML5ScriptRunner(Document* document, HTML5ScriptRunnerHost* host)
    4766    : m_document(document)
     
    115134    RefPtr<Element> scriptElement = m_parsingBlockingScript.element.release();
    116135    m_parsingBlockingScript = PendingScript();
    117 
    118     m_scriptNestingLevel++;
    119     if (errorOccurred)
    120         scriptElement->dispatchEvent(createScriptErrorEvent());
    121     else {
    122         executeScript(scriptElement.get(), sourceCode);
    123         scriptElement->dispatchEvent(createScriptLoadEvent());
    124     }
    125     m_scriptNestingLevel--;
     136    {
     137        NestScript nestingLevel(m_scriptNestingLevel, m_host->inputStream());
     138        if (errorOccurred)
     139            scriptElement->dispatchEvent(createScriptErrorEvent());
     140        else {
     141            executeScript(scriptElement.get(), sourceCode);
     142            scriptElement->dispatchEvent(createScriptLoadEvent());
     143        }
     144    }
    126145    ASSERT(!m_scriptNestingLevel);
    127146}
     
    140159    if (!m_document->frame())
    141160        return;
    142 
    143     InsertionPointRecord savedInsertionPoint(m_host->inputStream());
    144161    m_document->frame()->script()->executeScript(sourceCode);
    145162}
     
    237254        return;
    238255    // FIXME: We need to resolve the url relative to the element.
    239     {
    240         InsertionPointRecord savedInsertionPoint(m_host->inputStream());
    241         if (!script->dispatchBeforeLoadEvent(srcValue))
    242             return;
    243     }
     256    if (!script->dispatchBeforeLoadEvent(srcValue))
     257        return;
    244258    m_parsingBlockingScript.element = script;
    245259    // This should correctly return 0 for empty or invalid srcValues.
     
    266280{
    267281    ASSERT(!haveParsingBlockingScript());
    268     m_scriptNestingLevel++;
    269     // Check script type and language, current code uses ScriptElement::shouldExecuteAsJavaScript(), but that may not be HTML5 compliant.
    270     notImplemented(); // event for support
    271 
    272     if (script->hasAttribute(srcAttr)) {
    273         // FIXME: Handle defer and async
    274         requestScript(script);
    275     } else {
    276         // FIXME: We do not block inline <script> tags on stylesheets to match the
    277         // old parser for now.  See https://bugs.webkit.org/show_bug.cgi?id=40047
    278         ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), startingLineNumber);
    279         executeScript(script, sourceCode);
    280     }
    281     m_scriptNestingLevel--;
    282 }
    283 
    284 }
     282    {
     283        NestScript nestingLevel(m_scriptNestingLevel, m_host->inputStream());
     284
     285        // Check script type and language, current code uses ScriptElement::shouldExecuteAsJavaScript(), but that may not be HTML5 compliant.
     286        notImplemented(); // event for support
     287
     288        if (script->hasAttribute(srcAttr)) {
     289            // FIXME: Handle defer and async
     290            requestScript(script);
     291        } else {
     292            // FIXME: We do not block inline <script> tags on stylesheets to match the
     293            // old parser for now.  See https://bugs.webkit.org/show_bug.cgi?id=40047
     294            ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), startingLineNumber);
     295            executeScript(script, sourceCode);
     296        }
     297    }
     298}
     299
     300}
  • trunk/WebCore/html/HTMLInputStream.h

    r61606 r61608  
    4848// The network adds data at the end of the InputStream, which appends
    4949// them to the "last" string.
    50 class HTMLInputStream {
     50class HTMLInputStream : public Noncopyable {
    5151public:
    5252    HTMLInputStream()
     
    103103};
    104104
    105 class InsertionPointRecord {
     105class InsertionPointRecord : public Noncopyable {
    106106public:
    107107    explicit InsertionPointRecord(HTMLInputStream& inputStream)
Note: See TracChangeset for help on using the changeset viewer.