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

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

Issue 1133743004: Make right-most compound check explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 5 years, 7 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/SelectorChecker.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, 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (context.selector->isCustomPseudoElement()) { 255 if (context.selector->isCustomPseudoElement()) {
256 if (!matchesCustomPseudoElement(context.element, *context.selector)) 256 if (!matchesCustomPseudoElement(context.element, *context.selector))
257 return SelectorFailsLocally; 257 return SelectorFailsLocally;
258 } else if (context.selector->isContentPseudoElement()) { 258 } else if (context.selector->isContentPseudoElement()) {
259 if (!context.element->isInShadowTree() || !context.element->isInsert ionPoint()) 259 if (!context.element->isInShadowTree() || !context.element->isInsert ionPoint())
260 return SelectorFailsLocally; 260 return SelectorFailsLocally;
261 } else if (context.selector->isShadowPseudoElement()) { 261 } else if (context.selector->isShadowPseudoElement()) {
262 if (!context.element->isInShadowTree() || !context.previousElement) 262 if (!context.element->isInShadowTree() || !context.previousElement)
263 return SelectorFailsCompletely; 263 return SelectorFailsCompletely;
264 } else { 264 } else {
265 if ((!context.elementStyle && m_mode == ResolvingStyle) || m_mode == QueryingRules) 265 if ((!context.inRightmostCompound && m_mode == ResolvingStyle) || m_ mode == QueryingRules)
266 return SelectorFailsLocally; 266 return SelectorFailsLocally;
267 267
268 PseudoId pseudoId = CSSSelector::pseudoId(context.selector->pseudoTy pe()); 268 PseudoId pseudoId = CSSSelector::pseudoId(context.selector->pseudoTy pe());
269 if (pseudoId != NOPSEUDO && m_mode != SharingRules) 269 if (pseudoId != NOPSEUDO && m_mode != SharingRules)
270 result.dynamicPseudo = pseudoId; 270 result.dynamicPseudo = pseudoId;
271 } 271 }
272 } 272 }
273 273
274 // Prepare next selector 274 // Prepare next selector
275 if (context.selector->isLastInTagHistory()) { 275 if (context.selector->isLastInTagHistory()) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 SelectorChecker::Match SelectorChecker::matchForSubSelector(const SelectorChecki ngContext& context, MatchResult& result) const 316 SelectorChecker::Match SelectorChecker::matchForSubSelector(const SelectorChecki ngContext& context, MatchResult& result) const
317 { 317 {
318 SelectorCheckingContext nextContext = prepareNextContextForRelation(context) ; 318 SelectorCheckingContext nextContext = prepareNextContextForRelation(context) ;
319 319
320 PseudoId dynamicPseudo = result.dynamicPseudo; 320 PseudoId dynamicPseudo = result.dynamicPseudo;
321 // a selector is invalid if something follows a pseudo-element 321 // a selector is invalid if something follows a pseudo-element
322 // We make an exception for scrollbar pseudo elements and allow a set of pse udo classes (but nothing else) 322 // We make an exception for scrollbar pseudo elements and allow a set of pse udo classes (but nothing else)
323 // to follow the pseudo elements. 323 // to follow the pseudo elements.
324 nextContext.hasScrollbarPseudo = dynamicPseudo != NOPSEUDO && (context.scrol lbar || dynamicPseudo == SCROLLBAR_CORNER || dynamicPseudo == RESIZER); 324 nextContext.hasScrollbarPseudo = dynamicPseudo != NOPSEUDO && (context.scrol lbar || dynamicPseudo == SCROLLBAR_CORNER || dynamicPseudo == RESIZER);
325 nextContext.hasSelectionPseudo = dynamicPseudo == SELECTION; 325 nextContext.hasSelectionPseudo = dynamicPseudo == SELECTION;
326 if ((context.elementStyle || m_mode == CollectingCSSRules || m_mode == Colle ctingStyleRules || m_mode == QueryingRules) && dynamicPseudo != NOPSEUDO 326 if ((context.inRightmostCompound || m_mode == CollectingCSSRules || m_mode = = CollectingStyleRules || m_mode == QueryingRules) && dynamicPseudo != NOPSEUDO
327 && !nextContext.hasSelectionPseudo 327 && !nextContext.hasSelectionPseudo
328 && !(nextContext.hasScrollbarPseudo && nextContext.selector->match() == CSSSelector::PseudoClass)) 328 && !(nextContext.hasScrollbarPseudo && nextContext.selector->match() == CSSSelector::PseudoClass))
329 return SelectorFailsCompletely; 329 return SelectorFailsCompletely;
330 330
331 nextContext.isSubSelector = true; 331 nextContext.isSubSelector = true;
332 return matchSelector(nextContext, result); 332 return matchSelector(nextContext, result);
333 } 333 }
334 334
335 static inline Element* parentOrShadowHostButDisallowEscapingUserAgentShadowTree( const Element& element) 335 static inline Element* parentOrShadowHostButDisallowEscapingUserAgentShadowTree( const Element& element)
336 { 336 {
(...skipping 30 matching lines...) Expand all
367 switch (relation) { 367 switch (relation) {
368 case CSSSelector::Descendant: 368 case CSSSelector::Descendant:
369 if (context.selector->relationIsAffectedByPseudoContent()) { 369 if (context.selector->relationIsAffectedByPseudoContent()) {
370 for (Element* element = context.element; element; element = element- >parentElement()) { 370 for (Element* element = context.element; element; element = element- >parentElement()) {
371 if (matchForShadowDistributed(nextContext, *element, result) == SelectorMatches) 371 if (matchForShadowDistributed(nextContext, *element, result) == SelectorMatches)
372 return SelectorMatches; 372 return SelectorMatches;
373 } 373 }
374 return SelectorFailsCompletely; 374 return SelectorFailsCompletely;
375 } 375 }
376 nextContext.isSubSelector = false; 376 nextContext.isSubSelector = false;
377 nextContext.elementStyle = 0; 377 nextContext.inRightmostCompound = false;
378 378
379 if (nextContext.selector->isShadowPseudoElement()) 379 if (nextContext.selector->isShadowPseudoElement())
380 return matchForPseudoShadow(nextContext, context.element->containing ShadowRoot(), result); 380 return matchForPseudoShadow(nextContext, context.element->containing ShadowRoot(), result);
381 381
382 for (nextContext.element = parentElement(context); nextContext.element; nextContext.element = parentElement(nextContext)) { 382 for (nextContext.element = parentElement(context); nextContext.element; nextContext.element = parentElement(nextContext)) {
383 Match match = matchSelector(nextContext, result); 383 Match match = matchSelector(nextContext, result);
384 if (match == SelectorMatches || match == SelectorFailsCompletely) 384 if (match == SelectorMatches || match == SelectorFailsCompletely)
385 return match; 385 return match;
386 if (nextSelectorExceedsScope(nextContext)) 386 if (nextSelectorExceedsScope(nextContext))
387 return SelectorFailsCompletely; 387 return SelectorFailsCompletely;
388 } 388 }
389 return SelectorFailsCompletely; 389 return SelectorFailsCompletely;
390 case CSSSelector::Child: 390 case CSSSelector::Child:
391 { 391 {
392 if (context.selector->relationIsAffectedByPseudoContent()) 392 if (context.selector->relationIsAffectedByPseudoContent())
393 return matchForShadowDistributed(nextContext, *context.element, result); 393 return matchForShadowDistributed(nextContext, *context.element, result);
394 394
395 nextContext.isSubSelector = false; 395 nextContext.isSubSelector = false;
396 nextContext.elementStyle = 0; 396 nextContext.inRightmostCompound = false;
397 397
398 if (nextContext.selector->isShadowPseudoElement()) 398 if (nextContext.selector->isShadowPseudoElement())
399 return matchForPseudoShadow(nextContext, context.element->parent Node(), result); 399 return matchForPseudoShadow(nextContext, context.element->parent Node(), result);
400 400
401 nextContext.element = parentElement(context); 401 nextContext.element = parentElement(context);
402 if (!nextContext.element) 402 if (!nextContext.element)
403 return SelectorFailsCompletely; 403 return SelectorFailsCompletely;
404 return matchSelector(nextContext, result); 404 return matchSelector(nextContext, result);
405 } 405 }
406 case CSSSelector::DirectAdjacent: 406 case CSSSelector::DirectAdjacent:
407 // Shadow roots can't have sibling elements 407 // Shadow roots can't have sibling elements
408 if (nextContext.selector->isShadowPseudoElement()) 408 if (nextContext.selector->isShadowPseudoElement())
409 return SelectorFailsCompletely; 409 return SelectorFailsCompletely;
410 410
411 if (m_mode == ResolvingStyle) { 411 if (m_mode == ResolvingStyle) {
412 if (ContainerNode* parent = context.element->parentElementOrShadowRo ot()) 412 if (ContainerNode* parent = context.element->parentElementOrShadowRo ot())
413 parent->setChildrenAffectedByDirectAdjacentRules(); 413 parent->setChildrenAffectedByDirectAdjacentRules();
414 } 414 }
415 nextContext.element = ElementTraversal::previousSibling(*context.element ); 415 nextContext.element = ElementTraversal::previousSibling(*context.element );
416 if (!nextContext.element) 416 if (!nextContext.element)
417 return SelectorFailsAllSiblings; 417 return SelectorFailsAllSiblings;
418 nextContext.isSubSelector = false; 418 nextContext.isSubSelector = false;
419 nextContext.elementStyle = 0; 419 nextContext.inRightmostCompound = false;
420 return matchSelector(nextContext, result); 420 return matchSelector(nextContext, result);
421 421
422 case CSSSelector::IndirectAdjacent: 422 case CSSSelector::IndirectAdjacent:
423 // Shadow roots can't have sibling elements 423 // Shadow roots can't have sibling elements
424 if (nextContext.selector->isShadowPseudoElement()) 424 if (nextContext.selector->isShadowPseudoElement())
425 return SelectorFailsCompletely; 425 return SelectorFailsCompletely;
426 426
427 if (m_mode == ResolvingStyle) { 427 if (m_mode == ResolvingStyle) {
428 if (ContainerNode* parent = context.element->parentElementOrShadowRo ot()) 428 if (ContainerNode* parent = context.element->parentElementOrShadowRo ot())
429 parent->setChildrenAffectedByIndirectAdjacentRules(); 429 parent->setChildrenAffectedByIndirectAdjacentRules();
430 } 430 }
431 nextContext.element = ElementTraversal::previousSibling(*context.element ); 431 nextContext.element = ElementTraversal::previousSibling(*context.element );
432 nextContext.isSubSelector = false; 432 nextContext.isSubSelector = false;
433 nextContext.elementStyle = 0; 433 nextContext.inRightmostCompound = false;
434 for (; nextContext.element; nextContext.element = ElementTraversal::prev iousSibling(*nextContext.element)) { 434 for (; nextContext.element; nextContext.element = ElementTraversal::prev iousSibling(*nextContext.element)) {
435 Match match = matchSelector(nextContext, result); 435 Match match = matchSelector(nextContext, result);
436 if (match == SelectorMatches || match == SelectorFailsAllSiblings || match == SelectorFailsCompletely) 436 if (match == SelectorMatches || match == SelectorFailsAllSiblings || match == SelectorFailsCompletely)
437 return match; 437 return match;
438 }; 438 };
439 return SelectorFailsAllSiblings; 439 return SelectorFailsAllSiblings;
440 440
441 case CSSSelector::ShadowPseudo: 441 case CSSSelector::ShadowPseudo:
442 { 442 {
443 // If we're in the same tree-scope as the scoping element, then foll owing a shadow descendant combinator would escape that and thus the scope. 443 // If we're in the same tree-scope as the scoping element, then foll owing a shadow descendant combinator would escape that and thus the scope.
444 if (context.scope && context.scope->shadowHost() && context.scope->s hadowHost()->treeScope() == context.element->treeScope()) 444 if (context.scope && context.scope->shadowHost() && context.scope->s hadowHost()->treeScope() == context.element->treeScope())
445 return SelectorFailsCompletely; 445 return SelectorFailsCompletely;
446 446
447 Element* shadowHost = context.element->shadowHost(); 447 Element* shadowHost = context.element->shadowHost();
448 if (!shadowHost) 448 if (!shadowHost)
449 return SelectorFailsCompletely; 449 return SelectorFailsCompletely;
450 nextContext.element = shadowHost; 450 nextContext.element = shadowHost;
451 nextContext.isSubSelector = false; 451 nextContext.isSubSelector = false;
452 nextContext.elementStyle = 0; 452 nextContext.inRightmostCompound = false;
453 return matchSelector(nextContext, result); 453 return matchSelector(nextContext, result);
454 } 454 }
455 455
456 case CSSSelector::ShadowDeep: 456 case CSSSelector::ShadowDeep:
457 { 457 {
458 if (context.selector->relationIsAffectedByPseudoContent()) { 458 if (context.selector->relationIsAffectedByPseudoContent()) {
459 for (Element* element = context.element; element; element = pare ntOrShadowHostButDisallowEscapingUserAgentShadowTree(*element)) { 459 for (Element* element = context.element; element; element = pare ntOrShadowHostButDisallowEscapingUserAgentShadowTree(*element)) {
460 if (matchForShadowDistributed(nextContext, *element, result) == SelectorMatches) 460 if (matchForShadowDistributed(nextContext, *element, result) == SelectorMatches)
461 return SelectorMatches; 461 return SelectorMatches;
462 } 462 }
463 return SelectorFailsCompletely; 463 return SelectorFailsCompletely;
464 } 464 }
465 465
466 nextContext.isSubSelector = false; 466 nextContext.isSubSelector = false;
467 nextContext.elementStyle = 0; 467 nextContext.inRightmostCompound = false;
468 for (nextContext.element = parentOrShadowHostButDisallowEscapingUser AgentShadowTree(*context.element); nextContext.element; nextContext.element = pa rentOrShadowHostButDisallowEscapingUserAgentShadowTree(*nextContext.element)) { 468 for (nextContext.element = parentOrShadowHostButDisallowEscapingUser AgentShadowTree(*context.element); nextContext.element; nextContext.element = pa rentOrShadowHostButDisallowEscapingUserAgentShadowTree(*nextContext.element)) {
469 Match match = matchSelector(nextContext, result); 469 Match match = matchSelector(nextContext, result);
470 if (match == SelectorMatches || match == SelectorFailsCompletely ) 470 if (match == SelectorMatches || match == SelectorFailsCompletely )
471 return match; 471 return match;
472 if (nextSelectorExceedsScope(nextContext)) 472 if (nextSelectorExceedsScope(nextContext))
473 return SelectorFailsCompletely; 473 return SelectorFailsCompletely;
474 } 474 }
475 return SelectorFailsCompletely; 475 return SelectorFailsCompletely;
476 } 476 }
477 477
478 case CSSSelector::SubSelector: 478 case CSSSelector::SubSelector:
479 ASSERT_NOT_REACHED(); 479 ASSERT_NOT_REACHED();
480 } 480 }
481 481
482 ASSERT_NOT_REACHED(); 482 ASSERT_NOT_REACHED();
483 return SelectorFailsCompletely; 483 return SelectorFailsCompletely;
484 } 484 }
485 485
486 SelectorChecker::Match SelectorChecker::matchForShadowDistributed(const Selector CheckingContext& context, const Element& element, MatchResult& result) const 486 SelectorChecker::Match SelectorChecker::matchForShadowDistributed(const Selector CheckingContext& context, const Element& element, MatchResult& result) const
487 { 487 {
488 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; 488 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints;
489 collectDestinationInsertionPoints(element, insertionPoints); 489 collectDestinationInsertionPoints(element, insertionPoints);
490 SelectorCheckingContext nextContext(context); 490 SelectorCheckingContext nextContext(context);
491 nextContext.isSubSelector = false; 491 nextContext.isSubSelector = false;
492 nextContext.elementStyle = 0; 492 nextContext.inRightmostCompound = false;
493 for (const auto& insertionPoint : insertionPoints) { 493 for (const auto& insertionPoint : insertionPoints) {
494 nextContext.element = insertionPoint; 494 nextContext.element = insertionPoint;
495 // TODO(esprehn): Why does SharingRules have a special case? 495 // TODO(esprehn): Why does SharingRules have a special case?
496 if (m_mode == SharingRules) 496 if (m_mode == SharingRules)
497 nextContext.scope = insertionPoint->containingShadowRoot(); 497 nextContext.scope = insertionPoint->containingShadowRoot();
498 if (match(nextContext, result)) 498 if (match(nextContext, result))
499 return SelectorMatches; 499 return SelectorMatches;
500 } 500 }
501 return SelectorFailsLocally; 501 return SelectorFailsLocally;
502 } 502 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 if (n->isTextNode()) { 723 if (n->isTextNode()) {
724 Text* textNode = toText(n); 724 Text* textNode = toText(n);
725 if (!textNode->data().isEmpty()) { 725 if (!textNode->data().isEmpty()) {
726 result = false; 726 result = false;
727 break; 727 break;
728 } 728 }
729 } 729 }
730 } 730 }
731 if (m_mode == ResolvingStyle) { 731 if (m_mode == ResolvingStyle) {
732 element.setStyleAffectedByEmpty(); 732 element.setStyleAffectedByEmpty();
733 if (context.elementStyle) 733 if (context.inRightmostCompound)
734 context.elementStyle->setEmptyState(result); 734 context.elementStyle->setEmptyState(result);
735 else if (element.computedStyle() && (element.document().styleEng ine().usesSiblingRules() || element.computedStyle()->unique())) 735 else if (element.computedStyle() && (element.document().styleEng ine().usesSiblingRules() || element.computedStyle()->unique()))
736 element.mutableComputedStyle()->setEmptyState(result); 736 element.mutableComputedStyle()->setEmptyState(result);
737 } 737 }
738 return result; 738 return result;
739 } 739 }
740 case CSSSelector::PseudoFirstChild: 740 case CSSSelector::PseudoFirstChild:
741 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) { 741 if (ContainerNode* parent = element.parentElementOrDocumentFragment()) {
742 if (m_mode == ResolvingStyle) { 742 if (m_mode == ResolvingStyle) {
743 parent->setChildrenAffectedByFirstChildRules(); 743 parent->setChildrenAffectedByFirstChildRules();
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 break; 853 break;
854 case CSSSelector::PseudoAutofill: 854 case CSSSelector::PseudoAutofill:
855 return element.isFormControlElement() && toHTMLFormControlElement(elemen t).isAutofilled(); 855 return element.isFormControlElement() && toHTMLFormControlElement(elemen t).isAutofilled();
856 case CSSSelector::PseudoAnyLink: 856 case CSSSelector::PseudoAnyLink:
857 case CSSSelector::PseudoLink: 857 case CSSSelector::PseudoLink:
858 return element.isLink(); 858 return element.isLink();
859 case CSSSelector::PseudoVisited: 859 case CSSSelector::PseudoVisited:
860 return element.isLink() && context.visitedMatchType == VisitedMatchEnabl ed; 860 return element.isLink() && context.visitedMatchType == VisitedMatchEnabl ed;
861 case CSSSelector::PseudoDrag: 861 case CSSSelector::PseudoDrag:
862 if (m_mode == ResolvingStyle) { 862 if (m_mode == ResolvingStyle) {
863 if (context.elementStyle) 863 if (context.inRightmostCompound)
864 context.elementStyle->setAffectedByDrag(); 864 context.elementStyle->setAffectedByDrag();
865 else 865 else
866 element.setChildrenOrSiblingsAffectedByDrag(); 866 element.setChildrenOrSiblingsAffectedByDrag();
867 } 867 }
868 return element.layoutObject() && element.layoutObject()->isDragging(); 868 return element.layoutObject() && element.layoutObject()->isDragging();
869 case CSSSelector::PseudoFocus: 869 case CSSSelector::PseudoFocus:
870 if (m_mode == ResolvingStyle) { 870 if (m_mode == ResolvingStyle) {
871 if (context.elementStyle) 871 if (context.inRightmostCompound)
872 context.elementStyle->setAffectedByFocus(); 872 context.elementStyle->setAffectedByFocus();
873 else 873 else
874 element.setChildrenOrSiblingsAffectedByFocus(); 874 element.setChildrenOrSiblingsAffectedByFocus();
875 } 875 }
876 return matchesFocusPseudoClass(element); 876 return matchesFocusPseudoClass(element);
877 case CSSSelector::PseudoHover: 877 case CSSSelector::PseudoHover:
878 if (m_mode == ResolvingStyle) { 878 if (m_mode == ResolvingStyle) {
879 if (context.elementStyle) 879 if (context.inRightmostCompound)
880 context.elementStyle->setAffectedByHover(); 880 context.elementStyle->setAffectedByHover();
881 else 881 else
882 element.setChildrenOrSiblingsAffectedByHover(); 882 element.setChildrenOrSiblingsAffectedByHover();
883 } 883 }
884 if (!shouldMatchHoverOrActive(context)) 884 if (!shouldMatchHoverOrActive(context))
885 return false; 885 return false;
886 if (InspectorInstrumentation::forcePseudoState(&element, CSSSelector::Ps eudoHover)) 886 if (InspectorInstrumentation::forcePseudoState(&element, CSSSelector::Ps eudoHover))
887 return true; 887 return true;
888 return element.hovered(); 888 return element.hovered();
889 case CSSSelector::PseudoActive: 889 case CSSSelector::PseudoActive:
890 if (m_mode == ResolvingStyle) { 890 if (m_mode == ResolvingStyle) {
891 if (context.elementStyle) 891 if (context.inRightmostCompound)
892 context.elementStyle->setAffectedByActive(); 892 context.elementStyle->setAffectedByActive();
893 else 893 else
894 element.setChildrenOrSiblingsAffectedByActive(); 894 element.setChildrenOrSiblingsAffectedByActive();
895 } 895 }
896 if (!shouldMatchHoverOrActive(context)) 896 if (!shouldMatchHoverOrActive(context))
897 return false; 897 return false;
898 if (InspectorInstrumentation::forcePseudoState(&element, CSSSelector::Ps eudoActive)) 898 if (InspectorInstrumentation::forcePseudoState(&element, CSSSelector::Ps eudoActive))
899 return true; 899 return true;
900 return element.active(); 900 return element.active();
901 case CSSSelector::PseudoEnabled: 901 case CSSSelector::PseudoEnabled:
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 maxSpecificity = std::max(maxSpecificity, hostContext.selector-> specificity() + subResult.specificity); 1092 maxSpecificity = std::max(maxSpecificity, hostContext.selector-> specificity() + subResult.specificity);
1093 break; 1093 break;
1094 } 1094 }
1095 hostContext.scopeContainsLastMatchedElement = false; 1095 hostContext.scopeContainsLastMatchedElement = false;
1096 hostContext.treatShadowHostAsNormalScope = false; 1096 hostContext.treatShadowHostAsNormalScope = false;
1097 hostContext.scope = nullptr; 1097 hostContext.scope = nullptr;
1098 1098
1099 if (selector.pseudoType() == CSSSelector::PseudoHost) 1099 if (selector.pseudoType() == CSSSelector::PseudoHost)
1100 break; 1100 break;
1101 1101
1102 hostContext.elementStyle = 0; 1102 hostContext.inRightmostCompound = false;
1103 nextElement = ComposedTreeTraversal::parentElement(*nextElement); 1103 nextElement = ComposedTreeTraversal::parentElement(*nextElement);
1104 } while (nextElement); 1104 } while (nextElement);
1105 } 1105 }
1106 if (matched) { 1106 if (matched) {
1107 if (specificity) 1107 if (specificity)
1108 *specificity = maxSpecificity; 1108 *specificity = maxSpecificity;
1109 return true; 1109 return true;
1110 } 1110 }
1111 1111
1112 // FIXME: this was a fallthrough condition. 1112 // FIXME: this was a fallthrough condition.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 } 1198 }
1199 1199
1200 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) 1200 bool SelectorChecker::matchesFocusPseudoClass(const Element& element)
1201 { 1201 {
1202 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element ), CSSSelector::PseudoFocus)) 1202 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element ), CSSSelector::PseudoFocus))
1203 return true; 1203 return true;
1204 return element.focused() && isFrameFocused(element); 1204 return element.focused() && isFrameFocused(element);
1205 } 1205 }
1206 1206
1207 } 1207 }
OLDNEW
« no previous file with comments | « Source/core/css/SelectorChecker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698