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

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

Issue 2683373003: RuleSet invalidations on single feature only, including tags. (Closed)
Patch Set: Trace type ruleset invalidation Created 3 years, 10 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
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 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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 AtomicString id; 813 AtomicString id;
814 const SpaceSplitString* classNames = nullptr; 814 const SpaceSplitString* classNames = nullptr;
815 815
816 if (element.hasID()) 816 if (element.hasID())
817 id = element.idForStyleResolution(); 817 id = element.idForStyleResolution();
818 if (element.hasClass()) 818 if (element.hasClass())
819 classNames = &element.classNames(); 819 classNames = &element.classNames();
820 820
821 InvalidationLists invalidationLists; 821 InvalidationLists invalidationLists;
822 for (const auto& ruleSet : ruleSets) { 822 for (const auto& ruleSet : ruleSets) {
823 if (!id.isNull()) 823 if (!id.isNull()) {
824 ruleSet->features().collectInvalidationSetsForId(invalidationLists, 824 ruleSet->features().collectInvalidationSetsForId(
825 element, id); 825 invalidationLists, element, id,
826 RuleFeatureSet::InvalidationSetFilter::RuleSetInvalidation);
827 }
826 if (classNames) { 828 if (classNames) {
827 unsigned classNameCount = classNames->size(); 829 unsigned classNameCount = classNames->size();
828 for (size_t i = 0; i < classNameCount; i++) 830 for (size_t i = 0; i < classNameCount; i++) {
829 ruleSet->features().collectInvalidationSetsForClass( 831 ruleSet->features().collectInvalidationSetsForClass(
830 invalidationLists, element, (*classNames)[i]); 832 invalidationLists, element, (*classNames)[i],
833 RuleFeatureSet::InvalidationSetFilter::RuleSetInvalidation);
834 }
831 } 835 }
832 for (const Attribute& attribute : element.attributes()) 836 for (const Attribute& attribute : element.attributes()) {
833 ruleSet->features().collectInvalidationSetsForAttribute( 837 ruleSet->features().collectInvalidationSetsForAttribute(
834 invalidationLists, element, attribute.name()); 838 invalidationLists, element, attribute.name(),
835 if (ruleSet->tagRules(element.localNameForSelectorMatching())) 839 RuleFeatureSet::InvalidationSetFilter::RuleSetInvalidation);
836 element.setNeedsStyleRecalc(LocalStyleChange, 840 }
837 StyleChangeReasonForTracing::create(
838 StyleChangeReason::StyleSheetChange));
839 } 841 }
840 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, 842 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists,
841 element); 843 element);
842 } 844 }
843 845
846 void StyleEngine::scheduleTypeRuleSetInvalidations(
847 ContainerNode& node,
848 const HeapHashSet<Member<RuleSet>>& ruleSets) {
849 InvalidationLists invalidationLists;
850 for (const auto& ruleSet : ruleSets)
851 ruleSet->features().collectTypeRuleInvalidationSet(invalidationLists, node);
852 DCHECK(invalidationLists.siblings.isEmpty());
853 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, node);
854 }
855
844 void StyleEngine::invalidateSlottedElements(HTMLSlotElement& slot) { 856 void StyleEngine::invalidateSlottedElements(HTMLSlotElement& slot) {
845 for (auto& node : slot.getDistributedNodes()) { 857 for (auto& node : slot.getDistributedNodes()) {
846 if (node->isElementNode()) 858 if (node->isElementNode())
847 node->setNeedsStyleRecalc(LocalStyleChange, 859 node->setNeedsStyleRecalc(LocalStyleChange,
848 StyleChangeReasonForTracing::create( 860 StyleChangeReasonForTracing::create(
849 StyleChangeReason::StyleSheetChange)); 861 StyleChangeReason::StyleSheetChange));
850 } 862 }
851 } 863 }
852 864
853 void StyleEngine::scheduleInvalidationsForRuleSets( 865 void StyleEngine::scheduleInvalidationsForRuleSets(
854 TreeScope& treeScope, 866 TreeScope& treeScope,
855 const HeapHashSet<Member<RuleSet>>& ruleSets) { 867 const HeapHashSet<Member<RuleSet>>& ruleSets) {
856 #if DCHECK_IS_ON() 868 #if DCHECK_IS_ON()
857 // Full scope recalcs should be handled while collecting the ruleSets before 869 // Full scope recalcs should be handled while collecting the ruleSets before
858 // calling this method. 870 // calling this method.
859 for (auto ruleSet : ruleSets) 871 for (auto ruleSet : ruleSets)
860 DCHECK(!ruleSet->features().needsFullRecalcForRuleSetInvalidation()); 872 DCHECK(!ruleSet->features().needsFullRecalcForRuleSetInvalidation());
861 #endif // DCHECK_IS_ON() 873 #endif // DCHECK_IS_ON()
862 874
863 TRACE_EVENT0("blink,blink_style", 875 TRACE_EVENT0("blink,blink_style",
864 "StyleEngine::scheduleInvalidationsForRuleSets"); 876 "StyleEngine::scheduleInvalidationsForRuleSets");
865 877
878 scheduleTypeRuleSetInvalidations(treeScope.rootNode(), ruleSets);
879
866 bool invalidateSlotted = false; 880 bool invalidateSlotted = false;
867 if (treeScope.rootNode().isShadowRoot()) { 881 if (treeScope.rootNode().isShadowRoot()) {
868 Element& host = toShadowRoot(treeScope.rootNode()).host(); 882 Element& host = toShadowRoot(treeScope.rootNode()).host();
869 scheduleRuleSetInvalidationsForElement(host, ruleSets); 883 scheduleRuleSetInvalidationsForElement(host, ruleSets);
870 if (host.getStyleChangeType() >= SubtreeStyleChange) 884 if (host.getStyleChangeType() >= SubtreeStyleChange)
871 return; 885 return;
872 for (auto ruleSet : ruleSets) { 886 for (auto ruleSet : ruleSets) {
873 if (ruleSet->hasSlottedRules()) { 887 if (ruleSet->hasSlottedRules()) {
874 invalidateSlotted = true; 888 invalidateSlotted = true;
875 break; 889 break;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 } 1160 }
1147 1161
1148 DEFINE_TRACE_WRAPPERS(StyleEngine) { 1162 DEFINE_TRACE_WRAPPERS(StyleEngine) {
1149 for (auto sheet : m_injectedAuthorStyleSheets) { 1163 for (auto sheet : m_injectedAuthorStyleSheets) {
1150 visitor->traceWrappers(sheet); 1164 visitor->traceWrappers(sheet);
1151 } 1165 }
1152 visitor->traceWrappers(m_documentStyleSheetCollection); 1166 visitor->traceWrappers(m_documentStyleSheetCollection);
1153 } 1167 }
1154 1168
1155 } // namespace blink 1169 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | third_party/WebKit/Source/core/dom/StyleEngineTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698