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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 extractInvalidationSetFeature(*current, features); | 256 extractInvalidationSetFeature(*current, features); |
257 // Initialize the entry in the invalidation set map, if supported. | 257 // Initialize the entry in the invalidation set map, if supported. |
258 invalidationSetForSelector(*current); | 258 invalidationSetForSelector(*current); |
259 if (current->pseudoType() == CSSSelector::PseudoHost || current->pseudoT
ype() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelector::PseudoN
ot) { | 259 if (current->pseudoType() == CSSSelector::PseudoHost || current->pseudoT
ype() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelector::PseudoN
ot) { |
260 if (const CSSSelectorList* selectorList = current->selectorList()) { | 260 if (const CSSSelectorList* selectorList = current->selectorList()) { |
261 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) | 261 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) |
262 extractInvalidationSetFeatures(*selector, features, current-
>pseudoType() == CSSSelector::PseudoNot); | 262 extractInvalidationSetFeatures(*selector, features, current-
>pseudoType() == CSSSelector::PseudoNot); |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
266 switch (current->relation()) { | 266 if (current->relation() == CSSSelector::SubSelector) |
267 case CSSSelector::SubSelector: | 267 continue; |
268 break; | 268 |
269 case CSSSelector::ShadowPseudo: | 269 features.treeBoundaryCrossing = current->isShadowSelector(); |
270 case CSSSelector::ShadowDeep: | 270 features.adjacent = current->isAdjacentSelector(); |
271 features.treeBoundaryCrossing = true; | 271 return current->tagHistory(); |
272 return current->tagHistory(); | |
273 case CSSSelector::DirectAdjacent: | |
274 case CSSSelector::IndirectAdjacent: | |
275 features.wholeSubtree = true; | |
276 return current->tagHistory(); | |
277 case CSSSelector::Descendant: | |
278 case CSSSelector::Child: | |
279 return current->tagHistory(); | |
280 } | |
281 } | 272 } |
282 return 0; | 273 return 0; |
283 } | 274 } |
284 | 275 |
285 // Add features extracted from the rightmost compound selector to descendant inv
alidation | 276 // Add features extracted from the rightmost compound selector to descendant inv
alidation |
286 // sets for features found in other compound selectors. | 277 // sets for features found in other compound selectors. |
287 // | 278 // |
288 // Style invalidation is currently supported for descendants only, not for sibli
ng subtrees. | 279 // Style invalidation is currently supported for descendants only, not for sibli
ng subtrees. |
289 // We use wholeSubtree invalidation for features found left of adjacent combinat
ors as | 280 // We use wholeSubtree invalidation for features found left of adjacent combinat
ors as |
290 // SubtreeStyleChange will force sibling subtree recalc in | 281 // SubtreeStyleChange will force sibling subtree recalc in |
291 // ContainerNode::checkForChildrenAdjacentRuleChanges. | 282 // ContainerNode::checkForChildrenAdjacentRuleChanges. |
292 // | 283 // |
293 // As we encounter a descendant type of combinator, the features only need to be
checked | 284 // As we encounter a descendant type of combinator, the features only need to be
checked |
294 // against descendants in the same subtree only. Hence wholeSubtree is reset to
false. | 285 // against descendants in the same subtree only. features.adjacent is set to fal
se, and |
| 286 // we start adding features instead of calling setWholeSubtreeInvalid. |
295 | 287 |
296 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector,
InvalidationSetFeatures& features) | 288 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector,
InvalidationSetFeatures& features) |
297 { | 289 { |
298 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { | 290 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { |
299 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current)) { | 291 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current)) { |
300 if (features.treeBoundaryCrossing) | 292 if (features.treeBoundaryCrossing) |
301 invalidationSet->setTreeBoundaryCrossing(); | 293 invalidationSet->setTreeBoundaryCrossing(); |
302 if (features.wholeSubtree) { | 294 if (features.adjacent) { |
303 invalidationSet->setWholeSubtreeInvalid(); | 295 invalidationSet->setWholeSubtreeInvalid(); |
304 } else { | 296 } else { |
305 if (!features.id.isEmpty()) | 297 if (!features.id.isEmpty()) |
306 invalidationSet->addId(features.id); | 298 invalidationSet->addId(features.id); |
307 if (!features.tagName.isEmpty()) | 299 if (!features.tagName.isEmpty()) |
308 invalidationSet->addTagName(features.tagName); | 300 invalidationSet->addTagName(features.tagName); |
309 for (Vector<AtomicString>::const_iterator it = features.classes.
begin(); it != features.classes.end(); ++it) | 301 for (Vector<AtomicString>::const_iterator it = features.classes.
begin(); it != features.classes.end(); ++it) |
310 invalidationSet->addClass(*it); | 302 invalidationSet->addClass(*it); |
311 for (Vector<AtomicString>::const_iterator it = features.attribut
es.begin(); it != features.attributes.end(); ++it) | 303 for (Vector<AtomicString>::const_iterator it = features.attribut
es.begin(); it != features.attributes.end(); ++it) |
312 invalidationSet->addAttribute(*it); | 304 invalidationSet->addAttribute(*it); |
313 if (features.customPseudoElement) | 305 if (features.customPseudoElement) |
314 invalidationSet->setCustomPseudoInvalid(); | 306 invalidationSet->setCustomPseudoInvalid(); |
315 } | 307 } |
316 } else { | 308 } else { |
317 if (current->pseudoType() == CSSSelector::PseudoHost) | 309 if (current->pseudoType() == CSSSelector::PseudoHost) |
318 features.treeBoundaryCrossing = true; | 310 features.treeBoundaryCrossing = true; |
319 if (const CSSSelectorList* selectorList = current->selectorList()) { | 311 if (const CSSSelectorList* selectorList = current->selectorList()) { |
320 ASSERT(current->pseudoType() == CSSSelector::PseudoHost || curre
nt->pseudoType() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelect
or::PseudoNot); | 312 ASSERT(current->pseudoType() == CSSSelector::PseudoHost || curre
nt->pseudoType() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelect
or::PseudoNot); |
321 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) | 313 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) |
322 addFeaturesToInvalidationSets(*selector, features); | 314 addFeaturesToInvalidationSets(*selector, features); |
323 } | 315 } |
324 } | 316 } |
325 switch (current->relation()) { | 317 |
326 case CSSSelector::SubSelector: | 318 if (current->isShadowSelector()) |
327 break; | |
328 case CSSSelector::ShadowPseudo: | |
329 case CSSSelector::ShadowDeep: | |
330 features.treeBoundaryCrossing = true; | 319 features.treeBoundaryCrossing = true; |
331 features.wholeSubtree = false; | 320 |
332 break; | 321 if (current->relation() != CSSSelector::SubSelector) |
333 case CSSSelector::Descendant: | 322 features.adjacent = current->isAdjacentSelector(); |
334 case CSSSelector::Child: | |
335 features.wholeSubtree = false; | |
336 break; | |
337 case CSSSelector::DirectAdjacent: | |
338 case CSSSelector::IndirectAdjacent: | |
339 features.wholeSubtree = true; | |
340 break; | |
341 } | |
342 } | 323 } |
343 } | 324 } |
344 | 325 |
345 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) | 326 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) |
346 { | 327 { |
347 ensureAttributeInvalidationSet(attributeName); | 328 ensureAttributeInvalidationSet(attributeName); |
348 } | 329 } |
349 | 330 |
350 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 331 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
351 { | 332 { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 visitor->trace(uncommonAttributeRules); | 545 visitor->trace(uncommonAttributeRules); |
565 visitor->trace(m_classInvalidationSets); | 546 visitor->trace(m_classInvalidationSets); |
566 visitor->trace(m_attributeInvalidationSets); | 547 visitor->trace(m_attributeInvalidationSets); |
567 visitor->trace(m_idInvalidationSets); | 548 visitor->trace(m_idInvalidationSets); |
568 visitor->trace(m_pseudoInvalidationSets); | 549 visitor->trace(m_pseudoInvalidationSets); |
569 visitor->trace(m_styleInvalidator); | 550 visitor->trace(m_styleInvalidator); |
570 #endif | 551 #endif |
571 } | 552 } |
572 | 553 |
573 } // namespace blink | 554 } // namespace blink |
OLD | NEW |