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

Side by Side Diff: third_party/WebKit/Source/core/css/SelectorChecker.cpp

Issue 1616743002: Use more appropriate symbol names for "shadow distributed" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink_slotted_matching
Patch Set: Created 4 years, 11 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
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, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // Disable :visited matching when we see the first link or try to match anyt hing else than an ancestors. 342 // Disable :visited matching when we see the first link or try to match anyt hing else than an ancestors.
343 if (!context.isSubSelector && (context.element->isLink() || (relation != CSS Selector::Descendant && relation != CSSSelector::Child))) 343 if (!context.isSubSelector && (context.element->isLink() || (relation != CSS Selector::Descendant && relation != CSSSelector::Child)))
344 nextContext.visitedMatchType = VisitedMatchDisabled; 344 nextContext.visitedMatchType = VisitedMatchDisabled;
345 345
346 nextContext.pseudoId = NOPSEUDO; 346 nextContext.pseudoId = NOPSEUDO;
347 347
348 switch (relation) { 348 switch (relation) {
349 case CSSSelector::Descendant: 349 case CSSSelector::Descendant:
350 if (context.selector->relationIsAffectedByPseudoContent()) { 350 if (context.selector->relationIsAffectedByPseudoContent()) {
351 for (Element* element = context.element; element; element = element- >parentElement()) { 351 for (Element* element = context.element; element; element = element- >parentElement()) {
352 if (matchForShadowDistributed(nextContext, *element, result) == SelectorMatches) 352 if (matchForPseudoContent(nextContext, *element, result) == Sele ctorMatches)
353 return SelectorMatches; 353 return SelectorMatches;
354 } 354 }
355 return SelectorFailsCompletely; 355 return SelectorFailsCompletely;
356 } 356 }
357 nextContext.isSubSelector = false; 357 nextContext.isSubSelector = false;
358 nextContext.inRightmostCompound = false; 358 nextContext.inRightmostCompound = false;
359 359
360 if (nextContext.selector->pseudoType() == CSSSelector::PseudoShadow) 360 if (nextContext.selector->pseudoType() == CSSSelector::PseudoShadow)
361 return matchForPseudoShadow(nextContext, context.element->containing ShadowRoot(), result); 361 return matchForPseudoShadow(nextContext, context.element->containing ShadowRoot(), result);
362 362
363 for (nextContext.element = parentElement(context); nextContext.element; nextContext.element = parentElement(nextContext)) { 363 for (nextContext.element = parentElement(context); nextContext.element; nextContext.element = parentElement(nextContext)) {
364 Match match = matchSelector(nextContext, result); 364 Match match = matchSelector(nextContext, result);
365 if (match == SelectorMatches || match == SelectorFailsCompletely) 365 if (match == SelectorMatches || match == SelectorFailsCompletely)
366 return match; 366 return match;
367 if (nextSelectorExceedsScope(nextContext)) 367 if (nextSelectorExceedsScope(nextContext))
368 return SelectorFailsCompletely; 368 return SelectorFailsCompletely;
369 } 369 }
370 return SelectorFailsCompletely; 370 return SelectorFailsCompletely;
371 case CSSSelector::Child: 371 case CSSSelector::Child:
372 { 372 {
373 if (context.selector->relationIsAffectedByPseudoContent()) 373 if (context.selector->relationIsAffectedByPseudoContent())
374 return matchForShadowDistributed(nextContext, *context.element, result); 374 return matchForPseudoContent(nextContext, *context.element, resu lt);
375 375
376 nextContext.isSubSelector = false; 376 nextContext.isSubSelector = false;
377 nextContext.inRightmostCompound = false; 377 nextContext.inRightmostCompound = false;
378 378
379 if (nextContext.selector->pseudoType() == CSSSelector::PseudoShadow) 379 if (nextContext.selector->pseudoType() == CSSSelector::PseudoShadow)
380 return matchForPseudoShadow(nextContext, context.element->parent Node(), result); 380 return matchForPseudoShadow(nextContext, context.element->parent Node(), result);
381 381
382 nextContext.element = parentElement(context); 382 nextContext.element = parentElement(context);
383 if (!nextContext.element) 383 if (!nextContext.element)
384 return SelectorFailsCompletely; 384 return SelectorFailsCompletely;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if (!context.isUARule) 441 if (!context.isUARule)
442 UseCounter::countDeprecation(context.element->document(), UseCou nter::CSSDeepCombinator); 442 UseCounter::countDeprecation(context.element->document(), UseCou nter::CSSDeepCombinator);
443 if (ShadowRoot* root = context.element->containingShadowRoot()) { 443 if (ShadowRoot* root = context.element->containingShadowRoot()) {
444 if (root->type() == ShadowRootType::UserAgent) 444 if (root->type() == ShadowRootType::UserAgent)
445 return SelectorFailsCompletely; 445 return SelectorFailsCompletely;
446 } 446 }
447 447
448 if (context.selector->relationIsAffectedByPseudoContent()) { 448 if (context.selector->relationIsAffectedByPseudoContent()) {
449 // TODO(kochi): closed mode tree should be handled as well for : :content. 449 // TODO(kochi): closed mode tree should be handled as well for : :content.
450 for (Element* element = context.element; element; element = elem ent->parentOrShadowHostElement()) { 450 for (Element* element = context.element; element; element = elem ent->parentOrShadowHostElement()) {
451 if (matchForShadowDistributed(nextContext, *element, result) == SelectorMatches) 451 if (matchForPseudoContent(nextContext, *element, result) == SelectorMatches)
452 return SelectorMatches; 452 return SelectorMatches;
453 } 453 }
454 return SelectorFailsCompletely; 454 return SelectorFailsCompletely;
455 } 455 }
456 456
457 nextContext.isSubSelector = false; 457 nextContext.isSubSelector = false;
458 nextContext.inRightmostCompound = false; 458 nextContext.inRightmostCompound = false;
459 459
460 for (nextContext.element = parentOrV0ShadowHostElement(*context.elem ent); nextContext.element; nextContext.element = parentOrV0ShadowHostElement(*ne xtContext.element)) { 460 for (nextContext.element = parentOrV0ShadowHostElement(*context.elem ent); nextContext.element; nextContext.element = parentOrV0ShadowHostElement(*ne xtContext.element)) {
461 Match match = matchSelector(nextContext, result); 461 Match match = matchSelector(nextContext, result);
(...skipping 16 matching lines...) Expand all
478 } 478 }
479 479
480 case CSSSelector::SubSelector: 480 case CSSSelector::SubSelector:
481 ASSERT_NOT_REACHED(); 481 ASSERT_NOT_REACHED();
482 } 482 }
483 483
484 ASSERT_NOT_REACHED(); 484 ASSERT_NOT_REACHED();
485 return SelectorFailsCompletely; 485 return SelectorFailsCompletely;
486 } 486 }
487 487
488 SelectorChecker::Match SelectorChecker::matchForShadowDistributed(const Selector CheckingContext& context, const Element& element, MatchResult& result) const 488 SelectorChecker::Match SelectorChecker::matchForPseudoContent(const SelectorChec kingContext& context, const Element& element, MatchResult& result) const
489 { 489 {
490 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; 490 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints;
491 collectDestinationInsertionPoints(element, insertionPoints); 491 collectDestinationInsertionPoints(element, insertionPoints);
492 SelectorCheckingContext nextContext(context); 492 SelectorCheckingContext nextContext(context);
493 nextContext.isSubSelector = false; 493 nextContext.isSubSelector = false;
494 nextContext.inRightmostCompound = false; 494 nextContext.inRightmostCompound = false;
495 for (const auto& insertionPoint : insertionPoints) { 495 for (const auto& insertionPoint : insertionPoints) {
496 nextContext.element = insertionPoint; 496 nextContext.element = insertionPoint;
497 // TODO(esprehn): Why does SharingRules have a special case? 497 // TODO(esprehn): Why does SharingRules have a special case?
498 if (m_mode == SharingRules) 498 if (m_mode == SharingRules)
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 } 1232 }
1233 1233
1234 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) 1234 bool SelectorChecker::matchesFocusPseudoClass(const Element& element)
1235 { 1235 {
1236 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element ), CSSSelector::PseudoFocus)) 1236 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element ), CSSSelector::PseudoFocus))
1237 return true; 1237 return true;
1238 return element.focused() && isFrameFocused(element); 1238 return element.focused() && isFrameFocused(element);
1239 } 1239 }
1240 1240
1241 } 1241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698