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

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

Issue 462593002: Support invalidation sets for negated selectors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@tmp-upstream
Patch Set: Rebased 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
« no previous file with comments | « Source/core/css/RuleFeature.h ('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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // We have found an invalidation set feature in the rightmost co mpound selector.
133 foundIdent = true; 133 foundIdent = true;
134 } 134 }
135 } else if (component->pseudoType() == CSSSelector::PseudoHost || compone nt->pseudoType() == CSSSelector::PseudoAny) { 135 } else if (component->pseudoType() == CSSSelector::PseudoNot
136 || component->pseudoType() == CSSSelector::PseudoHost
137 || component->pseudoType() == CSSSelector::PseudoAny) {
136 if (const CSSSelectorList* selectorList = component->selectorList()) { 138 if (const CSSSelectorList* selectorList = component->selectorList()) {
137 bool foundUniversal = false; 139 // Features inside :not() are not added to the feature set, so c onsider it a universal selector.
140 bool foundUniversal = component->pseudoType() == CSSSelector::Ps eudoNot;
138 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) { 141 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) {
139 // Find the invalidation set mode for each of the selectors in the selector list 142 // Find the invalidation set mode for each of the selectors in the selector list
140 // of a :not(), :host(), etc. For instance, ".x :-webkit-any (.a, .b)" yields an 143 // 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 144 // AddFeatures mode for both ".a" and ".b". ":-webkit-any(.a , *)" yields AddFeatures
142 // for ".a", but UseSubtreeStyleChange for "*". One sub-sele ctor without invalidation 145 // 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 146 // set features is sufficient to cause the selector to be a universal selector as far
144 // the invalidation set is concerned. 147 // the invalidation set is concerned.
145 InvalidationSetMode subSelectorMode = invalidationSetModeFor Selector(*selector); 148 InvalidationSetMode subSelectorMode = invalidationSetModeFor Selector(*selector);
146 149
147 // The sub-selector contained something unskippable, fall ba ck to whole subtree 150 // The sub-selector contained something unskippable, fall ba ck to whole subtree
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // added to the invalidation sets for the features found in the other compound s electors 225 // added to the invalidation sets for the features found in the other compound s electors
223 // (addFeaturesToInvalidationSets). 226 // (addFeaturesToInvalidationSets).
224 227
225 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector) 228 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector)
226 { 229 {
227 InvalidationSetMode mode = invalidationSetModeForSelector(selector); 230 InvalidationSetMode mode = invalidationSetModeForSelector(selector);
228 if (mode != AddFeatures) 231 if (mode != AddFeatures)
229 return mode; 232 return mode;
230 233
231 InvalidationSetFeatures features; 234 InvalidationSetFeatures features;
232 if (const CSSSelector* current = extractInvalidationSetFeatures(selector, fe atures)) 235 if (const CSSSelector* current = extractInvalidationSetFeatures(selector, fe atures, false))
233 addFeaturesToInvalidationSets(*current, features); 236 addFeaturesToInvalidationSets(*current, features);
234 return AddFeatures; 237 return AddFeatures;
235 } 238 }
236 239
237 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec tor& selector, InvalidationSetFeatures& features) 240 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec tor& selector, InvalidationSetFeatures& features, bool negated)
238 { 241 {
239 for (const CSSSelector* current = &selector; current; current = current->tag History()) { 242 for (const CSSSelector* current = &selector; current; current = current->tag History()) {
240 extractInvalidationSetFeature(*current, features); 243 if (!negated)
244 extractInvalidationSetFeature(*current, features);
241 // Initialize the entry in the invalidation set map, if supported. 245 // Initialize the entry in the invalidation set map, if supported.
242 invalidationSetForSelector(*current); 246 invalidationSetForSelector(*current);
243 if (current->pseudoType() == CSSSelector::PseudoHost || current->pseudoT ype() == CSSSelector::PseudoAny) { 247 if (current->pseudoType() == CSSSelector::PseudoHost || current->pseudoT ype() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelector::PseudoN ot) {
244 if (const CSSSelectorList* selectorList = current->selectorList()) { 248 if (const CSSSelectorList* selectorList = current->selectorList()) {
245 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) 249 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector))
246 extractInvalidationSetFeatures(*selector, features); 250 extractInvalidationSetFeatures(*selector, features, current- >pseudoType() == CSSSelector::PseudoNot);
247 } 251 }
248 } 252 }
249 253
250 switch (current->relation()) { 254 switch (current->relation()) {
251 case CSSSelector::SubSelector: 255 case CSSSelector::SubSelector:
252 break; 256 break;
253 case CSSSelector::ShadowPseudo: 257 case CSSSelector::ShadowPseudo:
254 case CSSSelector::ShadowDeep: 258 case CSSSelector::ShadowDeep:
255 features.treeBoundaryCrossing = true; 259 features.treeBoundaryCrossing = true;
256 return current->tagHistory(); 260 return current->tagHistory();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 invalidationSet->addId(features.id); 294 invalidationSet->addId(features.id);
291 if (!features.tagName.isEmpty()) 295 if (!features.tagName.isEmpty())
292 invalidationSet->addTagName(features.tagName); 296 invalidationSet->addTagName(features.tagName);
293 for (Vector<AtomicString>::const_iterator it = features.classes. begin(); it != features.classes.end(); ++it) 297 for (Vector<AtomicString>::const_iterator it = features.classes. begin(); it != features.classes.end(); ++it)
294 invalidationSet->addClass(*it); 298 invalidationSet->addClass(*it);
295 for (Vector<AtomicString>::const_iterator it = features.attribut es.begin(); it != features.attributes.end(); ++it) 299 for (Vector<AtomicString>::const_iterator it = features.attribut es.begin(); it != features.attributes.end(); ++it)
296 invalidationSet->addAttribute(*it); 300 invalidationSet->addAttribute(*it);
297 if (features.customPseudoElement) 301 if (features.customPseudoElement)
298 invalidationSet->setCustomPseudoInvalid(); 302 invalidationSet->setCustomPseudoInvalid();
299 } 303 }
300 } else if (current->pseudoType() == CSSSelector::PseudoHost || current-> pseudoType() == CSSSelector::PseudoAny) { 304 } else {
301 if (current->pseudoType() == CSSSelector::PseudoHost) 305 if (current->pseudoType() == CSSSelector::PseudoHost)
302 features.treeBoundaryCrossing = true; 306 features.treeBoundaryCrossing = true;
303 if (const CSSSelectorList* selectorList = current->selectorList()) { 307 if (const CSSSelectorList* selectorList = current->selectorList()) {
308 ASSERT(current->pseudoType() == CSSSelector::PseudoHost || curre nt->pseudoType() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelect or::PseudoNot);
304 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) 309 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector))
305 addFeaturesToInvalidationSets(*selector, features); 310 addFeaturesToInvalidationSets(*selector, features);
306 } 311 }
307 } 312 }
308 switch (current->relation()) { 313 switch (current->relation()) {
309 case CSSSelector::SubSelector: 314 case CSSSelector::SubSelector:
310 break; 315 break;
311 case CSSSelector::ShadowPseudo: 316 case CSSSelector::ShadowPseudo:
312 case CSSSelector::ShadowDeep: 317 case CSSSelector::ShadowDeep:
313 features.treeBoundaryCrossing = true; 318 features.treeBoundaryCrossing = true;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 visitor->trace(uncommonAttributeRules); 560 visitor->trace(uncommonAttributeRules);
556 visitor->trace(m_classInvalidationSets); 561 visitor->trace(m_classInvalidationSets);
557 visitor->trace(m_attributeInvalidationSets); 562 visitor->trace(m_attributeInvalidationSets);
558 visitor->trace(m_idInvalidationSets); 563 visitor->trace(m_idInvalidationSets);
559 visitor->trace(m_pseudoInvalidationSets); 564 visitor->trace(m_pseudoInvalidationSets);
560 visitor->trace(m_styleInvalidator); 565 visitor->trace(m_styleInvalidator);
561 #endif 566 #endif
562 } 567 }
563 568
564 } // namespace blink 569 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/RuleFeature.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698