| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 bool usesSiblingRules() const { return !siblingRules.isEmpty(); } | 65 bool usesSiblingRules() const { return !siblingRules.isEmpty(); } |
| 66 bool usesFirstLineRules() const { return m_metadata.usesFirstLineRules; } | 66 bool usesFirstLineRules() const { return m_metadata.usesFirstLineRules; } |
| 67 | 67 |
| 68 unsigned maxDirectAdjacentSelectors() const { return m_metadata.maxDirectAdj
acentSelectors; } | 68 unsigned maxDirectAdjacentSelectors() const { return m_metadata.maxDirectAdj
acentSelectors; } |
| 69 void setMaxDirectAdjacentSelectors(unsigned value) { m_metadata.maxDirectAd
jacentSelectors = std::max(value, m_metadata.maxDirectAdjacentSelectors); } | 69 void setMaxDirectAdjacentSelectors(unsigned value) { m_metadata.maxDirectAd
jacentSelectors = std::max(value, m_metadata.maxDirectAdjacentSelectors); } |
| 70 | 70 |
| 71 inline bool hasSelectorForAttribute(const AtomicString& attributeName) const | 71 inline bool hasSelectorForAttribute(const AtomicString& attributeName) const |
| 72 { | 72 { |
| 73 ASSERT(!attributeName.isEmpty()); | 73 ASSERT(!attributeName.isEmpty()); |
| 74 return m_attributeInvalidationSets.get(attributeName); | 74 return m_attributeInvalidationSets.contains(attributeName); |
| 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.contains(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.contains(idValue); |
| 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 int hasIdsInSelectors() const | 93 void scheduleStyleInvalidationForIdChange(const AtomicString& oldId, const A
tomicString& newId, Element&); |
| 94 |
| 95 bool hasIdsInSelectors() const |
| 94 { | 96 { |
| 95 return m_metadata.idsInRules.size() > 0; | 97 return m_idInvalidationSets.size() > 0; |
| 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 InvalidationSetFeatures() : customPseudoElement(false) { } | 146 InvalidationSetFeatures() : customPseudoElement(false) { } |
| 145 Vector<AtomicString> classes; | 147 Vector<AtomicString> classes; |
| 146 Vector<AtomicString> attributes; | 148 Vector<AtomicString> attributes; |
| 147 AtomicString id; | 149 AtomicString id; |
| 148 AtomicString tagName; | 150 AtomicString tagName; |
| 149 bool customPseudoElement; | 151 bool customPseudoElement; |
| 150 }; | 152 }; |
| 151 | 153 |
| 152 static void extractInvalidationSetFeature(const CSSSelector&, InvalidationSe
tFeatures&); | 154 static void extractInvalidationSetFeature(const CSSSelector&, InvalidationSe
tFeatures&); |
| 153 const CSSSelector* extractInvalidationSetFeatures(const CSSSelector&, Invali
dationSetFeatures&); | 155 const CSSSelector* extractInvalidationSetFeatures(const CSSSelector&, Invali
dationSetFeatures&); |
| 154 void addFeaturesToInvalidationSets(const CSSSelector&, const InvalidationSet
Features&); | 156 void addFeaturesToInvalidationSets(const CSSSelector&, const InvalidationSet
Features&); |
| 155 | 157 |
| 156 void addClassToInvalidationSet(const AtomicString& className, Element&); | 158 void addClassToInvalidationSet(const AtomicString& className, Element&); |
| 157 | 159 |
| 158 FeatureMetadata m_metadata; | 160 FeatureMetadata m_metadata; |
| 159 InvalidationSetMap m_classInvalidationSets; | 161 InvalidationSetMap m_classInvalidationSets; |
| 160 InvalidationSetMap m_attributeInvalidationSets; | 162 InvalidationSetMap m_attributeInvalidationSets; |
| 163 InvalidationSetMap m_idInvalidationSets; |
| 161 bool m_targetedStyleRecalcEnabled; | 164 bool m_targetedStyleRecalcEnabled; |
| 162 StyleInvalidator m_styleInvalidator; | 165 StyleInvalidator m_styleInvalidator; |
| 163 }; | 166 }; |
| 164 | 167 |
| 165 | 168 |
| 166 } // namespace WebCore | 169 } // namespace WebCore |
| 167 | 170 |
| 168 #endif // RuleFeature_h | 171 #endif // RuleFeature_h |
| OLD | NEW |