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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 case CSSSelector::PseudoEnd: | 131 case CSSSelector::PseudoEnd: |
132 case CSSSelector::PseudoDoubleButton: | 132 case CSSSelector::PseudoDoubleButton: |
133 case CSSSelector::PseudoSingleButton: | 133 case CSSSelector::PseudoSingleButton: |
134 case CSSSelector::PseudoNoButton: | 134 case CSSSelector::PseudoNoButton: |
135 case CSSSelector::PseudoFullScreen: | 135 case CSSSelector::PseudoFullScreen: |
136 case CSSSelector::PseudoFullScreenDocument: | 136 case CSSSelector::PseudoFullScreenDocument: |
137 case CSSSelector::PseudoFullScreenAncestor: | 137 case CSSSelector::PseudoFullScreenAncestor: |
138 case CSSSelector::PseudoInRange: | 138 case CSSSelector::PseudoInRange: |
139 case CSSSelector::PseudoOutOfRange: | 139 case CSSSelector::PseudoOutOfRange: |
140 case CSSSelector::PseudoWebKitCustomElement: | 140 case CSSSelector::PseudoWebKitCustomElement: |
| 141 case CSSSelector::PseudoCue: |
| 142 case CSSSelector::PseudoFutureCue: |
| 143 case CSSSelector::PseudoPastCue: |
141 case CSSSelector::PseudoUnresolved: | 144 case CSSSelector::PseudoUnresolved: |
142 case CSSSelector::PseudoContent: | 145 case CSSSelector::PseudoContent: |
143 case CSSSelector::PseudoHost: | 146 case CSSSelector::PseudoHost: |
144 case CSSSelector::PseudoShadow: | 147 case CSSSelector::PseudoShadow: |
145 case CSSSelector::PseudoListBox: | 148 case CSSSelector::PseudoListBox: |
146 return true; | 149 return true; |
147 case CSSSelector::PseudoNotParsed: | 150 case CSSSelector::PseudoNotParsed: |
148 case CSSSelector::PseudoUnknown: | 151 case CSSSelector::PseudoUnknown: |
149 case CSSSelector::PseudoLeftPage: | 152 case CSSSelector::PseudoLeftPage: |
150 case CSSSelector::PseudoRightPage: | 153 case CSSSelector::PseudoRightPage: |
(...skipping 13 matching lines...) Expand all Loading... |
164 static bool requiresSubtreeInvalidation(const CSSSelector& selector) | 167 static bool requiresSubtreeInvalidation(const CSSSelector& selector) |
165 { | 168 { |
166 if (!selector.matchesPseudoElement() && selector.match() != CSSSelector::Pse
udoClass) { | 169 if (!selector.matchesPseudoElement() && selector.match() != CSSSelector::Pse
udoClass) { |
167 ASSERT(supportsInvalidation(selector.match())); | 170 ASSERT(supportsInvalidation(selector.match())); |
168 return false; | 171 return false; |
169 } | 172 } |
170 | 173 |
171 switch (selector.pseudoType()) { | 174 switch (selector.pseudoType()) { |
172 case CSSSelector::PseudoFirstLine: | 175 case CSSSelector::PseudoFirstLine: |
173 case CSSSelector::PseudoFirstLetter: | 176 case CSSSelector::PseudoFirstLetter: |
174 case CSSSelector::PseudoCue: | |
175 case CSSSelector::PseudoFutureCue: | |
176 case CSSSelector::PseudoPastCue: | |
177 case CSSSelector::PseudoSpatialNavigationFocus: | 177 case CSSSelector::PseudoSpatialNavigationFocus: |
178 // FIXME: Most pseudo classes/elements above can be supported and moved | 178 // FIXME: Most pseudo classes/elements above can be supported and moved |
179 // to assertSupportedPseudo(). Move on a case-by-case basis. If they | 179 // to assertSupportedPseudo(). Move on a case-by-case basis. If they |
180 // require subtree invalidation, document why. | 180 // require subtree invalidation, document why. |
181 case CSSSelector::PseudoHostContext: | 181 case CSSSelector::PseudoHostContext: |
182 // :host-context matches a shadow host, yet the simple selectors inside | 182 // :host-context matches a shadow host, yet the simple selectors inside |
183 // :host-context matches an ancestor of the shadow host. | 183 // :host-context matches an ancestor of the shadow host. |
184 return true; | 184 return true; |
185 default: | 185 default: |
186 ASSERT(supportsInvalidation(selector.pseudoType())); | 186 ASSERT(supportsInvalidation(selector.pseudoType())); |
187 return false; | 187 return false; |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 RuleFeature::RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocume
ntSecurityOrigin) | 191 RuleFeature::RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocume
ntSecurityOrigin) |
192 : rule(rule) | 192 : rule(rule) |
193 , selectorIndex(selectorIndex) | 193 , selectorIndex(selectorIndex) |
194 , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) | 194 , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) |
195 { | 195 { |
196 } | 196 } |
197 | 197 |
198 void RuleFeature::trace(Visitor* visitor) | 198 void RuleFeature::trace(Visitor* visitor) |
199 { | 199 { |
200 visitor->trace(rule); | 200 visitor->trace(rule); |
201 } | 201 } |
202 | 202 |
| 203 static bool supportsInvalidationWithSelectorList(CSSSelector::PseudoType pseudo) |
| 204 { |
| 205 return pseudo == CSSSelector::PseudoAny |
| 206 || pseudo == CSSSelector::PseudoCue |
| 207 || pseudo == CSSSelector::PseudoHost |
| 208 || pseudo == CSSSelector::PseudoNot; |
| 209 } |
| 210 |
203 // This method is somewhat conservative in what it accepts. | 211 // This method is somewhat conservative in what it accepts. |
204 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect
or(const CSSSelector& selector) | 212 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect
or(const CSSSelector& selector) |
205 { | 213 { |
206 bool foundCombinator = false; | 214 bool foundCombinator = false; |
207 bool foundIdent = false; | 215 bool foundIdent = false; |
208 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { | 216 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { |
209 | 217 |
210 if (component->match() == CSSSelector::Class || component->match() == CS
SSelector::Id | 218 if (component->match() == CSSSelector::Class || component->match() == CS
SSelector::Id |
211 || (component->match() == CSSSelector::Tag && component->tagQName().
localName() != starAtom) | 219 || (component->match() == CSSSelector::Tag && component->tagQName().
localName() != starAtom) |
212 || component->isAttributeSelector() || component->isCustomPseudoElem
ent()) { | 220 || component->isAttributeSelector() || component->isCustomPseudoElem
ent()) { |
213 if (!foundCombinator) { | 221 if (!foundCombinator) { |
214 // We have found an invalidation set feature in the rightmost co
mpound selector. | 222 // We have found an invalidation set feature in the rightmost co
mpound selector. |
215 foundIdent = true; | 223 foundIdent = true; |
216 } | 224 } |
217 } else if (component->pseudoType() == CSSSelector::PseudoNot | 225 } else if (supportsInvalidationWithSelectorList(component->pseudoType())
) { |
218 || component->pseudoType() == CSSSelector::PseudoHost | |
219 || component->pseudoType() == CSSSelector::PseudoAny) { | |
220 if (const CSSSelectorList* selectorList = component->selectorList())
{ | 226 if (const CSSSelectorList* selectorList = component->selectorList())
{ |
221 // Features inside :not() are not added to the feature set, so c
onsider it a universal selector. | 227 // Features inside :not() are not added to the feature set, so c
onsider it a universal selector. |
222 bool foundUniversal = component->pseudoType() == CSSSelector::Ps
eudoNot; | 228 bool foundUniversal = component->pseudoType() == CSSSelector::Ps
eudoNot; |
223 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) { | 229 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) { |
224 // Find the invalidation set mode for each of the selectors
in the selector list | 230 // Find the invalidation set mode for each of the selectors
in the selector list |
225 // of a :not(), :host(), etc. For instance, ".x :-webkit-any
(.a, .b)" yields an | 231 // of a :not(), :host(), etc. For instance, ".x :-webkit-any
(.a, .b)" yields an |
226 // AddFeatures mode for both ".a" and ".b". ":-webkit-any(.a
, *)" yields AddFeatures | 232 // AddFeatures mode for both ".a" and ".b". ":-webkit-any(.a
, *)" yields AddFeatures |
227 // for ".a", but UseSubtreeStyleChange for "*". One sub-sele
ctor without invalidation | 233 // for ".a", but UseSubtreeStyleChange for "*". One sub-sele
ctor without invalidation |
228 // set features is sufficient to cause the selector to be a
universal selector as far | 234 // set features is sufficient to cause the selector to be a
universal selector as far |
229 // the invalidation set is concerned. | 235 // the invalidation set is concerned. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 return AddFeatures; | 342 return AddFeatures; |
337 } | 343 } |
338 | 344 |
339 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec
tor& selector, InvalidationSetFeatures& features, bool negated) | 345 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec
tor& selector, InvalidationSetFeatures& features, bool negated) |
340 { | 346 { |
341 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { | 347 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { |
342 if (!negated) | 348 if (!negated) |
343 extractInvalidationSetFeature(*current, features); | 349 extractInvalidationSetFeature(*current, features); |
344 // Initialize the entry in the invalidation set map, if supported. | 350 // Initialize the entry in the invalidation set map, if supported. |
345 invalidationSetForSelector(*current); | 351 invalidationSetForSelector(*current); |
346 if (current->pseudoType() == CSSSelector::PseudoHost || current->pseudoT
ype() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelector::PseudoN
ot) { | 352 if (supportsInvalidationWithSelectorList(current->pseudoType())) { |
347 if (const CSSSelectorList* selectorList = current->selectorList()) { | 353 if (const CSSSelectorList* selectorList = current->selectorList()) { |
348 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) | 354 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) |
349 extractInvalidationSetFeatures(*selector, features, current-
>pseudoType() == CSSSelector::PseudoNot); | 355 extractInvalidationSetFeatures(*selector, features, current-
>pseudoType() == CSSSelector::PseudoNot); |
350 } | 356 } |
351 } | 357 } |
352 | 358 |
353 if (current->relation() == CSSSelector::SubSelector) | 359 if (current->relation() == CSSSelector::SubSelector) |
354 continue; | 360 continue; |
355 | 361 |
356 features.treeBoundaryCrossing = current->isShadowSelector(); | 362 features.treeBoundaryCrossing = current->isShadowSelector(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 { | 404 { |
399 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { | 405 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { |
400 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current)) { | 406 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current)) { |
401 addFeaturesToInvalidationSet(*invalidationSet, features); | 407 addFeaturesToInvalidationSet(*invalidationSet, features); |
402 } else { | 408 } else { |
403 if (current->isTreeBoundaryCrossing()) | 409 if (current->isTreeBoundaryCrossing()) |
404 features.treeBoundaryCrossing = true; | 410 features.treeBoundaryCrossing = true; |
405 if (current->isInsertionPointCrossing()) | 411 if (current->isInsertionPointCrossing()) |
406 features.insertionPointCrossing = true; | 412 features.insertionPointCrossing = true; |
407 if (const CSSSelectorList* selectorList = current->selectorList()) { | 413 if (const CSSSelectorList* selectorList = current->selectorList()) { |
408 ASSERT(current->pseudoType() == CSSSelector::PseudoHost || curre
nt->pseudoType() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelect
or::PseudoNot); | 414 ASSERT(supportsInvalidationWithSelectorList(current->pseudoType(
))); |
409 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) | 415 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) |
410 addFeaturesToInvalidationSets(*selector, features); | 416 addFeaturesToInvalidationSets(*selector, features); |
411 } | 417 } |
412 } | 418 } |
413 | 419 |
414 if (current->relation() == CSSSelector::SubSelector) | 420 if (current->relation() == CSSSelector::SubSelector) |
415 continue; | 421 continue; |
416 | 422 |
417 if (current->isShadowSelector()) | 423 if (current->isShadowSelector()) |
418 features.treeBoundaryCrossing = true; | 424 features.treeBoundaryCrossing = true; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 visitor->trace(uncommonAttributeRules); | 658 visitor->trace(uncommonAttributeRules); |
653 visitor->trace(m_classInvalidationSets); | 659 visitor->trace(m_classInvalidationSets); |
654 visitor->trace(m_attributeInvalidationSets); | 660 visitor->trace(m_attributeInvalidationSets); |
655 visitor->trace(m_idInvalidationSets); | 661 visitor->trace(m_idInvalidationSets); |
656 visitor->trace(m_pseudoInvalidationSets); | 662 visitor->trace(m_pseudoInvalidationSets); |
657 visitor->trace(m_styleInvalidator); | 663 visitor->trace(m_styleInvalidator); |
658 #endif | 664 #endif |
659 } | 665 } |
660 | 666 |
661 } // namespace blink | 667 } // namespace blink |
OLD | NEW |