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