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

Side by Side Diff: Source/core/css/RuleFeature.h

Issue 143873016: Implement style invalidation tree walk for targeted style recalc upon class change. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed unused methods. Created 6 years, 11 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 | « no previous file | Source/core/css/RuleFeature.cpp » ('j') | Source/core/css/RuleFeature.cpp » ('J')
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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 11 matching lines...) Expand all
22 #ifndef RuleFeature_h 22 #ifndef RuleFeature_h
23 #define RuleFeature_h 23 #define RuleFeature_h
24 24
25 #include "core/css/analyzer/DescendantInvalidationSet.h" 25 #include "core/css/analyzer/DescendantInvalidationSet.h"
26 #include "wtf/Forward.h" 26 #include "wtf/Forward.h"
27 #include "wtf/HashSet.h" 27 #include "wtf/HashSet.h"
28 #include "wtf/text/AtomicStringHash.h" 28 #include "wtf/text/AtomicStringHash.h"
29 29
30 namespace WebCore { 30 namespace WebCore {
31 31
32 class Document;
33 class ShadowRoot;
32 class StyleRule; 34 class StyleRule;
33 class CSSSelector; 35 class CSSSelector;
34 class CSSSelectorList; 36 class CSSSelectorList;
35 class RuleData; 37 class RuleData;
38 class SpaceSplitString;
36 39
37 struct RuleFeature { 40 struct RuleFeature {
38 RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocumentSecurit yOrigin) 41 RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocumentSecurit yOrigin)
39 : rule(rule) 42 : rule(rule)
40 , selectorIndex(selectorIndex) 43 , selectorIndex(selectorIndex)
41 , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) 44 , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin)
42 { 45 {
43 } 46 }
44 StyleRule* rule; 47 StyleRule* rule;
45 unsigned selectorIndex; 48 unsigned selectorIndex;
(...skipping 26 matching lines...) Expand all
72 { 75 {
73 ASSERT(!classValue.isEmpty()); 76 ASSERT(!classValue.isEmpty());
74 return m_metadata.classesInRules.contains(classValue); 77 return m_metadata.classesInRules.contains(classValue);
75 } 78 }
76 79
77 inline bool hasSelectorForId(const AtomicString& idValue) const 80 inline bool hasSelectorForId(const AtomicString& idValue) const
78 { 81 {
79 return m_metadata.idsInRules.contains(idValue); 82 return m_metadata.idsInRules.contains(idValue);
80 } 83 }
81 84
85 // If a class changed on the element, this method should be called in order to schedule style recalc.
86 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed Classes, Element*);
esprehn 2014/01/28 00:11:34 Element&
chrishtr 2014/01/28 01:11:55 Done.
87 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas ses, const SpaceSplitString& newClasses, Element*);
esprehn 2014/01/28 00:11:34 Element&
chrishtr 2014/01/28 01:11:55 Done.
88
89 // Computes which elements in the document need style recalculation.
90 void computeStyleInvalidation(Document*);
esprehn 2014/01/28 00:11:34 Document&
chrishtr 2014/01/28 01:11:55 Done.
91
82 int hasIdsInSelectors() const 92 int hasIdsInSelectors() const
83 { 93 {
84 return m_metadata.idsInRules.size() > 0; 94 return m_metadata.idsInRules.size() > 0;
85 } 95 }
86 96
87 // Marks the given attribute name as "appearing in a selector". Used for 97 // Marks the given attribute name as "appearing in a selector". Used for
88 // CSS properties such as content: ... attr(...) ... 98 // CSS properties such as content: ... attr(...) ...
89 void addAttributeInASelector(const AtomicString& attributeName); 99 void addAttributeInASelector(const AtomicString& attributeName);
90 100
91 Vector<RuleFeature> siblingRules; 101 Vector<RuleFeature> siblingRules;
92 Vector<RuleFeature> uncommonAttributeRules; 102 Vector<RuleFeature> uncommonAttributeRules;
93 103
94 private: 104 private:
95 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati onSetMap; 105 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati onSetMap;
106 typedef Vector<DescendantInvalidationSet*> InvalidationVec;
esprehn 2014/01/28 00:11:34 Don't use abbreviations like Vec. I'd use Invalida
chrishtr 2014/01/28 01:11:55 Done.
107 typedef HashMap<Element*, InvalidationVec* > PendingInvalidationMap;
esprehn 2014/01/28 00:11:34 No need for the space before >
chrishtr 2014/01/28 01:11:55 Done.
96 struct FeatureMetadata { 108 struct FeatureMetadata {
97 FeatureMetadata() 109 FeatureMetadata()
98 : usesFirstLineRules(false) 110 : usesFirstLineRules(false)
99 , foundSiblingSelector(false) 111 , foundSiblingSelector(false)
100 , maxDirectAdjacentSelectors(0) 112 , maxDirectAdjacentSelectors(0)
101 { } 113 { }
102 void add(const FeatureMetadata& other); 114 void add(const FeatureMetadata& other);
103 void clear(); 115 void clear();
104 116
105 bool usesFirstLineRules; 117 bool usesFirstLineRules;
106 bool foundSiblingSelector; 118 bool foundSiblingSelector;
107 unsigned maxDirectAdjacentSelectors; 119 unsigned maxDirectAdjacentSelectors;
108 HashSet<AtomicString> idsInRules; 120 HashSet<AtomicString> idsInRules;
109 HashSet<AtomicString> classesInRules; 121 HashSet<AtomicString> classesInRules;
110 HashSet<AtomicString> attrsInRules; 122 HashSet<AtomicString> attrsInRules;
111 }; 123 };
112 124
125 // These return true if setNeedsStyleRecalc() should be run on the Element, as a fallback.
126 bool scheduleStyleInvalidationForClassChangeInternal(const SpaceSplitString& changedClasses, Element*);
127 bool scheduleStyleInvalidationForClassChangeInternal(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, Element*);
esprehn 2014/01/28 00:11:34 Same, these should all take refs.
chrishtr 2014/01/28 01:11:55 The Element pointer is the key to the invalidation
128
113 void collectFeaturesFromSelector(const CSSSelector*, FeatureMetadata&); 129 void collectFeaturesFromSelector(const CSSSelector*, FeatureMetadata&);
114 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata &); 130 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata &);
131
115 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl assName); 132 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl assName);
116 bool updateClassInvalidationSets(const CSSSelector*); 133 bool updateClassInvalidationSets(const CSSSelector*);
117 134
135 void scheduleStyleInvalidationForOneClass(const AtomicString& className, Ele ment*);
136
137 bool computeStyleInvalidationInternal(Element*, Vector<AtomicString>&, bool foundInvalidationSet);
138 bool computeStyleInvalidationForChildren(Element*, Vector<AtomicString>& inv alidationClasses, bool foundInvalidationSet);
139
140 InvalidationVec* ensurePendingInvalidationVector(Element*);
141
142 FeatureMetadata m_metadata;
143
118 InvalidationSetMap m_classInvalidationSets; 144 InvalidationSetMap m_classInvalidationSets;
119 FeatureMetadata m_metadata; 145
146 PendingInvalidationMap m_pendingInvalidationMap;
120 }; 147 };
121 148
122 } // namespace WebCore 149 } // namespace WebCore
123 150
124 #endif // RuleFeature_h 151 #endif // RuleFeature_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/RuleFeature.cpp » ('j') | Source/core/css/RuleFeature.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698