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

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

Issue 286903024: Skip child ShadowRoots when invalidation does not have boundary crossing rules (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix set merging Created 6 years, 6 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
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return 0; 200 return 0;
201 } 201 }
202 202
203 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector) 203 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector)
204 { 204 {
205 InvalidationSetMode mode = invalidationSetModeForSelector(selector); 205 InvalidationSetMode mode = invalidationSetModeForSelector(selector);
206 if (mode != AddFeatures) 206 if (mode != AddFeatures)
207 return mode; 207 return mode;
208 208
209 InvalidationSetFeatures features; 209 InvalidationSetFeatures features;
210 const CSSSelector* current = extractInvalidationSetFeatures(selector, featur es); 210 if (const CSSSelector* current = extractInvalidationSetFeatures(selector, fe atures))
211 if (current) { 211 addFeaturesToInvalidationSets(*current, features);
212 bool wholeSubtree = current->relation() == CSSSelector::DirectAdjacent | | current->relation() == CSSSelector::IndirectAdjacent;
213 current = current->tagHistory();
214 if (current)
215 addFeaturesToInvalidationSets(*current, features, wholeSubtree);
216 }
217 return AddFeatures; 212 return AddFeatures;
218 } 213 }
219 214
220 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec tor& selector, InvalidationSetFeatures& features) 215 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec tor& selector, InvalidationSetFeatures& features)
221 { 216 {
222 const CSSSelector* lastSelector = &selector; 217 const CSSSelector* lastSelector = &selector;
223 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { 218 for (; lastSelector; lastSelector = lastSelector->tagHistory()) {
224 extractInvalidationSetFeature(*lastSelector, features); 219 extractInvalidationSetFeature(*lastSelector, features);
225 // Initialize the entry in the invalidation set map, if supported. 220 // Initialize the entry in the invalidation set map, if supported.
226 invalidationSetForSelector(*lastSelector); 221 invalidationSetForSelector(*lastSelector);
227 if (lastSelector->pseudoType() == CSSSelector::PseudoHost || lastSelecto r->pseudoType() == CSSSelector::PseudoAny) { 222 if (lastSelector->pseudoType() == CSSSelector::PseudoHost || lastSelecto r->pseudoType() == CSSSelector::PseudoAny) {
228 if (const CSSSelectorList* selectorList = lastSelector->selectorList ()) { 223 if (const CSSSelectorList* selectorList = lastSelector->selectorList ()) {
229 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) 224 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector))
230 extractInvalidationSetFeatures(*selector, features); 225 extractInvalidationSetFeatures(*selector, features);
231 } 226 }
232 } 227 }
233 228
229 if (lastSelector->relation() == CSSSelector::ShadowPseudo || lastSelecto r->relation() == CSSSelector::ShadowDeep)
230 features.treeBoundaryCrossing = true;
231 else if (lastSelector->relation() == CSSSelector::DirectAdjacent || last Selector->relation() == CSSSelector::IndirectAdjacent)
232 features.wholeSubtree = true;
233
234 if (lastSelector->relation() != CSSSelector::SubSelector) 234 if (lastSelector->relation() != CSSSelector::SubSelector)
235 break; 235 break;
236 } 236 }
237 return lastSelector; 237 if (lastSelector)
238 return lastSelector->tagHistory();
239 return 0;
238 } 240 }
239 241
240 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, const InvalidationSetFeatures& features, bool wholeSubtree) 242 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, InvalidationSetFeatures& features)
241 { 243 {
242 for (const CSSSelector* current = &selector; current; current = current->tag History()) { 244 for (const CSSSelector* current = &selector; current; current = current->tag History()) {
243 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { 245 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) {
244 if (wholeSubtree) { 246 if (features.treeBoundaryCrossing)
247 invalidationSet->setTreeBoundaryCrossing();
248 if (features.wholeSubtree) {
245 invalidationSet->setWholeSubtreeInvalid(); 249 invalidationSet->setWholeSubtreeInvalid();
246 } else { 250 } else {
247 if (!features.id.isEmpty()) 251 if (!features.id.isEmpty())
248 invalidationSet->addId(features.id); 252 invalidationSet->addId(features.id);
249 if (!features.tagName.isEmpty()) 253 if (!features.tagName.isEmpty())
250 invalidationSet->addTagName(features.tagName); 254 invalidationSet->addTagName(features.tagName);
251 for (Vector<AtomicString>::const_iterator it = features.classes. begin(); it != features.classes.end(); ++it) 255 for (Vector<AtomicString>::const_iterator it = features.classes. begin(); it != features.classes.end(); ++it)
252 invalidationSet->addClass(*it); 256 invalidationSet->addClass(*it);
253 for (Vector<AtomicString>::const_iterator it = features.attribut es.begin(); it != features.attributes.end(); ++it) 257 for (Vector<AtomicString>::const_iterator it = features.attribut es.begin(); it != features.attributes.end(); ++it)
254 invalidationSet->addAttribute(*it); 258 invalidationSet->addAttribute(*it);
255 if (features.customPseudoElement) 259 if (features.customPseudoElement)
256 invalidationSet->setCustomPseudoInvalid(); 260 invalidationSet->setCustomPseudoInvalid();
257 } 261 }
258 } else if (current->pseudoType() == CSSSelector::PseudoHost || current-> pseudoType() == CSSSelector::PseudoAny) { 262 } else if (current->pseudoType() == CSSSelector::PseudoHost || current-> pseudoType() == CSSSelector::PseudoAny) {
263 if (current->pseudoType() == CSSSelector::PseudoHost)
264 features.treeBoundaryCrossing = true;
259 if (const CSSSelectorList* selectorList = current->selectorList()) { 265 if (const CSSSelectorList* selectorList = current->selectorList()) {
260 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) 266 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector))
261 addFeaturesToInvalidationSets(*selector, features, wholeSubt ree); 267 addFeaturesToInvalidationSets(*selector, features);
262 } 268 }
263 } 269 }
264 switch (current->relation()) { 270 switch (current->relation()) {
265 case CSSSelector::Descendant: 271 case CSSSelector::Descendant:
266 case CSSSelector::Child: 272 case CSSSelector::Child:
273 features.wholeSubtree = false;
chrishtr 2014/05/29 20:54:07 Why this change?
esprehn 2014/05/29 21:07:30 Because I can't handle all 4 types of relations th
chrishtr 2014/05/29 21:43:43 Ah right, fallthrough.
274 break;
267 case CSSSelector::ShadowPseudo: 275 case CSSSelector::ShadowPseudo:
268 case CSSSelector::ShadowDeep: 276 case CSSSelector::ShadowDeep:
269 wholeSubtree = false; 277 features.treeBoundaryCrossing = true;
278 features.wholeSubtree = false;
chrishtr 2014/05/29 20:54:07 I don't get why it's ok to set wholeSubtree to fal
esprehn 2014/05/29 21:07:30 We always did that, see the old code. I just split
chrishtr 2014/05/29 21:43:43 Oh right.
chrishtr 2014/05/29 21:43:43 Ok.
rune 2014/05/30 21:02:45 FTR, it's because these shadow combinators are lik
270 break; 279 break;
271 case CSSSelector::DirectAdjacent: 280 case CSSSelector::DirectAdjacent:
272 case CSSSelector::IndirectAdjacent: 281 case CSSSelector::IndirectAdjacent:
273 wholeSubtree = true; 282 features.wholeSubtree = true;
274 break; 283 break;
275 case CSSSelector::SubSelector: 284 case CSSSelector::SubSelector:
276 break; 285 break;
277 default:
278 // All combinators should be handled above.
279 ASSERT_NOT_REACHED();
280 break;
281 } 286 }
282 } 287 }
283 } 288 }
284 289
285 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) 290 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName)
286 { 291 {
287 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName); 292 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName);
288 invalidationSet.setWholeSubtreeInvalid(); 293 invalidationSet.setWholeSubtreeInvalid();
289 } 294 }
290 295
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 visitor->trace(siblingRules); 513 visitor->trace(siblingRules);
509 visitor->trace(uncommonAttributeRules); 514 visitor->trace(uncommonAttributeRules);
510 visitor->trace(m_classInvalidationSets); 515 visitor->trace(m_classInvalidationSets);
511 visitor->trace(m_attributeInvalidationSets); 516 visitor->trace(m_attributeInvalidationSets);
512 visitor->trace(m_idInvalidationSets); 517 visitor->trace(m_idInvalidationSets);
513 visitor->trace(m_pseudoInvalidationSets); 518 visitor->trace(m_pseudoInvalidationSets);
514 visitor->trace(m_styleInvalidator); 519 visitor->trace(m_styleInvalidator);
515 } 520 }
516 521
517 } // namespace WebCore 522 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698