http://bugs.webkit.org/show_bug.cgi?id=11011
External CSS is parsed as iso-8859-1 even though the main document is utf-8
Test: fast/encoding/css-charset-default.xhtml
* loader/CachedResourceClient.h:
(WebCore::CachedResourceClient::setCSSStyleSheet):
(WebCore::CachedResourceClient::setXSLStyleSheet):
Divided setStyleSheet into setCSSStyleSheet and setXSLStyleSheet. The former
takes an additional charset parameter, to be passed to CSSStyleSheet constructor.
* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::setCSSStyleSheet):
(WebCore::CSSImportRule::insertedIntoParent): Default to parent stylesheet's charset.
* css/CSSImportRule.h:
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::CSSStyleSheet):
* css/CSSStyleSheet.h:
Added an m_charset member to be used when loading child stylesheets. Removed an unused m_implicit
member. Changed some String parameters to const String&.
* css/StyleSheet.cpp:
(WebCore::StyleSheet::StyleSheet):
* css/StyleSheet.h:
Changed some String parameters to const String&. Removed an unused (even unimplemented) constructor.
* css/StyleSheetList.cpp:
(WebCore::StyleSheetList::length):
(WebCore::StyleSheetList::item):
* css/StyleSheetList.h:
Special-casing implicit stylesheets seemed to be dead code, removed.
* dom/Document.cpp:
(WebCore::Document::setCSSStyleSheet):
(WebCore::Document::recalcStyleSelector):
* dom/Document.h:
Renamed setStyleSheet() to setCSSStyleSheet().
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::checkStyleSheet): Pass a correct charset to requestCSSStyleSheet().
(WebCore::ProcessingInstruction::setCSSStyleSheet):
(WebCore::ProcessingInstruction::setXSLStyleSheet):
(WebCore::ProcessingInstruction::parseStyleSheet):
* dom/ProcessingInstruction.h:
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process): Default to document encoding if a charset attribute
is not specified.
(WebCore::HTMLLinkElement::setCSSStyleSheet):
* html/HTMLLinkElement.h:
* html/HTMLStyleElement.cpp:
(WebCore::HTMLStyleElement::childrenChanged):
* ksvg2/svg/SVGStyleElement.cpp:
(WebCore::SVGStyleElement::childrenChanged):
Inherit URL and charset from the document.
* loader/Cache.cpp:
(WebCore::Cache::requestCSSStyleSheet):
* loader/Cache.h:
Adjust for setStyleSheet() renaming.
* loader/CachedCSSStyleSheet.h: Removed an unused constructor.
* loader/CachedCSSStyleSheet.cpp:
(WebCore::CachedCSSStyleSheet::ref):
(WebCore::CachedCSSStyleSheet::deref):
(WebCore::CachedCSSStyleSheet::checkNotify):
Pass the encoding to setCSSStyleSheet().
* loader/CachedXSLStyleSheet.cpp:
(WebCore::CachedXSLStyleSheet::ref):
(WebCore::CachedXSLStyleSheet::checkNotify):
* loader/DocLoader.cpp:
(WebCore::DocLoader::requestCSSStyleSheet):
* loader/DocLoader.h:
* page/Frame.cpp:
(WebCore::UserStyleSheetLoader::UserStyleSheetLoader):
(WebCore::UserStyleSheetLoader::setCSSStyleSheet):
* xml/XSLImportRule.cpp:
(WebCore::XSLImportRule::setXSLStyleSheet):
(WebCore::XSLImportRule::loadSheet):
* xml/XSLImportRule.h:
Adjust for setStyleSheet() renaming.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16689
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-09-30 Alexey Proskuryakov <ap@nypop.com>
+
+ Reviewed by Darin.
+
+ Test for http://bugs.webkit.org/show_bug.cgi?id=11011
+ External CSS is parsed as iso-8859-1 even though the main document is utf-8
+
+ * fast/encoding/css-charset-default-expected.txt: Added.
+ * fast/encoding/css-charset-default.xhtml: Added.
+ * fast/encoding/css-charset-import.css: Added.
+ * fast/encoding/css-charset-inherit-iso-8859-5.css: Added.
+ * fast/encoding/css-charset-inherit-koi-8.css: Added.
+
2006-09-30 Rob Buis <buis@kde.org>
Reviewed by eseidel.
--- /dev/null
+Test for bug 11011: External CSS is parsed as iso-8859-1 even though the main document is utf-8.
+
+Stylesheet 1 (inherit document charset using xml-stylesheet processing instruction): SUССЕSS
+
+Stylesheet 2 (inherit document charset using link): SUССЕSS
+
+Stylesheet 3 (inherit referring stylesheet charset): SUССЕSS
+
+Stylesheet 4 (inherit referring inline stylesheet charset): SUССЕSS
+
+
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-5"?>
+<?xml-stylesheet href="css-charset-inherit-iso-8859-5.css?1" type="text/css"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>CSS Default charset</title>
+ <link rel="stylesheet" type="text/css" href="css-charset-inherit-iso-8859-5.css?2"/>
+ <link rel="stylesheet" type="text/css" href="css-charset-import.css"/>
+ <style type="text/css">
+ @import "css-charset-inherit-iso-8859-5.css?4";
+ </style>
+</head>
+<body onload="test()">
+<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=11011">bug 11011</a>:
+External CSS is parsed as iso-8859-1 even though the main document is utf-8.</p>
+
+<p id="res1">Stylesheet 1 (inherit document charset using xml-stylesheet processing instruction): </p>
+<p id="res2">Stylesheet 2 (inherit document charset using link): </p>
+<p id="res3">Stylesheet 3 (inherit referring stylesheet charset): </p>
+<p id="res4">Stylesheet 4 (inherit referring inline stylesheet charset): </p>
+
+<script type="text/javascript">
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function test() {
+ try {
+ document.getElementById("res1").innerHTML += document.styleSheets[0].cssRules[0].style.content;
+
+ document.getElementById("res2").innerHTML += document.styleSheets[1].cssRules[0].style.content;
+
+ document.getElementById("res3").innerHTML += document.styleSheets[2].cssRules[1].styleSheet.cssRules[0].style.content;
+
+ document.getElementById("res4").innerHTML += document.styleSheets[3].cssRules[0].styleSheet.cssRules[0].style.content;
+ } catch (ex) {
+ alert(ex.toString());
+ }
+}
+</script>
+
+</body>
+</html>
--- /dev/null
+@charset "koi8-r";
+@import "css-charset-inherit-koi-8.css";
--- /dev/null
+/* iso-8859-5 encoding */
+#dummy:before { content: "SUÁÁµSS"; }
--- /dev/null
+/* koi-8 encoding */
+#dummy:before { content: "SUóóåSS"; }
+2006-09-30 Alexey Proskuryakov <ap@nypop.com>
+
+ Reviewed by Darin.
+
+ http://bugs.webkit.org/show_bug.cgi?id=11011
+ External CSS is parsed as iso-8859-1 even though the main document is utf-8
+
+ Test: fast/encoding/css-charset-default.xhtml
+
+ * loader/CachedResourceClient.h:
+ (WebCore::CachedResourceClient::setCSSStyleSheet):
+ (WebCore::CachedResourceClient::setXSLStyleSheet):
+ Divided setStyleSheet into setCSSStyleSheet and setXSLStyleSheet. The former
+ takes an additional charset parameter, to be passed to CSSStyleSheet constructor.
+
+ * css/CSSImportRule.cpp:
+ (WebCore::CSSImportRule::setCSSStyleSheet):
+ (WebCore::CSSImportRule::insertedIntoParent): Default to parent stylesheet's charset.
+ * css/CSSImportRule.h:
+
+ * css/CSSStyleSheet.cpp:
+ (WebCore::CSSStyleSheet::CSSStyleSheet):
+ * css/CSSStyleSheet.h:
+ Added an m_charset member to be used when loading child stylesheets. Removed an unused m_implicit
+ member. Changed some String parameters to const String&.
+
+ * css/StyleSheet.cpp:
+ (WebCore::StyleSheet::StyleSheet):
+ * css/StyleSheet.h:
+ Changed some String parameters to const String&. Removed an unused (even unimplemented) constructor.
+
+ * css/StyleSheetList.cpp:
+ (WebCore::StyleSheetList::length):
+ (WebCore::StyleSheetList::item):
+ * css/StyleSheetList.h:
+ Special-casing implicit stylesheets seemed to be dead code, removed.
+
+ * dom/Document.cpp:
+ (WebCore::Document::setCSSStyleSheet):
+ (WebCore::Document::recalcStyleSelector):
+ * dom/Document.h:
+ Renamed setStyleSheet() to setCSSStyleSheet().
+
+ * dom/ProcessingInstruction.cpp:
+ (WebCore::ProcessingInstruction::checkStyleSheet): Pass a correct charset to requestCSSStyleSheet().
+ (WebCore::ProcessingInstruction::setCSSStyleSheet):
+ (WebCore::ProcessingInstruction::setXSLStyleSheet):
+ (WebCore::ProcessingInstruction::parseStyleSheet):
+ * dom/ProcessingInstruction.h:
+
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::process): Default to document encoding if a charset attribute
+ is not specified.
+ (WebCore::HTMLLinkElement::setCSSStyleSheet):
+ * html/HTMLLinkElement.h:
+
+ * html/HTMLStyleElement.cpp:
+ (WebCore::HTMLStyleElement::childrenChanged):
+ * ksvg2/svg/SVGStyleElement.cpp:
+ (WebCore::SVGStyleElement::childrenChanged):
+ Inherit URL and charset from the document.
+
+ * loader/Cache.cpp:
+ (WebCore::Cache::requestCSSStyleSheet):
+ * loader/Cache.h:
+ Adjust for setStyleSheet() renaming.
+
+ * loader/CachedCSSStyleSheet.h: Removed an unused constructor.
+ * loader/CachedCSSStyleSheet.cpp:
+ (WebCore::CachedCSSStyleSheet::ref):
+ (WebCore::CachedCSSStyleSheet::deref):
+ (WebCore::CachedCSSStyleSheet::checkNotify):
+ Pass the encoding to setCSSStyleSheet().
+
+ * loader/CachedXSLStyleSheet.cpp:
+ (WebCore::CachedXSLStyleSheet::ref):
+ (WebCore::CachedXSLStyleSheet::checkNotify):
+ * loader/DocLoader.cpp:
+ (WebCore::DocLoader::requestCSSStyleSheet):
+ * loader/DocLoader.h:
+ * page/Frame.cpp:
+ (WebCore::UserStyleSheetLoader::UserStyleSheetLoader):
+ (WebCore::UserStyleSheetLoader::setCSSStyleSheet):
+ * xml/XSLImportRule.cpp:
+ (WebCore::XSLImportRule::setXSLStyleSheet):
+ (WebCore::XSLImportRule::loadSheet):
+ * xml/XSLImportRule.h:
+ Adjust for setStyleSheet() renaming.
+
2006-09-30 Rob Buis <buis@kde.org>
Reviewed by eseidel.
m_cachedSheet->deref(this);
}
-void CSSImportRule::setStyleSheet(const String &url, const String &sheet)
+void CSSImportRule::setCSSStyleSheet(const String &url, const String& charset, const String &sheet)
{
if (m_styleSheet)
m_styleSheet->setParent(0);
- m_styleSheet = new CSSStyleSheet(this, url);
+ m_styleSheet = new CSSStyleSheet(this, url, charset);
CSSStyleSheet *parent = parentStyleSheet();
m_styleSheet->parseString(sheet, !parent || parent->useStrictParsing());
if (absHref == parent->baseURL())
return;
- // ### pass correct charset here!!
- m_cachedSheet = docLoader->requestStyleSheet(absHref, String());
+ m_cachedSheet = docLoader->requestCSSStyleSheet(absHref, parentSheet->charset());
if (m_cachedSheet) {
m_loading = true;
m_cachedSheet->ref(this);
bool isLoading() const;
// from CachedResourceClient
- virtual void setStyleSheet(const String& url, const String& sheet);
+ virtual void setCSSStyleSheet(const String& url, const String& charset, const String& sheet);
virtual void insertedIntoParent();
namespace WebCore {
-CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, String href)
+CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const String& charset)
: StyleSheet(parentSheet, href)
, m_doc(parentSheet ? parentSheet->doc() : 0)
- , m_implicit(false)
, m_namespaces(0)
+ , m_charset(charset)
{
}
-CSSStyleSheet::CSSStyleSheet(Node *parentNode, String href, bool _implicit)
+CSSStyleSheet::CSSStyleSheet(Node *parentNode, const String& href, const String& charset)
: StyleSheet(parentNode, href)
, m_doc(parentNode->document())
- , m_implicit(_implicit)
, m_namespaces(0)
+ , m_charset(charset)
{
}
-CSSStyleSheet::CSSStyleSheet(CSSRule *ownerRule, String href)
+CSSStyleSheet::CSSStyleSheet(CSSRule *ownerRule, const String& href, const String& charset)
: StyleSheet(ownerRule, href)
, m_doc(0)
- , m_implicit(false)
, m_namespaces(0)
+ , m_charset(charset)
{
}
class CSSStyleSheet : public StyleSheet
{
public:
- CSSStyleSheet(Node* parentNode, String href = String(), bool _implicit = false);
- CSSStyleSheet(CSSStyleSheet* parentSheet, String href = String());
- CSSStyleSheet(CSSRule* ownerRule, String href = String());
+ CSSStyleSheet(Node* parentNode, const String& href = String(), const String& charset = String());
+ CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href = String(), const String& charset = String());
+ CSSStyleSheet(CSSRule* ownerRule, const String& href = String(), const String& charset = String());
~CSSStyleSheet();
virtual void checkLoaded();
DocLoader* docLoader();
Document* doc() { return m_doc; }
- bool implicit() { return m_implicit; }
+ const String& charset() const { return m_charset; }
protected:
Document* m_doc;
- bool m_implicit;
CSSNamespace* m_namespaces;
+ String m_charset;
};
} // namespace
namespace WebCore {
-StyleSheet::StyleSheet(StyleSheet* parentSheet, String href)
+StyleSheet::StyleSheet(StyleSheet* parentSheet, const String& href)
: StyleList(parentSheet)
, m_parentNode(0)
, m_strHref(href)
}
-StyleSheet::StyleSheet(Node* parentNode, String href)
+StyleSheet::StyleSheet(Node* parentNode, const String& href)
: StyleList(0)
, m_parentNode(parentNode)
, m_strHref(href)
{
}
-StyleSheet::StyleSheet(StyleBase* owner, String href)
+StyleSheet::StyleSheet(StyleBase* owner, const String& href)
: StyleList(owner)
, m_parentNode(0)
, m_strHref(href)
class StyleSheet : public StyleList {
public:
- StyleSheet(Node* ownerNode, String href = String());
- StyleSheet(StyleSheet* parentSheet, String href = String());
- StyleSheet(StyleBase* owner, String href = String());
- StyleSheet(CachedCSSStyleSheet*, String href = String());
+ StyleSheet(Node* ownerNode, const String& href = String());
+ StyleSheet(StyleSheet* parentSheet, const String& href = String());
+ StyleSheet(StyleBase* owner, const String& href = String());
virtual ~StyleSheet();
virtual bool isStyleSheet() const { return true; }
unsigned StyleSheetList::length() const
{
- // hack so implicit BODY stylesheets don't get counted here
- unsigned l = 0;
- DeprecatedPtrListIterator<StyleSheet> it(styleSheets);
- for (; it.current(); ++it) {
- if (!it.current()->isCSSStyleSheet() || !static_cast<CSSStyleSheet*>(it.current())->implicit())
- l++;
- }
- return l;
+ return styleSheets.count();
}
-StyleSheet *StyleSheetList::item (unsigned index)
+StyleSheet* StyleSheetList::item(unsigned index)
{
- unsigned l = 0;
- DeprecatedPtrListIterator<StyleSheet> it(styleSheets);
- for (; it.current(); ++it) {
- if (!it.current()->isCSSStyleSheet() || !static_cast<CSSStyleSheet*>(it.current())->implicit()) {
- if (l == index)
- return it.current();
- l++;
- }
- }
- return 0;
+ return index < length() ? styleSheets.at(index) : 0;
}
}
public:
~StyleSheetList();
- // the following two ignore implicit stylesheets
unsigned length() const;
StyleSheet* item(unsigned index);
m_styleSelector->setEncodedURL(m_url);
}
-void Document::setStyleSheet(const String &url, const String &sheet)
+void Document::setCSSStyleSheet(const String &url, const String& charset, const String &sheet)
{
- m_sheet = new CSSStyleSheet(this, url);
+ m_sheet = new CSSStyleSheet(this, url, charset);
m_sheet->parseString(sheet);
m_loadingSheet = false;
CSSStyleSheet *cssSheet = new CSSStyleSheet(this);
cssSheet->parseString(sheetText);
- pi->setStyleSheet(cssSheet);
+ pi->setCSSStyleSheet(cssSheet);
sheet = cssSheet;
}
}
String completeURL(const String&);
// from cachedObjectClient
- virtual void setStyleSheet(const String& url, const String& sheetStr);
+ virtual void setCSSStyleSheet(const String& url, const String& charset, const String& sheetStr);
void setUserStyleSheet(const String& sheet);
const String& userStyleSheet() const { return m_usersheet; }
void setPrintStyleSheet(const String& sheet) { m_printSheet = sheet; }
#include "Document.h"
#include "DocLoader.h"
#include "ExceptionCode.h"
+#include "Frame.h"
#include "XSLStyleSheet.h"
#include "XMLTokenizer.h" // for parseAttributes()
}
else
{
- // ### some validation on the URL?
- // ### FIXME charset
+ // FIXME: some validation on the URL?
if (document()->frame()) {
m_loading = true;
document()->addPendingSheet();
m_cachedSheet = document()->docLoader()->requestXSLStyleSheet(document()->completeURL(href));
else
#endif
- m_cachedSheet = document()->docLoader()->requestStyleSheet(document()->completeURL(href), String());
+ {
+ String charset = attrs.get("charset");
+ if (charset.isEmpty())
+ charset = document()->frame()->encoding();
+
+ m_cachedSheet = document()->docLoader()->requestCSSStyleSheet(document()->completeURL(href), charset);
+ }
if (m_cachedSheet)
m_cachedSheet->ref( this );
#if XSLT_SUPPORT
document()->stylesheetLoaded();
}
-void ProcessingInstruction::setStyleSheet(const String &url, const String &sheet)
+void ProcessingInstruction::setCSSStyleSheet(const String &url, const String& charset, const String &sheet)
{
+ ASSERT(!m_isXSL);
+ m_sheet = new CSSStyleSheet(this, url, charset);
+ parseStyleSheet(sheet);
+}
+
#if XSLT_SUPPORT
- if (m_isXSL)
- m_sheet = new XSLStyleSheet(this, url);
- else
+void ProcessingInstruction::setXSLStyleSheet(const String &url, const String &sheet)
+{
+ ASSERT(m_isXSL);
+ m_sheet = new XSLStyleSheet(this, url);
+ parseStyleSheet(sheet);
+}
#endif
- m_sheet = new CSSStyleSheet(this, url);
+
+void ProcessingInstruction::parseStyleSheet(const String &sheet)
+{
m_sheet->parseString(sheet);
if (m_cachedSheet)
m_cachedSheet->deref(this);
return result;
}
-void ProcessingInstruction::setStyleSheet(StyleSheet* sheet)
+void ProcessingInstruction::setCSSStyleSheet(CSSStyleSheet* sheet)
{
+ ASSERT(!m_cachedSheet);
+ ASSERT(!m_loading);
m_sheet = sheet;
}
namespace WebCore {
class StyleSheet;
+class CSSStyleSheet;
class ProcessingInstruction : public ContainerNode, private CachedResourceClient
{
String localHref() const { return m_localHref.get(); }
StyleSheet* sheet() const { return m_sheet.get(); }
bool checkStyleSheet();
- virtual void setStyleSheet(const String& URL, const String& sheet);
- void setStyleSheet(StyleSheet*);
+ virtual void setCSSStyleSheet(const String& URL, const String& charset, const String& sheet);
+#if XSLT_SUPPORT
+ virtual void setXSLStyleSheet(const String& URL, const String& sheet);
+#endif
+ void setCSSStyleSheet(CSSStyleSheet*);
bool isLoading() const;
void sheetLoaded();
virtual String toString() const;
#endif
private:
+ void parseStyleSheet(const String& sheet);
+
RefPtr<StringImpl> m_target;
RefPtr<StringImpl> m_data;
RefPtr<StringImpl> m_localHref;
if (!isAlternate())
document()->addPendingSheet();
- DeprecatedString chset = getAttribute(charsetAttr).deprecatedString();
+ String chset = getAttribute(charsetAttr);
+ if (chset.isEmpty() && document()->frame())
+ chset = document()->frame()->encoding();
+
if (m_cachedSheet) {
if (m_loading) {
document()->stylesheetLoaded();
m_cachedSheet->deref(this);
}
m_loading = true;
- m_cachedSheet = document()->docLoader()->requestStyleSheet(m_url, chset);
+ m_cachedSheet = document()->docLoader()->requestCSSStyleSheet(m_url, chset);
if (m_cachedSheet)
m_cachedSheet->ref(this);
}
process();
}
-void HTMLLinkElement::setStyleSheet(const String& url, const String& sheetStr)
+void HTMLLinkElement::setCSSStyleSheet(const String& url, const String& charset, const String& sheetStr)
{
- m_sheet = new CSSStyleSheet(this, url);
+ m_sheet = new CSSStyleSheet(this, url, charset);
m_sheet->parseString(sheetStr, !document()->inCompatMode());
RefPtr<MediaList> media = new MediaList((CSSStyleSheet*)0, m_media, true);
virtual void removedFromDocument();
// from CachedResourceClient
- virtual void setStyleSheet(const String &url, const String &sheet);
+ virtual void setCSSStyleSheet(const String &url, const String& charset, const String &sheet);
bool isLoading() const;
void sheetLoaded();
if (screenEval.eval(media.get()) || printEval.eval(media.get())) {
document()->addPendingSheet();
m_loading = true;
- m_sheet = new CSSStyleSheet(this);
+ m_sheet = new CSSStyleSheet(this, document()->URL(), document()->inputEncoding());
m_sheet->parseString(text, !document()->inCompatMode());
m_sheet->setMedia(media.get());
m_loading = false;
if(m_sheet)
m_sheet = 0;
+ // FIXME: this code should be shared with HTMLStyleElement::childrenChanged()
m_loading = false;
MediaQueryEvaluator screenEval("screen", true);
MediaQueryEvaluator printEval("print", true);
m_loading = true;
- m_sheet = new CSSStyleSheet(this);
+ m_sheet = new CSSStyleSheet(this, document()->URL(), document()->inputEncoding());
m_sheet->parseString(textContent()); // SVG css is always parsed in strict mode
m_sheet->setMedia(mediaList.get());
return static_cast<CachedImage *>(o);
}
-CachedCSSStyleSheet* Cache::requestStyleSheet(DocLoader* dl, const String& url, bool reload, time_t expireDate, const String& charset)
+CachedCSSStyleSheet* Cache::requestCSSStyleSheet(DocLoader* dl, const String& url, bool reload, time_t expireDate, const String& charset)
{
// this brings the _url to a standard form...
KURL kurl;
if (o->type() != CachedResource::CSSStyleSheet)
{
#ifdef CACHE_DEBUG
- kdDebug(6060) << "Cache::Internal Error in requestStyleSheet url=" << kurl.url() << "!" << endl;
+ kdDebug(6060) << "Cache::Internal Error in requestCSSStyleSheet url=" << kurl.url() << "!" << endl;
#endif
return 0;
}
*/
static CachedImage* requestImage(DocLoader*, const String& URL, bool reload = false, time_t expireDate = 0);
static CachedImage* requestImage(DocLoader*, const KURL& URL, bool reload, time_t expireDate);
- static CachedCSSStyleSheet* requestStyleSheet(DocLoader*, const String& URL, bool reload, time_t expireDate, const String& charset);
+ static CachedCSSStyleSheet* requestCSSStyleSheet(DocLoader*, const String& URL, bool reload, time_t expireDate, const String& charset);
static CachedScript* requestScript(DocLoader*, const String& URL, bool reload, time_t expireDate, const String& charset);
#ifdef XSLT_SUPPORT
m_loading = true;
}
-CachedCSSStyleSheet::CachedCSSStyleSheet(const String &url, const String& stylesheet_data)
- : CachedResource(url, CSSStyleSheet, CachePolicyVerify, 0, stylesheet_data.length())
-{
- m_loading = false;
- m_status = Persistent;
- m_sheet = stylesheet_data;
-}
-
CachedCSSStyleSheet::~CachedCSSStyleSheet()
{
}
CachedResource::ref(c);
if (!m_loading)
- c->setStyleSheet(m_url, m_sheet);
+ c->setCSSStyleSheet(m_url, m_decoder->encoding().name(), m_sheet);
}
void CachedCSSStyleSheet::deref(CachedResourceClient *c)
{
Cache::flush();
CachedResource::deref(c);
- if ( canDelete() && m_free )
- delete this;
+ if (canDelete() && m_free)
+ delete this;
}
void CachedCSSStyleSheet::setCharset(const String& chs)
while (CachedResourceClient *c = w.next()) {
#if __APPLE__
if (m_response && !IsResponseURLEqualToURL(m_response, m_url))
- c->setStyleSheet(String(ResponseURL(m_response)), m_sheet);
+ c->setCSSStyleSheet(ResponseURL(m_response), m_decoder->encoding().name(), m_sheet);
else
#endif
- c->setStyleSheet(m_url, m_sheet);
+ c->setCSSStyleSheet(m_url, m_decoder->encoding().name(), m_sheet);
}
}
class CachedCSSStyleSheet : public CachedResource {
public:
CachedCSSStyleSheet(DocLoader*, const String& URL, CachePolicy, time_t expireDate, const String& charset);
- CachedCSSStyleSheet(const String& URL, const String& stylesheetData);
virtual ~CachedCSSStyleSheet();
const String& sheet() const { return m_sheet; }
// e.g., in the b/f cache or in a background tab).
virtual bool willRenderImage(CachedImage*) { return false; }
- virtual void setStyleSheet(const String& /*URL*/, const String& /*sheet*/) { }
+ virtual void setCSSStyleSheet(const String& /*URL*/, const String& /*charset*/, const String& /*sheet*/) { }
+ virtual void setXSLStyleSheet(const String& /*URL*/, const String& /*sheet*/) { }
#ifdef XBL_SUPPORT
virtual void setXBLDocument(const String& /*URL*/, XBL::XBLDocument*) { }
CachedResource::ref(c);
if (!m_loading)
- c->setStyleSheet(m_url, m_sheet);
+ c->setXSLStyleSheet(m_url, m_sheet);
}
void CachedXSLStyleSheet::deref(CachedResourceClient *c)
CachedResourceClientWalker w(m_clients);
while (CachedResourceClient *c = w.next())
- c->setStyleSheet(m_url, m_sheet);
+ c->setXSLStyleSheet(m_url, m_sheet);
}
return cachedObject;
}
-CachedCSSStyleSheet *DocLoader::requestStyleSheet(const String& url, const String& charset)
+CachedCSSStyleSheet *DocLoader::requestCSSStyleSheet(const String& url, const String& charset)
{
KURL fullURL = m_doc->completeURL(url.deprecatedString());
bool reload = needReload(fullURL);
- CachedCSSStyleSheet* cachedObject = Cache::requestStyleSheet(this, url, reload, m_expireDate, charset);
+ CachedCSSStyleSheet* cachedObject = Cache::requestCSSStyleSheet(this, url, reload, m_expireDate, charset);
CheckCacheObjectStatus(this, cachedObject);
return cachedObject;
}
~DocLoader();
CachedImage* requestImage(const String& url);
- CachedCSSStyleSheet* requestStyleSheet(const String& url, const String& charset);
+ CachedCSSStyleSheet* requestCSSStyleSheet(const String& url, const String& charset);
CachedScript* requestScript(const String& url, const String& charset);
#ifdef XSLT_SUPPORT
public:
UserStyleSheetLoader(Frame* frame, const String& url, DocLoader* dl)
: m_frame(frame)
- , m_cachedSheet(Cache::requestStyleSheet(dl, url, false, 0, ""))
+ , m_cachedSheet(Cache::requestCSSStyleSheet(dl, url, false, 0, ""))
{
m_cachedSheet->ref(this);
}
m_cachedSheet->deref(this);
}
private:
- virtual void setStyleSheet(const String& /*URL*/, const String& sheet)
+ virtual void setCSSStyleSheet(const String& /*URL*/, const String& /*charset*/, const String& sheet)
{
m_frame->setUserStyleSheet(sheet);
}
return (parent() && parent()->isXSLStyleSheet()) ? static_cast<XSLStyleSheet*>(parent()) : 0;
}
-void XSLImportRule::setStyleSheet(const String& url, const String& sheet)
+void XSLImportRule::setXSLStyleSheet(const String& url, const String& sheet)
{
if (m_styleSheet)
m_styleSheet->setParent(0);
if (m_cachedSheet) {
m_cachedSheet->ref(this);
- // If the imported sheet is in the cache, then setStyleSheet gets called,
+ // If the imported sheet is in the cache, then setXSLStyleSheet gets called,
// and the sheet even gets parsed (via parseString). In this case we have
// loaded (even if our subresources haven't), so if we have a stylesheet after
// checking the cache, then we've clearly loaded.
XSLStyleSheet* parentStyleSheet() const;
// from CachedResourceClient
- virtual void setStyleSheet(const String& url, const String& sheet);
+ virtual void setXSLStyleSheet(const String& url, const String& sheet);
bool isLoading();
void loadSheet();