Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: Source/core/css/RuleFeature.cpp

Issue 383833002: All selectors in :-webkit-any must have an invalidation set feature. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Avoid eventSender Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/css/invalidation/webkit-any-universal.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // This method is somewhat conservative in what it accepts. 121 // This method is somewhat conservative in what it accepts.
122 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect or(const CSSSelector& selector) 122 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect or(const CSSSelector& selector)
123 { 123 {
124 bool foundCombinator = false; 124 bool foundCombinator = false;
125 bool foundIdent = false; 125 bool foundIdent = false;
126 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { 126 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) {
127 127
128 if (component->match() == CSSSelector::Class || component->match() == CS SSelector::Id 128 if (component->match() == CSSSelector::Class || component->match() == CS SSelector::Id
129 || (component->match() == CSSSelector::Tag && component->tagQName(). localName() != starAtom) 129 || (component->match() == CSSSelector::Tag && component->tagQName(). localName() != starAtom)
130 || component->isAttributeSelector() || component->isCustomPseudoElem ent()) { 130 || component->isAttributeSelector() || component->isCustomPseudoElem ent()) {
131 if (!foundCombinator) 131 if (!foundCombinator) {
132 // We have found an invalidation set feature in the rightmost co mpound selector.
132 foundIdent = true; 133 foundIdent = true;
134 }
133 } else if (component->pseudoType() == CSSSelector::PseudoHost || compone nt->pseudoType() == CSSSelector::PseudoAny) { 135 } else if (component->pseudoType() == CSSSelector::PseudoHost || compone nt->pseudoType() == CSSSelector::PseudoAny) {
134 if (const CSSSelectorList* selectorList = component->selectorList()) { 136 if (const CSSSelectorList* selectorList = component->selectorList()) {
137 bool foundUniversal = false;
135 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) { 138 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) {
136 InvalidationSetMode hostMode = invalidationSetModeForSelecto r(*selector); 139 // Find the invalidation set mode for each of the selectors in the selector list
137 if (hostMode == UseSubtreeStyleChange) 140 // of a :not(), :host(), etc. For instance, ".x :-webkit-any (.a, .b)" yields an
141 // AddFeatures mode for both ".a" and ".b". ":-webkit-any(.a , *)" yields AddFeatures
142 // for ".a", but UseSubtreeStyleChange for "*". One sub-sele ctor without invalidation
143 // set features is sufficient to cause the selector to be a universal selector as far
144 // the invalidation set is concerned.
145 InvalidationSetMode subSelectorMode = invalidationSetModeFor Selector(*selector);
146
147 // The sub-selector contained something unskippable, fall ba ck to whole subtree
148 // recalcs in collectFeaturesFromSelector. subSelectorMode w ill return
149 // UseSubtreeStyleChange since there are no combinators insi de the selector list,
150 // so translate it to UseLocalStyleChange if a combinator ha s been seen in the
151 // outer context.
152 //
153 // FIXME: Is UseSubtreeStyleChange ever needed as input to c ollectFeaturesFromSelector?
154 // That is, are there any selectors for which we need to use SubtreeStyleChange for
155 // changing features when present in the rightmost compound selector?
156 if (subSelectorMode == UseSubtreeStyleChange)
138 return foundCombinator ? UseLocalStyleChange : UseSubtre eStyleChange; 157 return foundCombinator ? UseLocalStyleChange : UseSubtre eStyleChange;
139 if (!foundCombinator && hostMode == AddFeatures) 158
140 foundIdent = true; 159 // We found no features in the sub-selector, only skippable ones (foundIdent was
160 // false at the end of this method). That is a universal sel ector as far as the
161 // invalidation set is concerned.
162 if (subSelectorMode == UseLocalStyleChange)
163 foundUniversal = true;
164 }
165 if (!foundUniversal && !foundCombinator) {
166 // All sub-selectors contained invalidation set features and
167 // we are in the rightmost compound selector.
168 foundIdent = true;
141 } 169 }
142 } 170 }
143 } else if (!isSkippableComponentForInvalidation(*component)) { 171 } else if (!isSkippableComponentForInvalidation(*component)) {
144 return foundCombinator ? UseLocalStyleChange : UseSubtreeStyleChange ; 172 return foundCombinator ? UseLocalStyleChange : UseSubtreeStyleChange ;
145 } 173 }
146 if (component->relation() != CSSSelector::SubSelector) 174 if (component->relation() != CSSSelector::SubSelector)
147 foundCombinator = true; 175 foundCombinator = true;
148 } 176 }
149 return foundIdent ? AddFeatures : UseLocalStyleChange; 177 return foundIdent ? AddFeatures : UseLocalStyleChange;
150 } 178 }
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 visitor->trace(uncommonAttributeRules); 555 visitor->trace(uncommonAttributeRules);
528 visitor->trace(m_classInvalidationSets); 556 visitor->trace(m_classInvalidationSets);
529 visitor->trace(m_attributeInvalidationSets); 557 visitor->trace(m_attributeInvalidationSets);
530 visitor->trace(m_idInvalidationSets); 558 visitor->trace(m_idInvalidationSets);
531 visitor->trace(m_pseudoInvalidationSets); 559 visitor->trace(m_pseudoInvalidationSets);
532 visitor->trace(m_styleInvalidator); 560 visitor->trace(m_styleInvalidator);
533 #endif 561 #endif
534 } 562 }
535 563
536 } // namespace blink 564 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/invalidation/webkit-any-universal.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698