| 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. | 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 return m_deviceDependentMediaQueryResults; | 115 return m_deviceDependentMediaQueryResults; |
| 116 } | 116 } |
| 117 MediaQueryResultList& viewportDependentMediaQueryResults() { | 117 MediaQueryResultList& viewportDependentMediaQueryResults() { |
| 118 return m_viewportDependentMediaQueryResults; | 118 return m_viewportDependentMediaQueryResults; |
| 119 } | 119 } |
| 120 MediaQueryResultList& deviceDependentMediaQueryResults() { | 120 MediaQueryResultList& deviceDependentMediaQueryResults() { |
| 121 return m_deviceDependentMediaQueryResults; | 121 return m_deviceDependentMediaQueryResults; |
| 122 } | 122 } |
| 123 | 123 |
| 124 // Collect descendant and sibling invalidation sets. | 124 // Collect descendant and sibling invalidation sets. |
| 125 void collectInvalidationSetsForClass(InvalidationLists&, | 125 |
| 126 Element&, | 126 enum class InvalidationSetFilter { |
| 127 const AtomicString& className) const; | 127 None, |
| 128 void collectInvalidationSetsForId(InvalidationLists&, | 128 RuleSetInvalidation, |
| 129 Element&, | 129 }; |
| 130 const AtomicString& id) const; | 130 |
| 131 void collectInvalidationSetsForClass( |
| 132 InvalidationLists&, |
| 133 Element&, |
| 134 const AtomicString& className, |
| 135 InvalidationSetFilter = InvalidationSetFilter::None) const; |
| 136 void collectInvalidationSetsForId( |
| 137 InvalidationLists&, |
| 138 Element&, |
| 139 const AtomicString& id, |
| 140 InvalidationSetFilter = InvalidationSetFilter::None) const; |
| 131 void collectInvalidationSetsForAttribute( | 141 void collectInvalidationSetsForAttribute( |
| 132 InvalidationLists&, | 142 InvalidationLists&, |
| 133 Element&, | 143 Element&, |
| 134 const QualifiedName& attributeName) const; | 144 const QualifiedName& attributeName, |
| 145 InvalidationSetFilter = InvalidationSetFilter::None) const; |
| 135 void collectInvalidationSetsForPseudoClass(InvalidationLists&, | 146 void collectInvalidationSetsForPseudoClass(InvalidationLists&, |
| 136 Element&, | 147 Element&, |
| 137 CSSSelector::PseudoType) const; | 148 CSSSelector::PseudoType) const; |
| 138 | 149 |
| 139 void collectSiblingInvalidationSetForClass(InvalidationLists&, | 150 void collectSiblingInvalidationSetForClass(InvalidationLists&, |
| 140 Element&, | 151 Element&, |
| 141 const AtomicString& className, | 152 const AtomicString& className, |
| 142 unsigned minDirectAdjacent) const; | 153 unsigned minDirectAdjacent) const; |
| 143 void collectSiblingInvalidationSetForId(InvalidationLists&, | 154 void collectSiblingInvalidationSetForId(InvalidationLists&, |
| 144 Element&, | 155 Element&, |
| 145 const AtomicString& id, | 156 const AtomicString& id, |
| 146 unsigned minDirectAdjacent) const; | 157 unsigned minDirectAdjacent) const; |
| 147 void collectSiblingInvalidationSetForAttribute( | 158 void collectSiblingInvalidationSetForAttribute( |
| 148 InvalidationLists&, | 159 InvalidationLists&, |
| 149 Element&, | 160 Element&, |
| 150 const QualifiedName& attributeName, | 161 const QualifiedName& attributeName, |
| 151 unsigned minDirectAdjacent) const; | 162 unsigned minDirectAdjacent) const; |
| 152 void collectUniversalSiblingInvalidationSet(InvalidationLists&, | 163 void collectUniversalSiblingInvalidationSet(InvalidationLists&, |
| 153 unsigned minDirectAdjacent) const; | 164 unsigned minDirectAdjacent) const; |
| 154 void collectNthInvalidationSet(InvalidationLists&) const; | 165 void collectNthInvalidationSet(InvalidationLists&) const; |
| 166 void collectTypeRuleInvalidationSet(InvalidationLists&) const; |
| 155 | 167 |
| 156 bool hasIdsInSelectors() const { return m_idInvalidationSets.size() > 0; } | 168 bool hasIdsInSelectors() const { return m_idInvalidationSets.size() > 0; } |
| 157 | 169 |
| 158 DECLARE_TRACE(); | 170 DECLARE_TRACE(); |
| 159 | 171 |
| 160 protected: | 172 protected: |
| 161 InvalidationSet* invalidationSetForSimpleSelector(const CSSSelector&, | 173 InvalidationSet* invalidationSetForSimpleSelector(const CSSSelector&, |
| 162 InvalidationType); | 174 InvalidationType); |
| 163 | 175 |
| 164 private: | 176 private: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 193 InvalidationType); | 205 InvalidationType); |
| 194 InvalidationSet& ensureAttributeInvalidationSet( | 206 InvalidationSet& ensureAttributeInvalidationSet( |
| 195 const AtomicString& attributeName, | 207 const AtomicString& attributeName, |
| 196 InvalidationType); | 208 InvalidationType); |
| 197 InvalidationSet& ensureIdInvalidationSet(const AtomicString& id, | 209 InvalidationSet& ensureIdInvalidationSet(const AtomicString& id, |
| 198 InvalidationType); | 210 InvalidationType); |
| 199 InvalidationSet& ensurePseudoInvalidationSet(CSSSelector::PseudoType, | 211 InvalidationSet& ensurePseudoInvalidationSet(CSSSelector::PseudoType, |
| 200 InvalidationType); | 212 InvalidationType); |
| 201 SiblingInvalidationSet& ensureUniversalSiblingInvalidationSet(); | 213 SiblingInvalidationSet& ensureUniversalSiblingInvalidationSet(); |
| 202 DescendantInvalidationSet& ensureNthInvalidationSet(); | 214 DescendantInvalidationSet& ensureNthInvalidationSet(); |
| 215 DescendantInvalidationSet& ensureTypeRuleInvalidationSet(); |
| 203 | 216 |
| 204 void updateInvalidationSets(const RuleData&); | 217 void updateInvalidationSets(const RuleData&); |
| 205 void updateInvalidationSetsForContentAttribute(const RuleData&); | 218 void updateInvalidationSetsForContentAttribute(const RuleData&); |
| 206 | 219 |
| 207 struct InvalidationSetFeatures { | 220 struct InvalidationSetFeatures { |
| 221 enum class RuleSetFeatureType { |
| 222 None, |
| 223 Tag, |
| 224 Attribute, |
| 225 Class, |
| 226 Id, |
| 227 }; |
| 228 |
| 208 DISALLOW_NEW(); | 229 DISALLOW_NEW(); |
| 209 | 230 |
| 210 void add(const InvalidationSetFeatures& other); | 231 void add(const InvalidationSetFeatures& other); |
| 211 bool hasFeatures() const; | 232 bool hasFeatures() const; |
| 212 bool hasTagIdClassOrAttribute() const; | 233 bool hasRuleSetInvalidationFeature() const { |
| 234 return ruleSetInvalidationFeatureType != RuleSetFeatureType::None; |
| 235 } |
| 236 void setRuleSetFeatureFromSimpleSelector(const CSSSelector&); |
| 237 void setRuleSetInvalidationFeature(const AtomicString& feature, |
| 238 RuleSetFeatureType type) { |
| 239 if (type < ruleSetInvalidationFeatureType) |
| 240 return; |
| 241 ruleSetInvalidationFeature = feature; |
| 242 ruleSetInvalidationFeatureType = type; |
| 243 } |
| 244 void clearRuleSetInvalidationFeature() { |
| 245 ruleSetInvalidationFeature = AtomicString(); |
| 246 ruleSetInvalidationFeatureType = RuleSetFeatureType::None; |
| 247 } |
| 213 | 248 |
| 214 Vector<AtomicString> classes; | 249 Vector<AtomicString> classes; |
| 215 Vector<AtomicString> attributes; | 250 Vector<AtomicString> attributes; |
| 216 Vector<AtomicString> ids; | 251 Vector<AtomicString> ids; |
| 217 Vector<AtomicString> tagNames; | 252 Vector<AtomicString> tagNames; |
| 253 AtomicString ruleSetInvalidationFeature; |
| 218 unsigned maxDirectAdjacentSelectors = 0; | 254 unsigned maxDirectAdjacentSelectors = 0; |
| 219 bool customPseudoElement = false; | 255 bool customPseudoElement = false; |
| 220 bool hasBeforeOrAfter = false; | 256 bool hasBeforeOrAfter = false; |
| 221 bool treeBoundaryCrossing = false; | 257 bool treeBoundaryCrossing = false; |
| 222 bool insertionPointCrossing = false; | 258 bool insertionPointCrossing = false; |
| 223 bool forceSubtree = false; | 259 bool forceSubtree = false; |
| 224 bool contentPseudoCrossing = false; | 260 bool contentPseudoCrossing = false; |
| 225 bool invalidatesSlotted = false; | 261 bool invalidatesSlotted = false; |
| 226 bool hasNthPseudo = false; | 262 bool hasNthPseudo = false; |
| 227 bool hasFeaturesForRuleSetInvalidation = false; | 263 RuleSetFeatureType ruleSetInvalidationFeatureType = |
| 264 InvalidationSetFeatures::RuleSetFeatureType::None; |
| 228 }; | 265 }; |
| 229 | 266 |
| 230 static void extractInvalidationSetFeature(const CSSSelector&, | 267 static void extractInvalidationSetFeature(const CSSSelector&, |
| 231 InvalidationSetFeatures&); | 268 InvalidationSetFeatures&); |
| 232 | 269 |
| 233 enum PositionType { Subject, Ancestor }; | 270 enum PositionType { Subject, Ancestor }; |
| 234 enum FeatureInvalidationType { | 271 enum FeatureInvalidationType { |
| 235 NormalInvalidation, | 272 NormalInvalidation, |
| 236 RequiresSubtreeInvalidation | 273 RequiresSubtreeInvalidation |
| 237 }; | 274 }; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 InvalidationSetFeatures& descendantFeatures); | 308 InvalidationSetFeatures& descendantFeatures); |
| 272 void addFeaturesToInvalidationSetsForSelectorList( | 309 void addFeaturesToInvalidationSetsForSelectorList( |
| 273 const CSSSelector&, | 310 const CSSSelector&, |
| 274 InvalidationSetFeatures* siblingFeatures, | 311 InvalidationSetFeatures* siblingFeatures, |
| 275 InvalidationSetFeatures& descendantFeatures); | 312 InvalidationSetFeatures& descendantFeatures); |
| 276 void addFeaturesToUniversalSiblingInvalidationSet( | 313 void addFeaturesToUniversalSiblingInvalidationSet( |
| 277 const InvalidationSetFeatures& siblingFeatures, | 314 const InvalidationSetFeatures& siblingFeatures, |
| 278 const InvalidationSetFeatures& descendantFeatures); | 315 const InvalidationSetFeatures& descendantFeatures); |
| 279 | 316 |
| 280 void addClassToInvalidationSet(const AtomicString& className, Element&); | 317 void addClassToInvalidationSet(const AtomicString& className, Element&); |
| 318 void processRuleSetInvalidationFeature(const InvalidationSetFeatures&); |
| 281 | 319 |
| 282 FeatureMetadata m_metadata; | 320 FeatureMetadata m_metadata; |
| 283 InvalidationSetMap m_classInvalidationSets; | 321 InvalidationSetMap m_classInvalidationSets; |
| 284 InvalidationSetMap m_attributeInvalidationSets; | 322 InvalidationSetMap m_attributeInvalidationSets; |
| 285 InvalidationSetMap m_idInvalidationSets; | 323 InvalidationSetMap m_idInvalidationSets; |
| 286 PseudoTypeInvalidationSetMap m_pseudoInvalidationSets; | 324 PseudoTypeInvalidationSetMap m_pseudoInvalidationSets; |
| 287 RefPtr<SiblingInvalidationSet> m_universalSiblingInvalidationSet; | 325 RefPtr<SiblingInvalidationSet> m_universalSiblingInvalidationSet; |
| 288 RefPtr<DescendantInvalidationSet> m_nthInvalidationSet; | 326 RefPtr<DescendantInvalidationSet> m_nthInvalidationSet; |
| 327 RefPtr<DescendantInvalidationSet> m_typeRuleInvalidationSet; |
| 289 HeapVector<RuleFeature> m_siblingRules; | 328 HeapVector<RuleFeature> m_siblingRules; |
| 290 HeapVector<RuleFeature> m_uncommonAttributeRules; | 329 HeapVector<RuleFeature> m_uncommonAttributeRules; |
| 291 MediaQueryResultList m_viewportDependentMediaQueryResults; | 330 MediaQueryResultList m_viewportDependentMediaQueryResults; |
| 292 MediaQueryResultList m_deviceDependentMediaQueryResults; | 331 MediaQueryResultList m_deviceDependentMediaQueryResults; |
| 293 | 332 |
| 294 friend class RuleFeatureSetTest; | 333 friend class RuleFeatureSetTest; |
| 295 }; | 334 }; |
| 296 | 335 |
| 297 } // namespace blink | 336 } // namespace blink |
| 298 | 337 |
| 299 #endif // RuleFeature_h | 338 #endif // RuleFeature_h |
| OLD | NEW |