⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 117756 in webkit


Ignore:
Timestamp:
May 21, 2012, 3:47:25 AM (14 years ago)
Author:
kov@webkit.org
Message:

Merge 113887 - StyleElement ownerNode is not cleared correctly
https://bugs.webkit.org/show_bug.cgi?id=83696

Reviewed by Antti Koivisto.

Source/WebCore:

When the css text changes in such a way that we remove the sheet of a style element or a link[rel=stylesheet]
element we need to ensure that the ownerNode of the sheet is cleared. If we don't do this and there is a
wrapper for the sheet the sheet is kept alive but the ownerNode of the sheet may point to a deleted node.

Tests: fast/dom/StyleSheet/detached-sheet-owner-node-link.html

fast/dom/StyleSheet/detached-sheet-owner-node.html

  • dom/StyleElement.cpp:

(WebCore::StyleElement::removedFromDocument):
(WebCore::StyleElement::clearSheet):
(WebCore):
(WebCore::StyleElement::createSheet):

  • dom/StyleElement.h:

(StyleElement):

  • html/HTMLLinkElement.cpp:

(WebCore::HTMLLinkElement::process):
(WebCore::HTMLLinkElement::clearSheet):
(WebCore):

  • html/HTMLLinkElement.h:

(HTMLLinkElement):

LayoutTests:

  • fast/dom/StyleSheet/detached-sheet-owner-node-expected.txt: Added.
  • fast/dom/StyleSheet/detached-sheet-owner-node-link-expected.txt: Added.
  • fast/dom/StyleSheet/detached-sheet-owner-node-link.html: Added.
  • fast/dom/StyleSheet/detached-sheet-owner-node.html: Added.
Location:
releases/WebKitGTK/webkit-1.8
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-1.8/LayoutTests/ChangeLog

    r117283 r117756  
     12012-04-11  Erik Arvidsson  <arv@chromium.org>
     2
     3        StyleElement ownerNode is not cleared correctly
     4        https://bugs.webkit.org/show_bug.cgi?id=83696
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/dom/StyleSheet/detached-sheet-owner-node-expected.txt: Added.
     9        * fast/dom/StyleSheet/detached-sheet-owner-node-link-expected.txt: Added.
     10        * fast/dom/StyleSheet/detached-sheet-owner-node-link.html: Added.
     11        * fast/dom/StyleSheet/detached-sheet-owner-node.html: Added.
     12
    1132012-04-03  Abhishek Arya  <inferno@chromium.org>
    214
  • releases/WebKitGTK/webkit-1.8/Source/WebCore/ChangeLog

    r117283 r117756  
     12012-04-11  Erik Arvidsson  <arv@chromium.org>
     2
     3        StyleElement ownerNode is not cleared correctly
     4        https://bugs.webkit.org/show_bug.cgi?id=83696
     5
     6        Reviewed by Antti Koivisto.
     7
     8        When the css text changes in such a way that we remove the sheet of a style element or a link[rel=stylesheet]
     9        element we need to ensure that the ownerNode of the sheet is cleared. If we don't do this and there is a
     10        wrapper for the sheet the sheet is kept alive but the ownerNode of the sheet may point to a deleted node.
     11
     12        Tests: fast/dom/StyleSheet/detached-sheet-owner-node-link.html
     13               fast/dom/StyleSheet/detached-sheet-owner-node.html
     14
     15        * dom/StyleElement.cpp:
     16        (WebCore::StyleElement::removedFromDocument):
     17        (WebCore::StyleElement::clearSheet):
     18        (WebCore):
     19        (WebCore::StyleElement::createSheet):
     20        * dom/StyleElement.h:
     21        (StyleElement):
     22        * html/HTMLLinkElement.cpp:
     23        (WebCore::HTMLLinkElement::process):
     24        (WebCore::HTMLLinkElement::clearSheet):
     25        (WebCore):
     26        * html/HTMLLinkElement.h:
     27        (HTMLLinkElement):
     28
    1292012-04-03  Abhishek Arya  <inferno@chromium.org>
    230
  • releases/WebKitGTK/webkit-1.8/Source/WebCore/dom/StyleElement.cpp

    r95223 r117756  
    7575    document->removeStyleSheetCandidateNode(element);
    7676
    77     if (m_sheet) {
    78         ASSERT(m_sheet->ownerNode() == element);
    79         m_sheet->clearOwnerNode();
    80         m_sheet = 0;
    81     }
     77    if (m_sheet)
     78        clearSheet();
    8279
    8380    // If we're in document teardown, then we don't need to do any notification of our sheet's removal.
     
    140137}
    141138
     139void StyleElement::clearSheet()
     140{
     141    ASSERT(m_sheet);
     142    m_sheet->clearOwnerNode();
     143    m_sheet = 0;
     144}
     145
    142146void StyleElement::createSheet(Element* e, int startLineNumber, const String& text)
    143147{
     
    148152        if (m_sheet->isLoading())
    149153            document->removePendingSheet();
    150         m_sheet = 0;
     154        clearSheet();
    151155    }
    152156
  • releases/WebKitGTK/webkit-1.8/Source/WebCore/dom/StyleElement.h

    r98106 r117756  
    5555    void createSheet(Element*, int startLineNumber, const String& text = String());
    5656    void process(Element*);
     57    void clearSheet();
    5758
    5859    bool m_createdByParser;
  • releases/WebKitGTK/webkit-1.8/Source/WebCore/html/HTMLLinkElement.cpp

    r114562 r117756  
    224224    } else if (m_sheet) {
    225225        // we no longer contain a stylesheet, e.g. perhaps rel or type was changed
    226         m_sheet = 0;
     226        clearSheet();
    227227        document()->styleSelectorChanged(DeferRecalcStyle);
    228228    }
     229}
     230
     231void HTMLLinkElement::clearSheet()
     232{
     233    ASSERT(m_sheet);
     234    ASSERT(m_sheet->ownerNode() == this);
     235    m_sheet->clearOwnerNode();
     236    m_sheet = 0;
    229237}
    230238
     
    252260    document()->removeStyleSheetCandidateNode(this);
    253261
    254     if (m_sheet) {
    255         ASSERT(m_sheet->ownerNode() == this);
    256         m_sheet->clearOwnerNode();
    257         m_sheet = 0;
    258     }
     262    if (m_sheet)
     263        clearSheet();
    259264
    260265    if (document()->renderer())
  • releases/WebKitGTK/webkit-1.8/Source/WebCore/html/HTMLLinkElement.h

    r106769 r117756  
    6767    void process();
    6868    static void processCallback(Node*);
     69    void clearSheet();
    6970
    7071    virtual void insertedIntoDocument();
Note: See TracChangeset for help on using the changeset viewer.