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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 // | 277 // |
278 // Style invalidation is currently supported for descendants only, not for sibli ng subtrees. | 278 // Style invalidation is currently supported for descendants only, not for sibli ng subtrees. |
279 // We use wholeSubtree invalidation for features found left of adjacent combinat ors as | 279 // We use wholeSubtree invalidation for features found left of adjacent combinat ors as |
280 // SubtreeStyleChange will force sibling subtree recalc in | 280 // SubtreeStyleChange will force sibling subtree recalc in |
281 // ContainerNode::checkForChildrenAdjacentRuleChanges. | 281 // ContainerNode::checkForChildrenAdjacentRuleChanges. |
282 // | 282 // |
283 // As we encounter a descendant type of combinator, the features only need to be checked | 283 // As we encounter a descendant type of combinator, the features only need to be checked |
284 // against descendants in the same subtree only. features.adjacent is set to fal se, and | 284 // against descendants in the same subtree only. features.adjacent is set to fal se, and |
285 // we start adding features instead of calling setWholeSubtreeInvalid. | 285 // we start adding features instead of calling setWholeSubtreeInvalid. |
286 | 286 |
287 void RuleFeatureSet::addFeaturesToInvalidationSet(DescendantInvalidationSet& inv alidationSet, const InvalidationSetFeatures& features) | |
288 { | |
289 if (features.treeBoundaryCrossing) | |
290 invalidationSet.setTreeBoundaryCrossing(); | |
291 if (features.adjacent) { | |
292 invalidationSet.setWholeSubtreeInvalid(); | |
293 return; | |
294 } | |
295 if (!features.id.isEmpty()) | |
296 invalidationSet.addId(features.id); | |
297 if (!features.tagName.isEmpty()) | |
298 invalidationSet.addTagName(features.tagName); | |
299 for (const auto& className : features.classes) | |
300 invalidationSet.addClass(className); | |
301 for (const auto& attribute : features.attributes) | |
302 invalidationSet.addAttribute(attribute); | |
303 if (features.customPseudoElement) | |
304 invalidationSet.setCustomPseudoInvalid(); | |
305 } | |
306 | |
287 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, InvalidationSetFeatures& features) | 307 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, InvalidationSetFeatures& features) |
288 { | 308 { |
289 for (const CSSSelector* current = &selector; current; current = current->tag History()) { | 309 for (const CSSSelector* current = &selector; current; current = current->tag History()) { |
290 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { | 310 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { |
291 if (features.treeBoundaryCrossing) | 311 addFeaturesToInvalidationSet(*invalidationSet, features); |
292 invalidationSet->setTreeBoundaryCrossing(); | |
293 if (features.adjacent) { | |
294 invalidationSet->setWholeSubtreeInvalid(); | |
295 } else { | |
296 if (!features.id.isEmpty()) | |
297 invalidationSet->addId(features.id); | |
298 if (!features.tagName.isEmpty()) | |
299 invalidationSet->addTagName(features.tagName); | |
300 for (const auto& className : features.classes) | |
301 invalidationSet->addClass(className); | |
302 for (const auto& attribute : features.attributes) | |
303 invalidationSet->addAttribute(attribute); | |
304 if (features.customPseudoElement) | |
305 invalidationSet->setCustomPseudoInvalid(); | |
306 } | |
307 } else { | 312 } else { |
308 if (current->pseudoType() == CSSSelector::PseudoHost) | 313 if (current->pseudoType() == CSSSelector::PseudoHost) |
309 features.treeBoundaryCrossing = true; | 314 features.treeBoundaryCrossing = true; |
310 if (const CSSSelectorList* selectorList = current->selectorList()) { | 315 if (const CSSSelectorList* selectorList = current->selectorList()) { |
311 ASSERT(current->pseudoType() == CSSSelector::PseudoHost || curre nt->pseudoType() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelect or::PseudoNot); | 316 ASSERT(current->pseudoType() == CSSSelector::PseudoHost || curre nt->pseudoType() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelect or::PseudoNot); |
312 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) | 317 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) |
313 addFeaturesToInvalidationSets(*selector, features); | 318 addFeaturesToInvalidationSets(*selector, features); |
314 } | 319 } |
315 } | 320 } |
316 | 321 |
322 if (current->relation() == CSSSelector::SubSelector) | |
chrishtr
2014/10/13 15:44:31
Why is this continue needed here? Is it because we
rune
2014/10/13 21:42:57
Yes, without this "continue", we'd have to check f
chrishtr
2014/10/13 22:00:25
Let me put it in a different way: what would be th
rune
2014/10/13 22:08:09
Something like:
// No combinator to update flags
| |
323 continue; | |
324 | |
317 if (current->isShadowSelector()) | 325 if (current->isShadowSelector()) |
chrishtr
2014/10/13 15:44:31
Is isShadowSelector() checked in?
rune
2014/10/13 21:42:57
I don't understand.
chrishtr
2014/10/13 22:00:25
Nevermind. I tried codesearching for this method e
| |
318 features.treeBoundaryCrossing = true; | 326 features.treeBoundaryCrossing = true; |
319 | 327 |
320 if (current->relation() != CSSSelector::SubSelector) | 328 features.adjacent = current->isAdjacentSelector(); |
321 features.adjacent = current->isAdjacentSelector(); | |
322 } | 329 } |
323 } | 330 } |
324 | 331 |
325 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) | 332 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) |
326 { | 333 { |
327 ensureAttributeInvalidationSet(attributeName); | 334 ensureAttributeInvalidationSet(attributeName); |
328 } | 335 } |
329 | 336 |
330 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 337 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
331 { | 338 { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 visitor->trace(uncommonAttributeRules); | 551 visitor->trace(uncommonAttributeRules); |
545 visitor->trace(m_classInvalidationSets); | 552 visitor->trace(m_classInvalidationSets); |
546 visitor->trace(m_attributeInvalidationSets); | 553 visitor->trace(m_attributeInvalidationSets); |
547 visitor->trace(m_idInvalidationSets); | 554 visitor->trace(m_idInvalidationSets); |
548 visitor->trace(m_pseudoInvalidationSets); | 555 visitor->trace(m_pseudoInvalidationSets); |
549 visitor->trace(m_styleInvalidator); | 556 visitor->trace(m_styleInvalidator); |
550 #endif | 557 #endif |
551 } | 558 } |
552 | 559 |
553 } // namespace blink | 560 } // namespace blink |
OLD | NEW |