Changeset 87867 in webkit


Ignore:
Timestamp:
Jun 1, 2011 5:53:01 PM (13 years ago)
Author:
jchaffraix@webkit.org
Message:

2011-06-01 Julien Chaffraix <jchaffraix@codeaurora.org>

Reviewed by Simon Fraser.

CSSStyleSheet#insertRule doesn't work well with imported stylesheets
https://bugs.webkit.org/show_bug.cgi?id=56981

Test that a combination of insertRule and @import works properly.

  • fast/css/import-and-insert-rule-no-update-expected.txt: Added.
  • fast/css/import-and-insert-rule-no-update.html: Added.
  • fast/css/resources/red.css: Added. (div):
  • fast/css/resources/redimport.css: Added.

2011-06-01 Julien Chaffraix <jchaffraix@codeaurora.org>

Reviewed by Simon Fraser.

CSSStyleSheet#insertRule doesn't work well with imported stylesheets
https://bugs.webkit.org/show_bug.cgi?id=56981

Test: fast/css/import-and-insert-rule-no-update.html

The bug arises from the fact that <link> element did not know about a programmatically
loading sheet (using insertRule and @import) and would thus never call removePendingSheet.
This is needed to make sure our style selector contains an up-to-date list of stylesheets.

The gist of the patch adds a way for style sheet owner element to know if we are
programmatically loading a style sheet. This is needed as <link> keeps the information
about that last loaded stylesheet.

  • css/CSSImportRule.cpp: (WebCore::CSSImportRule::insertedIntoParent): Call startLoadingDynamicSheet on our parent style sheet instead of directly adding a pending style sheet.
  • css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::startLoadingDynamicSheet): Call startLoadingDynamicSheet on our owner element if we have one.
  • css/CSSStyleSheet.h:
  • dom/Node.h: (WebCore::Node::startLoadingDynamicSheet): Added common implementation of startLoadingDynamicSheet, which should never be called.
  • dom/StyleElement.cpp: (WebCore::StyleElement::startLoadingDynamicSheet):
  • dom/StyleElement.h: Common implementation of startLoadingDynamicSheet for style elements.
  • html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::startLoadingDynamicSheet):
  • html/HTMLLinkElement.h: Use the HTMLLinkElement plumbing to make sure we call addRemovePendingSheet.
  • html/HTMLStyleElement.h: (WebCore::HTMLStyleElement::startLoadingDynamicSheet):
  • svg/SVGStyleElement.h: (WebCore::SVGStyleElement::startLoadingDynamicSheet): Forward the call to StyleElement.
Location:
trunk
Files:
4 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r87863 r87867  
     12011-06-01  Julien Chaffraix  <jchaffraix@codeaurora.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        CSSStyleSheet#insertRule doesn't work well with imported stylesheets
     6        https://bugs.webkit.org/show_bug.cgi?id=56981
     7
     8        Test that a combination of insertRule and @import works properly.
     9
     10        * fast/css/import-and-insert-rule-no-update-expected.txt: Added.
     11        * fast/css/import-and-insert-rule-no-update.html: Added.
     12        * fast/css/resources/red.css: Added.
     13        (div):
     14        * fast/css/resources/redimport.css: Added.
     15
    1162011-06-01  Abhishek Arya  <inferno@chromium.org>
    217
  • trunk/Source/WebCore/ChangeLog

    r87866 r87867  
     12011-06-01  Julien Chaffraix  <jchaffraix@codeaurora.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        CSSStyleSheet#insertRule doesn't work well with imported stylesheets
     6        https://bugs.webkit.org/show_bug.cgi?id=56981
     7
     8        Test: fast/css/import-and-insert-rule-no-update.html
     9
     10        The bug arises from the fact that <link> element did not know about a programmatically
     11        loading sheet (using insertRule and @import) and would thus never call removePendingSheet.
     12        This is needed to make sure our style selector contains an up-to-date list of stylesheets.
     13
     14        The gist of the patch adds a way for style sheet owner element to know if we are
     15        programmatically loading a style sheet. This is needed as <link> keeps the information
     16        about that last loaded stylesheet.
     17
     18        * css/CSSImportRule.cpp:
     19        (WebCore::CSSImportRule::insertedIntoParent): Call startLoadingDynamicSheet
     20        on our parent style sheet instead of directly adding a pending style sheet.
     21
     22        * css/CSSStyleSheet.cpp:
     23        (WebCore::CSSStyleSheet::startLoadingDynamicSheet): Call startLoadingDynamicSheet
     24        on our owner element if we have one.
     25
     26        * css/CSSStyleSheet.h:
     27        * dom/Node.h:
     28        (WebCore::Node::startLoadingDynamicSheet): Added common implementation of
     29        startLoadingDynamicSheet, which should never be called.
     30
     31        * dom/StyleElement.cpp:
     32        (WebCore::StyleElement::startLoadingDynamicSheet):
     33        * dom/StyleElement.h:
     34        Common implementation of startLoadingDynamicSheet for style elements.
     35
     36        * html/HTMLLinkElement.cpp:
     37        (WebCore::HTMLLinkElement::startLoadingDynamicSheet):
     38        * html/HTMLLinkElement.h:
     39        Use the HTMLLinkElement plumbing to make sure we call addRemovePendingSheet.
     40
     41        * html/HTMLStyleElement.h:
     42        (WebCore::HTMLStyleElement::startLoadingDynamicSheet):
     43        * svg/SVGStyleElement.h:
     44        (WebCore::SVGStyleElement::startLoadingDynamicSheet):
     45        Forward the call to StyleElement.
     46
    1472011-06-01  Levi Weintraub  <leviw@chromium.org>
    248
  • trunk/Source/WebCore/css/CSSImportRule.cpp

    r87239 r87867  
    145145        // the sheet being imported is pending.
    146146        if (parentSheet && parentSheet->loadCompleted() && root == parentSheet)
    147             parentSheet->document()->addPendingSheet();
     147            parentSheet->startLoadingDynamicSheet();
    148148        m_loading = true;
    149149        m_cachedSheet->addClient(this);
  • trunk/Source/WebCore/css/CSSStyleSheet.cpp

    r76728 r87867  
    231231}
    232232
     233void CSSStyleSheet::startLoadingDynamicSheet()
     234{
     235    if (Node* owner = ownerNode())
     236        owner->startLoadingDynamicSheet();
     237}
     238
    233239Document* CSSStyleSheet::document()
    234240{
  • trunk/Source/WebCore/css/CSSStyleSheet.h

    r76728 r87867  
    8787
    8888    virtual void checkLoaded();
     89    void startLoadingDynamicSheet();
    8990
    9091    Document* document();
  • trunk/Source/WebCore/dom/Node.h

    r87743 r87867  
    284284    // For <link> and <style> elements.
    285285    virtual bool sheetLoaded() { return true; }
     286    virtual void startLoadingDynamicSheet() { ASSERT_NOT_REACHED(); }
    286287
    287288    bool hasID() const { return getFlag(HasIDFlag); }
  • trunk/Source/WebCore/dom/StyleElement.cpp

    r85381 r87867  
    183183}
    184184
     185void StyleElement::startLoadingDynamicSheet(Document* document)
     186{
     187    ASSERT(document);
     188    document->addPendingSheet();
    185189}
     190
     191}
  • trunk/Source/WebCore/dom/StyleElement.h

    r75352 r87867  
    4242    bool isLoading() const;
    4343    bool sheetLoaded(Document*);
     44    void startLoadingDynamicSheet(Document*);
    4445
    4546    void insertedIntoDocument(Document*, Element*);
  • trunk/Source/WebCore/html/HTMLLinkElement.cpp

    r87693 r87867  
    473473}
    474474
     475void HTMLLinkElement::startLoadingDynamicSheet()
     476{
     477    // We don't support multiple blocking sheets.
     478    ASSERT(m_pendingSheetType < Blocking);
     479    addPendingSheet(Blocking);
     480}
     481
    475482bool HTMLLinkElement::isURLAttribute(Attribute *attr) const
    476483{
  • trunk/Source/WebCore/html/HTMLLinkElement.h

    r87020 r87867  
    102102#endif
    103103    virtual bool sheetLoaded();
     104    virtual void startLoadingDynamicSheet();
    104105
    105106    bool isAlternate() const { return m_disabledState == Unset && m_relAttribute.m_isAlternate; }
  • trunk/Source/WebCore/html/HTMLStyleElement.h

    r75352 r87867  
    5656    virtual bool isLoading() const { return StyleElement::isLoading(); }
    5757    virtual bool sheetLoaded() { return StyleElement::sheetLoaded(document()); }
     58    virtual void startLoadingDynamicSheet() { StyleElement::startLoadingDynamicSheet(document()); }
    5859
    5960    virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
  • trunk/Source/WebCore/svg/SVGStyleElement.h

    r87010 r87867  
    6060    virtual bool isLoading() const { return StyleElement::isLoading(); }
    6161    virtual bool sheetLoaded() { return StyleElement::sheetLoaded(document()); }
     62    virtual void startLoadingDynamicSheet() { StyleElement::startLoadingDynamicSheet(document()); }
    6263};
    6364
Note: See TracChangeset for help on using the changeset viewer.