Chromium Code Reviews| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 , m_usesFirstLineRules(false) | 69 , m_usesFirstLineRules(false) |
| 70 , m_usesFirstLetterRules(false) | 70 , m_usesFirstLetterRules(false) |
| 71 , m_usesRemUnits(false) | 71 , m_usesRemUnits(false) |
| 72 , m_maxDirectAdjacentSelectors(0) | 72 , m_maxDirectAdjacentSelectors(0) |
| 73 , m_ignorePendingStylesheets(false) | 73 , m_ignorePendingStylesheets(false) |
| 74 , m_didCalculateResolver(false) | 74 , m_didCalculateResolver(false) |
| 75 // We don't need to create CSSFontSelector for imported document or | 75 // We don't need to create CSSFontSelector for imported document or |
| 76 // HTMLTemplateElement's document, because those documents have no frame. | 76 // HTMLTemplateElement's document, because those documents have no frame. |
| 77 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nul lptr) | 77 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nul lptr) |
| 78 { | 78 { |
| 79 if (m_fontSelector) | |
| 80 m_fontSelector->registerForInvalidationCallbacks(this); | |
| 79 } | 81 } |
| 80 | 82 |
| 81 StyleEngine::~StyleEngine() | 83 StyleEngine::~StyleEngine() |
| 82 { | 84 { |
| 83 } | 85 } |
| 84 | 86 |
| 85 #if !ENABLE(OILPAN) | 87 #if !ENABLE(OILPAN) |
| 86 void StyleEngine::detachFromDocument() | 88 void StyleEngine::detachFromDocument() |
| 87 { | 89 { |
| 88 // Cleanup is performed eagerly when the StyleEngine is removed from the | 90 // Cleanup is performed eagerly when the StyleEngine is removed from the |
| 89 // document. The StyleEngine is unreachable after this, since only the | 91 // document. The StyleEngine is unreachable after this, since only the |
| 90 // document has a reference to it. | 92 // document has a reference to it. |
| 91 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) | 93 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) |
| 92 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); | 94 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); |
| 93 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i) | 95 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i) |
| 94 m_authorStyleSheets[i]->clearOwnerNode(); | 96 m_authorStyleSheets[i]->clearOwnerNode(); |
| 95 | 97 |
| 96 if (m_fontSelector) { | 98 if (m_fontSelector) { |
| 97 m_fontSelector->clearDocument(); | 99 m_fontSelector->clearDocument(); |
| 98 if (m_resolver) | 100 m_fontSelector->unregisterForInvalidationCallbacks(this); |
| 99 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()) ; | |
| 100 } | 101 } |
| 101 | 102 |
| 102 // Decrement reference counts for things we could be keeping alive. | 103 // Decrement reference counts for things we could be keeping alive. |
| 103 m_fontSelector.clear(); | 104 m_fontSelector.clear(); |
| 104 m_resolver.clear(); | 105 m_resolver.clear(); |
| 105 m_styleSheetCollectionMap.clear(); | 106 m_styleSheetCollectionMap.clear(); |
| 106 } | 107 } |
| 107 #endif | 108 #endif |
| 108 | 109 |
| 109 inline Document* StyleEngine::master() | 110 inline Document* StyleEngine::master() |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 { | 448 { |
| 448 // It is a programming error to attempt to resolve style on a Document | 449 // It is a programming error to attempt to resolve style on a Document |
| 449 // which is not in a frame. Code which hits this should have checked | 450 // which is not in a frame. Code which hits this should have checked |
| 450 // Document::isActive() before calling into code which could get here. | 451 // Document::isActive() before calling into code which could get here. |
| 451 | 452 |
| 452 ASSERT(document().frame()); | 453 ASSERT(document().frame()); |
| 453 ASSERT(m_fontSelector); | 454 ASSERT(m_fontSelector); |
| 454 | 455 |
| 455 m_resolver = adoptPtrWillBeNoop(new StyleResolver(*m_document)); | 456 m_resolver = adoptPtrWillBeNoop(new StyleResolver(*m_document)); |
| 456 appendActiveAuthorStyleSheets(); | 457 appendActiveAuthorStyleSheets(); |
| 457 m_fontSelector->registerForInvalidationCallbacks(m_resolver.get()); | |
| 458 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet()); | 458 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet()); |
| 459 } | 459 } |
| 460 | 460 |
| 461 void StyleEngine::clearResolver() | 461 void StyleEngine::clearResolver() |
| 462 { | 462 { |
| 463 ASSERT(!document().inStyleRecalc()); | 463 ASSERT(!document().inStyleRecalc()); |
| 464 ASSERT(isMaster() || !m_resolver); | 464 ASSERT(isMaster() || !m_resolver); |
| 465 ASSERT(m_fontSelector || !m_resolver); | 465 ASSERT(m_fontSelector || !m_resolver); |
|
Kunihiko Sakamoto
2014/05/29 05:56:53
Maybe remove m_fontSelector assertion here and the
tasak
2014/05/30 04:18:28
Done.
| |
| 466 if (m_resolver) { | 466 if (m_resolver) |
| 467 document().updateStyleInvalidationIfNeeded(); | 467 document().updateStyleInvalidationIfNeeded(); |
| 468 #if !ENABLE(OILPAN) | |
| 469 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()); | |
| 470 #endif | |
| 471 } | |
| 472 m_resolver.clear(); | 468 m_resolver.clear(); |
| 473 } | 469 } |
| 474 | 470 |
| 475 void StyleEngine::clearMasterResolver() | 471 void StyleEngine::clearMasterResolver() |
| 476 { | 472 { |
| 477 if (Document* master = this->master()) | 473 if (Document* master = this->master()) |
| 478 master->styleEngine()->clearResolver(); | 474 master->styleEngine()->clearResolver(); |
| 479 } | 475 } |
| 480 | 476 |
| 481 unsigned StyleEngine::resolverAccessCount() const | 477 unsigned StyleEngine::resolverAccessCount() const |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 627 void StyleEngine::removeSheet(StyleSheetContents* contents) | 623 void StyleEngine::removeSheet(StyleSheetContents* contents) |
| 628 { | 624 { |
| 629 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString>::ite rator it = m_sheetToTextCache.find(contents); | 625 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString>::ite rator it = m_sheetToTextCache.find(contents); |
| 630 if (it == m_sheetToTextCache.end()) | 626 if (it == m_sheetToTextCache.end()) |
| 631 return; | 627 return; |
| 632 | 628 |
| 633 m_textToSheetCache.remove(it->value); | 629 m_textToSheetCache.remove(it->value); |
| 634 m_sheetToTextCache.remove(contents); | 630 m_sheetToTextCache.remove(contents); |
| 635 } | 631 } |
| 636 | 632 |
| 633 void StyleEngine::fontsNeedUpdate(CSSFontSelector*) | |
| 634 { | |
| 635 if (!document().isActive()) | |
| 636 return; | |
| 637 | |
| 638 if (m_resolver) | |
| 639 m_resolver->invalidateMatchedPropertiesCache(); | |
| 640 document().setNeedsStyleRecalc(SubtreeStyleChange); | |
| 641 } | |
| 642 | |
| 637 void StyleEngine::trace(Visitor* visitor) | 643 void StyleEngine::trace(Visitor* visitor) |
| 638 { | 644 { |
| 639 visitor->trace(m_document); | 645 visitor->trace(m_document); |
| 640 visitor->trace(m_injectedAuthorStyleSheets); | 646 visitor->trace(m_injectedAuthorStyleSheets); |
| 641 visitor->trace(m_authorStyleSheets); | 647 visitor->trace(m_authorStyleSheets); |
| 642 visitor->trace(m_documentStyleSheetCollection); | 648 visitor->trace(m_documentStyleSheetCollection); |
| 643 visitor->trace(m_styleSheetCollectionMap); | 649 visitor->trace(m_styleSheetCollectionMap); |
| 644 visitor->trace(m_resolver); | 650 visitor->trace(m_resolver); |
| 645 visitor->trace(m_fontSelector); | 651 visitor->trace(m_fontSelector); |
| 646 visitor->trace(m_textToSheetCache); | 652 visitor->trace(m_textToSheetCache); |
| 647 visitor->trace(m_sheetToTextCache); | 653 visitor->trace(m_sheetToTextCache); |
| 654 CSSFontSelectorClient::trace(visitor); | |
| 648 } | 655 } |
| 649 | 656 |
| 650 } | 657 } |
| OLD | NEW |