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

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: no really 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 for (const CSSSelector* lastSelector = &selector;; lastSelector; lastSelecto r = lastSelector->tagHistory()) {
rune 2014/05/30 21:02:45 The double ;; is what gave you compile problems, I
223 for (; lastSelector; lastSelector = lastSelector->tagHistory()) {
224 extractInvalidationSetFeature(*lastSelector, features); 218 extractInvalidationSetFeature(*lastSelector, features);
225 // Initialize the entry in the invalidation set map, if supported. 219 // Initialize the entry in the invalidation set map, if supported.
226 invalidationSetForSelector(*lastSelector); 220 invalidationSetForSelector(*lastSelector);
227 if (lastSelector->pseudoType() == CSSSelector::PseudoHost || lastSelecto r->pseudoType() == CSSSelector::PseudoAny) { 221 if (lastSelector->pseudoType() == CSSSelector::PseudoHost || lastSelecto r->pseudoType() == CSSSelector::PseudoAny) {
228 if (const CSSSelectorList* selectorList = lastSelector->selectorList ()) { 222 if (const CSSSelectorList* selectorList = lastSelector->selectorList ()) {
229 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) 223 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector))
230 extractInvalidationSetFeatures(*selector, features); 224 extractInvalidationSetFeatures(*selector, features);
231 } 225 }
232 } 226 }
233 227
234 if (lastSelector->relation() != CSSSelector::SubSelector) 228 switch (current->relation()) {
235 break; 229 case CSSSelector::SubSelector:
230 continue;
231 case CSSSelector::ShadowPseudo:
232 case CSSSelector::ShadowDeep:
233 features.treeBoundaryCrossing = true;
234 return lastSelector->tagHistory();
235 case CSSSelector::DirectAdjacent:
236 case CSSSelector::IndirectAdjacent:
237 features.wholeSubtree = true;
238 return lastSelector->tagHistory();
239 case CSSSelector::Descendant:
240 case CSSSelector::Child:
241 return lastSelector->tagHistory();
242 }
236 } 243 }
237 return lastSelector; 244 return 0;
238 } 245 }
239 246
240 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, const InvalidationSetFeatures& features, bool wholeSubtree) 247 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, InvalidationSetFeatures& features)
241 { 248 {
242 for (const CSSSelector* current = &selector; current; current = current->tag History()) { 249 for (const CSSSelector* current = &selector; current; current = current->tag History()) {
243 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { 250 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) {
244 if (wholeSubtree) { 251 if (features.treeBoundaryCrossing)
252 invalidationSet->setTreeBoundaryCrossing();
253 if (features.wholeSubtree) {
245 invalidationSet->setWholeSubtreeInvalid(); 254 invalidationSet->setWholeSubtreeInvalid();
246 } else { 255 } else {
247 if (!features.id.isEmpty()) 256 if (!features.id.isEmpty())
248 invalidationSet->addId(features.id); 257 invalidationSet->addId(features.id);
249 if (!features.tagName.isEmpty()) 258 if (!features.tagName.isEmpty())
250 invalidationSet->addTagName(features.tagName); 259 invalidationSet->addTagName(features.tagName);
251 for (Vector<AtomicString>::const_iterator it = features.classes. begin(); it != features.classes.end(); ++it) 260 for (Vector<AtomicString>::const_iterator it = features.classes. begin(); it != features.classes.end(); ++it)
252 invalidationSet->addClass(*it); 261 invalidationSet->addClass(*it);
253 for (Vector<AtomicString>::const_iterator it = features.attribut es.begin(); it != features.attributes.end(); ++it) 262 for (Vector<AtomicString>::const_iterator it = features.attribut es.begin(); it != features.attributes.end(); ++it)
254 invalidationSet->addAttribute(*it); 263 invalidationSet->addAttribute(*it);
255 if (features.customPseudoElement) 264 if (features.customPseudoElement)
256 invalidationSet->setCustomPseudoInvalid(); 265 invalidationSet->setCustomPseudoInvalid();
257 } 266 }
258 } else if (current->pseudoType() == CSSSelector::PseudoHost || current-> pseudoType() == CSSSelector::PseudoAny) { 267 } else if (current->pseudoType() == CSSSelector::PseudoHost || current-> pseudoType() == CSSSelector::PseudoAny) {
268 if (current->pseudoType() == CSSSelector::PseudoHost)
269 features.treeBoundaryCrossing = true;
259 if (const CSSSelectorList* selectorList = current->selectorList()) { 270 if (const CSSSelectorList* selectorList = current->selectorList()) {
260 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) 271 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector))
261 addFeaturesToInvalidationSets(*selector, features, wholeSubt ree); 272 addFeaturesToInvalidationSets(*selector, features);
262 } 273 }
263 } 274 }
264 switch (current->relation()) { 275 switch (current->relation()) {
276 case CSSSelector::SubSelector:
277 break;
278 case CSSSelector::ShadowPseudo:
279 case CSSSelector::ShadowDeep:
280 features.treeBoundaryCrossing = true;
281 features.wholeSubtree = false;
282 break;
265 case CSSSelector::Descendant: 283 case CSSSelector::Descendant:
266 case CSSSelector::Child: 284 case CSSSelector::Child:
267 case CSSSelector::ShadowPseudo: 285 features.wholeSubtree = false;
268 case CSSSelector::ShadowDeep:
269 wholeSubtree = false;
270 break; 286 break;
271 case CSSSelector::DirectAdjacent: 287 case CSSSelector::DirectAdjacent:
272 case CSSSelector::IndirectAdjacent: 288 case CSSSelector::IndirectAdjacent:
273 wholeSubtree = true; 289 features.wholeSubtree = true;
274 break;
275 case CSSSelector::SubSelector:
276 break;
277 default:
278 // All combinators should be handled above.
279 ASSERT_NOT_REACHED();
280 break; 290 break;
281 } 291 }
282 } 292 }
283 } 293 }
284 294
285 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) 295 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName)
286 { 296 {
287 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName); 297 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName);
288 invalidationSet.setWholeSubtreeInvalid(); 298 invalidationSet.setWholeSubtreeInvalid();
289 } 299 }
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 visitor->trace(siblingRules); 518 visitor->trace(siblingRules);
509 visitor->trace(uncommonAttributeRules); 519 visitor->trace(uncommonAttributeRules);
510 visitor->trace(m_classInvalidationSets); 520 visitor->trace(m_classInvalidationSets);
511 visitor->trace(m_attributeInvalidationSets); 521 visitor->trace(m_attributeInvalidationSets);
512 visitor->trace(m_idInvalidationSets); 522 visitor->trace(m_idInvalidationSets);
513 visitor->trace(m_pseudoInvalidationSets); 523 visitor->trace(m_pseudoInvalidationSets);
514 visitor->trace(m_styleInvalidator); 524 visitor->trace(m_styleInvalidator);
515 } 525 }
516 526
517 } // namespace WebCore 527 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698