OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 m_currentNode = 0; | 57 m_currentNode = 0; |
58 return current; | 58 return current; |
59 } | 59 } |
60 | 60 |
61 private: | 61 private: |
62 Node* m_currentNode; | 62 Node* m_currentNode; |
63 }; | 63 }; |
64 | 64 |
65 class ClassRootNodeList : public SimpleNodeList { | 65 class ClassRootNodeList : public SimpleNodeList { |
66 public: | 66 public: |
67 ClassRootNodeList(Node* rootNode, const AtomicString& className) | 67 ClassRootNodeList(Node& rootNode, const AtomicString& className) |
68 : m_className(className) | 68 : m_className(className) |
69 , m_rootNode(rootNode) | 69 , m_rootNode(rootNode) |
70 , m_currentElement(nextInternal(ElementTraversal::firstWithin(m_rootNode
))) { } | 70 , m_currentElement(nextInternal(ElementTraversal::firstWithin(m_rootNode
))) { } |
71 | 71 |
72 bool isEmpty() const { return !m_currentElement; } | 72 bool isEmpty() const { return !m_currentElement; } |
73 | 73 |
74 Node* next() | 74 Node* next() |
75 { | 75 { |
76 Node* current = m_currentElement; | 76 Node* current = m_currentElement; |
77 ASSERT(current); | 77 ASSERT(current); |
78 m_currentElement = nextInternal(ElementTraversal::nextSkippingChildren(*
m_currentElement, m_rootNode)); | 78 m_currentElement = nextInternal(ElementTraversal::nextSkippingChildren(*
m_currentElement, &m_rootNode)); |
79 return current; | 79 return current; |
80 } | 80 } |
81 | 81 |
82 private: | 82 private: |
83 Element* nextInternal(Element* element) | 83 Element* nextInternal(Element* element) |
84 { | 84 { |
85 for (; element; element = ElementTraversal::next(*element, m_rootNode))
{ | 85 for (; element; element = ElementTraversal::next(*element, &m_rootNode))
{ |
86 if (element->hasClass() && element->classNames().contains(m_classNam
e)) | 86 if (element->hasClass() && element->classNames().contains(m_classNam
e)) |
87 return element; | 87 return element; |
88 } | 88 } |
89 return 0; | 89 return 0; |
90 } | 90 } |
91 | 91 |
92 const AtomicString& m_className; | 92 const AtomicString& m_className; |
93 Node* m_rootNode; | 93 Node& m_rootNode; |
94 Element* m_currentElement; | 94 Element* m_currentElement; |
95 }; | 95 }; |
96 | 96 |
97 class ClassElementList : public SimpleNodeList { | 97 class ClassElementList : public SimpleNodeList { |
98 public: | 98 public: |
99 ClassElementList(Node* rootNode, const AtomicString& className) | 99 ClassElementList(Node& rootNode, const AtomicString& className) |
100 : m_className(className) | 100 : m_className(className) |
101 , m_rootNode(rootNode) | 101 , m_rootNode(rootNode) |
102 , m_currentElement(nextInternal(ElementTraversal::firstWithin(rootNode))
) { } | 102 , m_currentElement(nextInternal(ElementTraversal::firstWithin(rootNode))
) { } |
103 | 103 |
104 bool isEmpty() const { return !m_currentElement; } | 104 bool isEmpty() const { return !m_currentElement; } |
105 | 105 |
106 Node* next() | 106 Node* next() |
107 { | 107 { |
108 Node* current = m_currentElement; | 108 Node* current = m_currentElement; |
109 ASSERT(current); | 109 ASSERT(current); |
110 m_currentElement = nextInternal(ElementTraversal::next(*m_currentElement
, m_rootNode)); | 110 m_currentElement = nextInternal(ElementTraversal::next(*m_currentElement
, &m_rootNode)); |
111 return current; | 111 return current; |
112 } | 112 } |
113 | 113 |
114 private: | 114 private: |
115 Element* nextInternal(Element* element) | 115 Element* nextInternal(Element* element) |
116 { | 116 { |
117 for (; element; element = ElementTraversal::next(*element, m_rootNode))
{ | 117 for (; element; element = ElementTraversal::next(*element, &m_rootNode))
{ |
118 if (element->hasClass() && element->classNames().contains(m_classNam
e)) | 118 if (element->hasClass() && element->classNames().contains(m_classNam
e)) |
119 return element; | 119 return element; |
120 } | 120 } |
121 return 0; | 121 return 0; |
122 } | 122 } |
123 | 123 |
124 const AtomicString& m_className; | 124 const AtomicString& m_className; |
125 Node* m_rootNode; | 125 Node& m_rootNode; |
126 Element* m_currentElement; | 126 Element* m_currentElement; |
127 }; | 127 }; |
128 | 128 |
129 void SelectorDataList::initialize(const CSSSelectorList& selectorList) | 129 void SelectorDataList::initialize(const CSSSelectorList& selectorList) |
130 { | 130 { |
131 ASSERT(m_selectors.isEmpty()); | 131 ASSERT(m_selectors.isEmpty()); |
132 | 132 |
133 unsigned selectorCount = 0; | 133 unsigned selectorCount = 0; |
134 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(selector)) | 134 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(selector)) |
135 selectorCount++; | 135 selectorCount++; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 | 181 |
182 static inline bool isTreeScopeRoot(Node* node) | 182 static inline bool isTreeScopeRoot(Node* node) |
183 { | 183 { |
184 ASSERT(node); | 184 ASSERT(node); |
185 return node->isDocumentNode() || node->isShadowRoot(); | 185 return node->isDocumentNode() || node->isShadowRoot(); |
186 } | 186 } |
187 | 187 |
188 void SelectorDataList::collectElementsByClassName(Node& rootNode, const AtomicSt
ring& className, Vector<RefPtr<Node> >& traversalRoots) const | 188 void SelectorDataList::collectElementsByClassName(Node& rootNode, const AtomicSt
ring& className, Vector<RefPtr<Node> >& traversalRoots) const |
189 { | 189 { |
190 for (Element* element = ElementTraversal::firstWithin(&rootNode); element; e
lement = ElementTraversal::next(*element, &rootNode)) { | 190 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el
ement = ElementTraversal::next(*element, &rootNode)) { |
191 if (element->hasClass() && element->classNames().contains(className)) | 191 if (element->hasClass() && element->classNames().contains(className)) |
192 traversalRoots.append(element); | 192 traversalRoots.append(element); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 void SelectorDataList::collectElementsByTagName(Node& rootNode, const QualifiedN
ame& tagName, Vector<RefPtr<Node> >& traversalRoots) const | 196 void SelectorDataList::collectElementsByTagName(Node& rootNode, const QualifiedN
ame& tagName, Vector<RefPtr<Node> >& traversalRoots) const |
197 { | 197 { |
198 for (Element* element = ElementTraversal::firstWithin(&rootNode); element; e
lement = ElementTraversal::next(*element, &rootNode)) { | 198 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el
ement = ElementTraversal::next(*element, &rootNode)) { |
199 if (SelectorChecker::tagMatches(*element, tagName)) | 199 if (SelectorChecker::tagMatches(*element, tagName)) |
200 traversalRoots.append(element); | 200 traversalRoots.append(element); |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 Element* SelectorDataList::findElementByClassName(Node& rootNode, const AtomicSt
ring& className) const | 204 Element* SelectorDataList::findElementByClassName(Node& rootNode, const AtomicSt
ring& className) const |
205 { | 205 { |
206 for (Element* element = ElementTraversal::firstWithin(&rootNode); element; e
lement = ElementTraversal::next(*element, &rootNode)) { | 206 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el
ement = ElementTraversal::next(*element, &rootNode)) { |
207 if (element->hasClass() && element->classNames().contains(className)) | 207 if (element->hasClass() && element->classNames().contains(className)) |
208 return element; | 208 return element; |
209 } | 209 } |
210 return 0; | 210 return 0; |
211 } | 211 } |
212 | 212 |
213 Element* SelectorDataList::findElementByTagName(Node& rootNode, const QualifiedN
ame& tagName) const | 213 Element* SelectorDataList::findElementByTagName(Node& rootNode, const QualifiedN
ame& tagName) const |
214 { | 214 { |
215 for (Element* element = ElementTraversal::firstWithin(&rootNode); element; e
lement = ElementTraversal::next(*element, &rootNode)) { | 215 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el
ement = ElementTraversal::next(*element, &rootNode)) { |
216 if (SelectorChecker::tagMatches(*element, tagName)) | 216 if (SelectorChecker::tagMatches(*element, tagName)) |
217 return element; | 217 return element; |
218 } | 218 } |
219 return 0; | 219 return 0; |
220 } | 220 } |
221 | 221 |
222 inline bool SelectorDataList::canUseFastQuery(const Node& rootNode) const | 222 inline bool SelectorDataList::canUseFastQuery(const Node& rootNode) const |
223 { | 223 { |
224 return m_selectors.size() == 1 && rootNode.inDocument() && !rootNode.documen
t().inQuirksMode(); | 224 return m_selectors.size() == 1 && rootNode.inDocument() && !rootNode.documen
t().inQuirksMode(); |
225 } | 225 } |
226 | 226 |
227 inline bool ancestorHasClassName(Node* rootNode, const AtomicString& className) | 227 inline bool ancestorHasClassName(Node& rootNode, const AtomicString& className) |
228 { | 228 { |
229 if (!rootNode->isElementNode()) | 229 if (!rootNode.isElementNode()) |
230 return false; | 230 return false; |
231 | 231 |
232 for (Element* element = toElement(rootNode); element; element = element->par
entElement()) { | 232 for (Element* element = &toElement(rootNode); element; element = element->pa
rentElement()) { |
233 if (element->hasClass() && element->classNames().contains(className)) | 233 if (element->hasClass() && element->classNames().contains(className)) |
234 return true; | 234 return true; |
235 } | 235 } |
236 return false; | 236 return false; |
237 } | 237 } |
238 | 238 |
239 | 239 |
240 // If returns true, traversalRoots has the elements that may match the selector
query. | 240 // If returns true, traversalRoots has the elements that may match the selector
query. |
241 // | 241 // |
242 // If returns false, traversalRoots has the rootNode parameter or descendants of
rootNode representing | 242 // If returns false, traversalRoots has the rootNode parameter or descendants of
rootNode representing |
243 // the subtree for which we can limit the querySelector traversal. | 243 // the subtree for which we can limit the querySelector traversal. |
244 // | 244 // |
245 // The travseralRoots may be empty, regardless of the returned bool value, if th
is method finds that the selectors won't | 245 // The travseralRoots may be empty, regardless of the returned bool value, if th
is method finds that the selectors won't |
246 // match any element. | 246 // match any element. |
247 PassOwnPtr<SimpleNodeList> SelectorDataList::findTraverseRoots(Node* rootNode, b
ool& matchTraverseRoots) const | 247 PassOwnPtr<SimpleNodeList> SelectorDataList::findTraverseRoots(Node& rootNode, b
ool& matchTraverseRoots) const |
248 { | 248 { |
249 // We need to return the matches in document order. To use id lookup while t
here is possiblity of multiple matches | 249 // We need to return the matches in document order. To use id lookup while t
here is possiblity of multiple matches |
250 // we would need to sort the results. For now, just traverse the document in
that case. | 250 // we would need to sort the results. For now, just traverse the document in
that case. |
251 ASSERT(rootNode); | |
252 ASSERT(m_selectors.size() == 1); | 251 ASSERT(m_selectors.size() == 1); |
253 ASSERT(m_selectors[0].selector); | 252 ASSERT(m_selectors[0].selector); |
254 | 253 |
255 bool isRightmostSelector = true; | 254 bool isRightmostSelector = true; |
256 bool startFromParent = false; | 255 bool startFromParent = false; |
257 | 256 |
258 for (const CSSSelector* selector = m_selectors[0].selector; selector; select
or = selector->tagHistory()) { | 257 for (const CSSSelector* selector = m_selectors[0].selector; selector; select
or = selector->tagHistory()) { |
259 if (selector->m_match == CSSSelector::Id && !rootNode->document().contai
nsMultipleElementsWithId(selector->value())) { | 258 if (selector->m_match == CSSSelector::Id && !rootNode.document().contain
sMultipleElementsWithId(selector->value())) { |
260 Element* element = rootNode->treeScope().getElementById(selector->va
lue()); | 259 Element* element = rootNode.treeScope().getElementById(selector->val
ue()); |
261 if (element && (isTreeScopeRoot(rootNode) || element->isDescendantOf
(rootNode))) | 260 Node* adjustedNode = &rootNode; |
262 rootNode = element; | 261 if (element && (isTreeScopeRoot(&rootNode) || element->isDescendantO
f(&rootNode))) |
| 262 adjustedNode = element; |
263 else if (!element || isRightmostSelector) | 263 else if (!element || isRightmostSelector) |
264 rootNode = 0; | 264 adjustedNode = 0; |
265 if (isRightmostSelector) { | 265 if (isRightmostSelector) { |
266 matchTraverseRoots = true; | 266 matchTraverseRoots = true; |
267 return adoptPtr(new SingleNodeList(rootNode)); | 267 return adoptPtr(new SingleNodeList(adjustedNode)); |
268 } | 268 } |
269 if (startFromParent && rootNode) | 269 if (startFromParent && adjustedNode) |
270 rootNode = rootNode->parentNode(); | 270 adjustedNode = adjustedNode->parentNode(); |
271 | 271 |
272 matchTraverseRoots = false; | 272 matchTraverseRoots = false; |
273 return adoptPtr(new SingleNodeList(rootNode)); | 273 return adoptPtr(new SingleNodeList(adjustedNode)); |
274 } | 274 } |
275 | 275 |
276 // If we have both CSSSelector::Id and CSSSelector::Class at the same ti
me, we should use Id | 276 // If we have both CSSSelector::Id and CSSSelector::Class at the same ti
me, we should use Id |
277 // to find traverse root. | 277 // to find traverse root. |
278 if (!startFromParent && selector->m_match == CSSSelector::Class) { | 278 if (!startFromParent && selector->m_match == CSSSelector::Class) { |
279 if (isRightmostSelector) { | 279 if (isRightmostSelector) { |
280 matchTraverseRoots = true; | 280 matchTraverseRoots = true; |
281 return adoptPtr(new ClassElementList(rootNode, selector->value()
)); | 281 return adoptPtr(new ClassElementList(rootNode, selector->value()
)); |
282 } | 282 } |
283 matchTraverseRoots = false; | 283 matchTraverseRoots = false; |
284 // Since there exists some ancestor element which has the class name
, we need to see all children of rootNode. | 284 // Since there exists some ancestor element which has the class name
, we need to see all children of rootNode. |
285 if (ancestorHasClassName(rootNode, selector->value())) | 285 if (ancestorHasClassName(rootNode, selector->value())) |
286 return adoptPtr(new SingleNodeList(rootNode)); | 286 return adoptPtr(new SingleNodeList(&rootNode)); |
287 | 287 |
288 return adoptPtr(new ClassRootNodeList(rootNode, selector->value())); | 288 return adoptPtr(new ClassRootNodeList(rootNode, selector->value())); |
289 } | 289 } |
290 | 290 |
291 if (selector->relation() == CSSSelector::SubSelector) | 291 if (selector->relation() == CSSSelector::SubSelector) |
292 continue; | 292 continue; |
293 isRightmostSelector = false; | 293 isRightmostSelector = false; |
294 if (selector->relation() == CSSSelector::DirectAdjacent || selector->rel
ation() == CSSSelector::IndirectAdjacent) | 294 if (selector->relation() == CSSSelector::DirectAdjacent || selector->rel
ation() == CSSSelector::IndirectAdjacent) |
295 startFromParent = true; | 295 startFromParent = true; |
296 else | 296 else |
297 startFromParent = false; | 297 startFromParent = false; |
298 } | 298 } |
299 | 299 |
300 matchTraverseRoots = false; | 300 matchTraverseRoots = false; |
301 return adoptPtr(new SingleNodeList(rootNode)); | 301 return adoptPtr(new SingleNodeList(&rootNode)); |
302 } | 302 } |
303 | 303 |
304 void SelectorDataList::executeSlowQueryAll(Node& rootNode, Vector<RefPtr<Node> >
& matchedElements) const | 304 void SelectorDataList::executeSlowQueryAll(Node& rootNode, Vector<RefPtr<Node> >
& matchedElements) const |
305 { | 305 { |
306 for (Element* element = ElementTraversal::firstWithin(&rootNode); element; e
lement = ElementTraversal::next(*element, &rootNode)) { | 306 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el
ement = ElementTraversal::next(*element, &rootNode)) { |
307 for (unsigned i = 0; i < m_selectors.size(); ++i) { | 307 for (unsigned i = 0; i < m_selectors.size(); ++i) { |
308 if (selectorMatches(m_selectors[i], *element, rootNode)) { | 308 if (selectorMatches(m_selectors[i], *element, rootNode)) { |
309 matchedElements.append(element); | 309 matchedElements.append(element); |
310 break; | 310 break; |
311 } | 311 } |
312 } | 312 } |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 void SelectorDataList::executeQueryAll(Node& rootNode, Vector<RefPtr<Node> >& ma
tchedElements) const | 316 void SelectorDataList::executeQueryAll(Node& rootNode, Vector<RefPtr<Node> >& ma
tchedElements) const |
(...skipping 23 matching lines...) Expand all Loading... |
340 case CSSSelector::Class: | 340 case CSSSelector::Class: |
341 return collectElementsByClassName(rootNode, firstSelector->value(),
matchedElements); | 341 return collectElementsByClassName(rootNode, firstSelector->value(),
matchedElements); |
342 case CSSSelector::Tag: | 342 case CSSSelector::Tag: |
343 return collectElementsByTagName(rootNode, firstSelector->tagQName(),
matchedElements); | 343 return collectElementsByTagName(rootNode, firstSelector->tagQName(),
matchedElements); |
344 default: | 344 default: |
345 break; // If we need another fast path, add here. | 345 break; // If we need another fast path, add here. |
346 } | 346 } |
347 } | 347 } |
348 | 348 |
349 bool matchTraverseRoots; | 349 bool matchTraverseRoots; |
350 OwnPtr<SimpleNodeList> traverseRoots = findTraverseRoots(&rootNode, matchTra
verseRoots); | 350 OwnPtr<SimpleNodeList> traverseRoots = findTraverseRoots(rootNode, matchTrav
erseRoots); |
351 if (traverseRoots->isEmpty()) | 351 if (traverseRoots->isEmpty()) |
352 return; | 352 return; |
353 | 353 |
354 const SelectorData& selector = m_selectors[0]; | 354 const SelectorData& selector = m_selectors[0]; |
355 if (matchTraverseRoots) { | 355 if (matchTraverseRoots) { |
356 while (!traverseRoots->isEmpty()) { | 356 while (!traverseRoots->isEmpty()) { |
357 Node& node = *traverseRoots->next(); | 357 Node& node = *traverseRoots->next(); |
358 Element& element = toElement(node); | 358 Element& element = toElement(node); |
359 if (selectorMatches(selector, element, rootNode)) | 359 if (selectorMatches(selector, element, rootNode)) |
360 matchedElements.append(&element); | 360 matchedElements.append(&element); |
361 } | 361 } |
362 return; | 362 return; |
363 } | 363 } |
364 | 364 |
365 while (!traverseRoots->isEmpty()) { | 365 while (!traverseRoots->isEmpty()) { |
366 Node* traverseRoot = traverseRoots->next(); | 366 Node* traverseRoot = traverseRoots->next(); |
367 for (Element* element = ElementTraversal::firstWithin(traverseRoot); ele
ment; element = ElementTraversal::next(*element, traverseRoot)) { | 367 ASSERT(traverseRoot); |
| 368 for (Element* element = ElementTraversal::firstWithin(*traverseRoot); el
ement; element = ElementTraversal::next(*element, traverseRoot)) { |
368 if (selectorMatches(selector, *element, rootNode)) | 369 if (selectorMatches(selector, *element, rootNode)) |
369 matchedElements.append(element); | 370 matchedElements.append(element); |
370 } | 371 } |
371 } | 372 } |
372 } | 373 } |
373 | 374 |
374 // If matchTraverseRoot is true, the returned Node is the single Element that ma
y match the selector query. | 375 // If matchTraverseRoot is true, the returned Node is the single Element that ma
y match the selector query. |
375 // | 376 // |
376 // If matchTraverseRoot is false, the returned Node is the rootNode parameter or
a descendant of rootNode representing | 377 // If matchTraverseRoot is false, the returned Node is the rootNode parameter or
a descendant of rootNode representing |
377 // the subtree for which we can limit the querySelector traversal. | 378 // the subtree for which we can limit the querySelector traversal. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 startFromParent = true; | 412 startFromParent = true; |
412 else | 413 else |
413 startFromParent = false; | 414 startFromParent = false; |
414 } | 415 } |
415 matchTraverseRoot = false; | 416 matchTraverseRoot = false; |
416 return &rootNode; | 417 return &rootNode; |
417 } | 418 } |
418 | 419 |
419 Element* SelectorDataList::executeSlowQueryFirst(Node& rootNode) const | 420 Element* SelectorDataList::executeSlowQueryFirst(Node& rootNode) const |
420 { | 421 { |
421 for (Element* element = ElementTraversal::firstWithin(&rootNode); element; e
lement = ElementTraversal::next(*element, &rootNode)) { | 422 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el
ement = ElementTraversal::next(*element, &rootNode)) { |
422 for (unsigned i = 0; i < m_selectors.size(); ++i) { | 423 for (unsigned i = 0; i < m_selectors.size(); ++i) { |
423 if (selectorMatches(m_selectors[i], *element, rootNode)) | 424 if (selectorMatches(m_selectors[i], *element, rootNode)) |
424 return element; | 425 return element; |
425 } | 426 } |
426 } | 427 } |
427 return 0; | 428 return 0; |
428 } | 429 } |
429 | 430 |
430 Element* SelectorDataList::executeQueryFirst(Node& rootNode) const | 431 Element* SelectorDataList::executeQueryFirst(Node& rootNode) const |
431 { | 432 { |
(...skipping 28 matching lines...) Expand all Loading... |
460 Node* traverseRootNode = findTraverseRoot(rootNode, matchTraverseRoot); | 461 Node* traverseRootNode = findTraverseRoot(rootNode, matchTraverseRoot); |
461 if (!traverseRootNode) | 462 if (!traverseRootNode) |
462 return 0; | 463 return 0; |
463 if (matchTraverseRoot) { | 464 if (matchTraverseRoot) { |
464 ASSERT(m_selectors.size() == 1); | 465 ASSERT(m_selectors.size() == 1); |
465 ASSERT(traverseRootNode->isElementNode()); | 466 ASSERT(traverseRootNode->isElementNode()); |
466 Element& element = toElement(*traverseRootNode); | 467 Element& element = toElement(*traverseRootNode); |
467 return selectorMatches(m_selectors[0], element, rootNode) ? &element : 0
; | 468 return selectorMatches(m_selectors[0], element, rootNode) ? &element : 0
; |
468 } | 469 } |
469 | 470 |
470 for (Element* element = ElementTraversal::firstWithin(traverseRootNode); ele
ment; element = ElementTraversal::next(*element, traverseRootNode)) { | 471 for (Element* element = ElementTraversal::firstWithin(*traverseRootNode); el
ement; element = ElementTraversal::next(*element, traverseRootNode)) { |
471 if (selectorMatches(m_selectors[0], *element, rootNode)) | 472 if (selectorMatches(m_selectors[0], *element, rootNode)) |
472 return element; | 473 return element; |
473 } | 474 } |
474 return 0; | 475 return 0; |
475 } | 476 } |
476 | 477 |
477 SelectorQuery::SelectorQuery(const CSSSelectorList& selectorList) | 478 SelectorQuery::SelectorQuery(const CSSSelectorList& selectorList) |
478 : m_selectorList(selectorList) | 479 : m_selectorList(selectorList) |
479 { | 480 { |
480 m_selectors.initialize(m_selectorList); | 481 m_selectors.initialize(m_selectorList); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 m_entries.add(selectors, selectorQuery.release()); | 526 m_entries.add(selectors, selectorQuery.release()); |
526 return rawSelectorQuery; | 527 return rawSelectorQuery; |
527 } | 528 } |
528 | 529 |
529 void SelectorQueryCache::invalidate() | 530 void SelectorQueryCache::invalidate() |
530 { | 531 { |
531 m_entries.clear(); | 532 m_entries.clear(); |
532 } | 533 } |
533 | 534 |
534 } | 535 } |
OLD | NEW |