Changeset 65281 in webkit


Ignore:
Timestamp:
Aug 12, 2010 4:23:13 PM (14 years ago)
Author:
Dimitri Glazkov
Message:

2010-08-12 Dimitri Glazkov <Dimitri Glazkov>

Reviewed by Adam Barth.

Ensure that parser doesn't attach children that have been removed by JavaScript event handlers.
https://bugs.webkit.org/show_bug.cgi?id=43813

This patch re-fixes bug 40742 in a way that keeps allowing HTMLLinkElement
to lazy-attach.

  • html/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::attach): Added parent check.
  • html/HTMLLinkElement.cpp: Basically undoes changes introduced by r61424.
  • html/HTMLLinkElement.h: Ditto.
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65280 r65281  
     12010-08-12  Dimitri Glazkov  <dglazkov@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Ensure that parser doesn't attach children that have been removed by JavaScript event handlers.
     6        https://bugs.webkit.org/show_bug.cgi?id=43813
     7
     8        This patch re-fixes bug 40742 in a way that keeps allowing HTMLLinkElement
     9        to lazy-attach.
     10
     11        * html/HTMLConstructionSite.cpp:
     12        (WebCore::HTMLConstructionSite::attach): Added parent check.
     13        * html/HTMLLinkElement.cpp: Basically undoes changes introduced by r61424.
     14        * html/HTMLLinkElement.h: Ditto.
     15
    1162010-08-12  Justin Schuh  <jschuh@chromium.org>
    217
  • trunk/WebCore/html/HTMLConstructionSite.cpp

    r65167 r65281  
    9898
    9999    parent->parserAddChild(child);
     100
     101    // An event handler (DOM Mutation, beforeload, et al.) could have removed
     102    // the child, in which case we shouldn't try attaching it.
     103    if (!child->parentNode())
     104        return child.release();
     105
    100106    // It's slightly unfortunate that we need to hold a reference to child
    101107    // here to call attach().  We should investigate whether we can rely on
  • trunk/WebCore/html/HTMLLinkElement.cpp

    r63924 r65281  
    5252    , m_loading(false)
    5353    , m_createdByParser(createdByParser)
    54     , m_shouldProcessAfterAttach(false)
    5554{
    5655    ASSERT(hasTagName(linkTag));
     
    243242    }
    244243}
    245    
    246 void HTMLLinkElement::processCallback(Node* node)
    247 {
    248     ASSERT_ARG(node, node && node->hasTagName(linkTag));
    249     static_cast<HTMLLinkElement*>(node)->process();
    250 }
    251244
    252245void HTMLLinkElement::insertedIntoDocument()
     
    254247    HTMLElement::insertedIntoDocument();
    255248    document()->addStyleSheetCandidateNode(this, m_createdByParser);
    256 
    257     // Since processing a stylesheet link causes a beforeload event
    258     // to fire, it is possible for JavaScript to remove the element in the midst
    259     // of it being inserted into the DOM, which can lead to assertion failures
    260     // and crashes. Avoid this by postponing the beforeload/load until after
    261     // attach if there are beforeload listeners.
    262     if (document()->hasListenerType(Document::BEFORELOAD_LISTENER)) {
    263         m_shouldProcessAfterAttach = true;
    264         return;
    265     }
    266249
    267250    process();
     
    277260    if (document()->renderer())
    278261        document()->updateStyleSelector();
    279    
    280     m_shouldProcessAfterAttach = false;
    281 }
    282 
    283 void HTMLLinkElement::attach()
    284 {
    285     if (m_shouldProcessAfterAttach) {
    286         m_shouldProcessAfterAttach = false;
    287         queuePostAttachCallback(&HTMLLinkElement::processCallback, this);
    288     }
    289 
    290     HTMLElement::attach();
    291 }
    292    
     262}
     263
    293264void HTMLLinkElement::finishParsingChildren()
    294265{
  • trunk/WebCore/html/HTMLLinkElement.h

    r63204 r65281  
    7474    bool isEnabledViaScript() const { return m_disabledState == EnabledViaScript; }
    7575    bool isIcon() const { return m_relAttribute.m_isIcon; }
    76    
    77     virtual void attach();
    78     virtual bool canLazyAttach() { return false; }
    7976
    8077private:
     
    126123    bool m_loading;
    127124    bool m_createdByParser;
    128     bool m_shouldProcessAfterAttach;
    129125};
    130126
Note: See TracChangeset for help on using the changeset viewer.