| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 if (m_fontSelector) { | 97 if (m_fontSelector) { |
| 98 m_fontSelector->clearDocument(); | 98 m_fontSelector->clearDocument(); |
| 99 m_fontSelector->unregisterForInvalidationCallbacks(this); | 99 m_fontSelector->unregisterForInvalidationCallbacks(this); |
| 100 } | 100 } |
| 101 | 101 |
| 102 // Decrement reference counts for things we could be keeping alive. | 102 // Decrement reference counts for things we could be keeping alive. |
| 103 m_fontSelector.clear(); | 103 m_fontSelector.clear(); |
| 104 m_resolver.clear(); | 104 m_resolver.clear(); |
| 105 m_styleSheetCollectionMap.clear(); | 105 m_styleSheetCollectionMap.clear(); |
| 106 for (const auto& resolver : m_scopedStyleResolvers) | 106 m_activeTreeScopes.clear(); |
| 107 const_cast<TreeScope&>(resolver->treeScope()).clearScopedStyleResolver()
; | |
| 108 m_scopedStyleResolvers.clear(); | |
| 109 } | 107 } |
| 110 #endif | 108 #endif |
| 111 | 109 |
| 112 inline Document* StyleEngine::master() | 110 inline Document* StyleEngine::master() |
| 113 { | 111 { |
| 114 if (isMaster()) | 112 if (isMaster()) |
| 115 return m_document; | 113 return m_document; |
| 116 HTMLImportsController* import = document().importsController(); | 114 HTMLImportsController* import = document().importsController(); |
| 117 if (!import) // Document::import() can return null while executing its destr
uctor. | 115 if (!import) // Document::import() can return null while executing its destr
uctor. |
| 118 return 0; | 116 return 0; |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { | 387 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { |
| 390 TreeScopeSet treeScopes = updateMode == FullStyleUpdate ? m_activeTreeSc
opes : m_dirtyTreeScopes; | 388 TreeScopeSet treeScopes = updateMode == FullStyleUpdate ? m_activeTreeSc
opes : m_dirtyTreeScopes; |
| 391 HashSet<TreeScope*> treeScopesRemoved; | 389 HashSet<TreeScope*> treeScopesRemoved; |
| 392 | 390 |
| 393 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.en
d(); ++it) { | 391 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.en
d(); ++it) { |
| 394 TreeScope* treeScope = *it; | 392 TreeScope* treeScope = *it; |
| 395 ASSERT(treeScope != m_document); | 393 ASSERT(treeScope != m_document); |
| 396 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeS
tyleSheetCollection*>(styleSheetCollectionFor(*treeScope)); | 394 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeS
tyleSheetCollection*>(styleSheetCollectionFor(*treeScope)); |
| 397 ASSERT(collection); | 395 ASSERT(collection); |
| 398 collection->updateActiveStyleSheets(this, updateMode); | 396 collection->updateActiveStyleSheets(this, updateMode); |
| 399 if (!collection->hasStyleSheetCandidateNodes()) | 397 if (!collection->hasStyleSheetCandidateNodes()) { |
| 400 treeScopesRemoved.add(treeScope); | 398 treeScopesRemoved.add(treeScope); |
| 399 // When removing TreeScope from ActiveTreeScopes, |
| 400 // its resolver should be destroyed by invoking resetAuthorStyle
. |
| 401 ASSERT(!treeScope->scopedStyleResolver()); |
| 402 } |
| 401 } | 403 } |
| 402 m_activeTreeScopes.removeAll(treeScopesRemoved); | 404 m_activeTreeScopes.removeAll(treeScopesRemoved); |
| 403 } | 405 } |
| 404 | 406 |
| 405 InspectorInstrumentation::activeStyleSheetsUpdated(m_document); | 407 InspectorInstrumentation::activeStyleSheetsUpdated(m_document); |
| 406 m_usesRemUnits = documentStyleSheetCollection()->usesRemUnits(); | 408 m_usesRemUnits = documentStyleSheetCollection()->usesRemUnits(); |
| 407 | 409 |
| 408 m_dirtyTreeScopes.clear(); | 410 m_dirtyTreeScopes.clear(); |
| 409 m_documentScopeDirty = false; | 411 m_documentScopeDirty = false; |
| 410 } | 412 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 426 } | 428 } |
| 427 | 429 |
| 428 // FIXME: Inspector needs a vector which has all active stylesheets. | 430 // FIXME: Inspector needs a vector which has all active stylesheets. |
| 429 // However, creating such a large vector might cause performance regression. | 431 // However, creating such a large vector might cause performance regression. |
| 430 // Need to implement some smarter solution. | 432 // Need to implement some smarter solution. |
| 431 return activeStyleSheets; | 433 return activeStyleSheets; |
| 432 } | 434 } |
| 433 | 435 |
| 434 void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot) | 436 void StyleEngine::didRemoveShadowRoot(ShadowRoot* shadowRoot) |
| 435 { | 437 { |
| 436 if (shadowRoot->scopedStyleResolver()) | |
| 437 removeScopedStyleResolver(shadowRoot->scopedStyleResolver()); | |
| 438 m_styleSheetCollectionMap.remove(shadowRoot); | 438 m_styleSheetCollectionMap.remove(shadowRoot); |
| 439 } | 439 } |
| 440 | 440 |
| 441 void StyleEngine::appendActiveAuthorStyleSheets() | 441 void StyleEngine::appendActiveAuthorStyleSheets() |
| 442 { | 442 { |
| 443 ASSERT(isMaster()); | 443 ASSERT(isMaster()); |
| 444 | 444 |
| 445 m_resolver->appendAuthorStyleSheets(documentStyleSheetCollection()->activeAu
thorStyleSheets()); | 445 m_resolver->appendAuthorStyleSheets(documentStyleSheetCollection()->activeAu
thorStyleSheets()); |
| 446 | 446 |
| 447 TreeScopeSet::iterator begin = m_activeTreeScopes.begin(); | 447 TreeScopeSet::iterator begin = m_activeTreeScopes.begin(); |
| 448 TreeScopeSet::iterator end = m_activeTreeScopes.end(); | 448 TreeScopeSet::iterator end = m_activeTreeScopes.end(); |
| 449 for (TreeScopeSet::iterator it = begin; it != end; ++it) { | 449 for (TreeScopeSet::iterator it = begin; it != end; ++it) { |
| 450 if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMa
p.get(*it)) | 450 if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMa
p.get(*it)) |
| 451 m_resolver->appendAuthorStyleSheets(collection->activeAuthorStyleShe
ets()); | 451 m_resolver->appendAuthorStyleSheets(collection->activeAuthorStyleShe
ets()); |
| 452 } | 452 } |
| 453 m_resolver->finishAppendAuthorStyleSheets(); | 453 m_resolver->finishAppendAuthorStyleSheets(); |
| 454 } | 454 } |
| 455 | 455 |
| 456 void StyleEngine::createResolver() | 456 void StyleEngine::createResolver() |
| 457 { | 457 { |
| 458 // It is a programming error to attempt to resolve style on a Document | 458 // It is a programming error to attempt to resolve style on a Document |
| 459 // which is not in a frame. Code which hits this should have checked | 459 // which is not in a frame. Code which hits this should have checked |
| 460 // Document::isActive() before calling into code which could get here. | 460 // Document::isActive() before calling into code which could get here. |
| 461 | 461 |
| 462 ASSERT(document().frame()); | 462 ASSERT(document().frame()); |
| 463 | 463 |
| 464 m_resolver = adoptPtrWillBeNoop(new StyleResolver(*m_document)); | 464 m_resolver = adoptPtrWillBeNoop(new StyleResolver(*m_document)); |
| 465 addScopedStyleResolver(&m_document->ensureScopedStyleResolver()); | |
| 466 | 465 |
| 466 // A scoped style resolver for document will be created during |
| 467 // appendActiveAuthorStyleSheets if needed. |
| 467 appendActiveAuthorStyleSheets(); | 468 appendActiveAuthorStyleSheets(); |
| 468 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet()); | 469 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet()); |
| 469 } | 470 } |
| 470 | 471 |
| 471 void StyleEngine::clearResolver() | 472 void StyleEngine::clearResolver() |
| 472 { | 473 { |
| 473 ASSERT(!document().inStyleRecalc()); | 474 ASSERT(!document().inStyleRecalc()); |
| 474 ASSERT(isMaster() || !m_resolver); | 475 ASSERT(isMaster() || !m_resolver); |
| 475 | 476 |
| 476 for (const auto& resolver: m_scopedStyleResolvers) | 477 document().clearScopedStyleResolver(); |
| 477 const_cast<TreeScope&>(resolver->treeScope()).clearScopedStyleResolver()
; | 478 for (auto& treeScope: m_activeTreeScopes) |
| 478 m_scopedStyleResolvers.clear(); | 479 treeScope->clearScopedStyleResolver(); |
| 479 | 480 |
| 480 if (m_resolver) | 481 if (m_resolver) |
| 481 document().updateStyleInvalidationIfNeeded(); | 482 document().updateStyleInvalidationIfNeeded(); |
| 482 m_resolver.clear(); | 483 m_resolver.clear(); |
| 483 } | 484 } |
| 484 | 485 |
| 485 void StyleEngine::clearMasterResolver() | 486 void StyleEngine::clearMasterResolver() |
| 486 { | 487 { |
| 487 if (Document* master = this->master()) | 488 if (Document* master = this->master()) |
| 488 master->styleEngine()->clearResolver(); | 489 master->styleEngine()->clearResolver(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 if (it == m_sheetToTextCache.end()) | 636 if (it == m_sheetToTextCache.end()) |
| 636 return; | 637 return; |
| 637 | 638 |
| 638 m_textToSheetCache.remove(it->value); | 639 m_textToSheetCache.remove(it->value); |
| 639 m_sheetToTextCache.remove(contents); | 640 m_sheetToTextCache.remove(contents); |
| 640 } | 641 } |
| 641 | 642 |
| 642 void StyleEngine::collectScopedStyleFeaturesTo(RuleFeatureSet& features) const | 643 void StyleEngine::collectScopedStyleFeaturesTo(RuleFeatureSet& features) const |
| 643 { | 644 { |
| 644 HashSet<const StyleSheetContents*> visitedSharedStyleSheetContents; | 645 HashSet<const StyleSheetContents*> visitedSharedStyleSheetContents; |
| 645 for (const auto& resolver : m_scopedStyleResolvers) | 646 if (document().scopedStyleResolver()) |
| 646 resolver->collectFeaturesTo(features, visitedSharedStyleSheetContents); | 647 document().scopedStyleResolver()->collectFeaturesTo(features, visitedSha
redStyleSheetContents); |
| 648 for (auto& treeScope: m_activeTreeScopes) { |
| 649 ASSERT(treeScope->scopedStyleResolver()); |
| 650 treeScope->scopedStyleResolver()->collectFeaturesTo(features, visitedSha
redStyleSheetContents); |
| 651 } |
| 647 } | 652 } |
| 648 | 653 |
| 649 void StyleEngine::fontsNeedUpdate(CSSFontSelector*) | 654 void StyleEngine::fontsNeedUpdate(CSSFontSelector*) |
| 650 { | 655 { |
| 651 if (!document().isActive()) | 656 if (!document().isActive()) |
| 652 return; | 657 return; |
| 653 | 658 |
| 654 if (m_resolver) | 659 if (m_resolver) |
| 655 m_resolver->invalidateMatchedPropertiesCache(); | 660 m_resolver->invalidateMatchedPropertiesCache(); |
| 656 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci
ng::create(StyleChangeReason::Fonts)); | 661 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci
ng::create(StyleChangeReason::Fonts)); |
| 657 } | 662 } |
| 658 | 663 |
| 659 void StyleEngine::trace(Visitor* visitor) | 664 void StyleEngine::trace(Visitor* visitor) |
| 660 { | 665 { |
| 661 #if ENABLE(OILPAN) | 666 #if ENABLE(OILPAN) |
| 662 visitor->trace(m_document); | 667 visitor->trace(m_document); |
| 663 visitor->trace(m_injectedAuthorStyleSheets); | 668 visitor->trace(m_injectedAuthorStyleSheets); |
| 664 visitor->trace(m_authorStyleSheets); | 669 visitor->trace(m_authorStyleSheets); |
| 665 visitor->trace(m_documentStyleSheetCollection); | 670 visitor->trace(m_documentStyleSheetCollection); |
| 666 visitor->trace(m_styleSheetCollectionMap); | 671 visitor->trace(m_styleSheetCollectionMap); |
| 667 visitor->trace(m_scopedStyleResolvers); | |
| 668 visitor->trace(m_resolver); | 672 visitor->trace(m_resolver); |
| 669 visitor->trace(m_fontSelector); | 673 visitor->trace(m_fontSelector); |
| 670 visitor->trace(m_textToSheetCache); | 674 visitor->trace(m_textToSheetCache); |
| 671 visitor->trace(m_sheetToTextCache); | 675 visitor->trace(m_sheetToTextCache); |
| 672 #endif | 676 #endif |
| 673 CSSFontSelectorClient::trace(visitor); | 677 CSSFontSelectorClient::trace(visitor); |
| 674 } | 678 } |
| 675 | 679 |
| 676 } | 680 } |
| OLD | NEW |