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

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

Issue 641583002: Rename wholeSubtree to adjacent. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 extractInvalidationSetFeature(*current, features); 256 extractInvalidationSetFeature(*current, features);
257 // Initialize the entry in the invalidation set map, if supported. 257 // Initialize the entry in the invalidation set map, if supported.
258 invalidationSetForSelector(*current); 258 invalidationSetForSelector(*current);
259 if (current->pseudoType() == CSSSelector::PseudoHost || current->pseudoT ype() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelector::PseudoN ot) { 259 if (current->pseudoType() == CSSSelector::PseudoHost || current->pseudoT ype() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelector::PseudoN ot) {
260 if (const CSSSelectorList* selectorList = current->selectorList()) { 260 if (const CSSSelectorList* selectorList = current->selectorList()) {
261 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) 261 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector))
262 extractInvalidationSetFeatures(*selector, features, current- >pseudoType() == CSSSelector::PseudoNot); 262 extractInvalidationSetFeatures(*selector, features, current- >pseudoType() == CSSSelector::PseudoNot);
263 } 263 }
264 } 264 }
265 265
266 switch (current->relation()) { 266 if (current->relation() == CSSSelector::SubSelector)
267 case CSSSelector::SubSelector: 267 continue;
268 break; 268
269 case CSSSelector::ShadowPseudo: 269 if (current->isShadowSelector())
270 case CSSSelector::ShadowDeep:
271 features.treeBoundaryCrossing = true; 270 features.treeBoundaryCrossing = true;
chrishtr 2014/10/10 16:26:02 Can be written as: features.treeBundaryCrossing =
rune 2014/10/10 20:00:35 Done.
272 return current->tagHistory(); 271
273 case CSSSelector::DirectAdjacent: 272 features.adjacent = current->isAdjacentSelector();
274 case CSSSelector::IndirectAdjacent: 273 return current->tagHistory();
Mike West 2014/10/08 12:24:00 This is a huge improvement in readability. Kudos.
275 features.wholeSubtree = true;
276 return current->tagHistory();
277 case CSSSelector::Descendant:
278 case CSSSelector::Child:
279 return current->tagHistory();
280 }
281 } 274 }
282 return 0; 275 return 0;
283 } 276 }
284 277
285 // Add features extracted from the rightmost compound selector to descendant inv alidation 278 // Add features extracted from the rightmost compound selector to descendant inv alidation
286 // sets for features found in other compound selectors. 279 // sets for features found in other compound selectors.
287 // 280 //
288 // Style invalidation is currently supported for descendants only, not for sibli ng subtrees. 281 // Style invalidation is currently supported for descendants only, not for sibli ng subtrees.
289 // We use wholeSubtree invalidation for features found left of adjacent combinat ors as 282 // We use wholeSubtree invalidation for features found left of adjacent combinat ors as
290 // SubtreeStyleChange will force sibling subtree recalc in 283 // SubtreeStyleChange will force sibling subtree recalc in
291 // ContainerNode::checkForChildrenAdjacentRuleChanges. 284 // ContainerNode::checkForChildrenAdjacentRuleChanges.
292 // 285 //
293 // As we encounter a descendant type of combinator, the features only need to be checked 286 // As we encounter a descendant type of combinator, the features only need to be checked
294 // against descendants in the same subtree only. Hence wholeSubtree is reset to false. 287 // against descendants in the same subtree only. features.adjacent is set to fal se, and
288 // we start adding features instead of calling setWholeSubtreeInvalid.
295 289
296 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, InvalidationSetFeatures& features) 290 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, InvalidationSetFeatures& features)
297 { 291 {
298 for (const CSSSelector* current = &selector; current; current = current->tag History()) { 292 for (const CSSSelector* current = &selector; current; current = current->tag History()) {
299 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { 293 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) {
300 if (features.treeBoundaryCrossing) 294 if (features.treeBoundaryCrossing)
301 invalidationSet->setTreeBoundaryCrossing(); 295 invalidationSet->setTreeBoundaryCrossing();
302 if (features.wholeSubtree) { 296 if (features.adjacent) {
303 invalidationSet->setWholeSubtreeInvalid(); 297 invalidationSet->setWholeSubtreeInvalid();
304 } else { 298 } else {
305 if (!features.id.isEmpty()) 299 if (!features.id.isEmpty())
306 invalidationSet->addId(features.id); 300 invalidationSet->addId(features.id);
307 if (!features.tagName.isEmpty()) 301 if (!features.tagName.isEmpty())
308 invalidationSet->addTagName(features.tagName); 302 invalidationSet->addTagName(features.tagName);
309 for (Vector<AtomicString>::const_iterator it = features.classes. begin(); it != features.classes.end(); ++it) 303 for (Vector<AtomicString>::const_iterator it = features.classes. begin(); it != features.classes.end(); ++it)
310 invalidationSet->addClass(*it); 304 invalidationSet->addClass(*it);
311 for (Vector<AtomicString>::const_iterator it = features.attribut es.begin(); it != features.attributes.end(); ++it) 305 for (Vector<AtomicString>::const_iterator it = features.attribut es.begin(); it != features.attributes.end(); ++it)
312 invalidationSet->addAttribute(*it); 306 invalidationSet->addAttribute(*it);
313 if (features.customPseudoElement) 307 if (features.customPseudoElement)
314 invalidationSet->setCustomPseudoInvalid(); 308 invalidationSet->setCustomPseudoInvalid();
315 } 309 }
316 } else { 310 } else {
317 if (current->pseudoType() == CSSSelector::PseudoHost) 311 if (current->pseudoType() == CSSSelector::PseudoHost)
318 features.treeBoundaryCrossing = true; 312 features.treeBoundaryCrossing = true;
319 if (const CSSSelectorList* selectorList = current->selectorList()) { 313 if (const CSSSelectorList* selectorList = current->selectorList()) {
320 ASSERT(current->pseudoType() == CSSSelector::PseudoHost || curre nt->pseudoType() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelect or::PseudoNot); 314 ASSERT(current->pseudoType() == CSSSelector::PseudoHost || curre nt->pseudoType() == CSSSelector::PseudoAny || current->pseudoType() == CSSSelect or::PseudoNot);
321 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) 315 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector))
322 addFeaturesToInvalidationSets(*selector, features); 316 addFeaturesToInvalidationSets(*selector, features);
323 } 317 }
324 } 318 }
325 switch (current->relation()) { 319
326 case CSSSelector::SubSelector: 320 if (current->isShadowSelector())
327 break;
328 case CSSSelector::ShadowPseudo:
329 case CSSSelector::ShadowDeep:
330 features.treeBoundaryCrossing = true; 321 features.treeBoundaryCrossing = true;
331 features.wholeSubtree = false; 322
332 break; 323 if (current->relation() != CSSSelector::SubSelector)
333 case CSSSelector::Descendant: 324 features.adjacent = current->isAdjacentSelector();
Mike West 2014/10/08 12:24:00 This is even better. :)
334 case CSSSelector::Child:
335 features.wholeSubtree = false;
336 break;
337 case CSSSelector::DirectAdjacent:
338 case CSSSelector::IndirectAdjacent:
339 features.wholeSubtree = true;
340 break;
341 }
342 } 325 }
343 } 326 }
344 327
345 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) 328 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName)
346 { 329 {
347 ensureAttributeInvalidationSet(attributeName); 330 ensureAttributeInvalidationSet(attributeName);
348 } 331 }
349 332
350 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) 333 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData)
351 { 334 {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 visitor->trace(uncommonAttributeRules); 547 visitor->trace(uncommonAttributeRules);
565 visitor->trace(m_classInvalidationSets); 548 visitor->trace(m_classInvalidationSets);
566 visitor->trace(m_attributeInvalidationSets); 549 visitor->trace(m_attributeInvalidationSets);
567 visitor->trace(m_idInvalidationSets); 550 visitor->trace(m_idInvalidationSets);
568 visitor->trace(m_pseudoInvalidationSets); 551 visitor->trace(m_pseudoInvalidationSets);
569 visitor->trace(m_styleInvalidator); 552 visitor->trace(m_styleInvalidator);
570 #endif 553 #endif
571 } 554 }
572 555
573 } // namespace blink 556 } // 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