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

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

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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/RuleFeature.cpp » ('j') | 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 16 matching lines...) Expand all
27 #include "core/css/CSSSelector.h" 27 #include "core/css/CSSSelector.h"
28 #include "core/css/MediaQueryEvaluator.h" 28 #include "core/css/MediaQueryEvaluator.h"
29 #include "core/css/invalidation/InvalidationSet.h" 29 #include "core/css/invalidation/InvalidationSet.h"
30 #include "platform/heap/Handle.h" 30 #include "platform/heap/Handle.h"
31 #include "wtf/Forward.h" 31 #include "wtf/Forward.h"
32 #include "wtf/HashSet.h" 32 #include "wtf/HashSet.h"
33 #include "wtf/text/AtomicStringHash.h" 33 #include "wtf/text/AtomicStringHash.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 class ContainerNode;
37 struct InvalidationLists; 38 struct InvalidationLists;
38 class QualifiedName; 39 class QualifiedName;
39 class RuleData; 40 class RuleData;
40 class StyleRule; 41 class StyleRule;
41 42
42 struct RuleFeature { 43 struct RuleFeature {
43 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 44 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
44 45
45 public: 46 public:
46 RuleFeature(StyleRule*, 47 RuleFeature(StyleRule*,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return m_deviceDependentMediaQueryResults; 116 return m_deviceDependentMediaQueryResults;
116 } 117 }
117 MediaQueryResultList& viewportDependentMediaQueryResults() { 118 MediaQueryResultList& viewportDependentMediaQueryResults() {
118 return m_viewportDependentMediaQueryResults; 119 return m_viewportDependentMediaQueryResults;
119 } 120 }
120 MediaQueryResultList& deviceDependentMediaQueryResults() { 121 MediaQueryResultList& deviceDependentMediaQueryResults() {
121 return m_deviceDependentMediaQueryResults; 122 return m_deviceDependentMediaQueryResults;
122 } 123 }
123 124
124 // Collect descendant and sibling invalidation sets. 125 // Collect descendant and sibling invalidation sets.
125 void collectInvalidationSetsForClass(InvalidationLists&, 126
126 Element&, 127 enum class InvalidationSetFilter {
127 const AtomicString& className) const; 128 None,
128 void collectInvalidationSetsForId(InvalidationLists&, 129 RuleSetInvalidation,
129 Element&, 130 };
130 const AtomicString& id) const; 131
132 void collectInvalidationSetsForClass(
133 InvalidationLists&,
134 Element&,
135 const AtomicString& className,
136 InvalidationSetFilter = InvalidationSetFilter::None) const;
137 void collectInvalidationSetsForId(
138 InvalidationLists&,
139 Element&,
140 const AtomicString& id,
141 InvalidationSetFilter = InvalidationSetFilter::None) const;
131 void collectInvalidationSetsForAttribute( 142 void collectInvalidationSetsForAttribute(
132 InvalidationLists&, 143 InvalidationLists&,
133 Element&, 144 Element&,
134 const QualifiedName& attributeName) const; 145 const QualifiedName& attributeName,
146 InvalidationSetFilter = InvalidationSetFilter::None) const;
135 void collectInvalidationSetsForPseudoClass(InvalidationLists&, 147 void collectInvalidationSetsForPseudoClass(InvalidationLists&,
136 Element&, 148 Element&,
137 CSSSelector::PseudoType) const; 149 CSSSelector::PseudoType) const;
138 150
139 void collectSiblingInvalidationSetForClass(InvalidationLists&, 151 void collectSiblingInvalidationSetForClass(InvalidationLists&,
140 Element&, 152 Element&,
141 const AtomicString& className, 153 const AtomicString& className,
142 unsigned minDirectAdjacent) const; 154 unsigned minDirectAdjacent) const;
143 void collectSiblingInvalidationSetForId(InvalidationLists&, 155 void collectSiblingInvalidationSetForId(InvalidationLists&,
144 Element&, 156 Element&,
145 const AtomicString& id, 157 const AtomicString& id,
146 unsigned minDirectAdjacent) const; 158 unsigned minDirectAdjacent) const;
147 void collectSiblingInvalidationSetForAttribute( 159 void collectSiblingInvalidationSetForAttribute(
148 InvalidationLists&, 160 InvalidationLists&,
149 Element&, 161 Element&,
150 const QualifiedName& attributeName, 162 const QualifiedName& attributeName,
151 unsigned minDirectAdjacent) const; 163 unsigned minDirectAdjacent) const;
152 void collectUniversalSiblingInvalidationSet(InvalidationLists&, 164 void collectUniversalSiblingInvalidationSet(InvalidationLists&,
153 unsigned minDirectAdjacent) const; 165 unsigned minDirectAdjacent) const;
154 void collectNthInvalidationSet(InvalidationLists&) const; 166 void collectNthInvalidationSet(InvalidationLists&) const;
167 void collectTypeRuleInvalidationSet(InvalidationLists&, ContainerNode&) const;
155 168
156 bool hasIdsInSelectors() const { return m_idInvalidationSets.size() > 0; } 169 bool hasIdsInSelectors() const { return m_idInvalidationSets.size() > 0; }
157 170
158 DECLARE_TRACE(); 171 DECLARE_TRACE();
159 172
160 protected: 173 protected:
161 InvalidationSet* invalidationSetForSimpleSelector(const CSSSelector&, 174 InvalidationSet* invalidationSetForSimpleSelector(const CSSSelector&,
162 InvalidationType); 175 InvalidationType);
163 176
164 private: 177 private:
(...skipping 28 matching lines...) Expand all
193 InvalidationType); 206 InvalidationType);
194 InvalidationSet& ensureAttributeInvalidationSet( 207 InvalidationSet& ensureAttributeInvalidationSet(
195 const AtomicString& attributeName, 208 const AtomicString& attributeName,
196 InvalidationType); 209 InvalidationType);
197 InvalidationSet& ensureIdInvalidationSet(const AtomicString& id, 210 InvalidationSet& ensureIdInvalidationSet(const AtomicString& id,
198 InvalidationType); 211 InvalidationType);
199 InvalidationSet& ensurePseudoInvalidationSet(CSSSelector::PseudoType, 212 InvalidationSet& ensurePseudoInvalidationSet(CSSSelector::PseudoType,
200 InvalidationType); 213 InvalidationType);
201 SiblingInvalidationSet& ensureUniversalSiblingInvalidationSet(); 214 SiblingInvalidationSet& ensureUniversalSiblingInvalidationSet();
202 DescendantInvalidationSet& ensureNthInvalidationSet(); 215 DescendantInvalidationSet& ensureNthInvalidationSet();
216 DescendantInvalidationSet& ensureTypeRuleInvalidationSet();
203 217
204 void updateInvalidationSets(const RuleData&); 218 void updateInvalidationSets(const RuleData&);
205 void updateInvalidationSetsForContentAttribute(const RuleData&); 219 void updateInvalidationSetsForContentAttribute(const RuleData&);
206 220
207 struct InvalidationSetFeatures { 221 struct InvalidationSetFeatures {
222 enum class RuleSetFeatureType {
223 None,
224 Tag,
225 Attribute,
226 Class,
227 Id,
228 };
229
208 DISALLOW_NEW(); 230 DISALLOW_NEW();
209 231
210 void add(const InvalidationSetFeatures& other); 232 void add(const InvalidationSetFeatures& other);
211 bool hasFeatures() const; 233 bool hasFeatures() const;
212 bool hasTagIdClassOrAttribute() const; 234 bool hasRuleSetInvalidationFeature() const {
235 return ruleSetInvalidationFeatureType != RuleSetFeatureType::None;
236 }
237 void setRuleSetFeatureFromSimpleSelector(const CSSSelector&);
238 void setRuleSetInvalidationFeature(const AtomicString& feature,
239 RuleSetFeatureType type) {
240 if (type < ruleSetInvalidationFeatureType)
241 return;
242 ruleSetInvalidationFeature = feature;
243 ruleSetInvalidationFeatureType = type;
244 }
245 void clearRuleSetInvalidationFeature() {
246 ruleSetInvalidationFeature = AtomicString();
247 ruleSetInvalidationFeatureType = RuleSetFeatureType::None;
248 }
213 249
214 Vector<AtomicString> classes; 250 Vector<AtomicString> classes;
215 Vector<AtomicString> attributes; 251 Vector<AtomicString> attributes;
216 Vector<AtomicString> ids; 252 Vector<AtomicString> ids;
217 Vector<AtomicString> tagNames; 253 Vector<AtomicString> tagNames;
254 AtomicString ruleSetInvalidationFeature;
218 unsigned maxDirectAdjacentSelectors = 0; 255 unsigned maxDirectAdjacentSelectors = 0;
219 bool customPseudoElement = false; 256 bool customPseudoElement = false;
220 bool hasBeforeOrAfter = false; 257 bool hasBeforeOrAfter = false;
221 bool treeBoundaryCrossing = false; 258 bool treeBoundaryCrossing = false;
222 bool insertionPointCrossing = false; 259 bool insertionPointCrossing = false;
223 bool forceSubtree = false; 260 bool forceSubtree = false;
224 bool contentPseudoCrossing = false; 261 bool contentPseudoCrossing = false;
225 bool invalidatesSlotted = false; 262 bool invalidatesSlotted = false;
226 bool hasNthPseudo = false; 263 bool hasNthPseudo = false;
227 bool hasFeaturesForRuleSetInvalidation = false; 264 RuleSetFeatureType ruleSetInvalidationFeatureType =
265 InvalidationSetFeatures::RuleSetFeatureType::None;
228 }; 266 };
229 267
230 static void extractInvalidationSetFeature(const CSSSelector&, 268 static void extractInvalidationSetFeature(const CSSSelector&,
231 InvalidationSetFeatures&); 269 InvalidationSetFeatures&);
232 270
233 enum PositionType { Subject, Ancestor }; 271 enum PositionType { Subject, Ancestor };
234 enum FeatureInvalidationType { 272 enum FeatureInvalidationType {
235 NormalInvalidation, 273 NormalInvalidation,
236 RequiresSubtreeInvalidation 274 RequiresSubtreeInvalidation
237 }; 275 };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 InvalidationSetFeatures& descendantFeatures); 309 InvalidationSetFeatures& descendantFeatures);
272 void addFeaturesToInvalidationSetsForSelectorList( 310 void addFeaturesToInvalidationSetsForSelectorList(
273 const CSSSelector&, 311 const CSSSelector&,
274 InvalidationSetFeatures* siblingFeatures, 312 InvalidationSetFeatures* siblingFeatures,
275 InvalidationSetFeatures& descendantFeatures); 313 InvalidationSetFeatures& descendantFeatures);
276 void addFeaturesToUniversalSiblingInvalidationSet( 314 void addFeaturesToUniversalSiblingInvalidationSet(
277 const InvalidationSetFeatures& siblingFeatures, 315 const InvalidationSetFeatures& siblingFeatures,
278 const InvalidationSetFeatures& descendantFeatures); 316 const InvalidationSetFeatures& descendantFeatures);
279 317
280 void addClassToInvalidationSet(const AtomicString& className, Element&); 318 void addClassToInvalidationSet(const AtomicString& className, Element&);
319 void processRuleSetInvalidationFeature(const InvalidationSetFeatures&);
281 320
282 FeatureMetadata m_metadata; 321 FeatureMetadata m_metadata;
283 InvalidationSetMap m_classInvalidationSets; 322 InvalidationSetMap m_classInvalidationSets;
284 InvalidationSetMap m_attributeInvalidationSets; 323 InvalidationSetMap m_attributeInvalidationSets;
285 InvalidationSetMap m_idInvalidationSets; 324 InvalidationSetMap m_idInvalidationSets;
286 PseudoTypeInvalidationSetMap m_pseudoInvalidationSets; 325 PseudoTypeInvalidationSetMap m_pseudoInvalidationSets;
287 RefPtr<SiblingInvalidationSet> m_universalSiblingInvalidationSet; 326 RefPtr<SiblingInvalidationSet> m_universalSiblingInvalidationSet;
288 RefPtr<DescendantInvalidationSet> m_nthInvalidationSet; 327 RefPtr<DescendantInvalidationSet> m_nthInvalidationSet;
328 RefPtr<DescendantInvalidationSet> m_typeRuleInvalidationSet;
289 HeapVector<RuleFeature> m_siblingRules; 329 HeapVector<RuleFeature> m_siblingRules;
290 HeapVector<RuleFeature> m_uncommonAttributeRules; 330 HeapVector<RuleFeature> m_uncommonAttributeRules;
291 MediaQueryResultList m_viewportDependentMediaQueryResults; 331 MediaQueryResultList m_viewportDependentMediaQueryResults;
292 MediaQueryResultList m_deviceDependentMediaQueryResults; 332 MediaQueryResultList m_deviceDependentMediaQueryResults;
293 333
294 friend class RuleFeatureSetTest; 334 friend class RuleFeatureSetTest;
295 }; 335 };
296 336
297 } // namespace blink 337 } // namespace blink
298 338
299 #endif // RuleFeature_h 339 #endif // RuleFeature_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/RuleFeature.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698