Changeset 53607 in webkit


Ignore:
Timestamp:
Jan 20, 2010 11:22:22 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-01-20 Adam Barth <abarth@webkit.org>

Reviewed by Darin Adler.

Stylesheet href property shows redirected URL unlike other browsers
https://bugs.webkit.org/show_bug.cgi?id=33683

Test whether the href property of style sheets contains the original or
final URL of the redirect chain that lead to the style sheet.

I couldn't figure out how to test the XSLStyleSheet parts of this
change. There didn't seem to be DOM bindings for the href property
here. If I missed it, please let me know.

  • http/tests/security/stylesheet-href-redirect-expected.txt: Added.
  • http/tests/security/stylesheet-href-redirect.html: Added.

2010-01-20 Adam Barth <abarth@webkit.org>

Reviewed by Darin Adler.

Stylesheet href property shows redirected URL unlike other browsers
https://bugs.webkit.org/show_bug.cgi?id=33683

Teach StyleSheet the difference between original and final URLs in
redirect chains. Unfortunately, StyleSheet needs to know both of these
URLs. The original URL is needed for the href property and the final
URL is needed as the baseURL.

This change required touching a lot of lines of code because we need to
plumb this information to the StyleSheet object. I audited all
existing clients of href() and setHref() to see whether they wanted the
original or final URLs. I then updated the clients (except the JS
bindings themselves) to use the correct accessor.

Test: http/tests/security/stylesheet-href-redirect.html

  • css/CSSImportRule.cpp: (WebCore::CSSImportRule::setCSSStyleSheet): (WebCore::CSSImportRule::insertedIntoParent):
  • css/CSSImportRule.h:
  • css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::CSSStyleSheet):
  • css/CSSStyleSheet.h: (WebCore::CSSStyleSheet::create): (WebCore::CSSStyleSheet::createInline): Added a new constructor to deal with "inline" style sheets that don't have a distinct original and final URL.
  • css/StyleBase.cpp: (WebCore::StyleBase::baseURL): This code wants to use the final URL, not the original URL. Updated it to grab the baseURL directly.
  • css/StyleSheet.cpp: (WebCore::StyleSheet::StyleSheet):
  • css/StyleSheet.h: (WebCore::StyleSheet::href): (WebCore::StyleSheet::setBaseURL): This function really just updates the base URL of the style sheet, so I made it more explicit. (WebCore::StyleSheet::putativeBaseURL): We need an accessor for the base URL, but baseURL is already taken.
  • dom/Document.cpp: (WebCore::Document::updateBaseURL): (WebCore::Document::pageUserSheet): (WebCore::Document::pageGroupUserSheets): (WebCore::Document::elementSheet): (WebCore::Document::mappedElementSheet):
  • dom/ProcessingInstruction.cpp: (WebCore::ProcessingInstruction::checkStyleSheet): (WebCore::ProcessingInstruction::setCSSStyleSheet): (WebCore::ProcessingInstruction::setXSLStyleSheet):
  • dom/ProcessingInstruction.h:
  • dom/StyleElement.cpp: (WebCore::StyleElement::createSheet):
  • html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::setCSSStyleSheet):
  • html/HTMLLinkElement.h:
  • loader/CachedCSSStyleSheet.cpp: (WebCore::CachedCSSStyleSheet::didAddClient): (WebCore::CachedCSSStyleSheet::checkNotify): This code now passes both the original and final URL into setCSSStyleSheet so that the style sheet can have both.
  • loader/CachedResourceClient.h: (WebCore::CachedResourceClient::setCSSStyleSheet): (WebCore::CachedResourceClient::setXSLStyleSheet):
  • loader/CachedXSLStyleSheet.cpp: (WebCore::CachedXSLStyleSheet::didAddClient): (WebCore::CachedXSLStyleSheet::checkNotify): I don't have any direct evidence that we need to change the XSLStyleSheet behavior, which is why I wasn't able to add a test for the behavior. However, the objects are parallel enough that it seemed like the right thing to do.
  • xml/XSLImportRule.cpp: (WebCore::XSLImportRule::setXSLStyleSheet): (WebCore::XSLImportRule::loadSheet):
  • xml/XSLImportRule.h:
  • xml/XSLStyleSheet.h: (WebCore::XSLStyleSheet::create): (WebCore::XSLStyleSheet::createEmbedded):
  • xml/XSLStyleSheetLibxslt.cpp: (WebCore::XSLStyleSheet::XSLStyleSheet): (WebCore::XSLStyleSheet::parseString): (WebCore::XSLStyleSheet::loadChildSheets):
  • xml/XSLStyleSheetQt.cpp: (WebCore::XSLStyleSheet::XSLStyleSheet):
  • xml/XSLTProcessorLibxslt.cpp: (WebCore::xsltStylesheetPointer):
  • xml/XSLTProcessorQt.cpp: (WebCore::XSLTProcessor::transformToString):
Location:
trunk
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r53606 r53607  
     12010-01-20  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Stylesheet href property shows redirected URL unlike other browsers
     6        https://bugs.webkit.org/show_bug.cgi?id=33683
     7
     8        Test whether the href property of style sheets contains the original or
     9        final URL of the redirect chain that lead to the style sheet.
     10
     11        I couldn't figure out how to test the XSLStyleSheet parts of this
     12        change.  There didn't seem to be DOM bindings for the href property
     13        here.  If I missed it, please let me know.
     14
     15        * http/tests/security/stylesheet-href-redirect-expected.txt: Added.
     16        * http/tests/security/stylesheet-href-redirect.html: Added.
     17
    1182010-01-21  Kent Tamura  <tkent@chromium.org>
    219
  • trunk/WebCore/ChangeLog

    r53604 r53607  
     12010-01-20  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Stylesheet href property shows redirected URL unlike other browsers
     6        https://bugs.webkit.org/show_bug.cgi?id=33683
     7
     8        Teach StyleSheet the difference between original and final URLs in
     9        redirect chains.  Unfortunately, StyleSheet needs to know both of these
     10        URLs.  The original URL is needed for the href property and the final
     11        URL is needed as the baseURL.
     12
     13        This change required touching a lot of lines of code because we need to
     14        plumb this information to the StyleSheet object.  I audited all
     15        existing clients of href() and setHref() to see whether they wanted the
     16        original or final URLs.  I then updated the clients (except the JS
     17        bindings themselves) to use the correct accessor.
     18
     19        Test: http/tests/security/stylesheet-href-redirect.html
     20
     21        * css/CSSImportRule.cpp:
     22        (WebCore::CSSImportRule::setCSSStyleSheet):
     23        (WebCore::CSSImportRule::insertedIntoParent):
     24        * css/CSSImportRule.h:
     25        * css/CSSStyleSheet.cpp:
     26        (WebCore::CSSStyleSheet::CSSStyleSheet):
     27        * css/CSSStyleSheet.h:
     28        (WebCore::CSSStyleSheet::create):
     29        (WebCore::CSSStyleSheet::createInline): Added a new constructor to deal
     30        with "inline" style sheets that don't have a distinct original and
     31        final URL.
     32        * css/StyleBase.cpp:
     33        (WebCore::StyleBase::baseURL): This code wants to use the final URL,
     34        not the original URL.  Updated it to grab the baseURL directly.
     35        * css/StyleSheet.cpp:
     36        (WebCore::StyleSheet::StyleSheet):
     37        * css/StyleSheet.h:
     38        (WebCore::StyleSheet::href):
     39        (WebCore::StyleSheet::setBaseURL): This function really just updates
     40        the base URL of the style sheet, so I made it more explicit.
     41        (WebCore::StyleSheet::putativeBaseURL): We need an accessor for the
     42        base URL, but baseURL is already taken.
     43        * dom/Document.cpp:
     44        (WebCore::Document::updateBaseURL):
     45        (WebCore::Document::pageUserSheet):
     46        (WebCore::Document::pageGroupUserSheets):
     47        (WebCore::Document::elementSheet):
     48        (WebCore::Document::mappedElementSheet):
     49        * dom/ProcessingInstruction.cpp:
     50        (WebCore::ProcessingInstruction::checkStyleSheet):
     51        (WebCore::ProcessingInstruction::setCSSStyleSheet):
     52        (WebCore::ProcessingInstruction::setXSLStyleSheet):
     53        * dom/ProcessingInstruction.h:
     54        * dom/StyleElement.cpp:
     55        (WebCore::StyleElement::createSheet):
     56        * html/HTMLLinkElement.cpp:
     57        (WebCore::HTMLLinkElement::setCSSStyleSheet):
     58        * html/HTMLLinkElement.h:
     59        * loader/CachedCSSStyleSheet.cpp:
     60        (WebCore::CachedCSSStyleSheet::didAddClient):
     61        (WebCore::CachedCSSStyleSheet::checkNotify): This code now passes both
     62        the original and final URL into setCSSStyleSheet so that the style
     63        sheet can have both.
     64        * loader/CachedResourceClient.h:
     65        (WebCore::CachedResourceClient::setCSSStyleSheet):
     66        (WebCore::CachedResourceClient::setXSLStyleSheet):
     67        * loader/CachedXSLStyleSheet.cpp:
     68        (WebCore::CachedXSLStyleSheet::didAddClient):
     69        (WebCore::CachedXSLStyleSheet::checkNotify): I don't have any direct
     70        evidence that we need to change the XSLStyleSheet behavior, which is
     71        why I wasn't able to add a test for the behavior.  However, the objects
     72        are parallel enough that it seemed like the right thing to do.
     73        * xml/XSLImportRule.cpp:
     74        (WebCore::XSLImportRule::setXSLStyleSheet):
     75        (WebCore::XSLImportRule::loadSheet):
     76        * xml/XSLImportRule.h:
     77        * xml/XSLStyleSheet.h:
     78        (WebCore::XSLStyleSheet::create):
     79        (WebCore::XSLStyleSheet::createEmbedded):
     80        * xml/XSLStyleSheetLibxslt.cpp:
     81        (WebCore::XSLStyleSheet::XSLStyleSheet):
     82        (WebCore::XSLStyleSheet::parseString):
     83        (WebCore::XSLStyleSheet::loadChildSheets):
     84        * xml/XSLStyleSheetQt.cpp:
     85        (WebCore::XSLStyleSheet::XSLStyleSheet):
     86        * xml/XSLTProcessorLibxslt.cpp:
     87        (WebCore::xsltStylesheetPointer):
     88        * xml/XSLTProcessorQt.cpp:
     89        (WebCore::XSLTProcessor::transformToString):
     90
    1912010-01-20  Kwang Yul Seo  <skyul@company100.net>
    292
  • trunk/WebCore/css/CSSImportRule.cpp

    r52784 r53607  
    5555}
    5656
    57 void CSSImportRule::setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet* sheet)
     57void CSSImportRule::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet)
    5858{
    5959    if (m_styleSheet)
    6060        m_styleSheet->setParent(0);
    61     m_styleSheet = CSSStyleSheet::create(this, url, charset);
     61    m_styleSheet = CSSStyleSheet::create(this, href, baseURL, charset);
    6262
    6363    bool crossOriginCSS = false;
     
    7171    if (enforceMIMEType && needsSiteSpecificQuirks) {
    7272        // Covers both http and https, with or without "www."
    73         if (url.contains("mcafee.com/japan/", false))
     73        if (baseURL.string().contains("mcafee.com/japan/", false))
    7474            enforceMIMEType = false;
    7575    }
     
    7979    m_styleSheet->parseString(sheetText, strict);
    8080
    81     if (!parent || !parent->doc() || !parent->doc()->securityOrigin()->canRequest(KURL(ParsedURLString, url)))
     81    if (!parent || !parent->doc() || !parent->doc()->securityOrigin()->canRequest(baseURL))
    8282        crossOriginCSS = true;
    8383
    8484    if (crossOriginCSS && !validMIMEType && !m_styleSheet->hasSyntacticallyValidCSSHeader())
    85         m_styleSheet = CSSStyleSheet::create(this, url, charset);
     85        m_styleSheet = CSSStyleSheet::create(this, href, baseURL, charset);
    8686
    8787    if (strict && needsSiteSpecificQuirks) {
     
    8989        DEFINE_STATIC_LOCAL(const String, slashKHTMLFixesDotCss, ("/KHTMLFixes.css"));
    9090        DEFINE_STATIC_LOCAL(const String, mediaWikiKHTMLFixesStyleSheet, ("/* KHTML fix stylesheet */\n/* work around the horizontal scrollbars */\n#column-content { margin-left: 0; }\n\n"));
    91         if (url.endsWith(slashKHTMLFixesDotCss) && sheetText == mediaWikiKHTMLFixesStyleSheet) {
     91        if (baseURL.string().endsWith(slashKHTMLFixesDotCss) && sheetText == mediaWikiKHTMLFixesStyleSheet) {
    9292            ASSERT(m_styleSheet->length() == 1);
    9393            ExceptionCode ec;
     
    118118
    119119    String absHref = m_strHref;
    120     if (!parentSheet->href().isNull())
     120    if (!parentSheet->putativeBaseURL().isNull())
    121121        // use parent styleheet's URL as the base URL
    122         absHref = KURL(KURL(ParsedURLString, parentSheet->href()), m_strHref).string();
     122        absHref = KURL(parentSheet->putativeBaseURL(), m_strHref).string();
    123123
    124124    // Check for a cycle in our import chain.  If we encounter a stylesheet
     
    126126    StyleBase* root = this;
    127127    for (StyleBase* curr = parent(); curr; curr = curr->parent()) {
    128         if (curr->isCSSStyleSheet() && absHref == static_cast<CSSStyleSheet*>(curr)->href())
     128        // FIXME: This is wrong if the putativeBaseURL was updated via document::updateBaseURL.
     129        if (curr->isCSSStyleSheet() && absHref == static_cast<CSSStyleSheet*>(curr)->putativeBaseURL().string())
    129130            return;
    130131        root = curr;
  • trunk/WebCore/css/CSSImportRule.h

    r39441 r53607  
    6464
    6565    // from CachedResourceClient
    66     virtual void setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet*);
     66    virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
    6767
    6868    String m_strHref;
  • trunk/WebCore/css/CSSStyleSheet.cpp

    r52784 r53607  
    3535namespace WebCore {
    3636
    37 CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const String& charset)
    38     : StyleSheet(parentSheet, href)
     37CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const KURL& baseURL, const String& charset)
     38    : StyleSheet(parentSheet, href, baseURL)
    3939    , m_doc(parentSheet ? parentSheet->doc() : 0)
    4040    , m_namespaces(0)
     
    4747}
    4848
    49 CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const String& charset)
    50     : StyleSheet(parentNode, href)
     49CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, const String& charset)
     50    : StyleSheet(parentNode, href, baseURL)
    5151    , m_doc(parentNode->document())
    5252    , m_namespaces(0)
     
    5959}
    6060
    61 CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const String& charset)
    62     : StyleSheet(ownerRule, href)
     61CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const KURL& baseURL, const String& charset)
     62    : StyleSheet(ownerRule, href, baseURL)
    6363    , m_namespaces(0)
    6464    , m_charset(charset)
  • trunk/WebCore/css/CSSStyleSheet.h

    r52784 r53607  
    3939    static PassRefPtr<CSSStyleSheet> create()
    4040    {
    41         return adoptRef(new CSSStyleSheet(static_cast<CSSStyleSheet*>(0), String(), String()));
     41        return adoptRef(new CSSStyleSheet(static_cast<CSSStyleSheet*>(0), String(), KURL(), String()));
    4242    }
    4343    static PassRefPtr<CSSStyleSheet> create(Node* ownerNode)
    4444    {
    45         return adoptRef(new CSSStyleSheet(ownerNode, String(), String()));
     45        return adoptRef(new CSSStyleSheet(ownerNode, String(), KURL(), String()));
    4646    }
    47     static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& href)
     47    static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& href, const KURL& baseURL)
    4848    {
    49         return adoptRef(new CSSStyleSheet(ownerNode, href, String()));
     49        return adoptRef(new CSSStyleSheet(ownerNode, href, baseURL, String()));
    5050    }
    51     static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& href, const String& charset)
     51    static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& href, const KURL& baseURL, const String& charset)
    5252    {
    53         return adoptRef(new CSSStyleSheet(ownerNode, href, charset));
     53        return adoptRef(new CSSStyleSheet(ownerNode, href, baseURL, charset));
    5454    }
    55     static PassRefPtr<CSSStyleSheet> create(CSSRule* ownerRule, const String& href, const String& charset)
     55    static PassRefPtr<CSSStyleSheet> create(CSSRule* ownerRule, const String& href, const KURL& baseURL, const String& charset)
    5656    {
    57         return adoptRef(new CSSStyleSheet(ownerRule, href, charset));
     57        return adoptRef(new CSSStyleSheet(ownerRule, href, baseURL, charset));
     58    }
     59    static PassRefPtr<CSSStyleSheet> createInline(Node* ownerNode, const KURL& baseURL)
     60    {
     61        return adoptRef(new CSSStyleSheet(ownerNode, baseURL.string(), baseURL, String()));
    5862    }
    5963
    6064    virtual ~CSSStyleSheet();
    61    
     65
    6266    CSSRule* ownerRule() const;
    6367    PassRefPtr<CSSRuleList> cssRules(bool omitCharsetRules = false);
     
    7377    void addNamespace(CSSParser*, const AtomicString& prefix, const AtomicString& uri);
    7478    const AtomicString& determineNamespace(const AtomicString& prefix);
    75    
     79
    7680    virtual void styleSheetChanged();
    7781
     
    100104
    101105private:
    102     CSSStyleSheet(Node* ownerNode, const String& href, const String& charset);
    103     CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const String& charset);
    104     CSSStyleSheet(CSSRule* ownerRule, const String& href, const String& charset);
    105    
     106    CSSStyleSheet(Node* ownerNode, const String& href, const KURL& baseURL, const String& charset);
     107    CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const KURL& baseURL, const String& charset);
     108    CSSStyleSheet(CSSRule* ownerRule, const String& href, const KURL& baseURL, const String& charset);
     109
    106110    virtual bool isCSSStyleSheet() const { return true; }
    107111    virtual String type() const { return "text/css"; }
  • trunk/WebCore/css/StyleBase.cpp

    r47907 r53607  
    5757    if (!sheet)
    5858        return KURL();
    59     if (!sheet->href().isNull())
    60         return KURL(ParsedURLString, sheet->href());
    61     if (sheet->parent()) 
     59    if (!sheet->putativeBaseURL().isNull())
     60        return sheet->putativeBaseURL();
     61    if (sheet->parent())
    6262        return sheet->parent()->baseURL();
    6363    if (!sheet->ownerNode())
  • trunk/WebCore/css/StyleSheet.cpp

    r50583 r53607  
    2525namespace WebCore {
    2626
    27 StyleSheet::StyleSheet(StyleSheet* parentSheet, const String& href)
     27StyleSheet::StyleSheet(StyleSheet* parentSheet, const String& href, const KURL& baseURL)
    2828    : StyleList(parentSheet)
    2929    , m_parentNode(0)
    30     , m_strHref(href)
     30    , m_href(href)
     31    , m_baseURL(baseURL)
    3132    , m_disabled(false)
    3233{
     
    3435
    3536
    36 StyleSheet::StyleSheet(Node* parentNode, const String& href)
     37StyleSheet::StyleSheet(Node* parentNode, const String& href, const KURL& baseURL)
    3738    : StyleList(0)
    3839    , m_parentNode(parentNode)
    39     , m_strHref(href)
     40    , m_href(href)
     41    , m_baseURL(baseURL)
    4042    , m_disabled(false)
    4143{
    4244}
    4345
    44 StyleSheet::StyleSheet(StyleBase* owner, const String& href)
     46StyleSheet::StyleSheet(StyleBase* owner, const String& href, const KURL& baseURL)
    4547    : StyleList(owner)
    4648    , m_parentNode(0)
    47     , m_strHref(href)
     49    , m_href(href)
     50    , m_baseURL(baseURL)
    4851    , m_disabled(false)
    4952{
  • trunk/WebCore/css/StyleSheet.h

    r39441 r53607  
    4242    Node* ownerNode() const { return m_parentNode; }
    4343    StyleSheet *parentStyleSheet() const;
    44     const String& href() const { return m_strHref; }
    45     void setHref(const String& href) { m_strHref = href; }
     44
     45    // Note that href is the URL that started the redirect chain that led to
     46    // this style sheet. This property probably isn't useful for much except
     47    // the JavaScript binding (which needs to use this value for security).
     48    const String& href() const { return m_href; }
     49
     50    void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; }
     51
     52    // Notice that this object inherits a baseURL function from StyleBase that
     53    // crawls the parent() relation looking for a non-0 putativeBaseURL.
     54    const KURL& putativeBaseURL() const { return m_baseURL; }
     55
    4656    const String& title() const { return m_strTitle; }
    4757    void setTitle(const String& s) { m_strTitle = s; }
     
    5969
    6070protected:
    61     StyleSheet(Node* ownerNode, const String& href);
    62     StyleSheet(StyleSheet* parentSheet, const String& href);
    63     StyleSheet(StyleBase* owner, const String& href);
     71    StyleSheet(Node* ownerNode, const String& href, const KURL& baseURL);
     72    StyleSheet(StyleSheet* parentSheet, const String& href, const KURL& baseURL);
     73    StyleSheet(StyleBase* owner, const String& href, const KURL& baseURL);
    6474
    6575private:
     
    6777
    6878    Node* m_parentNode;
    69     String m_strHref;
     79    String m_href;
     80    KURL m_baseURL;
    7081    String m_strTitle;
    7182    RefPtr<MediaList> m_media;
  • trunk/WebCore/dom/Document.cpp

    r53595 r53607  
    20102010
    20112011    if (m_elemSheet)
    2012         m_elemSheet->setHref(m_baseURL.string());
     2012        m_elemSheet->setBaseURL(m_baseURL);
    20132013    if (m_mappedElementSheet)
    2014         m_mappedElementSheet->setHref(m_baseURL.string());
     2014        m_mappedElementSheet->setBaseURL(m_baseURL);
    20152015}
    20162016
     
    20342034   
    20352035    // Parse the sheet and cache it.
    2036     m_pageUserSheet = CSSStyleSheet::create(this, settings()->userStyleSheetLocation());
     2036    m_pageUserSheet = CSSStyleSheet::createInline(this, settings()->userStyleSheetLocation());
    20372037    m_pageUserSheet->setIsUserStyleSheet(true);
    20382038    m_pageUserSheet->parseString(userSheetText, !inCompatMode());
     
    20692069            if (!UserContentURLPattern::matchesPatterns(url(), sheet->whitelist(), sheet->blacklist()))
    20702070                continue;
    2071             RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::create(const_cast<Document*>(this), sheet->url());
     2071            RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::createInline(const_cast<Document*>(this), sheet->url());
    20722072            parsedSheet->setIsUserStyleSheet(true);
    20732073            parsedSheet->parseString(sheet->source(), !inCompatMode());
     
    20912091{
    20922092    if (!m_elemSheet)
    2093         m_elemSheet = CSSStyleSheet::create(this, m_baseURL.string());
     2093        m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL);
    20942094    return m_elemSheet.get();
    20952095}
     
    20982098{
    20992099    if (!m_mappedElementSheet)
    2100         m_mappedElementSheet = CSSStyleSheet::create(this, m_baseURL.string());
     2100        m_mappedElementSheet = CSSStyleSheet::createInline(this, m_baseURL);
    21012101    return m_mappedElementSheet.get();
    21022102}
  • trunk/WebCore/dom/ProcessingInstruction.cpp

    r52784 r53607  
    140140            // to kick off import/include loads that can hang off some parent sheet.
    141141            if (m_isXSL) {
    142                 m_sheet = XSLStyleSheet::createEmbedded(this, m_localHref);
     142                KURL baseURL = KURL(ParsedURLString, m_localHref);
     143                m_sheet = XSLStyleSheet::createEmbedded(this, m_localHref, baseURL);
    143144                m_loading = false;
    144145            }
     
    198199}
    199200
    200 void ProcessingInstruction::setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet* sheet)
     201void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet)
    201202{
    202203#if ENABLE(XSLT)
    203204    ASSERT(!m_isXSL);
    204205#endif
    205     RefPtr<CSSStyleSheet> newSheet = CSSStyleSheet::create(this, url, charset);
     206    RefPtr<CSSStyleSheet> newSheet = CSSStyleSheet::create(this, href, baseURL, charset);
    206207    m_sheet = newSheet;
    207208    // We don't need the cross-origin security check here because we are
     
    215216
    216217#if ENABLE(XSLT)
    217 void ProcessingInstruction::setXSLStyleSheet(const String& url, const String& sheet)
     218void ProcessingInstruction::setXSLStyleSheet(const String& href, const KURL& baseURL, const String& sheet)
    218219{
    219220    ASSERT(m_isXSL);
    220     m_sheet = XSLStyleSheet::create(this, url);
     221    m_sheet = XSLStyleSheet::create(this, href, baseURL);
    221222    parseStyleSheet(sheet);
    222223}
  • trunk/WebCore/dom/ProcessingInstruction.h

    r47313 r53607  
    6969
    7070    void checkStyleSheet();
    71     virtual void setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet*);
     71    virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
    7272#if ENABLE(XSLT)
    73     virtual void setXSLStyleSheet(const String& url, const String& sheet);
     73    virtual void setXSLStyleSheet(const String& href, const KURL& baseURL, const String& sheet);
    7474#endif
    7575
  • trunk/WebCore/dom/StyleElement.cpp

    r44279 r53607  
    104104            document->addPendingSheet();
    105105            setLoading(true);
    106             m_sheet = CSSStyleSheet::create(e, String(), document->inputEncoding());
     106            m_sheet = CSSStyleSheet::create(e, String(), KURL(), document->inputEncoding());
    107107            m_sheet->parseString(text, !document->inCompatMode());
    108108            m_sheet->setMedia(mediaList.get());
  • trunk/WebCore/html/HTMLLinkElement.cpp

    r52784 r53607  
    255255}
    256256
    257 void HTMLLinkElement::setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet* sheet)
    258 {
    259     m_sheet = CSSStyleSheet::create(this, url, charset);
     257void HTMLLinkElement::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet)
     258{
     259    m_sheet = CSSStyleSheet::create(this, href, baseURL, charset);
    260260
    261261    bool strictParsing = !document()->inCompatMode();
     
    273273    if (enforceMIMEType && needsSiteSpecificQuirks) {
    274274        // Covers both http and https, with or without "www."
    275         if (url.contains("mcafee.com/japan/", false))
     275        if (baseURL.string().contains("mcafee.com/japan/", false))
    276276            enforceMIMEType = false;
    277277    }
     
    286286    // This prevents an attacker playing games by injecting CSS strings into
    287287    // HTML, XML, JSON, etc. etc.
    288     if (!document()->securityOrigin()->canRequest(KURL(ParsedURLString, url)))
     288    if (!document()->securityOrigin()->canRequest(baseURL))
    289289        crossOriginCSS = true;
    290290
    291291    if (crossOriginCSS && !validMIMEType && !m_sheet->hasSyntacticallyValidCSSHeader())
    292         m_sheet = CSSStyleSheet::create(this, url, charset);
     292        m_sheet = CSSStyleSheet::create(this, href, baseURL, charset);
    293293
    294294    if (strictParsing && needsSiteSpecificQuirks) {
     
    298298        // There are two variants of KHTMLFixes.css. One is equal to mediaWikiKHTMLFixesStyleSheet,
    299299        // while the other lacks the second trailing newline.
    300         if (url.endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
     300        if (baseURL.string().endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
    301301                && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) {
    302302            ASSERT(m_sheet->length() == 1);
  • trunk/WebCore/html/HTMLLinkElement.h

    r40221 r53607  
    8080
    8181    // from CachedResourceClient
    82     virtual void setCSSStyleSheet(const String &url, const String& charset, const CachedCSSStyleSheet* sheet);
     82    virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet);
    8383    bool isLoading() const;
    8484    virtual bool sheetLoaded();
  • trunk/WebCore/loader/CachedCSSStyleSheet.cpp

    r52784 r53607  
    5353{
    5454    if (!m_loading)
    55         c->setCSSStyleSheet(m_url, m_decoder->encoding().name(), this);
     55        c->setCSSStyleSheet(m_url, m_response.url(), m_decoder->encoding().name(), this);
    5656}
    57    
     57
    5858void CachedCSSStyleSheet::allClientsRemoved()
    5959{
     
    113113    CachedResourceClientWalker w(m_clients);
    114114    while (CachedResourceClient *c = w.next())
    115         c->setCSSStyleSheet(m_response.url().string(), m_decoder->encoding().name(), this);
     115        c->setCSSStyleSheet(m_url, m_response.url(), m_decoder->encoding().name(), this);
    116116}
    117117
  • trunk/WebCore/loader/CachedResourceClient.h

    r49251 r53607  
    4343    class Image;
    4444    class IntRect;
     45    class KURL;
    4546
    4647    /**
     
    6667        virtual bool willRenderImage(CachedImage*) { return false; }
    6768
    68         virtual void setCSSStyleSheet(const String& /*URL*/, const String& /*charset*/, const CachedCSSStyleSheet*) { }
    69         virtual void setXSLStyleSheet(const String& /*URL*/, const String& /*sheet*/) { }
     69        virtual void setCSSStyleSheet(const String& /* href */, const KURL& /* baseURL */, const String& /* charset */, const CachedCSSStyleSheet*) { }
     70        virtual void setXSLStyleSheet(const String& /* href */, const KURL& /* baseURL */, const String& /* sheet */) { }
    7071
    7172        virtual void fontLoaded(CachedFont*) {};
  • trunk/WebCore/loader/CachedXSLStyleSheet.cpp

    r44749 r53607  
    4949
    5050    if (!m_loading)
    51         c->setXSLStyleSheet(m_url, m_sheet);
     51        c->setXSLStyleSheet(m_url, m_response.url(), m_sheet);
    5252}
    5353
     
    8484    CachedResourceClientWalker w(m_clients);
    8585    while (CachedResourceClient *c = w.next())
    86         c->setXSLStyleSheet(m_url, m_sheet);
     86        c->setXSLStyleSheet(m_url, m_response.url(), m_sheet);
    8787}
    88 
    8988
    9089void CachedXSLStyleSheet::error()
  • trunk/WebCore/xml/XSLImportRule.cpp

    r47907 r53607  
    5353}
    5454
    55 void XSLImportRule::setXSLStyleSheet(const String& url, const String& sheet)
     55void XSLImportRule::setXSLStyleSheet(const String& href, const KURL& baseURL, const String& sheet)
    5656{
    5757    if (m_styleSheet)
    5858        m_styleSheet->setParent(0);
    59    
    60     m_styleSheet = XSLStyleSheet::create(this, url);
    61    
     59
     60    m_styleSheet = XSLStyleSheet::create(this, href, baseURL);
     61
    6262    XSLStyleSheet* parent = parentStyleSheet();
    6363    if (parent)
     
    8888    String absHref = m_strHref;
    8989    XSLStyleSheet* parentSheet = parentStyleSheet();
    90     if (!parentSheet->href().isNull())
     90    if (!parentSheet->putativeBaseURL().isNull())
    9191        // use parent styleheet's URL as the base URL
    92         absHref = KURL(KURL(ParsedURLString, parentSheet->href()), m_strHref).string();
     92        absHref = KURL(parentSheet->putativeBaseURL(), m_strHref).string();
    9393   
    9494    // Check for a cycle in our import chain.  If we encounter a stylesheet
    9595    // in our parent chain with the same URL, then just bail.
    9696    for (parent = this->parent(); parent; parent = parent->parent()) {
    97         if (parent->isXSLStyleSheet() && absHref == static_cast<XSLStyleSheet*>(parent)->href())
     97        if (parent->isXSLStyleSheet() && absHref == static_cast<XSLStyleSheet*>(parent)->putativeBaseURL().string())
    9898            return;
    9999    }
  • trunk/WebCore/xml/XSLImportRule.h

    r36109 r53607  
    5858
    5959    // from CachedResourceClient
    60     virtual void setXSLStyleSheet(const String& url, const String& sheet);
     60    virtual void setXSLStyleSheet(const String& href, const KURL& baseURL, const String& sheet);
    6161   
    6262    String m_strHref;
  • trunk/WebCore/xml/XSLStyleSheet.h

    r48826 r53607  
    4444public:
    4545#if !USE(QXMLQUERY)
    46     static PassRefPtr<XSLStyleSheet> create(XSLImportRule* parentImport, const String& href)
     46    static PassRefPtr<XSLStyleSheet> create(XSLImportRule* parentImport, const String& href, const KURL& baseURL)
    4747    {
    48         return adoptRef(new XSLStyleSheet(parentImport, href));
     48        return adoptRef(new XSLStyleSheet(parentImport, href, baseURL));
    4949    }
    5050#endif
    51     static PassRefPtr<XSLStyleSheet> create(Node* parentNode, const String& href)
     51    static PassRefPtr<XSLStyleSheet> create(Node* parentNode, const String& href, const KURL& baseURL)
    5252    {
    53         return adoptRef(new XSLStyleSheet(parentNode, href, false));
     53        return adoptRef(new XSLStyleSheet(parentNode, href, baseURL, false));
    5454    }
    55     static PassRefPtr<XSLStyleSheet> createEmbedded(Node* parentNode, const String& href)
     55    static PassRefPtr<XSLStyleSheet> createEmbedded(Node* parentNode, const String& href, const KURL& baseURL)
    5656    {
    57         return adoptRef(new XSLStyleSheet(parentNode, href, true));
     57        return adoptRef(new XSLStyleSheet(parentNode, href, baseURL, true));
    5858    }
    5959
     
    9191
    9292private:
    93     XSLStyleSheet(Node* parentNode, const String& href, bool embedded);
     93    XSLStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, bool embedded);
    9494#if !USE(QXMLQUERY)
    95     XSLStyleSheet(XSLImportRule* parentImport, const String& href);
     95    XSLStyleSheet(XSLImportRule* parentImport, const String& href, const KURL& baseURL);
    9696#endif
    9797
  • trunk/WebCore/xml/XSLStyleSheetLibxslt.cpp

    r48826 r53607  
    5656namespace WebCore {
    5757
    58 XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& href)
    59     : StyleSheet(parentRule, href)
     58XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& href, const KURL& baseURL)
     59    : StyleSheet(parentRule, href, baseURL)
    6060    , m_ownerDocument(0)
    6161    , m_embedded(false)
     
    6767}
    6868
    69 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& href, bool embedded)
    70     : StyleSheet(parentNode, href)
     69XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, bool embedded)
     70    : StyleSheet(parentNode, href, baseURL)
    7171    , m_ownerDocument(parentNode->document())
    7272    , m_embedded(embedded)
     
    169169
    170170    m_stylesheetDoc = xmlCtxtReadMemory(ctxt, buffer, size,
    171         href().utf8().data(),
     171        putativeBaseURL().string().utf8().data(),
    172172        BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE",
    173173        XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_NOWARNING | XML_PARSE_NOCDATA);
     
    193193        // We have to locate (by ID) the appropriate embedded stylesheet element, so that we can walk the
    194194        // import/include list.
    195         xmlAttrPtr idNode = xmlGetID(document(), (const xmlChar*)(href().utf8().data()));
     195        xmlAttrPtr idNode = xmlGetID(document(), (const xmlChar*)(putativeBaseURL().string().utf8().data()));
    196196        if (!idNode)
    197197            return;
  • trunk/WebCore/xml/XSLStyleSheetQt.cpp

    r49020 r53607  
    3434namespace WebCore {
    3535
    36 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& href, bool embedded)
    37     : StyleSheet(parentNode, href)
     36XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, bool embedded)
     37    : StyleSheet(parentNode, href, baseURL)
    3838    , m_ownerDocument(parentNode->document())
    3939    , m_embedded(embedded)
  • trunk/WebCore/xml/XSLTProcessorLibxslt.cpp

    r48826 r53607  
    227227    if (!cachedStylesheet && stylesheetRootNode) {
    228228        cachedStylesheet = XSLStyleSheet::create(stylesheetRootNode->parent() ? stylesheetRootNode->parent() : stylesheetRootNode,
    229             stylesheetRootNode->document()->url().string());
     229            stylesheetRootNode->document()->url().string(),
     230            stylesheetRootNode->document()->url()); // FIXME: Should we use baseURL here?
    230231        cachedStylesheet->parseString(createMarkup(stylesheetRootNode));
    231232    }
  • trunk/WebCore/xml/XSLTProcessorQt.cpp

    r53127 r53607  
    121121    if (!stylesheet && m_stylesheetRootNode) {
    122122        Node* node = m_stylesheetRootNode.get();
    123         stylesheet = XSLStyleSheet::create(node->parent() ? node->parent() : node, node->document()->url().string());
     123        stylesheet = XSLStyleSheet::create(node->parent() ? node->parent() : node,
     124            node->document()->url().string(),
     125            node->document()->url()); // FIXME: Should we use baseURL here?
    124126        stylesheet->parseString(createMarkup(node));
    125127    }
Note: See TracChangeset for help on using the changeset viewer.