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

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

Issue 304083003: Made StyleEngine CSSFontSelectorClient instead of StyleResolver. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/StyleEngine.h ('k') | no next file » | 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 m_resolver->setBuildScopedStyleTreeInDocumentOrder(false); 444 m_resolver->setBuildScopedStyleTreeInDocumentOrder(false);
444 } 445 }
445 446
446 void StyleEngine::createResolver() 447 void StyleEngine::createResolver()
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 454
455 m_resolver = adoptPtrWillBeNoop(new StyleResolver(*m_document)); 455 m_resolver = adoptPtrWillBeNoop(new StyleResolver(*m_document));
456 appendActiveAuthorStyleSheets(); 456 appendActiveAuthorStyleSheets();
457 m_fontSelector->registerForInvalidationCallbacks(m_resolver.get());
458 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet()); 457 combineCSSFeatureFlags(m_resolver->ensureUpdatedRuleFeatureSet());
459 } 458 }
460 459
461 void StyleEngine::clearResolver() 460 void StyleEngine::clearResolver()
462 { 461 {
463 ASSERT(!document().inStyleRecalc()); 462 ASSERT(!document().inStyleRecalc());
464 ASSERT(isMaster() || !m_resolver); 463 ASSERT(isMaster() || !m_resolver);
465 ASSERT(m_fontSelector || !m_resolver); 464 if (m_resolver)
466 if (m_resolver) {
467 document().updateStyleInvalidationIfNeeded(); 465 document().updateStyleInvalidationIfNeeded();
468 #if !ENABLE(OILPAN)
469 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get());
470 #endif
471 }
472 m_resolver.clear(); 466 m_resolver.clear();
473 } 467 }
474 468
475 void StyleEngine::clearMasterResolver() 469 void StyleEngine::clearMasterResolver()
476 { 470 {
477 if (Document* master = this->master()) 471 if (Document* master = this->master())
478 master->styleEngine()->clearResolver(); 472 master->styleEngine()->clearResolver();
479 } 473 }
480 474
481 unsigned StyleEngine::resolverAccessCount() const 475 unsigned StyleEngine::resolverAccessCount() const
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 void StyleEngine::removeSheet(StyleSheetContents* contents) 621 void StyleEngine::removeSheet(StyleSheetContents* contents)
628 { 622 {
629 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString>::ite rator it = m_sheetToTextCache.find(contents); 623 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString>::ite rator it = m_sheetToTextCache.find(contents);
630 if (it == m_sheetToTextCache.end()) 624 if (it == m_sheetToTextCache.end())
631 return; 625 return;
632 626
633 m_textToSheetCache.remove(it->value); 627 m_textToSheetCache.remove(it->value);
634 m_sheetToTextCache.remove(contents); 628 m_sheetToTextCache.remove(contents);
635 } 629 }
636 630
631 void StyleEngine::fontsNeedUpdate(CSSFontSelector*)
632 {
633 if (!document().isActive())
634 return;
635
636 if (m_resolver)
637 m_resolver->invalidateMatchedPropertiesCache();
638 document().setNeedsStyleRecalc(SubtreeStyleChange);
639 }
640
637 void StyleEngine::trace(Visitor* visitor) 641 void StyleEngine::trace(Visitor* visitor)
638 { 642 {
639 visitor->trace(m_document); 643 visitor->trace(m_document);
640 visitor->trace(m_injectedAuthorStyleSheets); 644 visitor->trace(m_injectedAuthorStyleSheets);
641 visitor->trace(m_authorStyleSheets); 645 visitor->trace(m_authorStyleSheets);
642 visitor->trace(m_documentStyleSheetCollection); 646 visitor->trace(m_documentStyleSheetCollection);
643 visitor->trace(m_styleSheetCollectionMap); 647 visitor->trace(m_styleSheetCollectionMap);
644 visitor->trace(m_resolver); 648 visitor->trace(m_resolver);
645 visitor->trace(m_fontSelector); 649 visitor->trace(m_fontSelector);
646 visitor->trace(m_textToSheetCache); 650 visitor->trace(m_textToSheetCache);
647 visitor->trace(m_sheetToTextCache); 651 visitor->trace(m_sheetToTextCache);
652 CSSFontSelectorClient::trace(visitor);
648 } 653 }
649 654
650 } 655 }
OLDNEW
« no previous file with comments | « Source/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698