Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: Source/WebCore/css/CSSStyleSheet.cpp

Issue 6483001: Merge 76728 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/648/
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/WebCore/css/CSSStyleSheet.h ('k') | Source/WebCore/xml/XSLStyleSheet.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)
57 , m_charset(charset) 56 , m_charset(charset)
58 , m_loadCompleted(false) 57 , m_loadCompleted(false)
59 , m_strictParsing(!parentSheet || parentSheet->useStrictParsing()) 58 , m_strictParsing(!parentSheet || parentSheet->useStrictParsing())
60 , m_isUserStyleSheet(parentSheet ? parentSheet->isUserStyleSheet() : false) 59 , m_isUserStyleSheet(parentSheet ? parentSheet->isUserStyleSheet() : false)
61 , m_hasSyntacticallyValidCSSHeader(true) 60 , m_hasSyntacticallyValidCSSHeader(true)
62 { 61 {
63 } 62 }
64 63
65 CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& b aseURL, const String& charset) 64 CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& b aseURL, const String& charset)
66 : StyleSheet(parentNode, href, baseURL) 65 : StyleSheet(parentNode, href, baseURL)
67 , m_document(parentNode->document())
68 , m_charset(charset) 66 , m_charset(charset)
69 , m_loadCompleted(false) 67 , m_loadCompleted(false)
70 , m_strictParsing(false) 68 , m_strictParsing(false)
71 , m_isUserStyleSheet(false) 69 , m_isUserStyleSheet(false)
72 , m_hasSyntacticallyValidCSSHeader(true) 70 , m_hasSyntacticallyValidCSSHeader(true)
73 { 71 {
74 ASSERT(isAcceptableCSSStyleSheetParent(parentNode)); 72 ASSERT(isAcceptableCSSStyleSheetParent(parentNode));
75 } 73 }
76 74
77 CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const KURL& baseURL, const String& charset) 75 CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const KURL& baseURL, const String& charset)
78 : StyleSheet(ownerRule, href, baseURL) 76 : StyleSheet(ownerRule, href, baseURL)
79 , m_charset(charset) 77 , m_charset(charset)
80 , m_loadCompleted(false) 78 , m_loadCompleted(false)
81 , m_strictParsing(!ownerRule || ownerRule->useStrictParsing()) 79 , m_strictParsing(!ownerRule || ownerRule->useStrictParsing())
82 , m_hasSyntacticallyValidCSSHeader(true) 80 , m_hasSyntacticallyValidCSSHeader(true)
83 { 81 {
84 CSSStyleSheet* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0; 82 CSSStyleSheet* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0;
85 m_document = parentSheet ? parentSheet->document() : 0;
86 m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false; 83 m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false;
87 } 84 }
88 85
89 CSSStyleSheet::~CSSStyleSheet() 86 CSSStyleSheet::~CSSStyleSheet()
90 { 87 {
91 } 88 }
92 89
93 CSSRule *CSSStyleSheet::ownerRule() const 90 CSSRule *CSSStyleSheet::ownerRule() const
94 { 91 {
95 return (parent() && parent()->isRule()) ? static_cast<CSSRule*>(parent()) : 0; 92 return (parent() && parent()->isRule()) ? static_cast<CSSRule*>(parent()) : 0;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 if (parent()) 223 if (parent())
227 parent()->checkLoaded(); 224 parent()->checkLoaded();
228 225
229 // Avoid |this| being deleted by scripts that run via 226 // Avoid |this| being deleted by scripts that run via
230 // ScriptableDocumentParser::executeScriptsWaitingForStylesheets(). 227 // ScriptableDocumentParser::executeScriptsWaitingForStylesheets().
231 // See <rdar://problem/6622300>. 228 // See <rdar://problem/6622300>.
232 RefPtr<CSSStyleSheet> protector(this); 229 RefPtr<CSSStyleSheet> protector(this);
233 m_loadCompleted = ownerNode() ? ownerNode()->sheetLoaded() : true; 230 m_loadCompleted = ownerNode() ? ownerNode()->sheetLoaded() : true;
234 } 231 }
235 232
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
236 void CSSStyleSheet::styleSheetChanged() 251 void CSSStyleSheet::styleSheetChanged()
237 { 252 {
238 StyleBase* root = this; 253 StyleBase* root = this;
239 while (StyleBase* parent = root->parent()) 254 while (StyleBase* parent = root->parent())
240 root = parent; 255 root = parent;
241 Document* documentToUpdate = root->isCSSStyleSheet() ? static_cast<CSSStyleS heet*>(root)->document() : 0; 256 Document* documentToUpdate = root->isCSSStyleSheet() ? static_cast<CSSStyleS heet*>(root)->document() : 0;
242 257
243 /* FIXME: We don't need to do everything updateStyleSelector does, 258 /* FIXME: We don't need to do everything updateStyleSelector does,
244 * basically we just need to recreate the document's selector with the 259 * basically we just need to recreate the document's selector with the
245 * already existing style sheets. 260 * already existing style sheets.
(...skipping 30 matching lines...) Expand all
276 if (rule->isImportRule()) { 291 if (rule->isImportRule()) {
277 if (CSSStyleSheet* ruleStyleSheet = static_cast<CSSImportRule*>( rule)->styleSheet()) 292 if (CSSStyleSheet* ruleStyleSheet = static_cast<CSSImportRule*>( rule)->styleSheet())
278 styleSheetQueue.append(ruleStyleSheet); 293 styleSheetQueue.append(ruleStyleSheet);
279 } 294 }
280 rule->addSubresourceStyleURLs(urls); 295 rule->addSubresourceStyleURLs(urls);
281 } 296 }
282 } 297 }
283 } 298 }
284 299
285 } 300 }
OLDNEW
« no previous file with comments | « Source/WebCore/css/CSSStyleSheet.h ('k') | Source/WebCore/xml/XSLStyleSheet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698