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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 , maxDirectAdjacentSelectors(0) | 118 , maxDirectAdjacentSelectors(0) |
119 { } | 119 { } |
120 void add(const FeatureMetadata& other); | 120 void add(const FeatureMetadata& other); |
121 void clear(); | 121 void clear(); |
122 | 122 |
123 bool usesFirstLineRules; | 123 bool usesFirstLineRules; |
124 bool foundSiblingSelector; | 124 bool foundSiblingSelector; |
125 unsigned maxDirectAdjacentSelectors; | 125 unsigned maxDirectAdjacentSelectors; |
126 }; | 126 }; |
127 | 127 |
128 enum InvalidationSetMode { | 128 void collectFeaturesFromSelector(const CSSSelector&, FeatureMetadata&); |
129 AddFeatures, | |
130 UseLocalStyleChange, | |
131 UseSubtreeStyleChange | |
132 }; | |
133 | |
134 static InvalidationSetMode invalidationSetModeForSelector(const CSSSelector&
); | |
135 | |
136 void collectFeaturesFromSelector(const CSSSelector&, FeatureMetadata&, Inval
idationSetMode); | |
137 void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata
&, InvalidationSetMode); | |
138 | 129 |
139 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl
assName); | 130 DescendantInvalidationSet& ensureClassInvalidationSet(const AtomicString& cl
assName); |
140 DescendantInvalidationSet& ensureAttributeInvalidationSet(const AtomicString
& attributeName); | 131 DescendantInvalidationSet& ensureAttributeInvalidationSet(const AtomicString
& attributeName); |
141 DescendantInvalidationSet& ensureIdInvalidationSet(const AtomicString& attri
buteName); | 132 DescendantInvalidationSet& ensureIdInvalidationSet(const AtomicString& attri
buteName); |
142 DescendantInvalidationSet& ensurePseudoInvalidationSet(CSSSelector::PseudoTy
pe); | 133 DescendantInvalidationSet& ensurePseudoInvalidationSet(CSSSelector::PseudoTy
pe); |
143 | 134 |
144 InvalidationSetMode updateInvalidationSets(const CSSSelector&); | 135 void updateInvalidationSets(const CSSSelector&); |
145 | 136 |
146 struct InvalidationSetFeatures { | 137 struct InvalidationSetFeatures { |
147 InvalidationSetFeatures() | 138 InvalidationSetFeatures() |
148 : customPseudoElement(false) | 139 : customPseudoElement(false) |
149 , treeBoundaryCrossing(false) | 140 , treeBoundaryCrossing(false) |
150 , wholeSubtree(false) | 141 , insertionPointCrossing(false) |
| 142 , adjacent(false) |
| 143 , hasFeatures(false) |
151 { } | 144 { } |
| 145 |
| 146 void addClass(AtomicString className) { classes.append(className); hasFe
atures = true; } |
| 147 void addAttribute(AtomicString attribute) { attributes.append(attribute)
; hasFeatures = true; } |
| 148 void setId(AtomicString idString) { id = idString; hasFeatures = true; } |
| 149 void setTagName(AtomicString tag) { tagName = tag; hasFeatures = true; } |
| 150 void setHasCustomPseudo() { customPseudoElement = true; hasFeatures = tr
ue; } |
| 151 |
| 152 bool useSubtreeInvalidation() const { return !hasFeatures || adjacent; } |
| 153 |
152 Vector<AtomicString> classes; | 154 Vector<AtomicString> classes; |
153 Vector<AtomicString> attributes; | 155 Vector<AtomicString> attributes; |
154 AtomicString id; | 156 AtomicString id; |
155 AtomicString tagName; | 157 AtomicString tagName; |
| 158 |
156 bool customPseudoElement; | 159 bool customPseudoElement; |
157 bool treeBoundaryCrossing; | 160 bool treeBoundaryCrossing; |
158 bool wholeSubtree; | 161 bool insertionPointCrossing; |
| 162 bool adjacent; |
| 163 bool hasFeatures; |
159 }; | 164 }; |
160 | 165 |
161 static void extractInvalidationSetFeature(const CSSSelector&, InvalidationSe
tFeatures&); | 166 static void extractInvalidationSetFeature(const CSSSelector&, InvalidationSe
tFeatures&); |
162 const CSSSelector* extractInvalidationSetFeatures(const CSSSelector&, Invali
dationSetFeatures&, bool negated); | 167 const CSSSelector* extractInvalidationSetFeatures(const CSSSelector&, Invali
dationSetFeatures&, bool negated); |
| 168 |
| 169 void addFeaturesToInvalidationSet(DescendantInvalidationSet&, const Invalida
tionSetFeatures&); |
163 void addFeaturesToInvalidationSets(const CSSSelector&, InvalidationSetFeatur
es&); | 170 void addFeaturesToInvalidationSets(const CSSSelector&, InvalidationSetFeatur
es&); |
164 | 171 |
165 void addClassToInvalidationSet(const AtomicString& className, Element&); | 172 void addClassToInvalidationSet(const AtomicString& className, Element&); |
166 | 173 |
167 FeatureMetadata m_metadata; | 174 FeatureMetadata m_metadata; |
168 InvalidationSetMap m_classInvalidationSets; | 175 InvalidationSetMap m_classInvalidationSets; |
169 InvalidationSetMap m_attributeInvalidationSets; | 176 InvalidationSetMap m_attributeInvalidationSets; |
170 InvalidationSetMap m_idInvalidationSets; | 177 InvalidationSetMap m_idInvalidationSets; |
171 PseudoTypeInvalidationSetMap m_pseudoInvalidationSets; | 178 PseudoTypeInvalidationSetMap m_pseudoInvalidationSets; |
172 StyleInvalidator m_styleInvalidator; | 179 StyleInvalidator m_styleInvalidator; |
173 }; | 180 }; |
174 | 181 |
175 | 182 |
176 } // namespace blink | 183 } // namespace blink |
177 | 184 |
178 namespace WTF { | 185 namespace WTF { |
179 | 186 |
180 template <> struct VectorTraits<blink::RuleFeature> : VectorTraitsBase<blink::Ru
leFeature> { | 187 template <> struct VectorTraits<blink::RuleFeature> : VectorTraitsBase<blink::Ru
leFeature> { |
181 static const bool needsDestruction = false; | 188 static const bool needsDestruction = false; |
182 static const bool canInitializeWithMemset = true; | 189 static const bool canInitializeWithMemset = true; |
183 static const bool canMoveWithMemcpy = true; | 190 static const bool canMoveWithMemcpy = true; |
184 }; | 191 }; |
185 | 192 |
186 } // namespace WTF | 193 } // namespace WTF |
187 | 194 |
188 #endif // RuleFeature_h | 195 #endif // RuleFeature_h |
OLD | NEW |