Changeset 53607 in webkit
- Timestamp:
- Jan 20, 2010 11:22:22 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r53606 r53607 1 2010-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 1 18 2010-01-21 Kent Tamura <tkent@chromium.org> 2 19 -
trunk/WebCore/ChangeLog
r53604 r53607 1 2010-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 1 91 2010-01-20 Kwang Yul Seo <skyul@company100.net> 2 92 -
trunk/WebCore/css/CSSImportRule.cpp
r52784 r53607 55 55 } 56 56 57 void CSSImportRule::setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet* sheet)57 void CSSImportRule::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet) 58 58 { 59 59 if (m_styleSheet) 60 60 m_styleSheet->setParent(0); 61 m_styleSheet = CSSStyleSheet::create(this, url, charset);61 m_styleSheet = CSSStyleSheet::create(this, href, baseURL, charset); 62 62 63 63 bool crossOriginCSS = false; … … 71 71 if (enforceMIMEType && needsSiteSpecificQuirks) { 72 72 // 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)) 74 74 enforceMIMEType = false; 75 75 } … … 79 79 m_styleSheet->parseString(sheetText, strict); 80 80 81 if (!parent || !parent->doc() || !parent->doc()->securityOrigin()->canRequest( KURL(ParsedURLString, url)))81 if (!parent || !parent->doc() || !parent->doc()->securityOrigin()->canRequest(baseURL)) 82 82 crossOriginCSS = true; 83 83 84 84 if (crossOriginCSS && !validMIMEType && !m_styleSheet->hasSyntacticallyValidCSSHeader()) 85 m_styleSheet = CSSStyleSheet::create(this, url, charset);85 m_styleSheet = CSSStyleSheet::create(this, href, baseURL, charset); 86 86 87 87 if (strict && needsSiteSpecificQuirks) { … … 89 89 DEFINE_STATIC_LOCAL(const String, slashKHTMLFixesDotCss, ("/KHTMLFixes.css")); 90 90 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) { 92 92 ASSERT(m_styleSheet->length() == 1); 93 93 ExceptionCode ec; … … 118 118 119 119 String absHref = m_strHref; 120 if (!parentSheet-> href().isNull())120 if (!parentSheet->putativeBaseURL().isNull()) 121 121 // 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(); 123 123 124 124 // Check for a cycle in our import chain. If we encounter a stylesheet … … 126 126 StyleBase* root = this; 127 127 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()) 129 130 return; 130 131 root = curr; -
trunk/WebCore/css/CSSImportRule.h
r39441 r53607 64 64 65 65 // 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*); 67 67 68 68 String m_strHref; -
trunk/WebCore/css/CSSStyleSheet.cpp
r52784 r53607 35 35 namespace WebCore { 36 36 37 CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const String& charset)38 : StyleSheet(parentSheet, href )37 CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const KURL& baseURL, const String& charset) 38 : StyleSheet(parentSheet, href, baseURL) 39 39 , m_doc(parentSheet ? parentSheet->doc() : 0) 40 40 , m_namespaces(0) … … 47 47 } 48 48 49 CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const String& charset)50 : StyleSheet(parentNode, href )49 CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, const String& charset) 50 : StyleSheet(parentNode, href, baseURL) 51 51 , m_doc(parentNode->document()) 52 52 , m_namespaces(0) … … 59 59 } 60 60 61 CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const String& charset)62 : StyleSheet(ownerRule, href )61 CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const KURL& baseURL, const String& charset) 62 : StyleSheet(ownerRule, href, baseURL) 63 63 , m_namespaces(0) 64 64 , m_charset(charset) -
trunk/WebCore/css/CSSStyleSheet.h
r52784 r53607 39 39 static PassRefPtr<CSSStyleSheet> create() 40 40 { 41 return adoptRef(new CSSStyleSheet(static_cast<CSSStyleSheet*>(0), String(), String()));41 return adoptRef(new CSSStyleSheet(static_cast<CSSStyleSheet*>(0), String(), KURL(), String())); 42 42 } 43 43 static PassRefPtr<CSSStyleSheet> create(Node* ownerNode) 44 44 { 45 return adoptRef(new CSSStyleSheet(ownerNode, String(), String()));45 return adoptRef(new CSSStyleSheet(ownerNode, String(), KURL(), String())); 46 46 } 47 static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& href )47 static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& href, const KURL& baseURL) 48 48 { 49 return adoptRef(new CSSStyleSheet(ownerNode, href, String()));49 return adoptRef(new CSSStyleSheet(ownerNode, href, baseURL, String())); 50 50 } 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) 52 52 { 53 return adoptRef(new CSSStyleSheet(ownerNode, href, charset));53 return adoptRef(new CSSStyleSheet(ownerNode, href, baseURL, charset)); 54 54 } 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) 56 56 { 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())); 58 62 } 59 63 60 64 virtual ~CSSStyleSheet(); 61 65 62 66 CSSRule* ownerRule() const; 63 67 PassRefPtr<CSSRuleList> cssRules(bool omitCharsetRules = false); … … 73 77 void addNamespace(CSSParser*, const AtomicString& prefix, const AtomicString& uri); 74 78 const AtomicString& determineNamespace(const AtomicString& prefix); 75 79 76 80 virtual void styleSheetChanged(); 77 81 … … 100 104 101 105 private: 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 106 110 virtual bool isCSSStyleSheet() const { return true; } 107 111 virtual String type() const { return "text/css"; } -
trunk/WebCore/css/StyleBase.cpp
r47907 r53607 57 57 if (!sheet) 58 58 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()) 62 62 return sheet->parent()->baseURL(); 63 63 if (!sheet->ownerNode()) -
trunk/WebCore/css/StyleSheet.cpp
r50583 r53607 25 25 namespace WebCore { 26 26 27 StyleSheet::StyleSheet(StyleSheet* parentSheet, const String& href )27 StyleSheet::StyleSheet(StyleSheet* parentSheet, const String& href, const KURL& baseURL) 28 28 : StyleList(parentSheet) 29 29 , m_parentNode(0) 30 , m_strHref(href) 30 , m_href(href) 31 , m_baseURL(baseURL) 31 32 , m_disabled(false) 32 33 { … … 34 35 35 36 36 StyleSheet::StyleSheet(Node* parentNode, const String& href )37 StyleSheet::StyleSheet(Node* parentNode, const String& href, const KURL& baseURL) 37 38 : StyleList(0) 38 39 , m_parentNode(parentNode) 39 , m_strHref(href) 40 , m_href(href) 41 , m_baseURL(baseURL) 40 42 , m_disabled(false) 41 43 { 42 44 } 43 45 44 StyleSheet::StyleSheet(StyleBase* owner, const String& href )46 StyleSheet::StyleSheet(StyleBase* owner, const String& href, const KURL& baseURL) 45 47 : StyleList(owner) 46 48 , m_parentNode(0) 47 , m_strHref(href) 49 , m_href(href) 50 , m_baseURL(baseURL) 48 51 , m_disabled(false) 49 52 { -
trunk/WebCore/css/StyleSheet.h
r39441 r53607 42 42 Node* ownerNode() const { return m_parentNode; } 43 43 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 46 56 const String& title() const { return m_strTitle; } 47 57 void setTitle(const String& s) { m_strTitle = s; } … … 59 69 60 70 protected: 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); 64 74 65 75 private: … … 67 77 68 78 Node* m_parentNode; 69 String m_strHref; 79 String m_href; 80 KURL m_baseURL; 70 81 String m_strTitle; 71 82 RefPtr<MediaList> m_media; -
trunk/WebCore/dom/Document.cpp
r53595 r53607 2010 2010 2011 2011 if (m_elemSheet) 2012 m_elemSheet->set Href(m_baseURL.string());2012 m_elemSheet->setBaseURL(m_baseURL); 2013 2013 if (m_mappedElementSheet) 2014 m_mappedElementSheet->set Href(m_baseURL.string());2014 m_mappedElementSheet->setBaseURL(m_baseURL); 2015 2015 } 2016 2016 … … 2034 2034 2035 2035 // Parse the sheet and cache it. 2036 m_pageUserSheet = CSSStyleSheet::create (this, settings()->userStyleSheetLocation());2036 m_pageUserSheet = CSSStyleSheet::createInline(this, settings()->userStyleSheetLocation()); 2037 2037 m_pageUserSheet->setIsUserStyleSheet(true); 2038 2038 m_pageUserSheet->parseString(userSheetText, !inCompatMode()); … … 2069 2069 if (!UserContentURLPattern::matchesPatterns(url(), sheet->whitelist(), sheet->blacklist())) 2070 2070 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()); 2072 2072 parsedSheet->setIsUserStyleSheet(true); 2073 2073 parsedSheet->parseString(sheet->source(), !inCompatMode()); … … 2091 2091 { 2092 2092 if (!m_elemSheet) 2093 m_elemSheet = CSSStyleSheet::create (this, m_baseURL.string());2093 m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL); 2094 2094 return m_elemSheet.get(); 2095 2095 } … … 2098 2098 { 2099 2099 if (!m_mappedElementSheet) 2100 m_mappedElementSheet = CSSStyleSheet::create (this, m_baseURL.string());2100 m_mappedElementSheet = CSSStyleSheet::createInline(this, m_baseURL); 2101 2101 return m_mappedElementSheet.get(); 2102 2102 } -
trunk/WebCore/dom/ProcessingInstruction.cpp
r52784 r53607 140 140 // to kick off import/include loads that can hang off some parent sheet. 141 141 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); 143 144 m_loading = false; 144 145 } … … 198 199 } 199 200 200 void ProcessingInstruction::setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet* sheet)201 void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet) 201 202 { 202 203 #if ENABLE(XSLT) 203 204 ASSERT(!m_isXSL); 204 205 #endif 205 RefPtr<CSSStyleSheet> newSheet = CSSStyleSheet::create(this, url, charset);206 RefPtr<CSSStyleSheet> newSheet = CSSStyleSheet::create(this, href, baseURL, charset); 206 207 m_sheet = newSheet; 207 208 // We don't need the cross-origin security check here because we are … … 215 216 216 217 #if ENABLE(XSLT) 217 void ProcessingInstruction::setXSLStyleSheet(const String& url, const String& sheet)218 void ProcessingInstruction::setXSLStyleSheet(const String& href, const KURL& baseURL, const String& sheet) 218 219 { 219 220 ASSERT(m_isXSL); 220 m_sheet = XSLStyleSheet::create(this, url);221 m_sheet = XSLStyleSheet::create(this, href, baseURL); 221 222 parseStyleSheet(sheet); 222 223 } -
trunk/WebCore/dom/ProcessingInstruction.h
r47313 r53607 69 69 70 70 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*); 72 72 #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); 74 74 #endif 75 75 -
trunk/WebCore/dom/StyleElement.cpp
r44279 r53607 104 104 document->addPendingSheet(); 105 105 setLoading(true); 106 m_sheet = CSSStyleSheet::create(e, String(), document->inputEncoding());106 m_sheet = CSSStyleSheet::create(e, String(), KURL(), document->inputEncoding()); 107 107 m_sheet->parseString(text, !document->inCompatMode()); 108 108 m_sheet->setMedia(mediaList.get()); -
trunk/WebCore/html/HTMLLinkElement.cpp
r52784 r53607 255 255 } 256 256 257 void HTMLLinkElement::setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet* sheet)258 { 259 m_sheet = CSSStyleSheet::create(this, url, charset);257 void HTMLLinkElement::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet) 258 { 259 m_sheet = CSSStyleSheet::create(this, href, baseURL, charset); 260 260 261 261 bool strictParsing = !document()->inCompatMode(); … … 273 273 if (enforceMIMEType && needsSiteSpecificQuirks) { 274 274 // 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)) 276 276 enforceMIMEType = false; 277 277 } … … 286 286 // This prevents an attacker playing games by injecting CSS strings into 287 287 // HTML, XML, JSON, etc. etc. 288 if (!document()->securityOrigin()->canRequest( KURL(ParsedURLString, url)))288 if (!document()->securityOrigin()->canRequest(baseURL)) 289 289 crossOriginCSS = true; 290 290 291 291 if (crossOriginCSS && !validMIMEType && !m_sheet->hasSyntacticallyValidCSSHeader()) 292 m_sheet = CSSStyleSheet::create(this, url, charset);292 m_sheet = CSSStyleSheet::create(this, href, baseURL, charset); 293 293 294 294 if (strictParsing && needsSiteSpecificQuirks) { … … 298 298 // There are two variants of KHTMLFixes.css. One is equal to mediaWikiKHTMLFixesStyleSheet, 299 299 // 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) 301 301 && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) { 302 302 ASSERT(m_sheet->length() == 1); -
trunk/WebCore/html/HTMLLinkElement.h
r40221 r53607 80 80 81 81 // 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); 83 83 bool isLoading() const; 84 84 virtual bool sheetLoaded(); -
trunk/WebCore/loader/CachedCSSStyleSheet.cpp
r52784 r53607 53 53 { 54 54 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); 56 56 } 57 57 58 58 void CachedCSSStyleSheet::allClientsRemoved() 59 59 { … … 113 113 CachedResourceClientWalker w(m_clients); 114 114 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); 116 116 } 117 117 -
trunk/WebCore/loader/CachedResourceClient.h
r49251 r53607 43 43 class Image; 44 44 class IntRect; 45 class KURL; 45 46 46 47 /** … … 66 67 virtual bool willRenderImage(CachedImage*) { return false; } 67 68 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 */) { } 70 71 71 72 virtual void fontLoaded(CachedFont*) {}; -
trunk/WebCore/loader/CachedXSLStyleSheet.cpp
r44749 r53607 49 49 { 50 50 if (!m_loading) 51 c->setXSLStyleSheet(m_url, m_ sheet);51 c->setXSLStyleSheet(m_url, m_response.url(), m_sheet); 52 52 } 53 53 … … 84 84 CachedResourceClientWalker w(m_clients); 85 85 while (CachedResourceClient *c = w.next()) 86 c->setXSLStyleSheet(m_url, m_ sheet);86 c->setXSLStyleSheet(m_url, m_response.url(), m_sheet); 87 87 } 88 89 88 90 89 void CachedXSLStyleSheet::error() -
trunk/WebCore/xml/XSLImportRule.cpp
r47907 r53607 53 53 } 54 54 55 void XSLImportRule::setXSLStyleSheet(const String& url, const String& sheet)55 void XSLImportRule::setXSLStyleSheet(const String& href, const KURL& baseURL, const String& sheet) 56 56 { 57 57 if (m_styleSheet) 58 58 m_styleSheet->setParent(0); 59 60 m_styleSheet = XSLStyleSheet::create(this, url);61 59 60 m_styleSheet = XSLStyleSheet::create(this, href, baseURL); 61 62 62 XSLStyleSheet* parent = parentStyleSheet(); 63 63 if (parent) … … 88 88 String absHref = m_strHref; 89 89 XSLStyleSheet* parentSheet = parentStyleSheet(); 90 if (!parentSheet-> href().isNull())90 if (!parentSheet->putativeBaseURL().isNull()) 91 91 // 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(); 93 93 94 94 // Check for a cycle in our import chain. If we encounter a stylesheet 95 95 // in our parent chain with the same URL, then just bail. 96 96 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()) 98 98 return; 99 99 } -
trunk/WebCore/xml/XSLImportRule.h
r36109 r53607 58 58 59 59 // 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); 61 61 62 62 String m_strHref; -
trunk/WebCore/xml/XSLStyleSheet.h
r48826 r53607 44 44 public: 45 45 #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) 47 47 { 48 return adoptRef(new XSLStyleSheet(parentImport, href ));48 return adoptRef(new XSLStyleSheet(parentImport, href, baseURL)); 49 49 } 50 50 #endif 51 static PassRefPtr<XSLStyleSheet> create(Node* parentNode, const String& href )51 static PassRefPtr<XSLStyleSheet> create(Node* parentNode, const String& href, const KURL& baseURL) 52 52 { 53 return adoptRef(new XSLStyleSheet(parentNode, href, false));53 return adoptRef(new XSLStyleSheet(parentNode, href, baseURL, false)); 54 54 } 55 static PassRefPtr<XSLStyleSheet> createEmbedded(Node* parentNode, const String& href )55 static PassRefPtr<XSLStyleSheet> createEmbedded(Node* parentNode, const String& href, const KURL& baseURL) 56 56 { 57 return adoptRef(new XSLStyleSheet(parentNode, href, true));57 return adoptRef(new XSLStyleSheet(parentNode, href, baseURL, true)); 58 58 } 59 59 … … 91 91 92 92 private: 93 XSLStyleSheet(Node* parentNode, const String& href, bool embedded);93 XSLStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, bool embedded); 94 94 #if !USE(QXMLQUERY) 95 XSLStyleSheet(XSLImportRule* parentImport, const String& href );95 XSLStyleSheet(XSLImportRule* parentImport, const String& href, const KURL& baseURL); 96 96 #endif 97 97 -
trunk/WebCore/xml/XSLStyleSheetLibxslt.cpp
r48826 r53607 56 56 namespace WebCore { 57 57 58 XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& href )59 : StyleSheet(parentRule, href )58 XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& href, const KURL& baseURL) 59 : StyleSheet(parentRule, href, baseURL) 60 60 , m_ownerDocument(0) 61 61 , m_embedded(false) … … 67 67 } 68 68 69 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& href, bool embedded)70 : StyleSheet(parentNode, href )69 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, bool embedded) 70 : StyleSheet(parentNode, href, baseURL) 71 71 , m_ownerDocument(parentNode->document()) 72 72 , m_embedded(embedded) … … 169 169 170 170 m_stylesheetDoc = xmlCtxtReadMemory(ctxt, buffer, size, 171 href().utf8().data(),171 putativeBaseURL().string().utf8().data(), 172 172 BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE", 173 173 XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_NOWARNING | XML_PARSE_NOCDATA); … … 193 193 // We have to locate (by ID) the appropriate embedded stylesheet element, so that we can walk the 194 194 // import/include list. 195 xmlAttrPtr idNode = xmlGetID(document(), (const xmlChar*)( href().utf8().data()));195 xmlAttrPtr idNode = xmlGetID(document(), (const xmlChar*)(putativeBaseURL().string().utf8().data())); 196 196 if (!idNode) 197 197 return; -
trunk/WebCore/xml/XSLStyleSheetQt.cpp
r49020 r53607 34 34 namespace WebCore { 35 35 36 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& href, bool embedded)37 : StyleSheet(parentNode, href )36 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, bool embedded) 37 : StyleSheet(parentNode, href, baseURL) 38 38 , m_ownerDocument(parentNode->document()) 39 39 , m_embedded(embedded) -
trunk/WebCore/xml/XSLTProcessorLibxslt.cpp
r48826 r53607 227 227 if (!cachedStylesheet && stylesheetRootNode) { 228 228 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? 230 231 cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); 231 232 } -
trunk/WebCore/xml/XSLTProcessorQt.cpp
r53127 r53607 121 121 if (!stylesheet && m_stylesheetRootNode) { 122 122 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? 124 126 stylesheet->parseString(createMarkup(node)); 125 127 }
Note: See TracChangeset
for help on using the changeset viewer.