Index: Source/WebCore/css/CSSStyleSheet.cpp |
=================================================================== |
--- Source/WebCore/css/CSSStyleSheet.cpp (revision 78109) |
+++ Source/WebCore/css/CSSStyleSheet.cpp (working copy) |
@@ -53,7 +53,6 @@ |
CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const KURL& baseURL, const String& charset) |
: StyleSheet(parentSheet, href, baseURL) |
- , m_document(parentSheet ? parentSheet->document() : 0) |
, m_charset(charset) |
, m_loadCompleted(false) |
, m_strictParsing(!parentSheet || parentSheet->useStrictParsing()) |
@@ -64,7 +63,6 @@ |
CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, const String& charset) |
: StyleSheet(parentNode, href, baseURL) |
- , m_document(parentNode->document()) |
, m_charset(charset) |
, m_loadCompleted(false) |
, m_strictParsing(false) |
@@ -82,7 +80,6 @@ |
, m_hasSyntacticallyValidCSSHeader(true) |
{ |
CSSStyleSheet* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0; |
- m_document = parentSheet ? parentSheet->document() : 0; |
m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false; |
} |
@@ -233,6 +230,24 @@ |
m_loadCompleted = ownerNode() ? ownerNode()->sheetLoaded() : true; |
} |
+Document* CSSStyleSheet::document() |
+{ |
+ StyleBase* styleObject = this; |
+ while (styleObject) { |
+ if (styleObject->isCSSStyleSheet()) { |
+ Node* ownerNode = static_cast<CSSStyleSheet*>(styleObject)->ownerNode(); |
+ if (ownerNode) |
+ return ownerNode->document(); |
+ } |
+ if (styleObject->isRule()) |
+ styleObject = static_cast<CSSRule*>(styleObject)->parentStyleSheet(); |
+ else |
+ styleObject = styleObject->parent(); |
+ } |
+ |
+ return 0; |
+} |
+ |
void CSSStyleSheet::styleSheetChanged() |
{ |
StyleBase* root = this; |