OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeSty leChange; | 127 return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeSty leChange; |
128 } | 128 } |
129 switch (component->relation()) { | 129 switch (component->relation()) { |
130 case CSSSelector::Descendant: | 130 case CSSSelector::Descendant: |
131 case CSSSelector::Child: | 131 case CSSSelector::Child: |
132 case CSSSelector::ShadowPseudo: | 132 case CSSSelector::ShadowPseudo: |
133 case CSSSelector::ShadowDeep: | 133 case CSSSelector::ShadowDeep: |
134 foundDescendantRelation = true; | 134 foundDescendantRelation = true; |
135 // Fall through! | 135 // Fall through! |
136 case CSSSelector::SubSelector: | 136 case CSSSelector::SubSelector: |
137 case CSSSelector::DirectAdjacent: | |
138 case CSSSelector::IndirectAdjacent: | |
137 continue; | 139 continue; |
138 default: | 140 default: |
141 // All combinators should be handled above. | |
142 ASSERT_NOT_REACHED(); | |
139 return UseLocalStyleChange; | 143 return UseLocalStyleChange; |
140 } | 144 } |
141 } | 145 } |
142 return foundIdent ? AddFeatures : UseLocalStyleChange; | 146 return foundIdent ? AddFeatures : UseLocalStyleChange; |
143 } | 147 } |
144 | 148 |
145 void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector, InvalidationSetFeatures& features) | 149 void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector, InvalidationSetFeatures& features) |
146 { | 150 { |
147 if (selector.m_match == CSSSelector::Tag) | 151 if (selector.m_match == CSSSelector::Tag) |
148 features.tagName = selector.tagQName().localName(); | 152 features.tagName = selector.tagQName().localName(); |
(...skipping 24 matching lines...) Expand all Loading... | |
173 } | 177 } |
174 | 178 |
175 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector) | 179 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector) |
176 { | 180 { |
177 InvalidationSetMode mode = invalidationSetModeForSelector(selector); | 181 InvalidationSetMode mode = invalidationSetModeForSelector(selector); |
178 if (mode != AddFeatures) | 182 if (mode != AddFeatures) |
179 return mode; | 183 return mode; |
180 | 184 |
181 InvalidationSetFeatures features; | 185 InvalidationSetFeatures features; |
182 const CSSSelector* current = extractInvalidationSetFeatures(selector, featur es); | 186 const CSSSelector* current = extractInvalidationSetFeatures(selector, featur es); |
183 if (current) | 187 if (current) { |
188 bool wholeSubtree = current->relation() == CSSSelector::DirectAdjacent | | current->relation() == CSSSelector::IndirectAdjacent; | |
esprehn
2014/04/03 22:58:05
It would be nicer to merge this check into the add
rune
2014/04/04 09:29:37
The problem with that is that there is no previous
| |
184 current = current->tagHistory(); | 189 current = current->tagHistory(); |
185 | 190 if (current) |
186 if (current) | 191 addFeaturesToInvalidationSets(*current, features, wholeSubtree); |
187 addFeaturesToInvalidationSets(*current, features); | 192 } |
188 return AddFeatures; | 193 return AddFeatures; |
189 } | 194 } |
190 | 195 |
191 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec tor& selector, InvalidationSetFeatures& features) | 196 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec tor& selector, InvalidationSetFeatures& features) |
192 { | 197 { |
193 const CSSSelector* lastSelector = &selector; | 198 const CSSSelector* lastSelector = &selector; |
194 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { | 199 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { |
195 extractInvalidationSetFeature(*lastSelector, features); | 200 extractInvalidationSetFeature(*lastSelector, features); |
196 // Initialize the entry in the invalidation set map, if supported. | 201 // Initialize the entry in the invalidation set map, if supported. |
197 invalidationSetForSelector(*lastSelector); | 202 invalidationSetForSelector(*lastSelector); |
198 if (lastSelector->pseudoType() == CSSSelector::PseudoHost || lastSelecto r->pseudoType() == CSSSelector::PseudoAny) { | 203 if (lastSelector->pseudoType() == CSSSelector::PseudoHost || lastSelecto r->pseudoType() == CSSSelector::PseudoAny) { |
199 if (const CSSSelectorList* selectorList = lastSelector->selectorList ()) { | 204 if (const CSSSelectorList* selectorList = lastSelector->selectorList ()) { |
200 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) | 205 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) |
201 extractInvalidationSetFeatures(*selector, features); | 206 extractInvalidationSetFeatures(*selector, features); |
202 } | 207 } |
203 } | 208 } |
204 | 209 |
205 if (lastSelector->relation() != CSSSelector::SubSelector) | 210 if (lastSelector->relation() != CSSSelector::SubSelector) |
206 break; | 211 break; |
207 } | 212 } |
208 return lastSelector; | 213 return lastSelector; |
209 } | 214 } |
210 | 215 |
211 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, const InvalidationSetFeatures& features) | 216 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, const InvalidationSetFeatures& features, bool wholeSubtree) |
212 { | 217 { |
213 for (const CSSSelector* current = &selector; current; current = current->tag History()) { | 218 for (const CSSSelector* current = &selector; current; current = current->tag History()) { |
214 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { | 219 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { |
215 if (!features.id.isEmpty()) | 220 if (wholeSubtree) { |
216 invalidationSet->addId(features.id); | 221 invalidationSet->setWholeSubtreeInvalid(); |
217 if (!features.tagName.isEmpty()) | 222 } else { |
218 invalidationSet->addTagName(features.tagName); | 223 if (!features.id.isEmpty()) |
219 for (Vector<AtomicString>::const_iterator it = features.classes.begi n(); it != features.classes.end(); ++it) | 224 invalidationSet->addId(features.id); |
220 invalidationSet->addClass(*it); | 225 if (!features.tagName.isEmpty()) |
221 for (Vector<AtomicString>::const_iterator it = features.attributes.b egin(); it != features.attributes.end(); ++it) | 226 invalidationSet->addTagName(features.tagName); |
222 invalidationSet->addAttribute(*it); | 227 for (Vector<AtomicString>::const_iterator it = features.classes. begin(); it != features.classes.end(); ++it) |
223 if (features.customPseudoElement) | 228 invalidationSet->addClass(*it); |
224 invalidationSet->setCustomPseudoInvalid(); | 229 for (Vector<AtomicString>::const_iterator it = features.attribut es.begin(); it != features.attributes.end(); ++it) |
230 invalidationSet->addAttribute(*it); | |
231 if (features.customPseudoElement) | |
232 invalidationSet->setCustomPseudoInvalid(); | |
233 } | |
225 } else if (current->pseudoType() == CSSSelector::PseudoHost || current-> pseudoType() == CSSSelector::PseudoAny) { | 234 } else if (current->pseudoType() == CSSSelector::PseudoHost || current-> pseudoType() == CSSSelector::PseudoAny) { |
226 if (const CSSSelectorList* selectorList = current->selectorList()) { | 235 if (const CSSSelectorList* selectorList = current->selectorList()) { |
227 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) | 236 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) |
228 addFeaturesToInvalidationSets(*selector, features); | 237 addFeaturesToInvalidationSets(*selector, features, wholeSubt ree); |
229 } | 238 } |
230 } | 239 } |
240 switch (current->relation()) { | |
241 case CSSSelector::Descendant: | |
242 case CSSSelector::Child: | |
243 case CSSSelector::ShadowPseudo: | |
244 case CSSSelector::ShadowDeep: | |
245 wholeSubtree = false; | |
246 break; | |
247 case CSSSelector::DirectAdjacent: | |
248 case CSSSelector::IndirectAdjacent: | |
249 wholeSubtree = true; | |
250 break; | |
251 case CSSSelector::SubSelector: | |
252 break; | |
253 default: | |
254 // All combinators should be handled above. | |
255 ASSERT_NOT_REACHED(); | |
256 break; | |
257 } | |
231 } | 258 } |
232 } | 259 } |
233 | 260 |
234 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) | 261 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) |
235 { | 262 { |
236 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName); | 263 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName); |
237 invalidationSet.setWholeSubtreeInvalid(); | 264 invalidationSet.setWholeSubtreeInvalid(); |
238 } | 265 } |
239 | 266 |
240 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 267 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationS ets.get(className)) | 453 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationS ets.get(className)) |
427 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); | 454 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); |
428 } | 455 } |
429 | 456 |
430 StyleInvalidator& RuleFeatureSet::styleInvalidator() | 457 StyleInvalidator& RuleFeatureSet::styleInvalidator() |
431 { | 458 { |
432 return m_styleInvalidator; | 459 return m_styleInvalidator; |
433 } | 460 } |
434 | 461 |
435 } // namespace WebCore | 462 } // namespace WebCore |
OLD | NEW |