Changeset 31578 in webkit


Ignore:
Timestamp:
Apr 2, 2008 10:56:21 PM (16 years ago)
Author:
beidson@apple.com
Message:

WebCore:

2008-04-02 Brady Eidson <beidson@apple.com>

Reviewed by Mitz Pettel

<rdar://problem/5838347> and http://bugs.webkit.org/show_bug.cgi?id=11839
Webarchive fails to save CSS files in @import statements

  • css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::addSubresourceURLStrings): Recursively add the URL each @import rule under the current style sheet.
  • css/CSSStyleSheet.h:
  • css/StyleSheet.h: (WebCore::StyleSheet::addSubresourceURLStrings):
  • html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::getSubresourceAttributeStrings): Add the linked URL as well as all @import rules rooted at the linked stylesheet.
  • html/HTMLStyleElement.cpp: (WebCore::HTMLStyleElement::getSubresourceAttributeStrings): Walk all @import rules rooted at this stylesheet to add to the list.
  • html/HTMLStyleElement.h:

LayoutTests:

2008-04-02 Brady Eidson <beidson@apple.com>

Written by David Kilzer, tweaked by Brady, Reviewed by Mitz Pettel

The idea is to <link> to a CSS file which @imports another CSS file,
and also @import a CSS file inside a <style> element, which also @imports another CSS file

Then make sure all 4 of the css files are in the resulting webarchive

  • webarchive/resources/test-css-import-recurse.css: Added.
  • webarchive/resources/test-css-import.css: Added.
  • webarchive/resources/test-css-link-recurse.css: Added.
  • webarchive/resources/test-css-link.css: Added.
  • webarchive/test-css-import-expected.txt: Added.
  • webarchive/test-css-import.html: Added.
Location:
trunk
Files:
6 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r31566 r31578  
     12008-04-02  Brady Eidson  <beidson@apple.com>
     2
     3        Written by David Kilzer, tweaked by Brady, Reviewed by Mitz Pettel
     4
     5        - test for http://bugs.webkit.org/show_bug.cgi?id=11839
     6          Webarchive fails to save CSS files in @import statements
     7
     8        The idea is to <link> to a CSS file which @imports another CSS file,
     9        and also @import a CSS file inside a <style> element, which also @imports another CSS file
     10
     11        Then make sure all 4 of the css files are in the resulting webarchive
     12
     13        * webarchive/resources/test-css-import-recurse.css: Added.
     14        * webarchive/resources/test-css-import.css: Added.
     15        * webarchive/resources/test-css-link-recurse.css: Added.
     16        * webarchive/resources/test-css-link.css: Added.
     17        * webarchive/test-css-import-expected.txt: Added.
     18        * webarchive/test-css-import.html: Added.
     19
    1202008-04-02  Nikolas Zimmermann  <zimmermann@kde.org>
    221
  • trunk/WebCore/ChangeLog

    r31577 r31578  
     12008-04-02  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Mitz Pettel
     4
     5        <rdar://problem/5838347> and http://bugs.webkit.org/show_bug.cgi?id=11839
     6        Webarchive fails to save CSS files in @import statements
     7
     8        * css/CSSStyleSheet.cpp:
     9        (WebCore::CSSStyleSheet::addSubresourceURLStrings): Recursively add the URL each @import rule under the current style sheet.
     10        * css/CSSStyleSheet.h:
     11        * css/StyleSheet.h:
     12        (WebCore::StyleSheet::addSubresourceURLStrings):
     13
     14        * html/HTMLLinkElement.cpp:
     15        (WebCore::HTMLLinkElement::getSubresourceAttributeStrings): Add the linked URL as well as all @import
     16          rules rooted at the linked stylesheet.
     17
     18        * html/HTMLStyleElement.cpp:
     19        (WebCore::HTMLStyleElement::getSubresourceAttributeStrings): Walk all @import rules rooted at this
     20          stylesheet to add to the list.
     21        * html/HTMLStyleElement.h:
     22
    1232008-04-02  Mark Rowe  <mrowe@apple.com>
    224
  • trunk/WebCore/css/CSSStyleSheet.cpp

    r25754 r31578  
    204204}
    205205
    206 }
     206void CSSStyleSheet::addSubresourceURLStrings(HashSet<String>& urls, const String& base) const
     207{       
     208    OwnPtr<CSSRuleList> ruleList(const_cast<CSSStyleSheet*>(this)->cssRules());
     209   
     210    // Add the URLs for each child import rule, and recurse for the stylesheet belonging to each of those rules.
     211    for (unsigned i = 0; i < ruleList->length(); ++i) {
     212        CSSRule* rule = ruleList->item(i);
     213        if (rule->type() != CSSRule::IMPORT_RULE)
     214            continue;
     215
     216        CSSImportRule* importRule = static_cast<CSSImportRule*>(rule);
     217        CSSStyleSheet* ruleSheet = importRule->styleSheet();
     218        if (!ruleSheet)
     219            continue;
     220
     221        KURL fullURL(KURL(base), importRule->href());
     222        urls.add(fullURL.string());
     223        ruleSheet->addSubresourceURLStrings(urls, fullURL.string());
     224    }
     225}
     226
     227}
  • trunk/WebCore/css/CSSStyleSheet.h

    r29963 r31578  
    7373
    7474    bool loadCompleted() const { return m_loadCompleted; }
     75   
     76    virtual void addSubresourceURLStrings(HashSet<String>&, const String& baseURL) const;
    7577
    7678protected:
  • trunk/WebCore/css/StyleSheet.h

    r31405 r31578  
    2626#include "StyleList.h"
    2727#include "PlatformString.h"
     28
     29#include <wtf/HashSet.h>
    2830
    2931namespace WebCore {
     
    6062    virtual void styleSheetChanged() { }
    6163   
     64    virtual void addSubresourceURLStrings(HashSet<String>&, const String& baseURL) const { }
     65
    6266protected:
    6367    Node* m_parentNode;
  • trunk/WebCore/html/HTMLLinkElement.cpp

    r31357 r31578  
    349349
    350350void HTMLLinkElement::getSubresourceAttributeStrings(Vector<String>& urls) const
    351 {
    352     if (!m_isStyleSheet && !m_isIcon)
     351{   
     352    if (m_isIcon) {
     353        urls.append(href().string());
    353354        return;
     355    }
    354356   
     357    if (!m_isStyleSheet)
     358        return;
     359       
     360    // Append the URL of this link element.
    355361    urls.append(href().string());
    356 }
    357 
    358 }
     362   
     363    // Walk the URLs linked by the linked-to stylesheet.
     364    HashSet<String> styleURLs;
     365    StyleSheet* styleSheet = const_cast<HTMLLinkElement*>(this)->sheet();
     366    if (styleSheet)
     367        styleSheet->addSubresourceURLStrings(styleURLs, href());
     368   
     369    HashSet<String>::iterator end = styleURLs.end();
     370    for (HashSet<String>::iterator i = styleURLs.begin(); i != end; ++i)
     371        urls.append(*i);
     372}
     373
     374}
  • trunk/WebCore/html/HTMLStyleElement.cpp

    r30633 r31578  
    131131}
    132132
     133void HTMLStyleElement::getSubresourceAttributeStrings(Vector<String>& urls) const
     134{   
     135    HashSet<String> styleURLs;
     136    StyleSheet* styleSheet = const_cast<HTMLStyleElement*>(this)->sheet();
     137    if (styleSheet)
     138        styleSheet->addSubresourceURLStrings(styleURLs, ownerDocument()->baseURL());
     139   
     140    HashSet<String>::iterator end = styleURLs.end();
     141    for (HashSet<String>::iterator i = styleURLs.begin(); i != end; ++i)
     142        urls.append(*i);
    133143}
     144
     145}
  • trunk/WebCore/html/HTMLStyleElement.h

    r30633 r31578  
    6565    virtual void setLoading(bool loading) { m_loading = loading; }
    6666
     67    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
     68
    6769protected:
    6870    String m_media;
Note: See TracChangeset for help on using the changeset viewer.