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

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

Issue 53683007: Have SelectorQuery API take rootNode by reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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/ElementRuleCollector.cpp ('k') | Source/core/css/SelectorChecker.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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 template<typename SiblingTraversalStrategy> 96 template<typename SiblingTraversalStrategy>
97 Match matchForShadowDistributed(const Element*, const SiblingTraversalStrate gy&, PseudoId&, SelectorCheckingContext& nextContext) const; 97 Match matchForShadowDistributed(const Element*, const SiblingTraversalStrate gy&, PseudoId&, SelectorCheckingContext& nextContext) const;
98 98
99 template<typename SiblingTraversalStrategy> 99 template<typename SiblingTraversalStrategy>
100 bool checkOne(const SelectorCheckingContext&, const SiblingTraversalStrategy &) const; 100 bool checkOne(const SelectorCheckingContext&, const SiblingTraversalStrategy &) const;
101 101
102 bool strictParsing() const { return m_strictParsing; } 102 bool strictParsing() const { return m_strictParsing; }
103 103
104 Mode mode() const { return m_mode; } 104 Mode mode() const { return m_mode; }
105 105
106 static bool tagMatches(const Element*, const QualifiedName&, MatchingTagType = MatchingElement); 106 static bool tagMatches(const Element&, const QualifiedName&, MatchingTagType = MatchingElement);
107 static bool isCommonPseudoClassSelector(const CSSSelector*); 107 static bool isCommonPseudoClassSelector(const CSSSelector*);
108 static bool matchesFocusPseudoClass(const Element*); 108 static bool matchesFocusPseudoClass(const Element&);
109 static bool checkExactAttribute(const Element*, const QualifiedName& selecto rAttributeName, const StringImpl* value); 109 static bool checkExactAttribute(const Element&, const QualifiedName& selecto rAttributeName, const StringImpl* value);
110 110
111 enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink | MatchVisited }; 111 enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink | MatchVisited };
112 static unsigned determineLinkMatchType(const CSSSelector*); 112 static unsigned determineLinkMatchType(const CSSSelector*);
113 113
114 static bool isHostInItsShadowTree(const Element*, BehaviorAtBoundary, const ContainerNode* scope); 114 static bool isHostInItsShadowTree(const Element&, BehaviorAtBoundary, const ContainerNode* scope);
115 115
116 private: 116 private:
117 bool checkScrollbarPseudoClass(const SelectorCheckingContext&, Document*, co nst CSSSelector*) const; 117 bool checkScrollbarPseudoClass(const SelectorCheckingContext&, Document*, co nst CSSSelector*) const;
118 Element* parentElement(const SelectorCheckingContext&) const; 118 Element* parentElement(const SelectorCheckingContext&) const;
119 bool scopeContainsLastMatchedElement(const SelectorCheckingContext&) const; 119 bool scopeContainsLastMatchedElement(const SelectorCheckingContext&) const;
120 120
121 static bool isFrameFocused(const Element*); 121 static bool isFrameFocused(const Element&);
122 122
123 bool m_strictParsing; 123 bool m_strictParsing;
124 bool m_documentIsHTML; 124 bool m_documentIsHTML;
125 Mode m_mode; 125 Mode m_mode;
126 }; 126 };
127 127
128 inline bool SelectorChecker::isCommonPseudoClassSelector(const CSSSelector* sele ctor) 128 inline bool SelectorChecker::isCommonPseudoClassSelector(const CSSSelector* sele ctor)
129 { 129 {
130 if (selector->m_match != CSSSelector::PseudoClass) 130 if (selector->m_match != CSSSelector::PseudoClass)
131 return false; 131 return false;
132 CSSSelector::PseudoType pseudoType = selector->pseudoType(); 132 CSSSelector::PseudoType pseudoType = selector->pseudoType();
133 return pseudoType == CSSSelector::PseudoLink 133 return pseudoType == CSSSelector::PseudoLink
134 || pseudoType == CSSSelector::PseudoAnyLink 134 || pseudoType == CSSSelector::PseudoAnyLink
135 || pseudoType == CSSSelector::PseudoVisited 135 || pseudoType == CSSSelector::PseudoVisited
136 || pseudoType == CSSSelector::PseudoFocus; 136 || pseudoType == CSSSelector::PseudoFocus;
137 } 137 }
138 138
139 inline bool SelectorChecker::tagMatches(const Element* element, const QualifiedN ame& tagQName, MatchingTagType matchingTagType) 139 inline bool SelectorChecker::tagMatches(const Element& element, const QualifiedN ame& tagQName, MatchingTagType matchingTagType)
140 { 140 {
141 if (tagQName == anyQName()) 141 if (tagQName == anyQName())
142 return true; 142 return true;
143 const AtomicString& localName = tagQName.localName(); 143 const AtomicString& localName = tagQName.localName();
144 if (localName != starAtom && (localName != element->localName() || matchingT agType == MatchingHostInItsShadowTree)) 144 if (localName != starAtom && (localName != element.localName() || matchingTa gType == MatchingHostInItsShadowTree))
145 return false; 145 return false;
146 const AtomicString& namespaceURI = tagQName.namespaceURI(); 146 const AtomicString& namespaceURI = tagQName.namespaceURI();
147 return namespaceURI == starAtom || namespaceURI == element->namespaceURI(); 147 return namespaceURI == starAtom || namespaceURI == element.namespaceURI();
148 } 148 }
149 149
150 inline bool SelectorChecker::checkExactAttribute(const Element* element, const Q ualifiedName& selectorAttributeName, const StringImpl* value) 150 inline bool SelectorChecker::checkExactAttribute(const Element& element, const Q ualifiedName& selectorAttributeName, const StringImpl* value)
151 { 151 {
152 if (!element->hasAttributesWithoutUpdate()) 152 if (!element.hasAttributesWithoutUpdate())
153 return false; 153 return false;
154 unsigned size = element->attributeCount(); 154 unsigned size = element.attributeCount();
155 for (unsigned i = 0; i < size; ++i) { 155 for (unsigned i = 0; i < size; ++i) {
156 const Attribute* attribute = element->attributeItem(i); 156 const Attribute* attribute = element.attributeItem(i);
157 if (attribute->matches(selectorAttributeName) && (!value || attribute->v alue().impl() == value)) 157 if (attribute->matches(selectorAttributeName) && (!value || attribute->v alue().impl() == value))
158 return true; 158 return true;
159 } 159 }
160 return false; 160 return false;
161 } 161 }
162 162
163 inline bool SelectorChecker::isHostInItsShadowTree(const Element* element, Behav iorAtBoundary behaviorAtBoundary, const ContainerNode* scope) 163 inline bool SelectorChecker::isHostInItsShadowTree(const Element& element, Behav iorAtBoundary behaviorAtBoundary, const ContainerNode* scope)
164 { 164 {
165 return (behaviorAtBoundary & ScopeIsShadowHost) && scope == element; 165 return (behaviorAtBoundary & ScopeIsShadowHost) && scope == element;
166 } 166 }
167 167
168 } 168 }
169 169
170 #endif 170 #endif
OLDNEW
« no previous file with comments | « Source/core/css/ElementRuleCollector.cpp ('k') | Source/core/css/SelectorChecker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698