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

Side by Side Diff: Source/core/dom/SelectorQuery.cpp

Issue 138743008: Make sure the root node of selector queries is a ContainerNode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 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
« no previous file with comments | « Source/core/dom/SelectorQuery.h ('k') | Source/core/inspector/InspectorDOMAgent.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) 2011, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 { 56 {
57 output.append(RefPtr<Node>(element)); 57 output.append(RefPtr<Node>(element));
58 } 58 }
59 }; 59 };
60 60
61 enum ClassElementListBehavior { AllElements, OnlyRoots }; 61 enum ClassElementListBehavior { AllElements, OnlyRoots };
62 62
63 template <ClassElementListBehavior onlyRoots> 63 template <ClassElementListBehavior onlyRoots>
64 class ClassElementList { 64 class ClassElementList {
65 public: 65 public:
66 ClassElementList(Node& rootNode, const AtomicString& className) 66 ClassElementList(ContainerNode& rootNode, const AtomicString& className)
67 : m_className(className) 67 : m_className(className)
68 , m_rootNode(rootNode) 68 , m_rootNode(rootNode)
69 , m_currentElement(nextInternal(ElementTraversal::firstWithin(rootNode)) ) { } 69 , m_currentElement(nextInternal(ElementTraversal::firstWithin(rootNode)) ) { }
70 70
71 bool isEmpty() const { return !m_currentElement; } 71 bool isEmpty() const { return !m_currentElement; }
72 72
73 Node* next() 73 Node* next()
74 { 74 {
75 Node* current = m_currentElement; 75 Node* current = m_currentElement;
76 ASSERT(current); 76 ASSERT(current);
77 if (onlyRoots) 77 if (onlyRoots)
78 m_currentElement = nextInternal(ElementTraversal::nextSkippingChildr en(*m_currentElement, &m_rootNode)); 78 m_currentElement = nextInternal(ElementTraversal::nextSkippingChildr en(*m_currentElement, &m_rootNode));
79 else 79 else
80 m_currentElement = nextInternal(ElementTraversal::next(*m_currentEle ment, &m_rootNode)); 80 m_currentElement = nextInternal(ElementTraversal::next(*m_currentEle ment, &m_rootNode));
81 return current; 81 return current;
82 } 82 }
83 83
84 private: 84 private:
85 Element* nextInternal(Element* element) 85 Element* nextInternal(Element* element)
86 { 86 {
87 for (; element; element = ElementTraversal::next(*element, &m_rootNode)) { 87 for (; element; element = ElementTraversal::next(*element, &m_rootNode)) {
88 if (element->hasClass() && element->classNames().contains(m_classNam e)) 88 if (element->hasClass() && element->classNames().contains(m_classNam e))
89 return element; 89 return element;
90 } 90 }
91 return 0; 91 return 0;
92 } 92 }
93 93
94 const AtomicString& m_className; 94 const AtomicString& m_className;
95 Node& m_rootNode; 95 ContainerNode& m_rootNode;
96 Element* m_currentElement; 96 Element* m_currentElement;
97 }; 97 };
98 98
99 void SelectorDataList::initialize(const CSSSelectorList& selectorList) 99 void SelectorDataList::initialize(const CSSSelectorList& selectorList)
100 { 100 {
101 ASSERT(m_selectors.isEmpty()); 101 ASSERT(m_selectors.isEmpty());
102 102
103 unsigned selectorCount = 0; 103 unsigned selectorCount = 0;
104 for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector)) 104 for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector))
105 selectorCount++; 105 selectorCount++;
106 106
107 m_selectors.reserveInitialCapacity(selectorCount); 107 m_selectors.reserveInitialCapacity(selectorCount);
108 for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector)) 108 for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector))
109 m_selectors.uncheckedAppend(SelectorData(selector, SelectorCheckerFastPa th::canUse(selector))); 109 m_selectors.uncheckedAppend(SelectorData(selector, SelectorCheckerFastPa th::canUse(selector)));
110 } 110 }
111 111
112 inline bool SelectorDataList::selectorMatches(const SelectorData& selectorData, Element& element, const Node& rootNode) const 112 inline bool SelectorDataList::selectorMatches(const SelectorData& selectorData, Element& element, const ContainerNode& rootNode) const
113 { 113 {
114 if (selectorData.isFastCheckable && !element.isSVGElement()) { 114 if (selectorData.isFastCheckable && !element.isSVGElement()) {
115 SelectorCheckerFastPath selectorCheckerFastPath(selectorData.selector, e lement); 115 SelectorCheckerFastPath selectorCheckerFastPath(selectorData.selector, e lement);
116 if (!selectorCheckerFastPath.matchesRightmostSelector(SelectorChecker::V isitedMatchDisabled)) 116 if (!selectorCheckerFastPath.matchesRightmostSelector(SelectorChecker::V isitedMatchDisabled))
117 return false; 117 return false;
118 return selectorCheckerFastPath.matches(); 118 return selectorCheckerFastPath.matches();
119 } 119 }
120 120
121 SelectorChecker selectorChecker(element.document(), SelectorChecker::Queryin gRules); 121 SelectorChecker selectorChecker(element.document(), SelectorChecker::Queryin gRules);
122 SelectorChecker::SelectorCheckingContext selectorCheckingContext(selectorDat a.selector, &element, SelectorChecker::VisitedMatchDisabled); 122 SelectorChecker::SelectorCheckingContext selectorCheckingContext(selectorDat a.selector, &element, SelectorChecker::VisitedMatchDisabled);
123 selectorCheckingContext.behaviorAtBoundary = SelectorChecker::StaysWithinTre eScope; 123 selectorCheckingContext.behaviorAtBoundary = SelectorChecker::StaysWithinTre eScope;
124 selectorCheckingContext.scope = !rootNode.isDocumentNode() && rootNode.isCon tainerNode() ? &toContainerNode(rootNode) : 0; 124 selectorCheckingContext.scope = !rootNode.isDocumentNode() ? &rootNode : 0;
125 return selectorChecker.match(selectorCheckingContext, DOMSiblingTraversalStr ategy()) == SelectorChecker::SelectorMatches; 125 return selectorChecker.match(selectorCheckingContext, DOMSiblingTraversalStr ategy()) == SelectorChecker::SelectorMatches;
126 } 126 }
127 127
128 bool SelectorDataList::matches(Element& targetElement) const 128 bool SelectorDataList::matches(Element& targetElement) const
129 { 129 {
130 unsigned selectorCount = m_selectors.size(); 130 unsigned selectorCount = m_selectors.size();
131 for (unsigned i = 0; i < selectorCount; ++i) { 131 for (unsigned i = 0; i < selectorCount; ++i) {
132 if (selectorMatches(m_selectors[i], targetElement, targetElement)) 132 if (selectorMatches(m_selectors[i], targetElement, targetElement))
133 return true; 133 return true;
134 } 134 }
135 135
136 return false; 136 return false;
137 } 137 }
138 138
139 PassRefPtr<NodeList> SelectorDataList::queryAll(Node& rootNode) const 139 PassRefPtr<NodeList> SelectorDataList::queryAll(ContainerNode& rootNode) const
140 { 140 {
141 Vector<RefPtr<Node> > result; 141 Vector<RefPtr<Node> > result;
142 execute<AllElementsSelectorQueryTrait>(rootNode, result); 142 execute<AllElementsSelectorQueryTrait>(rootNode, result);
143 return StaticNodeList::adopt(result); 143 return StaticNodeList::adopt(result);
144 } 144 }
145 145
146 PassRefPtr<Element> SelectorDataList::queryFirst(Node& rootNode) const 146 PassRefPtr<Element> SelectorDataList::queryFirst(ContainerNode& rootNode) const
147 { 147 {
148 Element* matchedElement = 0; 148 Element* matchedElement = 0;
149 execute<SingleElementSelectorQueryTrait>(rootNode, matchedElement); 149 execute<SingleElementSelectorQueryTrait>(rootNode, matchedElement);
150 return matchedElement; 150 return matchedElement;
151 } 151 }
152 152
153 template <typename SelectorQueryTrait> 153 template <typename SelectorQueryTrait>
154 void SelectorDataList::collectElementsByClassName(Node& rootNode, const AtomicSt ring& className, typename SelectorQueryTrait::OutputType& output) const 154 void SelectorDataList::collectElementsByClassName(ContainerNode& rootNode, const AtomicString& className, typename SelectorQueryTrait::OutputType& output) cons t
155 { 155 {
156 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el ement = ElementTraversal::next(*element, &rootNode)) { 156 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el ement = ElementTraversal::next(*element, &rootNode)) {
157 if (element->hasClass() && element->classNames().contains(className)) { 157 if (element->hasClass() && element->classNames().contains(className)) {
158 SelectorQueryTrait::appendElement(output, *element); 158 SelectorQueryTrait::appendElement(output, *element);
159 if (SelectorQueryTrait::shouldOnlyMatchFirstElement) 159 if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
160 return; 160 return;
161 } 161 }
162 } 162 }
163 } 163 }
164 164
165 template <typename SelectorQueryTrait> 165 template <typename SelectorQueryTrait>
166 void SelectorDataList::collectElementsByTagName(Node& rootNode, const QualifiedN ame& tagName, typename SelectorQueryTrait::OutputType& output) const 166 void SelectorDataList::collectElementsByTagName(ContainerNode& rootNode, const Q ualifiedName& tagName, typename SelectorQueryTrait::OutputType& output) const
167 { 167 {
168 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el ement = ElementTraversal::next(*element, &rootNode)) { 168 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el ement = ElementTraversal::next(*element, &rootNode)) {
169 if (SelectorChecker::tagMatches(*element, tagName)) { 169 if (SelectorChecker::tagMatches(*element, tagName)) {
170 SelectorQueryTrait::appendElement(output, *element); 170 SelectorQueryTrait::appendElement(output, *element);
171 if (SelectorQueryTrait::shouldOnlyMatchFirstElement) 171 if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
172 return; 172 return;
173 } 173 }
174 } 174 }
175 } 175 }
176 176
177 inline bool SelectorDataList::canUseFastQuery(const Node& rootNode) const 177 inline bool SelectorDataList::canUseFastQuery(const ContainerNode& rootNode) con st
178 { 178 {
179 return m_selectors.size() == 1 && rootNode.inDocument() && !rootNode.documen t().inQuirksMode(); 179 return m_selectors.size() == 1 && rootNode.inDocument() && !rootNode.documen t().inQuirksMode();
180 } 180 }
181 181
182 inline bool ancestorHasClassName(Node& rootNode, const AtomicString& className) 182 inline bool ancestorHasClassName(ContainerNode& rootNode, const AtomicString& cl assName)
183 { 183 {
184 if (!rootNode.isElementNode()) 184 if (!rootNode.isElementNode())
185 return false; 185 return false;
186 186
187 for (Element* element = &toElement(rootNode); element; element = element->pa rentElement()) { 187 for (Element* element = &toElement(rootNode); element; element = element->pa rentElement()) {
188 if (element->hasClass() && element->classNames().contains(className)) 188 if (element->hasClass() && element->classNames().contains(className))
189 return true; 189 return true;
190 } 190 }
191 return false; 191 return false;
192 } 192 }
193 193
194 194
195 // If returns true, traversalRoots has the elements that may match the selector query. 195 // If returns true, traversalRoots has the elements that may match the selector query.
196 // 196 //
197 // If returns false, traversalRoots has the rootNode parameter or descendants of rootNode representing 197 // If returns false, traversalRoots has the rootNode parameter or descendants of rootNode representing
198 // the subtree for which we can limit the querySelector traversal. 198 // the subtree for which we can limit the querySelector traversal.
199 // 199 //
200 // The travseralRoots may be empty, regardless of the returned bool value, if th is method finds that the selectors won't 200 // The travseralRoots may be empty, regardless of the returned bool value, if th is method finds that the selectors won't
201 // match any element. 201 // match any element.
202 template <typename SelectorQueryTrait> 202 template <typename SelectorQueryTrait>
203 void SelectorDataList::findTraverseRootsAndExecute(Node& rootNode, typename Sele ctorQueryTrait::OutputType& output) const 203 void SelectorDataList::findTraverseRootsAndExecute(ContainerNode& rootNode, type name SelectorQueryTrait::OutputType& output) const
204 { 204 {
205 // We need to return the matches in document order. To use id lookup while t here is possiblity of multiple matches 205 // We need to return the matches in document order. To use id lookup while t here is possiblity of multiple matches
206 // we would need to sort the results. For now, just traverse the document in that case. 206 // we would need to sort the results. For now, just traverse the document in that case.
207 ASSERT(m_selectors.size() == 1); 207 ASSERT(m_selectors.size() == 1);
208 ASSERT(m_selectors[0].selector); 208 ASSERT(m_selectors[0].selector);
209 209
210 bool isRightmostSelector = true; 210 bool isRightmostSelector = true;
211 bool startFromParent = false; 211 bool startFromParent = false;
212 212
213 for (const CSSSelector* selector = m_selectors[0].selector; selector; select or = selector->tagHistory()) { 213 for (const CSSSelector* selector = m_selectors[0].selector; selector; select or = selector->tagHistory()) {
214 if (selector->m_match == CSSSelector::Id && !rootNode.document().contain sMultipleElementsWithId(selector->value())) { 214 if (selector->m_match == CSSSelector::Id && !rootNode.document().contain sMultipleElementsWithId(selector->value())) {
215 Element* element = rootNode.treeScope().getElementById(selector->val ue()); 215 Element* element = rootNode.treeScope().getElementById(selector->val ue());
216 Node* adjustedNode = &rootNode; 216 ContainerNode* adjustedNode = &rootNode;
217 if (element && (isTreeScopeRoot(rootNode) || element->isDescendantOf (&rootNode))) 217 if (element && (isTreeScopeRoot(rootNode) || element->isDescendantOf (&rootNode)))
218 adjustedNode = element; 218 adjustedNode = element;
219 else if (!element || isRightmostSelector) 219 else if (!element || isRightmostSelector)
220 adjustedNode = 0; 220 adjustedNode = 0;
221 if (isRightmostSelector) { 221 if (isRightmostSelector) {
222 executeForTraverseRoot<SelectorQueryTrait>(m_selectors[0], adjus tedNode, MatchesTraverseRoots, rootNode, output); 222 executeForTraverseRoot<SelectorQueryTrait>(m_selectors[0], adjus tedNode, MatchesTraverseRoots, rootNode, output);
223 return; 223 return;
224 } 224 }
225 225
226 if (startFromParent && adjustedNode) 226 if (startFromParent && adjustedNode)
(...skipping 28 matching lines...) Expand all
255 if (selector->relation() == CSSSelector::DirectAdjacent || selector->rel ation() == CSSSelector::IndirectAdjacent) 255 if (selector->relation() == CSSSelector::DirectAdjacent || selector->rel ation() == CSSSelector::IndirectAdjacent)
256 startFromParent = true; 256 startFromParent = true;
257 else 257 else
258 startFromParent = false; 258 startFromParent = false;
259 } 259 }
260 260
261 executeForTraverseRoot<SelectorQueryTrait>(m_selectors[0], &rootNode, DoesNo tMatchTraverseRoots, rootNode, output); 261 executeForTraverseRoot<SelectorQueryTrait>(m_selectors[0], &rootNode, DoesNo tMatchTraverseRoots, rootNode, output);
262 } 262 }
263 263
264 template <typename SelectorQueryTrait> 264 template <typename SelectorQueryTrait>
265 void SelectorDataList::executeForTraverseRoot(const SelectorData& selector, Node * traverseRoot, MatchTraverseRootState matchTraverseRoot, Node& rootNode, typena me SelectorQueryTrait::OutputType& output) const 265 void SelectorDataList::executeForTraverseRoot(const SelectorData& selector, Node * traverseRoot, MatchTraverseRootState matchTraverseRoot, ContainerNode& rootNod e, typename SelectorQueryTrait::OutputType& output) const
266 { 266 {
267 if (!traverseRoot) 267 if (!traverseRoot)
268 return; 268 return;
269 269
270 if (matchTraverseRoot) { 270 if (matchTraverseRoot) {
271 if (selectorMatches(selector, toElement(*traverseRoot), rootNode)) 271 if (selectorMatches(selector, toElement(*traverseRoot), rootNode))
272 SelectorQueryTrait::appendElement(output, toElement(*traverseRoot)); 272 SelectorQueryTrait::appendElement(output, toElement(*traverseRoot));
273 return; 273 return;
274 } 274 }
275 275
276 for (Element* element = ElementTraversal::firstWithin(*traverseRoot); elemen t; element = ElementTraversal::next(*element, traverseRoot)) { 276 for (Element* element = ElementTraversal::firstWithin(*traverseRoot); elemen t; element = ElementTraversal::next(*element, traverseRoot)) {
277 if (selectorMatches(selector, *element, rootNode)) { 277 if (selectorMatches(selector, *element, rootNode)) {
278 SelectorQueryTrait::appendElement(output, *element); 278 SelectorQueryTrait::appendElement(output, *element);
279 if (SelectorQueryTrait::shouldOnlyMatchFirstElement) 279 if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
280 return; 280 return;
281 } 281 }
282 } 282 }
283 } 283 }
284 284
285 template <typename SelectorQueryTrait, typename SimpleNodeListType> 285 template <typename SelectorQueryTrait, typename SimpleNodeListType>
286 void SelectorDataList::executeForTraverseRoots(const SelectorData& selector, Sim pleNodeListType& traverseRoots, MatchTraverseRootState matchTraverseRoots, Node& rootNode, typename SelectorQueryTrait::OutputType& output) const 286 void SelectorDataList::executeForTraverseRoots(const SelectorData& selector, Sim pleNodeListType& traverseRoots, MatchTraverseRootState matchTraverseRoots, Conta inerNode& rootNode, typename SelectorQueryTrait::OutputType& output) const
287 { 287 {
288 if (traverseRoots.isEmpty()) 288 if (traverseRoots.isEmpty())
289 return; 289 return;
290 290
291 if (matchTraverseRoots) { 291 if (matchTraverseRoots) {
292 while (!traverseRoots.isEmpty()) { 292 while (!traverseRoots.isEmpty()) {
293 Node& node = *traverseRoots.next(); 293 Node& node = *traverseRoots.next();
294 Element& element = toElement(node); 294 Element& element = toElement(node);
295 if (selectorMatches(selector, element, rootNode)) { 295 if (selectorMatches(selector, element, rootNode)) {
296 SelectorQueryTrait::appendElement(output, element); 296 SelectorQueryTrait::appendElement(output, element);
(...skipping 11 matching lines...) Expand all
308 if (selectorMatches(selector, *element, rootNode)) { 308 if (selectorMatches(selector, *element, rootNode)) {
309 SelectorQueryTrait::appendElement(output, *element); 309 SelectorQueryTrait::appendElement(output, *element);
310 if (SelectorQueryTrait::shouldOnlyMatchFirstElement) 310 if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
311 return; 311 return;
312 } 312 }
313 } 313 }
314 } 314 }
315 } 315 }
316 316
317 template <typename SelectorQueryTrait> 317 template <typename SelectorQueryTrait>
318 void SelectorDataList::executeSlow(Node& rootNode, typename SelectorQueryTrait:: OutputType& output) const 318 void SelectorDataList::executeSlow(ContainerNode& rootNode, typename SelectorQue ryTrait::OutputType& output) const
319 { 319 {
320 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el ement = ElementTraversal::next(*element, &rootNode)) { 320 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el ement = ElementTraversal::next(*element, &rootNode)) {
321 for (unsigned i = 0; i < m_selectors.size(); ++i) { 321 for (unsigned i = 0; i < m_selectors.size(); ++i) {
322 if (selectorMatches(m_selectors[i], *element, rootNode)) { 322 if (selectorMatches(m_selectors[i], *element, rootNode)) {
323 SelectorQueryTrait::appendElement(output, *element); 323 SelectorQueryTrait::appendElement(output, *element);
324 if (SelectorQueryTrait::shouldOnlyMatchFirstElement) 324 if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
325 return; 325 return;
326 break; 326 break;
327 } 327 }
328 } 328 }
329 } 329 }
330 } 330 }
331 331
332 const CSSSelector* SelectorDataList::selectorForIdLookup(const CSSSelector* firs tSelector) const 332 const CSSSelector* SelectorDataList::selectorForIdLookup(const CSSSelector* firs tSelector) const
333 { 333 {
334 for (const CSSSelector* selector = firstSelector; selector; selector = selec tor->tagHistory()) { 334 for (const CSSSelector* selector = firstSelector; selector; selector = selec tor->tagHistory()) {
335 if (selector->m_match == CSSSelector::Id) 335 if (selector->m_match == CSSSelector::Id)
336 return selector; 336 return selector;
337 if (selector->relation() != CSSSelector::SubSelector) 337 if (selector->relation() != CSSSelector::SubSelector)
338 break; 338 break;
339 } 339 }
340 return 0; 340 return 0;
341 } 341 }
342 342
343 template <typename SelectorQueryTrait> 343 template <typename SelectorQueryTrait>
344 void SelectorDataList::execute(Node& rootNode, typename SelectorQueryTrait::Outp utType& output) const 344 void SelectorDataList::execute(ContainerNode& rootNode, typename SelectorQueryTr ait::OutputType& output) const
345 { 345 {
346 if (!canUseFastQuery(rootNode)) { 346 if (!canUseFastQuery(rootNode)) {
347 executeSlow<SelectorQueryTrait>(rootNode, output); 347 executeSlow<SelectorQueryTrait>(rootNode, output);
348 return; 348 return;
349 } 349 }
350 350
351 ASSERT(m_selectors.size() == 1); 351 ASSERT(m_selectors.size() == 1);
352 ASSERT(m_selectors[0].selector); 352 ASSERT(m_selectors[0].selector);
353 353
354 const SelectorData& selector = m_selectors[0]; 354 const SelectorData& selector = m_selectors[0];
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 : m_selectorList(selectorList) 401 : m_selectorList(selectorList)
402 { 402 {
403 m_selectors.initialize(m_selectorList); 403 m_selectors.initialize(m_selectorList);
404 } 404 }
405 405
406 bool SelectorQuery::matches(Element& element) const 406 bool SelectorQuery::matches(Element& element) const
407 { 407 {
408 return m_selectors.matches(element); 408 return m_selectors.matches(element);
409 } 409 }
410 410
411 PassRefPtr<NodeList> SelectorQuery::queryAll(Node& rootNode) const 411 PassRefPtr<NodeList> SelectorQuery::queryAll(ContainerNode& rootNode) const
412 { 412 {
413 return m_selectors.queryAll(rootNode); 413 return m_selectors.queryAll(rootNode);
414 } 414 }
415 415
416 PassRefPtr<Element> SelectorQuery::queryFirst(Node& rootNode) const 416 PassRefPtr<Element> SelectorQuery::queryFirst(ContainerNode& rootNode) const
417 { 417 {
418 return m_selectors.queryFirst(rootNode); 418 return m_selectors.queryFirst(rootNode);
419 } 419 }
420 420
421 SelectorQuery* SelectorQueryCache::add(const AtomicString& selectors, const Docu ment& document, ExceptionState& exceptionState) 421 SelectorQuery* SelectorQueryCache::add(const AtomicString& selectors, const Docu ment& document, ExceptionState& exceptionState)
422 { 422 {
423 HashMap<AtomicString, OwnPtr<SelectorQuery> >::iterator it = m_entries.find( selectors); 423 HashMap<AtomicString, OwnPtr<SelectorQuery> >::iterator it = m_entries.find( selectors);
424 if (it != m_entries.end()) 424 if (it != m_entries.end())
425 return it->value.get(); 425 return it->value.get();
426 426
(...skipping 21 matching lines...) Expand all
448 m_entries.add(selectors, selectorQuery.release()); 448 m_entries.add(selectors, selectorQuery.release());
449 return rawSelectorQuery; 449 return rawSelectorQuery;
450 } 450 }
451 451
452 void SelectorQueryCache::invalidate() 452 void SelectorQueryCache::invalidate()
453 { 453 {
454 m_entries.clear(); 454 m_entries.clear();
455 } 455 }
456 456
457 } 457 }
OLDNEW
« no previous file with comments | « Source/core/dom/SelectorQuery.h ('k') | Source/core/inspector/InspectorDOMAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698