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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 // This method is somewhat conservative in what it accepts. | 119 // This method is somewhat conservative in what it accepts. |
| 120 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect or(const CSSSelector& selector) | 120 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect or(const CSSSelector& selector) |
| 121 { | 121 { |
| 122 bool foundCombinator = false; | 122 bool foundCombinator = false; |
| 123 bool foundIdent = false; | 123 bool foundIdent = false; |
| 124 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { | 124 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { |
| 125 | 125 |
| 126 if (component->match() == CSSSelector::Class || component->match() == CS SSelector::Id | 126 if (component->match() == CSSSelector::Class || component->match() == CS SSelector::Id |
| 127 || (component->match() == CSSSelector::Tag && component->tagQName(). localName() != starAtom) | 127 || (component->match() == CSSSelector::Tag && component->tagQName(). localName() != starAtom) |
| 128 || component->isAttributeSelector() || component->isCustomPseudoElem ent()) { | 128 || component->isAttributeSelector() || component->isCustomPseudoElem ent()) { |
| 129 if (!foundCombinator) | 129 if (!foundCombinator) { |
| 130 // We have found an invalidation set feature in the rightmost co mpound selector. | |
| 130 foundIdent = true; | 131 foundIdent = true; |
| 132 } | |
| 131 } else if (component->pseudoType() == CSSSelector::PseudoHost || compone nt->pseudoType() == CSSSelector::PseudoAny) { | 133 } else if (component->pseudoType() == CSSSelector::PseudoHost || compone nt->pseudoType() == CSSSelector::PseudoAny) { |
| 132 if (const CSSSelectorList* selectorList = component->selectorList()) { | 134 if (const CSSSelectorList* selectorList = component->selectorList()) { |
| 135 bool foundUniversal = false; | |
| 133 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) { | 136 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) { |
| 134 InvalidationSetMode hostMode = invalidationSetModeForSelecto r(*selector); | 137 // Find the invalidation set mode for each of the selectors in the selector list |
| 135 if (hostMode == UseSubtreeStyleChange) | 138 // of a :not(), :host(), etc. For instance, ".x :-webkit-any (.a, .b)" yields an |
| 139 // AddFeatures mode for both ".a" and ".b". ":-webkit-any(.a , *)" yields AddFeatures | |
| 140 // for ".a", but UseSubtreeStyleChange for "*". One sub-sele ctor without invalidation | |
| 141 // set features is sufficient to cause the selector to be a universal selector as far | |
| 142 // the invalidation set is concerned. | |
| 143 InvalidationSetMode subSelectorMode = invalidationSetModeFor Selector(*selector); | |
| 144 | |
| 145 // The sub-selector contained something unskippable, fall ba ck to whole subtree | |
| 146 // recalcs in collectFeaturesFromSelector. | |
| 147 if (subSelectorMode == UseSubtreeStyleChange) | |
| 136 return foundCombinator ? UseLocalStyleChange : UseSubtre eStyleChange; | 148 return foundCombinator ? UseLocalStyleChange : UseSubtre eStyleChange; |
|
chrishtr
2014/07/11 18:14:08
Please explain in the comment why it is sometimes
rune
2014/07/11 21:02:57
I have to investigate why the _UseSubtreeStyleChan
rune
2014/07/11 21:49:37
Done.
| |
| 137 if (!foundCombinator && hostMode == AddFeatures) | 149 |
| 138 foundIdent = true; | 150 // We found no features in the sub-selector, only skippable ones (foundIdent was |
| 151 // false at the end of this method). That is a universal sel ector as far as the | |
| 152 // invalidation set is concerned. | |
| 153 if (subSelectorMode == UseLocalStyleChange) | |
| 154 foundUniversal = true; | |
| 155 } | |
| 156 if (!foundUniversal && !foundCombinator) { | |
| 157 // All sub-selectors contained invalidation set features and | |
| 158 // we are in the rightmost compound selector. | |
| 159 foundIdent = true; | |
| 139 } | 160 } |
| 140 } | 161 } |
| 141 } else if (!isSkippableComponentForInvalidation(*component)) { | 162 } else if (!isSkippableComponentForInvalidation(*component)) { |
| 142 return foundCombinator ? UseLocalStyleChange : UseSubtreeStyleChange ; | 163 return foundCombinator ? UseLocalStyleChange : UseSubtreeStyleChange ; |
| 143 } | 164 } |
| 144 if (component->relation() != CSSSelector::SubSelector) | 165 if (component->relation() != CSSSelector::SubSelector) |
| 145 foundCombinator = true; | 166 foundCombinator = true; |
| 146 } | 167 } |
| 147 return foundIdent ? AddFeatures : UseLocalStyleChange; | 168 return foundIdent ? AddFeatures : UseLocalStyleChange; |
| 148 } | 169 } |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 visitor->trace(siblingRules); | 527 visitor->trace(siblingRules); |
| 507 visitor->trace(uncommonAttributeRules); | 528 visitor->trace(uncommonAttributeRules); |
| 508 visitor->trace(m_classInvalidationSets); | 529 visitor->trace(m_classInvalidationSets); |
| 509 visitor->trace(m_attributeInvalidationSets); | 530 visitor->trace(m_attributeInvalidationSets); |
| 510 visitor->trace(m_idInvalidationSets); | 531 visitor->trace(m_idInvalidationSets); |
| 511 visitor->trace(m_pseudoInvalidationSets); | 532 visitor->trace(m_pseudoInvalidationSets); |
| 512 visitor->trace(m_styleInvalidator); | 533 visitor->trace(m_styleInvalidator); |
| 513 } | 534 } |
| 514 | 535 |
| 515 } // namespace WebCore | 536 } // namespace WebCore |
| OLD | NEW |