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

Side by Side Diff: sky/engine/core/dom/StyleEngine.cpp

Issue 775783002: Remove dead code from StyleEngine. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « sky/engine/core/dom/StyleEngine.h ('k') | no next file » | 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 146 }
147 147
148 const Vector<RefPtr<StyleSheet> >& StyleEngine::styleSheetsForStyleSheetList(Tre eScope& treeScope) 148 const Vector<RefPtr<StyleSheet> >& StyleEngine::styleSheetsForStyleSheetList(Tre eScope& treeScope)
149 { 149 {
150 if (treeScope == m_document) 150 if (treeScope == m_document)
151 return documentStyleSheetCollection()->styleSheetsForStyleSheetList(); 151 return documentStyleSheetCollection()->styleSheetsForStyleSheetList();
152 152
153 return ensureStyleSheetCollectionFor(treeScope)->styleSheetsForStyleSheetLis t(); 153 return ensureStyleSheetCollectionFor(treeScope)->styleSheetsForStyleSheetLis t();
154 } 154 }
155 155
156 const Vector<RefPtr<CSSStyleSheet> >& StyleEngine::activeAuthorStyleSheets() con st
157 {
158 return documentStyleSheetCollection()->activeAuthorStyleSheets();
159 }
160
161 void StyleEngine::modifiedStyleSheet(StyleSheet* sheet) 156 void StyleEngine::modifiedStyleSheet(StyleSheet* sheet)
162 { 157 {
163 if (!sheet) 158 if (!sheet)
164 return; 159 return;
165 160
166 Node* node = sheet->ownerNode(); 161 Node* node = sheet->ownerNode();
167 if (!node || !node->inDocument()) 162 if (!node || !node->inDocument())
168 return; 163 return;
169 164
170 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do cument; 165 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do cument;
(...skipping 11 matching lines...) Expand all
182 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); 177 ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
183 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr eeScope); 178 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr eeScope);
184 ASSERT(collection); 179 ASSERT(collection);
185 collection->addStyleSheetCandidateNode(node, createdByParser); 180 collection->addStyleSheetCandidateNode(node, createdByParser);
186 181
187 markTreeScopeDirty(treeScope); 182 markTreeScopeDirty(treeScope);
188 if (treeScope != m_document) 183 if (treeScope != m_document)
189 insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope); 184 insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope);
190 } 185 }
191 186
192 void StyleEngine::removeStyleSheetCandidateNode(Node* node)
193 {
194 removeStyleSheetCandidateNode(node, 0, *m_document);
195 }
196
197 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi ngNode, TreeScope& treeScope) 187 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi ngNode, TreeScope& treeScope)
198 { 188 {
199 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); 189 ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
200 190
201 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop e); 191 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop e);
202 ASSERT(collection); 192 ASSERT(collection);
203 collection->removeStyleSheetCandidateNode(node, scopingNode); 193 collection->removeStyleSheetCandidateNode(node, scopingNode);
204 194
205 markTreeScopeDirty(treeScope); 195 markTreeScopeDirty(treeScope);
206 m_activeTreeScopes.remove(&treeScope); 196 m_activeTreeScopes.remove(&treeScope);
207 } 197 }
208 198
209 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node)
210 {
211 if (!node->inDocument())
212 return;
213
214 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do cument;
215 ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
216 markTreeScopeDirty(treeScope);
217 }
218
219 bool StyleEngine::shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMo de updateMode) const 199 bool StyleEngine::shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMo de updateMode) const
220 { 200 {
221 return m_documentScopeDirty || updateMode == FullStyleUpdate; 201 return m_documentScopeDirty || updateMode == FullStyleUpdate;
222 } 202 }
223 203
224 bool StyleEngine::shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdate Mode updateMode) const 204 bool StyleEngine::shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdate Mode updateMode) const
225 { 205 {
226 return !m_dirtyTreeScopes.isEmpty() || updateMode == FullStyleUpdate; 206 return !m_dirtyTreeScopes.isEmpty() || updateMode == FullStyleUpdate;
227 } 207 }
228 208
229 void StyleEngine::clearMediaQueryRuleSetOnTreeScopeStyleSheets(TreeScopeSet tree Scopes) 209 void StyleEngine::clearMediaQueryRuleSetOnTreeScopeStyleSheets(TreeScopeSet tree Scopes)
230 { 210 {
231 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end(); ++it) { 211 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end(); ++it) {
232 TreeScope& treeScope = **it; 212 TreeScope& treeScope = **it;
233 ASSERT(treeScope != m_document); 213 ASSERT(treeScope != m_document);
234 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyle SheetCollection*>(styleSheetCollectionFor(treeScope)); 214 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyle SheetCollection*>(styleSheetCollectionFor(treeScope));
235 ASSERT(collection); 215 ASSERT(collection);
236 collection->clearMediaQueryRuleSetStyleSheets(); 216 collection->clearMediaQueryRuleSetStyleSheets();
237 } 217 }
238 } 218 }
239 219
240 void StyleEngine::clearMediaQueryRuleSetStyleSheets() 220 void StyleEngine::clearMediaQueryRuleSetStyleSheets()
241 { 221 {
242 documentStyleSheetCollection()->clearMediaQueryRuleSetStyleSheets(); 222 documentStyleSheetCollection()->clearMediaQueryRuleSetStyleSheets();
243 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes); 223 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes);
244 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_dirtyTreeScopes); 224 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_dirtyTreeScopes);
245 } 225 }
246 226
247 void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentC ollector)
248 {
249 ASSERT(!isMaster());
250 Vector<RefPtr<StyleSheet> > sheetsForList;
251 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL ist);
252 documentStyleSheetCollection()->collectStyleSheets(this, subcollector);
253 documentStyleSheetCollection()->swapSheetsForSheetList(sheetsForList);
254 }
255
256 void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) 227 void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode)
257 { 228 {
258 ASSERT(isMaster()); 229 ASSERT(isMaster());
259 ASSERT(!document().inStyleRecalc()); 230 ASSERT(!document().inStyleRecalc());
260 231
261 if (!document().isActive()) 232 if (!document().isActive())
262 return; 233 return;
263 234
264 if (shouldUpdateDocumentStyleSheetCollection(updateMode)) 235 if (shouldUpdateDocumentStyleSheetCollection(updateMode))
265 documentStyleSheetCollection()->updateActiveStyleSheets(this, updateMode ); 236 documentStyleSheetCollection()->updateActiveStyleSheets(this, updateMode );
(...skipping 13 matching lines...) Expand all
279 } 250 }
280 m_activeTreeScopes.removeAll(treeScopesRemoved); 251 m_activeTreeScopes.removeAll(treeScopesRemoved);
281 } 252 }
282 253
283 m_usesRemUnits = documentStyleSheetCollection()->usesRemUnits(); 254 m_usesRemUnits = documentStyleSheetCollection()->usesRemUnits();
284 255
285 m_dirtyTreeScopes.clear(); 256 m_dirtyTreeScopes.clear();
286 m_documentScopeDirty = false; 257 m_documentScopeDirty = false;
287 } 258 }
288 259
289 const Vector<RefPtr<CSSStyleSheet> > StyleEngine::activeStyleSheetsForInspector( ) const
290 {
291 if (m_activeTreeScopes.isEmpty())
292 return documentStyleSheetCollection()->activeAuthorStyleSheets();
293
294 Vector<RefPtr<CSSStyleSheet> > activeStyleSheets;
295
296 activeStyleSheets.appendVector(documentStyleSheetCollection()->activeAuthorS tyleSheets());
297
298 TreeScopeSet::const_iterator begin = m_activeTreeScopes.begin();
299 TreeScopeSet::const_iterator end = m_activeTreeScopes.end();
300 for (TreeScopeSet::const_iterator it = begin; it != end; ++it) {
301 if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMa p.get(*it))
302 activeStyleSheets.appendVector(collection->activeAuthorStyleSheets() );
303 }
304
305 // FIXME: Inspector needs a vector which has all active stylesheets.
306 // However, creating such a large vector might cause performance regression.
307 // Need to implement some smarter solution.
308 return activeStyleSheets;
309 }
310
311 void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot) 260 void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot)
312 { 261 {
313 if (shadowRoot->scopedStyleResolver()) 262 if (shadowRoot->scopedStyleResolver())
314 removeScopedStyleResolver(shadowRoot->scopedStyleResolver()); 263 removeScopedStyleResolver(shadowRoot->scopedStyleResolver());
315 m_styleSheetCollectionMap.remove(shadowRoot); 264 m_styleSheetCollectionMap.remove(shadowRoot);
316 } 265 }
317 266
318 void StyleEngine::appendActiveAuthorStyleSheets() 267 void StyleEngine::appendActiveAuthorStyleSheets()
319 { 268 {
320 ASSERT(isMaster()); 269 ASSERT(isMaster());
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 { 455 {
507 if (!document().isActive()) 456 if (!document().isActive())
508 return; 457 return;
509 458
510 if (m_resolver) 459 if (m_resolver)
511 m_resolver->invalidateMatchedPropertiesCache(); 460 m_resolver->invalidateMatchedPropertiesCache();
512 document().setNeedsStyleRecalc(SubtreeStyleChange); 461 document().setNeedsStyleRecalc(SubtreeStyleChange);
513 } 462 }
514 463
515 } 464 }
OLDNEW
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698