Chromium Code Reviews| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 // in its selector. The first step is to extract the features from the rightmost | 312 // in its selector. The first step is to extract the features from the rightmost |
| 313 // compound selector (extractInvalidationSetFeatures). Secondly, add those featu res | 313 // compound selector (extractInvalidationSetFeatures). Secondly, add those featu res |
| 314 // to the invalidation sets for the features found in the other compound selecto rs | 314 // to the invalidation sets for the features found in the other compound selecto rs |
| 315 // (addFeaturesToInvalidationSets). If we find a feature in the right-most compo und | 315 // (addFeaturesToInvalidationSets). If we find a feature in the right-most compo und |
| 316 // selector that requires a subtree recalc, we addFeaturesToInvalidationSets for the | 316 // selector that requires a subtree recalc, we addFeaturesToInvalidationSets for the |
| 317 // rightmost compound selector as well. | 317 // rightmost compound selector as well. |
| 318 | 318 |
| 319 void RuleFeatureSet::updateInvalidationSets(const RuleData& ruleData) | 319 void RuleFeatureSet::updateInvalidationSets(const RuleData& ruleData) |
| 320 { | 320 { |
| 321 InvalidationSetFeatures features; | 321 InvalidationSetFeatures features; |
| 322 auto result = extractInvalidationSetFeatures(ruleData.selector(), features, false); | 322 auto result = extractInvalidationSetFeatures(ruleData.selector(), features, false, true); |
|
rune
2015/10/27 09:05:28
Would increase readability to use enums instead of
Eric Willigers
2015/10/28 00:13:07
I changed the code to use two enums.
| |
| 323 | 323 |
| 324 if (result.first) { | 324 if (result.first) { |
| 325 features.forceSubtree = result.second == ForceSubtree; | 325 features.forceSubtree = result.second == ForceSubtree; |
| 326 addFeaturesToInvalidationSets(result.first, features.adjacent ? &feature s : nullptr, features); | 326 addFeaturesToInvalidationSets(result.first, features.adjacent ? &feature s : nullptr, features); |
| 327 } | 327 } |
| 328 | 328 |
| 329 // If any ::before and ::after rules specify 'content: attr(...)', we | 329 // If any ::before and ::after rules specify 'content: attr(...)', we |
| 330 // need to create invalidation sets for those attributes. | 330 // need to create invalidation sets for those attributes. |
| 331 if (features.hasBeforeOrAfter) | 331 if (features.hasBeforeOrAfter) |
| 332 updateInvalidationSetsForContentAttribute(ruleData); | 332 updateInvalidationSetsForContentAttribute(ruleData); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 351 if (!item->isFunctionValue()) | 351 if (!item->isFunctionValue()) |
| 352 continue; | 352 continue; |
| 353 CSSFunctionValue* functionValue = toCSSFunctionValue(item.get()); | 353 CSSFunctionValue* functionValue = toCSSFunctionValue(item.get()); |
| 354 if (functionValue->functionType() != CSSValueAttr) | 354 if (functionValue->functionType() != CSSValueAttr) |
| 355 continue; | 355 continue; |
| 356 ensureAttributeInvalidationSet(AtomicString(toCSSCustomIdentValue(functi onValue->item(0))->value()), InvalidateDescendants).setInvalidatesSelf(); | 356 ensureAttributeInvalidationSet(AtomicString(toCSSCustomIdentValue(functi onValue->item(0))->value()), InvalidateDescendants).setInvalidatesSelf(); |
| 357 } | 357 } |
| 358 } | 358 } |
| 359 | 359 |
| 360 std::pair<const CSSSelector*, RuleFeatureSet::UseFeaturesType> | 360 std::pair<const CSSSelector*, RuleFeatureSet::UseFeaturesType> |
| 361 RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelector& selector, Inva lidationSetFeatures& features, bool negated) | 361 RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelector& selector, Inva lidationSetFeatures& features, bool negated, bool rightmost) |
| 362 { | 362 { |
| 363 bool foundFeatures = false; | 363 bool foundFeatures = false; |
| 364 for (const CSSSelector* current = &selector; current; current = current->tag History()) { | 364 for (const CSSSelector* current = &selector; current; current = current->tag History()) { |
| 365 if (!negated) | 365 if (!negated) |
| 366 foundFeatures |= extractInvalidationSetFeature(*current, features); | 366 foundFeatures |= extractInvalidationSetFeature(*current, features); |
| 367 // Initialize the entry in the invalidation set map, if supported. | 367 // Initialize the entry in the invalidation set map, if supported. |
| 368 if (InvalidationSet* invalidationSet = invalidationSetForSelector(*curre nt, InvalidateDescendants)) { | 368 if (InvalidationSet* invalidationSet = invalidationSetForSelector(*curre nt, InvalidateDescendants)) { |
| 369 invalidationSet->setInvalidatesSelf(); | 369 if (rightmost) |
| 370 invalidationSet->setInvalidatesSelf(); | |
| 370 } else { | 371 } else { |
| 371 if (requiresSubtreeInvalidation(*current)) { | 372 if (requiresSubtreeInvalidation(*current)) { |
| 372 // Fall back to use subtree invalidations, even for features in the | 373 // Fall back to use subtree invalidations, even for features in the |
| 373 // rightmost compound selector. Returning the start &selector he re | 374 // rightmost compound selector. Returning the start &selector he re |
| 374 // will make addFeaturesToInvalidationSets start marking invalid ation | 375 // will make addFeaturesToInvalidationSets start marking invalid ation |
| 375 // sets for subtree recalc for features in the rightmost compoun d | 376 // sets for subtree recalc for features in the rightmost compoun d |
| 376 // selector. | 377 // selector. |
| 377 return std::make_pair(&selector, ForceSubtree); | 378 return std::make_pair(&selector, ForceSubtree); |
| 378 } | 379 } |
| 379 if (const CSSSelectorList* selectorList = current->selectorList()) { | 380 if (const CSSSelectorList* selectorList = current->selectorList()) { |
| 380 ASSERT(supportsInvalidationWithSelectorList(current->pseudoType( ))); | 381 ASSERT(supportsInvalidationWithSelectorList(current->pseudoType( ))); |
| 381 const CSSSelector* subSelector = selectorList->first(); | 382 const CSSSelector* subSelector = selectorList->first(); |
| 382 bool allSubSelectorsHaveFeatures = !!subSelector; | 383 bool allSubSelectorsHaveFeatures = !!subSelector; |
| 383 for (; subSelector; subSelector = CSSSelectorList::next(*subSele ctor)) { | 384 for (; subSelector; subSelector = CSSSelectorList::next(*subSele ctor)) { |
| 384 auto result = extractInvalidationSetFeatures(*subSelector, f eatures, current->pseudoType() == CSSSelector::PseudoNot); | 385 auto result = extractInvalidationSetFeatures(*subSelector, f eatures, current->pseudoType() == CSSSelector::PseudoNot, rightmost); |
| 385 if (result.first) { | 386 if (result.first) { |
| 386 // A non-null selector return means the sub-selector con tained a | 387 // A non-null selector return means the sub-selector con tained a |
| 387 // selector which requiresSubtreeInvalidation(). Return the rightmost | 388 // selector which requiresSubtreeInvalidation(). Return the rightmost |
| 388 // selector to mark for subtree recalcs like above. | 389 // selector to mark for subtree recalcs like above. |
| 389 return std::make_pair(&selector, ForceSubtree); | 390 return std::make_pair(&selector, ForceSubtree); |
| 390 } | 391 } |
| 391 allSubSelectorsHaveFeatures &= result.second == UseFeatures; | 392 allSubSelectorsHaveFeatures &= result.second == UseFeatures; |
| 392 } | 393 } |
| 393 foundFeatures |= allSubSelectorsHaveFeatures; | 394 foundFeatures |= allSubSelectorsHaveFeatures; |
| 394 } | 395 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 continue; | 492 continue; |
| 492 | 493 |
| 493 if (current->relation() == CSSSelector::DirectAdjacent) | 494 if (current->relation() == CSSSelector::DirectAdjacent) |
| 494 siblingFeatures->maxDirectAdjacentSelectors++; | 495 siblingFeatures->maxDirectAdjacentSelectors++; |
| 495 else | 496 else |
| 496 siblingFeatures->maxDirectAdjacentSelectors = UINT_MAX; | 497 siblingFeatures->maxDirectAdjacentSelectors = UINT_MAX; |
| 497 continue; | 498 continue; |
| 498 } | 499 } |
| 499 | 500 |
| 500 localFeatures = InvalidationSetFeatures(); | 501 localFeatures = InvalidationSetFeatures(); |
| 501 auto result = extractInvalidationSetFeatures(*lastCompoundSelectorInAdja centChain, localFeatures, false); | 502 auto result = extractInvalidationSetFeatures(*lastCompoundSelectorInAdja centChain, localFeatures, false, false); |
| 502 ASSERT(result.first); | 503 ASSERT(result.first); |
| 503 localFeatures.forceSubtree = result.second == ForceSubtree; | 504 localFeatures.forceSubtree = result.second == ForceSubtree; |
| 504 siblingFeatures = &localFeatures; | 505 siblingFeatures = &localFeatures; |
| 505 } | 506 } |
| 506 } | 507 } |
| 507 | 508 |
| 508 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 509 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
| 509 { | 510 { |
| 510 updateInvalidationSets(ruleData); | 511 updateInvalidationSets(ruleData); |
| 511 | 512 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 | 656 |
| 656 DEFINE_TRACE(RuleFeatureSet) | 657 DEFINE_TRACE(RuleFeatureSet) |
| 657 { | 658 { |
| 658 #if ENABLE(OILPAN) | 659 #if ENABLE(OILPAN) |
| 659 visitor->trace(siblingRules); | 660 visitor->trace(siblingRules); |
| 660 visitor->trace(uncommonAttributeRules); | 661 visitor->trace(uncommonAttributeRules); |
| 661 #endif | 662 #endif |
| 662 } | 663 } |
| 663 | 664 |
| 664 } // namespace blink | 665 } // namespace blink |
| OLD | NEW |