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

Side by Side Diff: Source/core/dom/StyleElement.cpp

Issue 23516012: Rename StyleSheetCollections to StyleEngine. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ShadowTreeStyleSheetCollection.cpp ('k') | Source/core/dom/StyleEngine.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 * Copyright (C) 2006, 2007 Rob Buis 2 * Copyright (C) 2006, 2007 Rob Buis
3 * Copyright (C) 2008 Apple, Inc. All rights reserved. 3 * Copyright (C) 2008 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,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #include "config.h" 21 #include "config.h"
22 #include "core/dom/StyleElement.h" 22 #include "core/dom/StyleElement.h"
23 23
24 #include "core/css/MediaList.h" 24 #include "core/css/MediaList.h"
25 #include "core/css/MediaQueryEvaluator.h" 25 #include "core/css/MediaQueryEvaluator.h"
26 #include "core/css/StyleSheetContents.h" 26 #include "core/css/StyleSheetContents.h"
27 #include "core/dom/Document.h" 27 #include "core/dom/Document.h"
28 #include "core/dom/Element.h" 28 #include "core/dom/Element.h"
29 #include "core/dom/ScriptableDocumentParser.h" 29 #include "core/dom/ScriptableDocumentParser.h"
30 #include "core/dom/StyleSheetCollections.h" 30 #include "core/dom/StyleEngine.h"
31 #include "core/html/HTMLStyleElement.h" 31 #include "core/html/HTMLStyleElement.h"
32 #include "core/page/ContentSecurityPolicy.h" 32 #include "core/page/ContentSecurityPolicy.h"
33 #include "wtf/text/StringBuilder.h" 33 #include "wtf/text/StringBuilder.h"
34 #include "wtf/text/TextPosition.h" 34 #include "wtf/text/TextPosition.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 static bool isCSS(Element* element, const AtomicString& type) 38 static bool isCSS(Element* element, const AtomicString& type)
39 { 39 {
40 return type.isEmpty() || (element->isHTMLElement() ? equalIgnoringCase(type, "text/css") : (type == "text/css")); 40 return type.isEmpty() || (element->isHTMLElement() ? equalIgnoringCase(type, "text/css") : (type == "text/css"));
(...skipping 10 matching lines...) Expand all
51 51
52 StyleElement::~StyleElement() 52 StyleElement::~StyleElement()
53 { 53 {
54 if (m_sheet) 54 if (m_sheet)
55 clearSheet(); 55 clearSheet();
56 } 56 }
57 57
58 void StyleElement::processStyleSheet(Document& document, Element* element) 58 void StyleElement::processStyleSheet(Document& document, Element* element)
59 { 59 {
60 ASSERT(element); 60 ASSERT(element);
61 document.styleSheetCollections()->addStyleSheetCandidateNode(element, m_crea tedByParser); 61 document.styleEngine()->addStyleSheetCandidateNode(element, m_createdByParse r);
62 if (m_createdByParser) 62 if (m_createdByParser)
63 return; 63 return;
64 64
65 process(element); 65 process(element);
66 } 66 }
67 67
68 void StyleElement::removedFromDocument(Document& document, Element* element, Con tainerNode* scopingNode) 68 void StyleElement::removedFromDocument(Document& document, Element* element, Con tainerNode* scopingNode)
69 { 69 {
70 ASSERT(element); 70 ASSERT(element);
71 document.styleSheetCollections()->removeStyleSheetCandidateNode(element, sco pingNode); 71 document.styleEngine()->removeStyleSheetCandidateNode(element, scopingNode);
72 72
73 RefPtr<StyleSheet> removedSheet = m_sheet; 73 RefPtr<StyleSheet> removedSheet = m_sheet;
74 74
75 if (m_sheet) 75 if (m_sheet)
76 clearSheet(); 76 clearSheet();
77 77
78 // If we're in document teardown, then we don't need to do any notification of our sheet's removal. 78 // If we're in document teardown, then we don't need to do any notification of our sheet's removal.
79 if (document.renderer()) 79 if (document.renderer())
80 document.removedStyleSheet(removedSheet.get()); 80 document.removedStyleSheet(removedSheet.get());
81 } 81 }
82 82
83 void StyleElement::clearDocumentData(Document& document, Element* element) 83 void StyleElement::clearDocumentData(Document& document, Element* element)
84 { 84 {
85 if (m_sheet) 85 if (m_sheet)
86 m_sheet->clearOwnerNode(); 86 m_sheet->clearOwnerNode();
87 87
88 if (element->inDocument()) 88 if (element->inDocument())
89 document.styleSheetCollections()->removeStyleSheetCandidateNode(element, isHTMLStyleElement(element) ? toHTMLStyleElement(element)->scopingNode() : 0); 89 document.styleEngine()->removeStyleSheetCandidateNode(element, isHTMLSty leElement(element) ? toHTMLStyleElement(element)->scopingNode() : 0);
90 } 90 }
91 91
92 void StyleElement::childrenChanged(Element* element) 92 void StyleElement::childrenChanged(Element* element)
93 { 93 {
94 ASSERT(element); 94 ASSERT(element);
95 if (m_createdByParser) 95 if (m_createdByParser)
96 return; 96 return;
97 97
98 process(element); 98 process(element);
99 } 99 }
(...skipping 18 matching lines...) Expand all
118 m_sheet.release()->clearOwnerNode(); 118 m_sheet.release()->clearOwnerNode();
119 } 119 }
120 120
121 void StyleElement::createSheet(Element* e, const String& text) 121 void StyleElement::createSheet(Element* e, const String& text)
122 { 122 {
123 ASSERT(e); 123 ASSERT(e);
124 ASSERT(e->inDocument()); 124 ASSERT(e->inDocument());
125 Document& document = e->document(); 125 Document& document = e->document();
126 if (m_sheet) { 126 if (m_sheet) {
127 if (m_sheet->isLoading()) 127 if (m_sheet->isLoading())
128 document.styleSheetCollections()->removePendingSheet(e); 128 document.styleEngine()->removePendingSheet(e);
129 clearSheet(); 129 clearSheet();
130 } 130 }
131 131
132 // If type is empty or CSS, this is a CSS style sheet. 132 // If type is empty or CSS, this is a CSS style sheet.
133 const AtomicString& type = this->type(); 133 const AtomicString& type = this->type();
134 if (document.contentSecurityPolicy()->allowInlineStyle(e->document().url(), m_startPosition.m_line) && isCSS(e, type)) { 134 if (document.contentSecurityPolicy()->allowInlineStyle(e->document().url(), m_startPosition.m_line) && isCSS(e, type)) {
135 RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(media()); 135 RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(media());
136 136
137 MediaQueryEvaluator screenEval("screen", true); 137 MediaQueryEvaluator screenEval("screen", true);
138 MediaQueryEvaluator printEval("print", true); 138 MediaQueryEvaluator printEval("print", true);
139 if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.g et())) { 139 if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.g et())) {
140 document.styleSheetCollections()->addPendingSheet(); 140 document.styleEngine()->addPendingSheet();
141 m_loading = true; 141 m_loading = true;
142 142
143 TextPosition startPosition = m_startPosition == TextPosition::belowR angePosition() ? TextPosition::minimumPosition() : m_startPosition; 143 TextPosition startPosition = m_startPosition == TextPosition::belowR angePosition() ? TextPosition::minimumPosition() : m_startPosition;
144 m_sheet = CSSStyleSheet::createInline(e, KURL(), startPosition, docu ment.inputEncoding()); 144 m_sheet = CSSStyleSheet::createInline(e, KURL(), startPosition, docu ment.inputEncoding());
145 m_sheet->setMediaQueries(mediaQueries.release()); 145 m_sheet->setMediaQueries(mediaQueries.release());
146 m_sheet->setTitle(e->title()); 146 m_sheet->setTitle(e->title());
147 m_sheet->contents()->parseStringAtPosition(text, startPosition, m_cr eatedByParser); 147 m_sheet->contents()->parseStringAtPosition(text, startPosition, m_cr eatedByParser);
148 148
149 m_loading = false; 149 m_loading = false;
150 } 150 }
151 } 151 }
152 152
153 if (m_sheet) 153 if (m_sheet)
154 m_sheet->contents()->checkLoaded(); 154 m_sheet->contents()->checkLoaded();
155 } 155 }
156 156
157 bool StyleElement::isLoading() const 157 bool StyleElement::isLoading() const
158 { 158 {
159 if (m_loading) 159 if (m_loading)
160 return true; 160 return true;
161 return m_sheet ? m_sheet->isLoading() : false; 161 return m_sheet ? m_sheet->isLoading() : false;
162 } 162 }
163 163
164 bool StyleElement::sheetLoaded(Document& document) 164 bool StyleElement::sheetLoaded(Document& document)
165 { 165 {
166 if (isLoading()) 166 if (isLoading())
167 return false; 167 return false;
168 168
169 document.styleSheetCollections()->removePendingSheet(m_sheet->ownerNode()); 169 document.styleEngine()->removePendingSheet(m_sheet->ownerNode());
170 return true; 170 return true;
171 } 171 }
172 172
173 void StyleElement::startLoadingDynamicSheet(Document& document) 173 void StyleElement::startLoadingDynamicSheet(Document& document)
174 { 174 {
175 document.styleSheetCollections()->addPendingSheet(); 175 document.styleEngine()->addPendingSheet();
176 } 176 }
177 177
178 } 178 }
OLDNEW
« no previous file with comments | « Source/core/dom/ShadowTreeStyleSheetCollection.cpp ('k') | Source/core/dom/StyleEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698