Commit 1cfc800e authored by hyatt@apple.com's avatar hyatt@apple.com

https://bugs.webkit.org/show_bug.cgi?id=24399

Make @import work in user stylesheets.  The first bug was that the URL wasn't being set on the
user sheets themselves, so relative @import URLs couldn't resolve properly.  The second bug
was that the loads would be denied.  This is fixed by using the requestUserCSSStyleSheet method
instead of the normal request method.  In order to know when to do this, CSSStyleSheets now have
a propagated boolean, m_isUserStyleSheet, that lets them know if they are user stylesheets or not.

Reviewed by Anders Carlsson.

* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::insertedIntoParent):
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::CSSStyleSheet):
* css/CSSStyleSheet.h:
(WebCore::CSSStyleSheet::setIsUserStyleSheet):
(WebCore::CSSStyleSheet::isUserStyleSheet):
* dom/Document.cpp:
(WebCore::Document::pageUserSheet):
(WebCore::Document::pageGroupUserSheets):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48773 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 89ebda16
2009-09-25 Dave Hyatt <hyatt@apple.com>
Reviewed by Anders Carlsson.
https://bugs.webkit.org/show_bug.cgi?id=24399
Make @import work in user stylesheets. The first bug was that the URL wasn't being set on the
user sheets themselves, so relative @import URLs couldn't resolve properly. The second bug
was that the loads would be denied. This is fixed by using the requestUserCSSStyleSheet method
instead of the normal request method. In order to know when to do this, CSSStyleSheets now have
a propagated boolean, m_isUserStyleSheet, that lets them know if they are user stylesheets or not.
* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::insertedIntoParent):
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::CSSStyleSheet):
* css/CSSStyleSheet.h:
(WebCore::CSSStyleSheet::setIsUserStyleSheet):
(WebCore::CSSStyleSheet::isUserStyleSheet):
* dom/Document.cpp:
(WebCore::Document::pageUserSheet):
(WebCore::Document::pageGroupUserSheets):
2009-09-25 Simon Fraser <simon.fraser@apple.com>
Reviewed by Darin Adler.
......@@ -111,7 +111,10 @@ void CSSImportRule::insertedIntoParent()
root = curr;
}
m_cachedSheet = docLoader->requestCSSStyleSheet(absHref, parentSheet->charset());
if (parentSheet->isUserStyleSheet())
m_cachedSheet = docLoader->requestUserCSSStyleSheet(absHref, parentSheet->charset());
else
m_cachedSheet = docLoader->requestCSSStyleSheet(absHref, parentSheet->charset());
if (m_cachedSheet) {
// if the import rule is issued dynamically, the sheet may be
// removed from the pending sheet count, so let the doc know
......
......@@ -40,20 +40,22 @@ CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, con
, m_charset(charset)
, m_loadCompleted(false)
, m_strictParsing(!parentSheet || parentSheet->useStrictParsing())
, m_isUserStyleSheet(parentSheet ? parentSheet->isUserStyleSheet() : false)
{
}
CSSStyleSheet::CSSStyleSheet(Node *parentNode, const String& href, const String& charset)
CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const String& charset)
: StyleSheet(parentNode, href)
, m_doc(parentNode->document())
, m_namespaces(0)
, m_charset(charset)
, m_loadCompleted(false)
, m_strictParsing(false)
, m_isUserStyleSheet(false)
{
}
CSSStyleSheet::CSSStyleSheet(CSSRule *ownerRule, const String& href, const String& charset)
CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const String& charset)
: StyleSheet(ownerRule, href)
, m_namespaces(0)
, m_charset(charset)
......@@ -62,6 +64,7 @@ CSSStyleSheet::CSSStyleSheet(CSSRule *ownerRule, const String& href, const Strin
{
CSSStyleSheet* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0;
m_doc = parentSheet ? parentSheet->doc() : 0;
m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false;
}
CSSStyleSheet::~CSSStyleSheet()
......
......@@ -93,6 +93,9 @@ public:
void setStrictParsing(bool b) { m_strictParsing = b; }
bool useStrictParsing() const { return m_strictParsing; }
void setIsUserStyleSheet(bool b) { m_isUserStyleSheet = b; }
bool isUserStyleSheet() const { return m_isUserStyleSheet; }
private:
CSSStyleSheet(Node* ownerNode, const String& href, const String& charset);
CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const String& charset);
......@@ -106,6 +109,7 @@ private:
String m_charset;
bool m_loadCompleted : 1;
bool m_strictParsing : 1;
bool m_isUserStyleSheet : 1;
};
} // namespace
......
......@@ -1941,7 +1941,8 @@ CSSStyleSheet* Document::pageUserSheet()
return 0;
// Parse the sheet and cache it.
m_pageUserSheet = CSSStyleSheet::create(this);
m_pageUserSheet = CSSStyleSheet::create(this, settings()->userStyleSheetLocation());
m_pageUserSheet->setIsUserStyleSheet(true);
m_pageUserSheet->parseString(userSheetText, !inCompatMode());
return m_pageUserSheet.get();
}
......@@ -1973,7 +1974,8 @@ const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
const UserStyleSheetVector* sheets = it->second;
for (unsigned i = 0; i < sheets->size(); ++i) {
const UserStyleSheet* sheet = sheets->at(i).get();
RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::create(const_cast<Document*>(this));
RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::create(const_cast<Document*>(this), sheet->url());
parsedSheet->setIsUserStyleSheet(true);
parsedSheet->parseString(sheet->source(), !inCompatMode());
if (!m_pageGroupUserSheets)
m_pageGroupUserSheets.set(new Vector<RefPtr<CSSStyleSheet> >);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment