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

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

Issue 1108993006: Make SelectorChecker::tagMatches internal to the SelectorChecker (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/SelectorChecker.h ('k') | Source/core/dom/SelectorQuery.cpp » ('j') | 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 static bool matchesSpatialNavigationFocusPseudoClass(const Element& element) 87 static bool matchesSpatialNavigationFocusPseudoClass(const Element& element)
88 { 88 {
89 return isHTMLOptionElement(element) && toHTMLOptionElement(element).spatialN avigationFocused() && isFrameFocused(element); 89 return isHTMLOptionElement(element) && toHTMLOptionElement(element).spatialN avigationFocused() && isFrameFocused(element);
90 } 90 }
91 91
92 static bool matchesListBoxPseudoClass(const Element& element) 92 static bool matchesListBoxPseudoClass(const Element& element)
93 { 93 {
94 return isHTMLSelectElement(element) && !toHTMLSelectElement(element).usesMen uList(); 94 return isHTMLSelectElement(element) && !toHTMLSelectElement(element).usesMen uList();
95 } 95 }
96 96
97 static bool matchesTagName(const Element& element, const QualifiedName& tagQName )
98 {
99 if (tagQName == anyQName())
100 return true;
101 const AtomicString& localName = tagQName.localName();
102 if (localName != starAtom && localName != element.localName())
103 return false;
104 const AtomicString& namespaceURI = tagQName.namespaceURI();
105 return namespaceURI == starAtom || namespaceURI == element.namespaceURI();
106 }
107
97 static Element* parentElement(const SelectorChecker::SelectorCheckingContext& co ntext) 108 static Element* parentElement(const SelectorChecker::SelectorCheckingContext& co ntext)
98 { 109 {
99 // - If context.scope is a shadow root, we should walk up to its shadow host . 110 // - If context.scope is a shadow root, we should walk up to its shadow host .
100 // - If context.scope is some element in some shadow tree and querySelector initialized the context, 111 // - If context.scope is some element in some shadow tree and querySelector initialized the context,
101 // e.g. shadowRoot.querySelector(':host *'), 112 // e.g. shadowRoot.querySelector(':host *'),
102 // (a) context.element has the same treescope as context.scope, need to wa lk up to its shadow host. 113 // (a) context.element has the same treescope as context.scope, need to wa lk up to its shadow host.
103 // (b) Otherwise, should not walk up from a shadow root to a shadow host. 114 // (b) Otherwise, should not walk up from a shadow root to a shadow host.
104 if (context.scope && (context.scope == context.element->containingShadowRoot () || context.scope->treeScope() == context.element->treeScope())) 115 if (context.scope && (context.scope == context.element->containingShadowRoot () || context.scope->treeScope() == context.element->treeScope()))
105 return context.element->parentOrShadowHostElement(); 116 return context.element->parentOrShadowHostElement();
106 return context.element->parentElement(); 117 return context.element->parentElement();
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 const CSSSelector& selector = *context.selector; 567 const CSSSelector& selector = *context.selector;
557 568
558 // Only :host and :host-context() should match the host: http://drafts.csswg .org/css-scoping/#host-element 569 // Only :host and :host-context() should match the host: http://drafts.csswg .org/css-scoping/#host-element
559 if (context.scope && context.scope->shadowHost() == element && (!selector.is HostPseudoClass() 570 if (context.scope && context.scope->shadowHost() == element && (!selector.is HostPseudoClass()
560 && !context.treatShadowHostAsNormalScope 571 && !context.treatShadowHostAsNormalScope
561 && selector.match() != CSSSelector::PseudoElement)) 572 && selector.match() != CSSSelector::PseudoElement))
562 return false; 573 return false;
563 574
564 switch (selector.match()) { 575 switch (selector.match()) {
565 case CSSSelector::Tag: 576 case CSSSelector::Tag:
566 return SelectorChecker::tagMatches(element, selector.tagQName()); 577 return matchesTagName(element, selector.tagQName());
567 case CSSSelector::Class: 578 case CSSSelector::Class:
568 return element.hasClass() && element.classNames().contains(selector.valu e()); 579 return element.hasClass() && element.classNames().contains(selector.valu e());
569 case CSSSelector::Id: 580 case CSSSelector::Id:
570 return element.hasID() && element.idForStyleResolution() == selector.val ue(); 581 return element.hasID() && element.idForStyleResolution() == selector.val ue();
571 582
572 // Attribute selectors 583 // Attribute selectors
573 case CSSSelector::AttributeExact: 584 case CSSSelector::AttributeExact:
574 case CSSSelector::AttributeSet: 585 case CSSSelector::AttributeSet:
575 case CSSSelector::AttributeHyphen: 586 case CSSSelector::AttributeHyphen:
576 case CSSSelector::AttributeList: 587 case CSSSelector::AttributeList:
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 && &element == element.treeScope().adjustedFocusedElement(); 1144 && &element == element.treeScope().adjustedFocusedElement();
1134 } 1145 }
1135 1146
1136 template 1147 template
1137 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const; 1148 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const;
1138 1149
1139 template 1150 template
1140 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; 1151 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const;
1141 1152
1142 } 1153 }
OLDNEW
« no previous file with comments | « Source/core/css/SelectorChecker.h ('k') | Source/core/dom/SelectorQuery.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698