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

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

Issue 1131493008: WIP: Move StyleEngine::m_activeTreeScopes to TreeScope::m_childTreeScopesWithActiveStyleSheets (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reflected kochi's review Created 5 years, 7 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/core/dom/StyleEngine.h ('k') | Source/core/dom/TreeScope.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) 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 if (m_fontSelector) { 93 if (m_fontSelector) {
94 m_fontSelector->clearDocument(); 94 m_fontSelector->clearDocument();
95 m_fontSelector->unregisterForInvalidationCallbacks(this); 95 m_fontSelector->unregisterForInvalidationCallbacks(this);
96 } 96 }
97 97
98 // Decrement reference counts for things we could be keeping alive. 98 // Decrement reference counts for things we could be keeping alive.
99 m_fontSelector.clear(); 99 m_fontSelector.clear();
100 m_resolver.clear(); 100 m_resolver.clear();
101 m_styleSheetCollectionMap.clear(); 101 m_styleSheetCollectionMap.clear();
102 m_activeTreeScopes.clear();
103 } 102 }
104 #endif 103 #endif
105 104
106 inline Document* StyleEngine::master() 105 inline Document* StyleEngine::master()
107 { 106 {
108 if (isMaster()) 107 if (isMaster())
109 return m_document; 108 return m_document;
110 HTMLImportsController* import = document().importsController(); 109 HTMLImportsController* import = document().importsController();
111 if (!import) // Document::import() can return null while executing its destr uctor. 110 if (!import) // Document::import() can return null while executing its destr uctor.
112 return 0; 111 return 0;
113 return import->master(); 112 return import->master();
114 } 113 }
115 114
116 void StyleEngine::OrderedTreeScopeSet::insert(TreeScope* treeScope)
117 {
118 if (m_treeScopes.isEmpty()) {
119 m_treeScopes.append(treeScope);
120 m_hash.add(treeScope);
121 return;
122 }
123 if (m_hash.contains(treeScope))
124 return;
125
126 int end = m_treeScopes.size() - 1;
127 int start = 0;
128 int position = 0;
129 unsigned result = 0;
130
131 while (start <= end) {
132 position = (start + end) / 2;
133 result = m_treeScopes[position]->comparePosition(*treeScope);
134
135 if (result & Node::DOCUMENT_POSITION_PRECEDING) {
136 end = position - 1;
137 } else {
138 ASSERT(result & Node::DOCUMENT_POSITION_FOLLOWING);
139 start = position + 1;
140 }
141 }
142
143 if (result & Node::DOCUMENT_POSITION_FOLLOWING) {
144 ++position;
145 ASSERT(static_cast<size_t>(position) == m_treeScopes.size() || (m_treeSc opes[position]->comparePosition(*treeScope) & Node::DOCUMENT_POSITION_PRECEDING) );
146 }
147 m_treeScopes.insert(position, treeScope);
148 m_hash.add(treeScope);
149
150 #if ENABLE(ASSERT)
151 // Check whether m_treeScopes is sorted in document order or not.
152 for (unsigned i = 0; i < m_treeScopes.size() - 1; ++i) {
153 unsigned result = m_treeScopes[i]->comparePosition(*m_treeScopes[i + 1]) ;
154 ASSERT(result & Node::DOCUMENT_POSITION_FOLLOWING);
155 }
156 #endif
157 }
158
159 void StyleEngine::OrderedTreeScopeSet::remove(TreeScope* treeScope)
160 {
161 if (!m_hash.contains(treeScope))
162 return;
163 size_t position = m_treeScopes.find(treeScope);
164 m_treeScopes.remove(position);
165 m_hash.remove(treeScope);
166 }
167
168 DEFINE_TRACE(StyleEngine::OrderedTreeScopeSet)
169 {
170 #if ENABLE(OILPAN)
171 visitor->trace(m_treeScopes);
172 visitor->trace(m_hash);
173 #endif
174 }
175
176 TreeScopeStyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor(TreeSc ope& treeScope) 115 TreeScopeStyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor(TreeSc ope& treeScope)
177 { 116 {
178 if (treeScope == m_document) 117 if (treeScope == m_document)
179 return documentStyleSheetCollection(); 118 return documentStyleSheetCollection();
180 119
181 StyleSheetCollectionMap::AddResult result = m_styleSheetCollectionMap.add(&t reeScope, nullptr); 120 StyleSheetCollectionMap::AddResult result = m_styleSheetCollectionMap.add(&t reeScope, nullptr);
182 if (result.isNewEntry) 121 if (result.isNewEntry)
183 result.storedValue->value = adoptPtrWillBeNoop(new ShadowTreeStyleSheetC ollection(toShadowRoot(treeScope))); 122 result.storedValue->value = adoptPtrWillBeNoop(new ShadowTreeStyleSheetC ollection(toShadowRoot(treeScope)));
184 return result.storedValue->value.get(); 123 return result.storedValue->value.get();
185 } 124 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 218
280 TreeScope& treeScope = isStyleElement(*node) ? node->treeScope() : *m_docume nt; 219 TreeScope& treeScope = isStyleElement(*node) ? node->treeScope() : *m_docume nt;
281 ASSERT(isStyleElement(*node) || treeScope == m_document); 220 ASSERT(isStyleElement(*node) || treeScope == m_document);
282 ASSERT(!isXSLStyleSheet(*node)); 221 ASSERT(!isXSLStyleSheet(*node));
283 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr eeScope); 222 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr eeScope);
284 ASSERT(collection); 223 ASSERT(collection);
285 collection->addStyleSheetCandidateNode(node, createdByParser); 224 collection->addStyleSheetCandidateNode(node, createdByParser);
286 225
287 markTreeScopeDirty(treeScope); 226 markTreeScopeDirty(treeScope);
288 if (treeScope != m_document) 227 if (treeScope != m_document)
289 m_activeTreeScopes.insert(&treeScope); 228 treeScope.setSelfOrDescendantsHaveActiveStyleSheets();
290 } 229 }
291 230
292 void StyleEngine::removeStyleSheetCandidateNode(Node* node) 231 void StyleEngine::removeStyleSheetCandidateNode(Node* node)
293 { 232 {
294 removeStyleSheetCandidateNode(node, *m_document); 233 removeStyleSheetCandidateNode(node, *m_document);
295 } 234 }
296 235
297 void StyleEngine::removeStyleSheetCandidateNode(Node* node, TreeScope& treeScope ) 236 void StyleEngine::removeStyleSheetCandidateNode(Node* node, TreeScope& treeScope )
298 { 237 {
299 ASSERT(isStyleElement(*node) || treeScope == m_document); 238 ASSERT(isStyleElement(*node) || treeScope == m_document);
(...skipping 22 matching lines...) Expand all
322 bool StyleEngine::shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMo de updateMode) const 261 bool StyleEngine::shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMo de updateMode) const
323 { 262 {
324 return m_documentScopeDirty || updateMode == FullStyleUpdate; 263 return m_documentScopeDirty || updateMode == FullStyleUpdate;
325 } 264 }
326 265
327 bool StyleEngine::shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdate Mode updateMode) const 266 bool StyleEngine::shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdate Mode updateMode) const
328 { 267 {
329 return !m_dirtyTreeScopes.isEmpty() || updateMode == FullStyleUpdate; 268 return !m_dirtyTreeScopes.isEmpty() || updateMode == FullStyleUpdate;
330 } 269 }
331 270
332 void StyleEngine::clearMediaQueryRuleSetOnTreeScopeStyleSheets(UnorderedTreeScop eSet::iterator begin, UnorderedTreeScopeSet::iterator end) 271 void StyleEngine::clearMediaQueryRuleSetStyleSheets()
333 { 272 {
334 for (UnorderedTreeScopeSet::iterator it = begin; it != end; ++it) { 273 for (TreeScope* treeScope : TreeScope::TreeScopesWithActiveStyleSheetsTraver sal(document())) {
335 TreeScope& treeScope = **it; 274 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(*tre eScope);
336 ASSERT(treeScope != m_document); 275 ASSERT(collection);
337 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyle SheetCollection*>(styleSheetCollectionFor(treeScope)); 276 collection->clearMediaQueryRuleSetStyleSheets();
277 }
278 for (TreeScope* treeScope : m_dirtyTreeScopes) {
279 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(*tre eScope);
338 ASSERT(collection); 280 ASSERT(collection);
339 collection->clearMediaQueryRuleSetStyleSheets(); 281 collection->clearMediaQueryRuleSetStyleSheets();
340 } 282 }
341 } 283 }
342 284
343 void StyleEngine::clearMediaQueryRuleSetStyleSheets()
344 {
345 documentStyleSheetCollection()->clearMediaQueryRuleSetStyleSheets();
346 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes.beginUnorder ed(), m_activeTreeScopes.endUnordered());
347 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_dirtyTreeScopes.begin(), m_di rtyTreeScopes.end());
348 }
349
350 void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentC ollector) 285 void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentC ollector)
351 { 286 {
352 ASSERT(!isMaster()); 287 ASSERT(!isMaster());
353 WillBeHeapVector<RefPtrWillBeMember<StyleSheet>> sheetsForList; 288 WillBeHeapVector<RefPtrWillBeMember<StyleSheet>> sheetsForList;
354 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL ist); 289 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL ist);
355 documentStyleSheetCollection()->collectStyleSheets(*this, subcollector); 290 documentStyleSheetCollection()->collectStyleSheets(*this, subcollector);
356 documentStyleSheetCollection()->swapSheetsForSheetList(sheetsForList); 291 documentStyleSheetCollection()->swapSheetsForSheetList(sheetsForList);
357 } 292 }
358 293
359 void StyleEngine::updateActiveStyleSheetsInShadow(StyleResolverUpdateMode update Mode, TreeScope* treeScope, UnorderedTreeScopeSet& treeScopesRemoved) 294 void StyleEngine::updateActiveStyleSheetsInShadow(StyleResolverUpdateMode update Mode, TreeScope* treeScope, TreeScope::UnorderedTreeScopeSet& treeScopesRemoved)
360 { 295 {
361 ASSERT(treeScope != m_document); 296 ASSERT(treeScope != m_document);
362 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyleShee tCollection*>(styleSheetCollectionFor(*treeScope)); 297 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyleShee tCollection*>(styleSheetCollectionFor(*treeScope));
363 ASSERT(collection); 298 ASSERT(collection);
364 collection->updateActiveStyleSheets(*this, updateMode); 299 collection->updateActiveStyleSheets(*this, updateMode);
365 if (!collection->hasStyleSheetCandidateNodes()) { 300 if (!collection->hasStyleSheetCandidateNodes()) {
366 treeScopesRemoved.add(treeScope); 301 if (treeScope->selfOrDescendantsHaveActiveStyleSheets() && !treeScope->h asChildTreeScopesWithActiveStyleSheets())
302 treeScopesRemoved.add(treeScope);
367 // When removing TreeScope from ActiveTreeScopes, 303 // When removing TreeScope from ActiveTreeScopes,
368 // its resolver should be destroyed by invoking resetAuthorStyle. 304 // its resolver should be destroyed by invoking resetAuthorStyle.
369 ASSERT(!treeScope->scopedStyleResolver()); 305 ASSERT(!treeScope->scopedStyleResolver());
370 } 306 }
371 } 307 }
372 308
373 void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) 309 void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode)
374 { 310 {
375 ASSERT(isMaster()); 311 ASSERT(isMaster());
376 ASSERT(!document().inStyleRecalc()); 312 ASSERT(!document().inStyleRecalc());
377 313
378 if (!document().isActive()) 314 if (!document().isActive())
379 return; 315 return;
380 316
381 if (shouldUpdateDocumentStyleSheetCollection(updateMode)) 317 if (shouldUpdateDocumentStyleSheetCollection(updateMode))
382 documentStyleSheetCollection()->updateActiveStyleSheets(*this, updateMod e); 318 documentStyleSheetCollection()->updateActiveStyleSheets(*this, updateMod e);
383 319
384 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { 320 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) {
385 UnorderedTreeScopeSet treeScopesRemoved; 321 TreeScope::UnorderedTreeScopeSet treeScopesRemoved;
386
387 if (updateMode == FullStyleUpdate) { 322 if (updateMode == FullStyleUpdate) {
388 for (unsigned i = 0; i < m_activeTreeScopes.size(); ++i) 323 for (TreeScope* treeScope : TreeScope::TreeScopesWithActiveStyleShee tsTraversal(document().childTreeScopesWithActiveStyleSheets()))
389 updateActiveStyleSheetsInShadow(updateMode, m_activeTreeScopes[i ], treeScopesRemoved); 324 updateActiveStyleSheetsInShadow(updateMode, treeScope, treeScope sRemoved);
390 } else { 325 } else {
391 for (UnorderedTreeScopeSet::iterator it = m_dirtyTreeScopes.begin(); it != m_dirtyTreeScopes.end(); ++it) { 326 for (TreeScope* treeScope : m_dirtyTreeScopes) {
392 updateActiveStyleSheetsInShadow(updateMode, *it, treeScopesRemov ed); 327 updateActiveStyleSheetsInShadow(updateMode, treeScope, treeScope sRemoved);
393 } 328 }
394 } 329 }
395 for (UnorderedTreeScopeSet::iterator it = treeScopesRemoved.begin(); it != treeScopesRemoved.end(); ++it) 330 for (TreeScope* removed : treeScopesRemoved)
396 m_activeTreeScopes.remove(*it); 331 removed->clearSelfOrDescendantsHaveActiveStyleSheets();
397 } 332 }
398 333
399 InspectorInstrumentation::activeStyleSheetsUpdated(m_document); 334 InspectorInstrumentation::activeStyleSheetsUpdated(m_document);
400 m_usesRemUnits = documentStyleSheetCollection()->usesRemUnits(); 335 m_usesRemUnits = documentStyleSheetCollection()->usesRemUnits();
401 336
402 m_dirtyTreeScopes.clear(); 337 m_dirtyTreeScopes.clear();
403 m_documentScopeDirty = false; 338 m_documentScopeDirty = false;
404 } 339 }
405 340
406 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> StyleEngine::activeSty leSheetsForInspector() const 341 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> StyleEngine::activeSty leSheetsForInspector()
407 { 342 {
408 if (m_activeTreeScopes.isEmpty()) 343 if (!document().hasChildTreeScopesWithActiveStyleSheets())
409 return documentStyleSheetCollection()->activeAuthorStyleSheets(); 344 return documentStyleSheetCollection()->activeAuthorStyleSheets();
410 345
411 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> activeStyleSheets; 346 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> activeStyleSheets;
412 347 for (TreeScope* treeScope : TreeScope::TreeScopesWithActiveStyleSheetsTraver sal(document())) {
413 activeStyleSheets.appendVector(documentStyleSheetCollection()->activeAuthorS tyleSheets()); 348 if (TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor( *treeScope))
414 for (unsigned i = 0; i < m_activeTreeScopes.size(); ++i) {
415 TreeScope* treeScope = const_cast<TreeScope*>(m_activeTreeScopes[i]);
416 if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMa p.get(treeScope))
417 activeStyleSheets.appendVector(collection->activeAuthorStyleSheets() ); 349 activeStyleSheets.appendVector(collection->activeAuthorStyleSheets() );
418 } 350 }
419 351
420 // FIXME: Inspector needs a vector which has all active stylesheets. 352 // FIXME: Inspector needs a vector which has all active stylesheets.
421 // However, creating such a large vector might cause performance regression. 353 // However, creating such a large vector might cause performance regression.
422 // Need to implement some smarter solution. 354 // Need to implement some smarter solution.
423 return activeStyleSheets; 355 return activeStyleSheets;
424 } 356 }
425 357
426 void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot) 358 void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot)
427 { 359 {
428 m_styleSheetCollectionMap.remove(shadowRoot); 360 m_styleSheetCollectionMap.remove(shadowRoot);
429 m_activeTreeScopes.remove(shadowRoot);
430 m_dirtyTreeScopes.remove(shadowRoot); 361 m_dirtyTreeScopes.remove(shadowRoot);
431 } 362 }
432 363
433 void StyleEngine::shadowRootRemovedFromDocument(ShadowRoot* shadowRoot) 364 void StyleEngine::shadowRootRemovedFromDocument(ShadowRoot* shadowRoot)
434 { 365 {
435 if (StyleResolver* styleResolver = resolver()) { 366 if (StyleResolver* styleResolver = resolver()) {
436 styleResolver->resetAuthorStyle(*shadowRoot); 367 styleResolver->resetAuthorStyle(*shadowRoot);
437 368
438 if (TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor( *shadowRoot)) 369 if (TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor( *shadowRoot))
439 styleResolver->removePendingAuthorStyleSheets(collection->activeAuth orStyleSheets()); 370 styleResolver->removePendingAuthorStyleSheets(collection->activeAuth orStyleSheets());
440 } 371 }
441 m_styleSheetCollectionMap.remove(shadowRoot); 372 m_styleSheetCollectionMap.remove(shadowRoot);
442 m_activeTreeScopes.remove(shadowRoot);
443 m_dirtyTreeScopes.remove(shadowRoot); 373 m_dirtyTreeScopes.remove(shadowRoot);
444 } 374 }
445 375
446 void StyleEngine::appendActiveAuthorStyleSheets() 376 void StyleEngine::appendActiveAuthorStyleSheets()
447 { 377 {
448 ASSERT(isMaster()); 378 ASSERT(isMaster());
449 379
450 m_resolver->appendAuthorStyleSheets(documentStyleSheetCollection()->activeAu thorStyleSheets()); 380 for (TreeScope* treeScope : TreeScope::TreeScopesWithActiveStyleSheetsTraver sal(document())) {
451 for (unsigned i = 0; i < m_activeTreeScopes.size(); ++i) { 381 if (TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor( *treeScope))
452 if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMa p.get(m_activeTreeScopes[i]))
453 m_resolver->appendAuthorStyleSheets(collection->activeAuthorStyleShe ets()); 382 m_resolver->appendAuthorStyleSheets(collection->activeAuthorStyleShe ets());
454 } 383 }
455 m_resolver->finishAppendAuthorStyleSheets(); 384 m_resolver->finishAppendAuthorStyleSheets();
456 } 385 }
457 386
458 void StyleEngine::createResolver() 387 void StyleEngine::createResolver()
459 { 388 {
460 // It is a programming error to attempt to resolve style on a Document 389 // It is a programming error to attempt to resolve style on a Document
461 // which is not in a frame. Code which hits this should have checked 390 // which is not in a frame. Code which hits this should have checked
462 // Document::isActive() before calling into code which could get here. 391 // Document::isActive() before calling into code which could get here.
463 392
464 ASSERT(document().frame()); 393 ASSERT(document().frame());
465 394
466 m_resolver = adoptPtrWillBeNoop(new StyleResolver(*m_document)); 395 m_resolver = adoptPtrWillBeNoop(new StyleResolver(*m_document));
467 396
468 // A scoped style resolver for document will be created during 397 // A scoped style resolver for document will be created during
469 // appendActiveAuthorStyleSheets if needed. 398 // appendActiveAuthorStyleSheets if needed.
470 appendActiveAuthorStyleSheets(); 399 appendActiveAuthorStyleSheets();
471 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet()); 400 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet());
472 } 401 }
473 402
474 void StyleEngine::clearResolver() 403 void StyleEngine::clearResolver()
475 { 404 {
476 ASSERT(!document().inStyleRecalc()); 405 ASSERT(!document().inStyleRecalc());
477 ASSERT(isMaster() || !m_resolver); 406 ASSERT(isMaster() || !m_resolver);
478 407
479 document().clearScopedStyleResolver();
480 // StyleEngine::shadowRootRemovedFromDocument removes not-in-document 408 // StyleEngine::shadowRootRemovedFromDocument removes not-in-document
481 // treescopes from activeTreeScopes. StyleEngine::didRemoveShadowRoot 409 // treescopes from activeTreeScopes. StyleEngine::didRemoveShadowRoot
482 // removes treescopes which are being destroyed from activeTreeScopes. 410 // removes treescopes which are being destroyed from activeTreeScopes.
483 // So we need to clearScopedStyleResolver for treescopes which have been 411 // So we need to clearScopedStyleResolver for treescopes which have been
484 // just removed from document. If document is destroyed before invoking 412 // just removed from document. If document is destroyed before invoking
485 // updateActiveStyleSheets, the treescope has a scopedStyleResolver which 413 // updateActiveStyleSheets, the treescope has a scopedStyleResolver which
486 // has destroyed StyleSheetContents. 414 // has destroyed StyleSheetContents.
487 for (UnorderedTreeScopeSet::iterator it = m_activeTreeScopes.beginUnordered( ); it != m_activeTreeScopes.endUnordered(); ++it) 415 for (TreeScope* treeScope : TreeScope::TreeScopesWithActiveStyleSheetsTraver sal(document()))
488 (*it)->clearScopedStyleResolver(); 416 treeScope->clearScopedStyleResolver();
489 417
490 m_resolver.clear(); 418 m_resolver.clear();
491 } 419 }
492 420
493 void StyleEngine::clearMasterResolver() 421 void StyleEngine::clearMasterResolver()
494 { 422 {
495 if (Document* master = this->master()) 423 if (Document* master = this->master())
496 master->styleEngine().clearResolver(); 424 master->styleEngine().clearResolver();
497 } 425 }
498 426
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 if (it == m_sheetToTextCache.end()) 573 if (it == m_sheetToTextCache.end())
646 return; 574 return;
647 575
648 m_textToSheetCache.remove(it->value); 576 m_textToSheetCache.remove(it->value);
649 m_sheetToTextCache.remove(contents); 577 m_sheetToTextCache.remove(contents);
650 } 578 }
651 579
652 void StyleEngine::collectScopedStyleFeaturesTo(RuleFeatureSet& features) const 580 void StyleEngine::collectScopedStyleFeaturesTo(RuleFeatureSet& features) const
653 { 581 {
654 HashSet<const StyleSheetContents*> visitedSharedStyleSheetContents; 582 HashSet<const StyleSheetContents*> visitedSharedStyleSheetContents;
655 if (document().scopedStyleResolver()) 583 for (TreeScope* treeScope : TreeScope::TreeScopesWithActiveStyleSheetsTraver sal(document())) {
656 document().scopedStyleResolver()->collectFeaturesTo(features, visitedSha redStyleSheetContents);
657 for (unsigned i = 0; i < m_activeTreeScopes.size(); ++i) {
658 TreeScope* treeScope = const_cast<TreeScope*>(m_activeTreeScopes[i]);
659 // When creating StyleResolver, dirty treescopes might not be processed. 584 // When creating StyleResolver, dirty treescopes might not be processed.
660 // So some active treescopes might not have a scoped style resolver. 585 // So some active treescopes might not have a scoped style resolver.
661 // In this case, we should skip collectFeatures for the treescopes witho ut 586 // In this case, we should skip collectFeatures for the treescopes witho ut
662 // scoped style resolvers. When invoking updateActiveStyleSheets, 587 // scoped style resolvers. When invoking updateActiveStyleSheets,
663 // the treescope's features will be processed. 588 // the treescope's features will be processed.
664 if (ScopedStyleResolver* resolver = treeScope->scopedStyleResolver()) 589 if (ScopedStyleResolver* resolver = treeScope->scopedStyleResolver())
665 resolver->collectFeaturesTo(features, visitedSharedStyleSheetContent s); 590 resolver->collectFeaturesTo(features, visitedSharedStyleSheetContent s);
666 } 591 }
667 } 592 }
668 593
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 DEFINE_TRACE(StyleEngine) 702 DEFINE_TRACE(StyleEngine)
778 { 703 {
779 #if ENABLE(OILPAN) 704 #if ENABLE(OILPAN)
780 visitor->trace(m_document); 705 visitor->trace(m_document);
781 visitor->trace(m_authorStyleSheets); 706 visitor->trace(m_authorStyleSheets);
782 visitor->trace(m_documentStyleSheetCollection); 707 visitor->trace(m_documentStyleSheetCollection);
783 visitor->trace(m_styleSheetCollectionMap); 708 visitor->trace(m_styleSheetCollectionMap);
784 visitor->trace(m_resolver); 709 visitor->trace(m_resolver);
785 visitor->trace(m_styleInvalidator); 710 visitor->trace(m_styleInvalidator);
786 visitor->trace(m_dirtyTreeScopes); 711 visitor->trace(m_dirtyTreeScopes);
787 visitor->trace(m_activeTreeScopes);
788 visitor->trace(m_fontSelector); 712 visitor->trace(m_fontSelector);
789 visitor->trace(m_textToSheetCache); 713 visitor->trace(m_textToSheetCache);
790 visitor->trace(m_sheetToTextCache); 714 visitor->trace(m_sheetToTextCache);
791 #endif 715 #endif
792 CSSFontSelectorClient::trace(visitor); 716 CSSFontSelectorClient::trace(visitor);
793 } 717 }
794 718
795 } 719 }
OLDNEW
« no previous file with comments | « Source/core/dom/StyleEngine.h ('k') | Source/core/dom/TreeScope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698