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

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

Issue 1111643003: Move StyleInvalidator to StyleEngine. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 m_fontSelector = fontSelector; 687 m_fontSelector = fontSelector;
688 } 688 }
689 689
690 void StyleEngine::platformColorsChanged() 690 void StyleEngine::platformColorsChanged()
691 { 691 {
692 if (m_resolver) 692 if (m_resolver)
693 m_resolver->invalidateMatchedPropertiesCache(); 693 m_resolver->invalidateMatchedPropertiesCache();
694 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci ng::create(StyleChangeReason::PlatformColorChange)); 694 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci ng::create(StyleChangeReason::PlatformColorChange));
695 } 695 }
696 696
697 void StyleEngine::classChangedForElement(const SpaceSplitString& changedClasses, Element& element)
698 {
699 ASSERT(isMaster());
700 InvalidationSetVector invalidationSets;
701 unsigned changedSize = changedClasses.size();
702 for (unsigned i = 0; i < changedSize; ++i)
703 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsFo rClass(invalidationSets, element, changedClasses[i]);
esprehn 2015/04/30 05:40:24 I don't think you want to call ensureUpdatedRuleFe
rune 2015/04/30 08:05:57 Done.
704 scheduleInvalidationSetsForElement(invalidationSets, element);
705 }
706
707 void StyleEngine::classChangedForElement(const SpaceSplitString& oldClasses, con st SpaceSplitString& newClasses, Element& element)
708 {
709 ASSERT(isMaster());
710 InvalidationSetVector invalidationSets;
711 if (!oldClasses.size()) {
712 classChangedForElement(newClasses, element);
713 return;
714 }
715
716 // Class vectors tend to be very short. This is faster than using a hash tab le.
717 BitVector remainingClassBits;
718 remainingClassBits.ensureSize(oldClasses.size());
719
720 for (unsigned i = 0; i < newClasses.size(); ++i) {
721 bool found = false;
722 for (unsigned j = 0; j < oldClasses.size(); ++j) {
723 if (newClasses[i] == oldClasses[j]) {
724 // Mark each class that is still in the newClasses so we can ski p doing
725 // an n^2 search below when looking for removals. We can't break from
726 // this loop early since a class can appear more than once.
727 remainingClassBits.quickSet(j);
728 found = true;
729 }
730 }
731 // Class was added.
732 if (!found)
733 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSe tsForClass(invalidationSets, element, newClasses[i]);
734 }
735
736 for (unsigned i = 0; i < oldClasses.size(); ++i) {
737 if (remainingClassBits.quickGet(i))
738 continue;
739 // Class was removed.
740 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsFo rClass(invalidationSets, element, oldClasses[i]);
esprehn 2015/04/30 05:40:24 ditto. Don't want to call ensureResolver or ensure
rune 2015/04/30 08:05:57 Done.
741 }
742
743 scheduleInvalidationSetsForElement(invalidationSets, element);
744 }
745
746 void StyleEngine::attributeChangedForElement(const QualifiedName& attributeName, Element& element)
747 {
748 ASSERT(isMaster());
749 InvalidationSetVector invalidationSets;
750 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForAtt ribute(invalidationSets, element, attributeName);
751 scheduleInvalidationSetsForElement(invalidationSets, element);
752 }
753
754 void StyleEngine::idChangedForElement(const AtomicString& oldId, const AtomicStr ing& newId, Element& element)
755 {
756 ASSERT(isMaster());
757 InvalidationSetVector invalidationSets;
758 if (!oldId.isEmpty())
759 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsFo rId(invalidationSets, element, oldId);
760 if (!newId.isEmpty())
761 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsFo rId(invalidationSets, element, newId);
762 scheduleInvalidationSetsForElement(invalidationSets, element);
763 }
764
765 void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoTyp e, Element& element)
766 {
767 ASSERT(isMaster());
768 InvalidationSetVector invalidationSets;
769 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForPse udoClass(invalidationSets, element, pseudoType);
770 scheduleInvalidationSetsForElement(invalidationSets, element);
771 }
772
773 void StyleEngine::scheduleInvalidationSetsForElement(const InvalidationSetVector & invalidationSets, Element& element)
774 {
775 for (auto invalidationSet : invalidationSets)
776 m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
777 }
778
697 DEFINE_TRACE(StyleEngine) 779 DEFINE_TRACE(StyleEngine)
698 { 780 {
699 #if ENABLE(OILPAN) 781 #if ENABLE(OILPAN)
700 visitor->trace(m_document); 782 visitor->trace(m_document);
701 visitor->trace(m_authorStyleSheets); 783 visitor->trace(m_authorStyleSheets);
702 visitor->trace(m_documentStyleSheetCollection); 784 visitor->trace(m_documentStyleSheetCollection);
703 visitor->trace(m_styleSheetCollectionMap); 785 visitor->trace(m_styleSheetCollectionMap);
704 visitor->trace(m_resolver); 786 visitor->trace(m_resolver);
787 visitor->trace(m_styleInvalidator);
705 visitor->trace(m_dirtyTreeScopes); 788 visitor->trace(m_dirtyTreeScopes);
706 visitor->trace(m_activeTreeScopes); 789 visitor->trace(m_activeTreeScopes);
707 visitor->trace(m_fontSelector); 790 visitor->trace(m_fontSelector);
708 visitor->trace(m_textToSheetCache); 791 visitor->trace(m_textToSheetCache);
709 visitor->trace(m_sheetToTextCache); 792 visitor->trace(m_sheetToTextCache);
710 #endif 793 #endif
711 CSSFontSelectorClient::trace(visitor); 794 CSSFontSelectorClient::trace(visitor);
712 } 795 }
713 796
714 } 797 }
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