| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 || parentNode->hasTagName(HTMLNames::styleTag) | 46 || parentNode->hasTagName(HTMLNames::styleTag) |
| 47 #if ENABLE(SVG) | 47 #if ENABLE(SVG) |
| 48 || parentNode->hasTagName(SVGNames::styleTag) | 48 || parentNode->hasTagName(SVGNames::styleTag) |
| 49 #endif | 49 #endif |
| 50 || parentNode->nodeType() == Node::PROCESSING_INSTRUCTION_NODE; | 50 || parentNode->nodeType() == Node::PROCESSING_INSTRUCTION_NODE; |
| 51 } | 51 } |
| 52 #endif | 52 #endif |
| 53 | 53 |
| 54 CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, con
st KURL& baseURL, const String& charset) | 54 CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, con
st KURL& baseURL, const String& charset) |
| 55 : StyleSheet(parentSheet, href, baseURL) | 55 : StyleSheet(parentSheet, href, baseURL) |
| 56 , m_document(parentSheet ? parentSheet->document() : 0) |
| 56 , m_charset(charset) | 57 , m_charset(charset) |
| 57 , m_loadCompleted(false) | 58 , m_loadCompleted(false) |
| 58 , m_strictParsing(!parentSheet || parentSheet->useStrictParsing()) | 59 , m_strictParsing(!parentSheet || parentSheet->useStrictParsing()) |
| 59 , m_isUserStyleSheet(parentSheet ? parentSheet->isUserStyleSheet() : false) | 60 , m_isUserStyleSheet(parentSheet ? parentSheet->isUserStyleSheet() : false) |
| 60 , m_hasSyntacticallyValidCSSHeader(true) | 61 , m_hasSyntacticallyValidCSSHeader(true) |
| 61 { | 62 { |
| 62 } | 63 } |
| 63 | 64 |
| 64 CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& b
aseURL, const String& charset) | 65 CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& b
aseURL, const String& charset) |
| 65 : StyleSheet(parentNode, href, baseURL) | 66 : StyleSheet(parentNode, href, baseURL) |
| 67 , m_document(parentNode->document()) |
| 66 , m_charset(charset) | 68 , m_charset(charset) |
| 67 , m_loadCompleted(false) | 69 , m_loadCompleted(false) |
| 68 , m_strictParsing(false) | 70 , m_strictParsing(false) |
| 69 , m_isUserStyleSheet(false) | 71 , m_isUserStyleSheet(false) |
| 70 , m_hasSyntacticallyValidCSSHeader(true) | 72 , m_hasSyntacticallyValidCSSHeader(true) |
| 71 { | 73 { |
| 72 ASSERT(isAcceptableCSSStyleSheetParent(parentNode)); | 74 ASSERT(isAcceptableCSSStyleSheetParent(parentNode)); |
| 73 } | 75 } |
| 74 | 76 |
| 75 CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const KURL&
baseURL, const String& charset) | 77 CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const KURL&
baseURL, const String& charset) |
| 76 : StyleSheet(ownerRule, href, baseURL) | 78 : StyleSheet(ownerRule, href, baseURL) |
| 77 , m_charset(charset) | 79 , m_charset(charset) |
| 78 , m_loadCompleted(false) | 80 , m_loadCompleted(false) |
| 79 , m_strictParsing(!ownerRule || ownerRule->useStrictParsing()) | 81 , m_strictParsing(!ownerRule || ownerRule->useStrictParsing()) |
| 80 , m_hasSyntacticallyValidCSSHeader(true) | 82 , m_hasSyntacticallyValidCSSHeader(true) |
| 81 { | 83 { |
| 82 CSSStyleSheet* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0; | 84 CSSStyleSheet* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0; |
| 85 m_document = parentSheet ? parentSheet->document() : 0; |
| 83 m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false; | 86 m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false; |
| 84 } | 87 } |
| 85 | 88 |
| 86 CSSStyleSheet::~CSSStyleSheet() | 89 CSSStyleSheet::~CSSStyleSheet() |
| 87 { | 90 { |
| 88 } | 91 } |
| 89 | 92 |
| 90 CSSRule *CSSStyleSheet::ownerRule() const | 93 CSSRule *CSSStyleSheet::ownerRule() const |
| 91 { | 94 { |
| 92 return (parent() && parent()->isRule()) ? static_cast<CSSRule*>(parent()) :
0; | 95 return (parent() && parent()->isRule()) ? static_cast<CSSRule*>(parent()) :
0; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 if (parent()) | 226 if (parent()) |
| 224 parent()->checkLoaded(); | 227 parent()->checkLoaded(); |
| 225 | 228 |
| 226 // Avoid |this| being deleted by scripts that run via | 229 // Avoid |this| being deleted by scripts that run via |
| 227 // ScriptableDocumentParser::executeScriptsWaitingForStylesheets(). | 230 // ScriptableDocumentParser::executeScriptsWaitingForStylesheets(). |
| 228 // See <rdar://problem/6622300>. | 231 // See <rdar://problem/6622300>. |
| 229 RefPtr<CSSStyleSheet> protector(this); | 232 RefPtr<CSSStyleSheet> protector(this); |
| 230 m_loadCompleted = ownerNode() ? ownerNode()->sheetLoaded() : true; | 233 m_loadCompleted = ownerNode() ? ownerNode()->sheetLoaded() : true; |
| 231 } | 234 } |
| 232 | 235 |
| 233 Document* CSSStyleSheet::document() | |
| 234 { | |
| 235 StyleBase* styleObject = this; | |
| 236 while (styleObject) { | |
| 237 if (styleObject->isCSSStyleSheet()) { | |
| 238 Node* ownerNode = static_cast<CSSStyleSheet*>(styleObject)->ownerNod
e(); | |
| 239 if (ownerNode) | |
| 240 return ownerNode->document(); | |
| 241 } | |
| 242 if (styleObject->isRule()) | |
| 243 styleObject = static_cast<CSSRule*>(styleObject)->parentStyleSheet()
; | |
| 244 else | |
| 245 styleObject = styleObject->parent(); | |
| 246 } | |
| 247 | |
| 248 return 0; | |
| 249 } | |
| 250 | |
| 251 void CSSStyleSheet::styleSheetChanged() | 236 void CSSStyleSheet::styleSheetChanged() |
| 252 { | 237 { |
| 253 StyleBase* root = this; | 238 StyleBase* root = this; |
| 254 while (StyleBase* parent = root->parent()) | 239 while (StyleBase* parent = root->parent()) |
| 255 root = parent; | 240 root = parent; |
| 256 Document* documentToUpdate = root->isCSSStyleSheet() ? static_cast<CSSStyleS
heet*>(root)->document() : 0; | 241 Document* documentToUpdate = root->isCSSStyleSheet() ? static_cast<CSSStyleS
heet*>(root)->document() : 0; |
| 257 | 242 |
| 258 /* FIXME: We don't need to do everything updateStyleSelector does, | 243 /* FIXME: We don't need to do everything updateStyleSelector does, |
| 259 * basically we just need to recreate the document's selector with the | 244 * basically we just need to recreate the document's selector with the |
| 260 * already existing style sheets. | 245 * already existing style sheets. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 291 if (rule->isImportRule()) { | 276 if (rule->isImportRule()) { |
| 292 if (CSSStyleSheet* ruleStyleSheet = static_cast<CSSImportRule*>(
rule)->styleSheet()) | 277 if (CSSStyleSheet* ruleStyleSheet = static_cast<CSSImportRule*>(
rule)->styleSheet()) |
| 293 styleSheetQueue.append(ruleStyleSheet); | 278 styleSheetQueue.append(ruleStyleSheet); |
| 294 } | 279 } |
| 295 rule->addSubresourceStyleURLs(urls); | 280 rule->addSubresourceStyleURLs(urls); |
| 296 } | 281 } |
| 297 } | 282 } |
| 298 } | 283 } |
| 299 | 284 |
| 300 } | 285 } |
| OLD | NEW |