Changeset 62028 in webkit


Ignore:
Timestamp:
Jun 28, 2010 1:05:25 PM (14 years ago)
Author:
abarth@webkit.org
Message:

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

Reviewed by Eric Seidel.

The new tree builder needs to call attach() on elements it attaches to
the DOM
https://bugs.webkit.org/show_bug.cgi?id=41293

Update expected results to show that the contents of the iframe
actually get created. This only gets us a few lines down the test
harness before erroring out again, but I'll take it.

  • html5lib/runner-expected-html5.txt:
  • html5lib/webkit-resumer-expected-html5.txt:

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

Reviewed by Eric Seidel.

The new tree builder needs to call attach() on elements it attaches to
the DOM
https://bugs.webkit.org/show_bug.cgi?id=41293

Apparently Nodes expect to have their attach() method called when they
are attached to the DOM. The new tree builder is happy to oblige.
Making this call requires some fancy footwork with RefPtr/PassRefPtr to
avoid extra ref churn while keeping each function small.

  • html/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::insertHTMLStartTagBeforeHTML): (WebCore::HTMLTreeBuilder::processCharacter): (WebCore::HTMLTreeBuilder::insertDoctype): (WebCore::HTMLTreeBuilder::insertComment): (WebCore::HTMLTreeBuilder::insertCommentOnDocument): (WebCore::HTMLTreeBuilder::insertElement): (WebCore::HTMLTreeBuilder::insertSelfClosingElement): (WebCore::HTMLTreeBuilder::insertScriptElement):
  • html/HTMLTreeBuilder.h: (WebCore::HTMLTreeBuilder::attach):
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r62024 r62028  
     12010-06-28  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        The new tree builder needs to call attach() on elements it attaches to
     6        the DOM
     7        https://bugs.webkit.org/show_bug.cgi?id=41293
     8
     9        Update expected results to show that the contents of the iframe
     10        actually get created.  This only gets us a few lines down the test
     11        harness before erroring out again, but I'll take it.
     12
     13        * html5lib/runner-expected-html5.txt:
     14        * html5lib/webkit-resumer-expected-html5.txt:
     15
    1162010-06-28  Robert Hogan  <robert@webkit.org>
    217
  • trunk/LayoutTests/html5lib/runner-expected-html5.txt

    r61991 r62028  
    1 CONSOLE MESSAGE: line 33: TypeError: Result of expression 'iframe.contentWindow' [null] is not an object.
     1CONSOLE MESSAGE: line 36: TypeError: Result of expression 'iframe.contentWindow.document.lastChild' [null] is not an object.
    22Content-Type: text/plain
    33
  • trunk/LayoutTests/html5lib/webkit-resumer-expected-html5.txt

    r61991 r62028  
    1 CONSOLE MESSAGE: line 33: TypeError: Result of expression 'iframe.contentWindow' [null] is not an object.
     1CONSOLE MESSAGE: line 36: TypeError: Result of expression 'iframe.contentWindow.document.lastChild' [null] is not an object.
    22Content-Type: text/plain
    33
  • trunk/WebCore/ChangeLog

    r62026 r62028  
     12010-06-28  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        The new tree builder needs to call attach() on elements it attaches to
     6        the DOM
     7        https://bugs.webkit.org/show_bug.cgi?id=41293
     8
     9        Apparently Nodes expect to have their attach() method called when they
     10        are attached to the DOM.  The new tree builder is happy to oblige.
     11        Making this call requires some fancy footwork with RefPtr/PassRefPtr to
     12        avoid extra ref churn while keeping each function small.
     13
     14        * html/HTMLTreeBuilder.cpp:
     15        (WebCore::HTMLTreeBuilder::insertHTMLStartTagBeforeHTML):
     16        (WebCore::HTMLTreeBuilder::processCharacter):
     17        (WebCore::HTMLTreeBuilder::insertDoctype):
     18        (WebCore::HTMLTreeBuilder::insertComment):
     19        (WebCore::HTMLTreeBuilder::insertCommentOnDocument):
     20        (WebCore::HTMLTreeBuilder::insertElement):
     21        (WebCore::HTMLTreeBuilder::insertSelfClosingElement):
     22        (WebCore::HTMLTreeBuilder::insertScriptElement):
     23        * html/HTMLTreeBuilder.h:
     24        (WebCore::HTMLTreeBuilder::attach):
     25
    1262010-06-28  Xan Lopez  <xlopez@igalia.com>
    227
  • trunk/WebCore/html/HTMLTreeBuilder.cpp

    r61989 r62028  
    282282    RefPtr<Element> element = HTMLHtmlElement::create(m_document);
    283283    element->setAttributeMap(token.attributes(), m_fragmentScriptingPermission);
    284     m_document->addChild(element);
    285     m_openElements.push(element.release());
     284    m_openElements.push(attach(m_document, element.release()));
    286285}
    287286
     
    667666{
    668667    if (insertionMode() == TextMode) {
    669         currentElement()->addChild(Text::create(m_document, token.characters()));
     668        attach(currentElement(), Text::create(m_document, token.characters()));
    670669        return;
    671670    }
     
    793792{
    794793    ASSERT(token.type() == HTMLToken::DOCTYPE);
    795     m_document->addChild(DocumentType::create(m_document, token.name(), String::adopt(token.publicIdentifier()), String::adopt(token.systemIdentifier())));
     794    attach(m_document, DocumentType::create(m_document, token.name(), String::adopt(token.publicIdentifier()), String::adopt(token.systemIdentifier())));
    796795    // FIXME: Move quirks mode detection from DocumentType element to here.
    797796    notImplemented();
     
    803802{
    804803    ASSERT(token.type() == HTMLToken::Comment);
    805     currentElement()->addChild(Comment::create(m_document, token.comment()));
     804    attach(currentElement(), Comment::create(m_document, token.comment()));
    806805}
    807806
     
    809808{
    810809    ASSERT(token.type() == HTMLToken::Comment);
    811     m_document->addChild(Comment::create(m_document, token.comment()));
     810    attach(m_document, Comment::create(m_document, token.comment()));
    812811}
    813812
     
    815814{
    816815    ASSERT(token.type() == HTMLToken::StartTag);
    817     RefPtr<Element> element = createElement(token);
    818     currentElement()->addChild(element);
    819     m_openElements.push(element.release());
     816    m_openElements.push(attach(currentElement(), createElement(token)));
    820817}
    821818
     
    823820{
    824821    ASSERT(token.type() == HTMLToken::StartTag);
    825     currentElement()->addChild(createElement(token));
     822    attach(currentElement(), createElement(token));
    826823    // FIXME: Do we want to acknowledge the token's self-closing flag?
    827824    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#acknowledge-self-closing-flag
     
    857854    RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, m_document, true);
    858855    element->setAttributeMap(token.attributes(), m_fragmentScriptingPermission);
    859     currentElement()->addChild(element);
    860     m_openElements.push(element.release());
     856    m_openElements.push(attach(currentElement(), element.release()));
    861857    m_tokenizer->setState(HTMLTokenizer::ScriptDataState);
    862858    m_originalInsertionMode = m_insertionMode;
  • trunk/WebCore/html/HTMLTreeBuilder.h

    r61990 r62028  
    178178    bool processStartTagForInHead(AtomicHTMLToken&);
    179179
     180    template<typename ChildType>
     181    PassRefPtr<ChildType> attach(Node* parent, PassRefPtr<ChildType> prpChild)
     182    {
     183        RefPtr<ChildType> child = prpChild;
     184        parent->addChild(child);
     185        // It's slightly unfortunate that we need to hold a reference to child
     186        // here to call attach().  We should investigate whether we can rely on
     187        // |parent| to hold a ref at this point.  In the common case (at least
     188        // for elements), however, we'll get to use this ref in the stack of
     189        // open elements.
     190        child->attach();
     191        return child.release();
     192    };
     193
    180194    void insertDoctype(AtomicHTMLToken&);
    181195    void insertComment(AtomicHTMLToken&);
Note: See TracChangeset for help on using the changeset viewer.