OLD | NEW |
---|---|
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 } | 75 } |
76 | 76 |
77 inline bool hasSelectorForClass(const AtomicString& classValue) const | 77 inline bool hasSelectorForClass(const AtomicString& classValue) const |
78 { | 78 { |
79 ASSERT(!classValue.isEmpty()); | 79 ASSERT(!classValue.isEmpty()); |
80 return m_classInvalidationSets.get(classValue); | 80 return m_classInvalidationSets.get(classValue); |
81 } | 81 } |
82 | 82 |
83 inline bool hasSelectorForId(const AtomicString& idValue) const | 83 inline bool hasSelectorForId(const AtomicString& idValue) const |
84 { | 84 { |
85 return m_metadata.idsInRules.contains(idValue); | 85 return m_idInvalidationSets.get(idValue); |
esprehn
2014/04/01 23:11:19
This can still be contains right? Same with the ab
chrishtr
2014/04/01 23:20:08
Done.
| |
86 } | 86 } |
87 | 87 |
88 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed Classes, Element&); | 88 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& changed Classes, Element&); |
89 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas ses, const SpaceSplitString& newClasses, Element&); | 89 void scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClas ses, const SpaceSplitString& newClasses, Element&); |
90 | 90 |
91 void scheduleStyleInvalidationForAttributeChange(const QualifiedName& attrib uteName, Element&); | 91 void scheduleStyleInvalidationForAttributeChange(const QualifiedName& attrib uteName, Element&); |
92 | 92 |
93 void scheduleStyleInvalidationForIdChange(const AtomicString& oldId, const A tomicString& newId, Element&); | |
94 | |
93 int hasIdsInSelectors() const | 95 int hasIdsInSelectors() const |
94 { | 96 { |
95 return m_metadata.idsInRules.size() > 0; | 97 return m_idInvalidationSets.size() > 0; |
esprehn
2014/04/01 23:11:19
This function should really return a bool too
chrishtr
2014/04/01 23:20:08
Done.
| |
96 } | 98 } |
97 | 99 |
98 // Marks the given attribute name as "appearing in a selector". Used for | 100 // Marks the given attribute name as "appearing in a selector". Used for |
99 // CSS properties such as content: ... attr(...) ... | 101 // CSS properties such as content: ... attr(...) ... |
100 // FIXME: record these internally to this class instead calls from StyleReso lver to here. | 102 // FIXME: record these internally to this class instead calls from StyleReso lver to here. |
101 void addContentAttr(const AtomicString& attributeName); | 103 void addContentAttr(const AtomicString& attributeName); |
102 | 104 |
103 StyleInvalidator& styleInvalidator(); | 105 StyleInvalidator& styleInvalidator(); |
104 | 106 |
105 Vector<RuleFeature> siblingRules; | 107 Vector<RuleFeature> siblingRules; |
106 Vector<RuleFeature> uncommonAttributeRules; | 108 Vector<RuleFeature> uncommonAttributeRules; |
107 | 109 |
108 private: | 110 private: |
109 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati onSetMap; | 111 typedef HashMap<AtomicString, RefPtr<DescendantInvalidationSet> > Invalidati onSetMap; |
110 | 112 |
111 struct FeatureMetadata { | 113 struct FeatureMetadata { |
112 FeatureMetadata() | 114 FeatureMetadata() |
113 : usesFirstLineRules(false) | 115 : usesFirstLineRules(false) |
114 , foundSiblingSelector(false) | 116 , foundSiblingSelector(false) |
115 , maxDirectAdjacentSelectors(0) | 117 , maxDirectAdjacentSelectors(0) |
116 { } | 118 { } |
117 void add(const FeatureMetadata& other); | 119 void add(const FeatureMetadata& other); |
118 void clear(); | 120 void clear(); |
119 | 121 |
120 bool usesFirstLineRules; | 122 bool usesFirstLineRules; |
121 bool foundSiblingSelector; | 123 bool foundSiblingSelector; |
122 unsigned maxDirectAdjacentSelectors; | 124 unsigned maxDirectAdjacentSelectors; |
123 HashSet<AtomicString> idsInRules; | |
124 }; | 125 }; |
125 | 126 |
126 enum InvalidationSetMode { | 127 enum InvalidationSetMode { |
127 AddFeatures, | 128 AddFeatures, |
128 UseLocalStyleChange, | 129 UseLocalStyleChange, |
129 UseSubtreeStyleChange | 130 UseSubtreeStyleChange |
130 }; | 131 }; |
131 | 132 |
132 static InvalidationSetMode supportsClassDescendantInvalidation(const CSSSele ctor&); | 133 static InvalidationSetMode supportsClassDescendantInvalidation(const CSSSele ctor&); |
133 | 134 |
134 void collectFeaturesFromSelector(const CSSSelector&, FeatureMetadata&, Inval idationSetMode); | 135 void collectFeaturesFromSelector(const CSSSelector&, FeatureMetadata&, Inval idationSetMode); |
135 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata &, InvalidationSetMode); | 136 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata &, InvalidationSetMode); |
136 | 137 |
137 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl assName); | 138 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl assName); |
138 DescendantInvalidationSet& ensureAttributeInvalidationSet(const AtomicString & attributeName); | 139 DescendantInvalidationSet& ensureAttributeInvalidationSet(const AtomicString & attributeName); |
140 DescendantInvalidationSet& ensureIdInvalidationSet(const AtomicString& attri buteName); | |
139 DescendantInvalidationSet* invalidationSetForSelector(const CSSSelector&); | 141 DescendantInvalidationSet* invalidationSetForSelector(const CSSSelector&); |
140 | 142 |
141 InvalidationSetMode updateInvalidationSets(const CSSSelector&); | 143 InvalidationSetMode updateInvalidationSets(const CSSSelector&); |
142 | 144 |
143 struct InvalidationSetFeatures { | 145 struct InvalidationSetFeatures { |
144 Vector<AtomicString> classes; | 146 Vector<AtomicString> classes; |
145 Vector<AtomicString> attributes; | 147 Vector<AtomicString> attributes; |
146 AtomicString id; | 148 AtomicString id; |
147 AtomicString tagName; | 149 AtomicString tagName; |
148 }; | 150 }; |
149 | 151 |
150 static void extractInvalidationSetFeature(const CSSSelector&, InvalidationSe tFeatures&); | 152 static void extractInvalidationSetFeature(const CSSSelector&, InvalidationSe tFeatures&); |
151 const CSSSelector* extractInvalidationSetFeatures(const CSSSelector&, Invali dationSetFeatures&); | 153 const CSSSelector* extractInvalidationSetFeatures(const CSSSelector&, Invali dationSetFeatures&); |
152 void addFeaturesToInvalidationSets(const CSSSelector&, const InvalidationSet Features&); | 154 void addFeaturesToInvalidationSets(const CSSSelector&, const InvalidationSet Features&); |
153 | 155 |
154 void addClassToInvalidationSet(const AtomicString& className, Element&); | 156 void addClassToInvalidationSet(const AtomicString& className, Element&); |
155 | 157 |
156 FeatureMetadata m_metadata; | 158 FeatureMetadata m_metadata; |
157 InvalidationSetMap m_classInvalidationSets; | 159 InvalidationSetMap m_classInvalidationSets; |
158 InvalidationSetMap m_attributeInvalidationSets; | 160 InvalidationSetMap m_attributeInvalidationSets; |
161 InvalidationSetMap m_idInvalidationSets; | |
159 bool m_targetedStyleRecalcEnabled; | 162 bool m_targetedStyleRecalcEnabled; |
160 StyleInvalidator m_styleInvalidator; | 163 StyleInvalidator m_styleInvalidator; |
161 }; | 164 }; |
162 | 165 |
163 | 166 |
164 } // namespace WebCore | 167 } // namespace WebCore |
165 | 168 |
166 #endif // RuleFeature_h | 169 #endif // RuleFeature_h |
OLD | NEW |