| 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 | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 HTMLImportsController* import = document().importsController(); | 85 HTMLImportsController* import = document().importsController(); |
| 86 // Document::import() can return null while executing its destructor. | 86 // Document::import() can return null while executing its destructor. |
| 87 if (!import) | 87 if (!import) |
| 88 return nullptr; | 88 return nullptr; |
| 89 return import->master(); | 89 return import->master(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 TreeScopeStyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor( | 92 TreeScopeStyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor( |
| 93 TreeScope& treeScope) { | 93 TreeScope& treeScope) { |
| 94 if (treeScope == m_document) | 94 if (treeScope == m_document) |
| 95 return documentStyleSheetCollection(); | 95 return &documentStyleSheetCollection(); |
| 96 | 96 |
| 97 StyleSheetCollectionMap::AddResult result = | 97 StyleSheetCollectionMap::AddResult result = |
| 98 m_styleSheetCollectionMap.add(&treeScope, nullptr); | 98 m_styleSheetCollectionMap.add(&treeScope, nullptr); |
| 99 if (result.isNewEntry) | 99 if (result.isNewEntry) |
| 100 result.storedValue->value = | 100 result.storedValue->value = |
| 101 new ShadowTreeStyleSheetCollection(toShadowRoot(treeScope)); | 101 new ShadowTreeStyleSheetCollection(toShadowRoot(treeScope)); |
| 102 return result.storedValue->value.get(); | 102 return result.storedValue->value.get(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 TreeScopeStyleSheetCollection* StyleEngine::styleSheetCollectionFor( | 105 TreeScopeStyleSheetCollection* StyleEngine::styleSheetCollectionFor( |
| 106 TreeScope& treeScope) { | 106 TreeScope& treeScope) { |
| 107 if (treeScope == m_document) | 107 if (treeScope == m_document) |
| 108 return documentStyleSheetCollection(); | 108 return &documentStyleSheetCollection(); |
| 109 | 109 |
| 110 StyleSheetCollectionMap::iterator it = | 110 StyleSheetCollectionMap::iterator it = |
| 111 m_styleSheetCollectionMap.find(&treeScope); | 111 m_styleSheetCollectionMap.find(&treeScope); |
| 112 if (it == m_styleSheetCollectionMap.end()) | 112 if (it == m_styleSheetCollectionMap.end()) |
| 113 return 0; | 113 return nullptr; |
| 114 return it->value.get(); | 114 return it->value.get(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 const HeapVector<Member<StyleSheet>>& StyleEngine::styleSheetsForStyleSheetList( | 117 const HeapVector<Member<StyleSheet>>& StyleEngine::styleSheetsForStyleSheetList( |
| 118 TreeScope& treeScope) { | 118 TreeScope& treeScope) { |
| 119 if (treeScope == m_document) | 119 if (treeScope == m_document) |
| 120 return documentStyleSheetCollection()->styleSheetsForStyleSheetList(); | 120 return documentStyleSheetCollection().styleSheetsForStyleSheetList(); |
| 121 | 121 |
| 122 return ensureStyleSheetCollectionFor(treeScope) | 122 return ensureStyleSheetCollectionFor(treeScope) |
| 123 ->styleSheetsForStyleSheetList(); | 123 ->styleSheetsForStyleSheetList(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void StyleEngine::resetCSSFeatureFlags(const RuleFeatureSet& features) { | 126 void StyleEngine::resetCSSFeatureFlags(const RuleFeatureSet& features) { |
| 127 m_usesSiblingRules = features.usesSiblingRules(); | 127 m_usesSiblingRules = features.usesSiblingRules(); |
| 128 m_usesFirstLineRules = features.usesFirstLineRules(); | 128 m_usesFirstLineRules = features.usesFirstLineRules(); |
| 129 m_usesWindowInactiveSelector = features.usesWindowInactiveSelector(); | 129 m_usesWindowInactiveSelector = features.usesWindowInactiveSelector(); |
| 130 m_maxDirectAdjacentSelectors = features.maxDirectAdjacentSelectors(); | 130 m_maxDirectAdjacentSelectors = features.maxDirectAdjacentSelectors(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 DCHECK(treeScope != m_document); | 277 DCHECK(treeScope != m_document); |
| 278 ShadowTreeStyleSheetCollection* collection = | 278 ShadowTreeStyleSheetCollection* collection = |
| 279 toShadowTreeStyleSheetCollection(styleSheetCollectionFor(*treeScope)); | 279 toShadowTreeStyleSheetCollection(styleSheetCollectionFor(*treeScope)); |
| 280 DCHECK(collection); | 280 DCHECK(collection); |
| 281 collection->clearMediaQueryRuleSetStyleSheets(); | 281 collection->clearMediaQueryRuleSetStyleSheets(); |
| 282 } | 282 } |
| 283 } | 283 } |
| 284 | 284 |
| 285 void StyleEngine::clearMediaQueryRuleSetStyleSheets() { | 285 void StyleEngine::clearMediaQueryRuleSetStyleSheets() { |
| 286 resolverChanged(FullStyleUpdate); | 286 resolverChanged(FullStyleUpdate); |
| 287 documentStyleSheetCollection()->clearMediaQueryRuleSetStyleSheets(); | 287 documentStyleSheetCollection().clearMediaQueryRuleSetStyleSheets(); |
| 288 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes); | 288 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes); |
| 289 } | 289 } |
| 290 | 290 |
| 291 void StyleEngine::updateStyleSheetsInImport( | 291 void StyleEngine::updateStyleSheetsInImport( |
| 292 DocumentStyleSheetCollector& parentCollector) { | 292 DocumentStyleSheetCollector& parentCollector) { |
| 293 DCHECK(!isMaster()); | 293 DCHECK(!isMaster()); |
| 294 HeapVector<Member<StyleSheet>> sheetsForList; | 294 HeapVector<Member<StyleSheet>> sheetsForList; |
| 295 ImportedDocumentStyleSheetCollector subcollector(parentCollector, | 295 ImportedDocumentStyleSheetCollector subcollector(parentCollector, |
| 296 sheetsForList); | 296 sheetsForList); |
| 297 documentStyleSheetCollection()->collectStyleSheets(*this, subcollector); | 297 documentStyleSheetCollection().collectStyleSheets(*this, subcollector); |
| 298 documentStyleSheetCollection()->swapSheetsForSheetList(sheetsForList); | 298 documentStyleSheetCollection().swapSheetsForSheetList(sheetsForList); |
| 299 } | 299 } |
| 300 | 300 |
| 301 void StyleEngine::updateActiveStyleSheetsInShadow( | 301 void StyleEngine::updateActiveStyleSheetsInShadow( |
| 302 StyleResolverUpdateMode updateMode, | 302 StyleResolverUpdateMode updateMode, |
| 303 TreeScope* treeScope, | 303 TreeScope* treeScope, |
| 304 UnorderedTreeScopeSet& treeScopesRemoved) { | 304 UnorderedTreeScopeSet& treeScopesRemoved) { |
| 305 DCHECK_NE(treeScope, m_document); | 305 DCHECK_NE(treeScope, m_document); |
| 306 ShadowTreeStyleSheetCollection* collection = | 306 ShadowTreeStyleSheetCollection* collection = |
| 307 toShadowTreeStyleSheetCollection(styleSheetCollectionFor(*treeScope)); | 307 toShadowTreeStyleSheetCollection(styleSheetCollectionFor(*treeScope)); |
| 308 DCHECK(collection); | 308 DCHECK(collection); |
| 309 collection->updateActiveStyleSheets(*this, updateMode); | 309 collection->updateActiveStyleSheets(*this, updateMode); |
| 310 if (!collection->hasStyleSheetCandidateNodes()) { | 310 if (!collection->hasStyleSheetCandidateNodes()) { |
| 311 treeScopesRemoved.add(treeScope); | 311 treeScopesRemoved.add(treeScope); |
| 312 // When removing TreeScope from ActiveTreeScopes, | 312 // When removing TreeScope from ActiveTreeScopes, |
| 313 // its resolver should be destroyed by invoking resetAuthorStyle. | 313 // its resolver should be destroyed by invoking resetAuthorStyle. |
| 314 DCHECK(!treeScope->scopedStyleResolver()); | 314 DCHECK(!treeScope->scopedStyleResolver()); |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 | 317 |
| 318 void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) { | 318 void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) { |
| 319 DCHECK(isMaster()); | 319 DCHECK(isMaster()); |
| 320 DCHECK(!document().inStyleRecalc()); | 320 DCHECK(!document().inStyleRecalc()); |
| 321 | 321 |
| 322 if (!document().isActive()) | 322 if (!document().isActive()) |
| 323 return; | 323 return; |
| 324 | 324 |
| 325 TRACE_EVENT0("blink,blink_style", "StyleEngine::updateActiveStyleSheets"); | 325 TRACE_EVENT0("blink,blink_style", "StyleEngine::updateActiveStyleSheets"); |
| 326 | 326 |
| 327 if (shouldUpdateDocumentStyleSheetCollection(updateMode)) | 327 if (shouldUpdateDocumentStyleSheetCollection(updateMode)) |
| 328 documentStyleSheetCollection()->updateActiveStyleSheets(*this, updateMode); | 328 documentStyleSheetCollection().updateActiveStyleSheets(*this, updateMode); |
| 329 | 329 |
| 330 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { | 330 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { |
| 331 UnorderedTreeScopeSet treeScopesRemoved; | 331 UnorderedTreeScopeSet treeScopesRemoved; |
| 332 | 332 |
| 333 if (updateMode == FullStyleUpdate) { | 333 if (updateMode == FullStyleUpdate) { |
| 334 for (TreeScope* treeScope : m_activeTreeScopes) | 334 for (TreeScope* treeScope : m_activeTreeScopes) |
| 335 updateActiveStyleSheetsInShadow(updateMode, treeScope, | 335 updateActiveStyleSheetsInShadow(updateMode, treeScope, |
| 336 treeScopesRemoved); | 336 treeScopesRemoved); |
| 337 } else { | 337 } else { |
| 338 for (TreeScope* treeScope : m_dirtyTreeScopes) | 338 for (TreeScope* treeScope : m_dirtyTreeScopes) |
| 339 updateActiveStyleSheetsInShadow(updateMode, treeScope, | 339 updateActiveStyleSheetsInShadow(updateMode, treeScope, |
| 340 treeScopesRemoved); | 340 treeScopesRemoved); |
| 341 } | 341 } |
| 342 for (TreeScope* treeScope : treeScopesRemoved) | 342 for (TreeScope* treeScope : treeScopesRemoved) |
| 343 m_activeTreeScopes.remove(treeScope); | 343 m_activeTreeScopes.remove(treeScope); |
| 344 } | 344 } |
| 345 | 345 |
| 346 InspectorInstrumentation::activeStyleSheetsUpdated(m_document); | 346 InspectorInstrumentation::activeStyleSheetsUpdated(m_document); |
| 347 | 347 |
| 348 m_dirtyTreeScopes.clear(); | 348 m_dirtyTreeScopes.clear(); |
| 349 m_documentScopeDirty = false; | 349 m_documentScopeDirty = false; |
| 350 } | 350 } |
| 351 | 351 |
| 352 const HeapVector<Member<CSSStyleSheet>> | 352 const HeapVector<Member<CSSStyleSheet>> |
| 353 StyleEngine::activeStyleSheetsForInspector() const { | 353 StyleEngine::activeStyleSheetsForInspector() const { |
| 354 if (m_activeTreeScopes.isEmpty()) | 354 if (m_activeTreeScopes.isEmpty()) |
| 355 return documentStyleSheetCollection()->activeAuthorStyleSheets(); | 355 return documentStyleSheetCollection().activeAuthorStyleSheets(); |
| 356 | 356 |
| 357 HeapVector<Member<CSSStyleSheet>> activeStyleSheets; | 357 HeapVector<Member<CSSStyleSheet>> activeStyleSheets; |
| 358 | 358 |
| 359 activeStyleSheets.appendVector( | 359 activeStyleSheets.appendVector( |
| 360 documentStyleSheetCollection()->activeAuthorStyleSheets()); | 360 documentStyleSheetCollection().activeAuthorStyleSheets()); |
| 361 for (TreeScope* treeScope : m_activeTreeScopes) { | 361 for (TreeScope* treeScope : m_activeTreeScopes) { |
| 362 if (TreeScopeStyleSheetCollection* collection = | 362 if (TreeScopeStyleSheetCollection* collection = |
| 363 m_styleSheetCollectionMap.get(treeScope)) | 363 m_styleSheetCollectionMap.get(treeScope)) |
| 364 activeStyleSheets.appendVector(collection->activeAuthorStyleSheets()); | 364 activeStyleSheets.appendVector(collection->activeAuthorStyleSheets()); |
| 365 } | 365 } |
| 366 | 366 |
| 367 // FIXME: Inspector needs a vector which has all active stylesheets. | 367 // FIXME: Inspector needs a vector which has all active stylesheets. |
| 368 // However, creating such a large vector might cause performance regression. | 368 // However, creating such a large vector might cause performance regression. |
| 369 // Need to implement some smarter solution. | 369 // Need to implement some smarter solution. |
| 370 return activeStyleSheets; | 370 return activeStyleSheets; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 387 } | 387 } |
| 388 m_styleSheetCollectionMap.remove(shadowRoot); | 388 m_styleSheetCollectionMap.remove(shadowRoot); |
| 389 m_activeTreeScopes.remove(shadowRoot); | 389 m_activeTreeScopes.remove(shadowRoot); |
| 390 m_dirtyTreeScopes.remove(shadowRoot); | 390 m_dirtyTreeScopes.remove(shadowRoot); |
| 391 } | 391 } |
| 392 | 392 |
| 393 void StyleEngine::appendActiveAuthorStyleSheets() { | 393 void StyleEngine::appendActiveAuthorStyleSheets() { |
| 394 DCHECK(isMaster()); | 394 DCHECK(isMaster()); |
| 395 | 395 |
| 396 m_resolver->appendAuthorStyleSheets( | 396 m_resolver->appendAuthorStyleSheets( |
| 397 documentStyleSheetCollection()->activeAuthorStyleSheets()); | 397 documentStyleSheetCollection().activeAuthorStyleSheets()); |
| 398 for (TreeScope* treeScope : m_activeTreeScopes) { | 398 for (TreeScope* treeScope : m_activeTreeScopes) { |
| 399 if (TreeScopeStyleSheetCollection* collection = | 399 if (TreeScopeStyleSheetCollection* collection = |
| 400 m_styleSheetCollectionMap.get(treeScope)) | 400 m_styleSheetCollectionMap.get(treeScope)) |
| 401 m_resolver->appendAuthorStyleSheets( | 401 m_resolver->appendAuthorStyleSheets( |
| 402 collection->activeAuthorStyleSheets()); | 402 collection->activeAuthorStyleSheets()); |
| 403 } | 403 } |
| 404 m_resolver->finishAppendAuthorStyleSheets(); | 404 m_resolver->finishAppendAuthorStyleSheets(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 void StyleEngine::createResolver() { | 407 void StyleEngine::createResolver() { |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 } | 964 } |
| 965 | 965 |
| 966 DEFINE_TRACE_WRAPPERS(StyleEngine) { | 966 DEFINE_TRACE_WRAPPERS(StyleEngine) { |
| 967 for (auto sheet : m_injectedAuthorStyleSheets) { | 967 for (auto sheet : m_injectedAuthorStyleSheets) { |
| 968 visitor->traceWrappers(sheet); | 968 visitor->traceWrappers(sheet); |
| 969 } | 969 } |
| 970 visitor->traceWrappers(m_documentStyleSheetCollection); | 970 visitor->traceWrappers(m_documentStyleSheetCollection); |
| 971 } | 971 } |
| 972 | 972 |
| 973 } // namespace blink | 973 } // namespace blink |
| OLD | NEW |