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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 | 330 |
331 // Fast path for querySelectorAll('#id'), querySelectorAll('tag#id'). | 331 // Fast path for querySelectorAll('#id'), querySelectorAll('tag#id'). |
332 if (const CSSSelector* idSelector = selectorForIdLookup(firstSelector)) { | 332 if (const CSSSelector* idSelector = selectorForIdLookup(firstSelector)) { |
333 const AtomicString& idToMatch = idSelector->value(); | 333 const AtomicString& idToMatch = idSelector->value(); |
334 if (rootNode.treeScope().containsMultipleElementsWithId(idToMatch)) { | 334 if (rootNode.treeScope().containsMultipleElementsWithId(idToMatch)) { |
335 const Vector<Element*>& elements = rootNode.treeScope().getAllElemen tsById(idToMatch); | 335 const Vector<Element*>& elements = rootNode.treeScope().getAllElemen tsById(idToMatch); |
336 size_t count = elements.size(); | 336 size_t count = elements.size(); |
337 for (size_t i = 0; i < count; ++i) { | 337 for (size_t i = 0; i < count; ++i) { |
338 Element* element = elements[i]; | 338 Element* element = elements[i]; |
339 ASSERT(element); | 339 ASSERT(element); |
340 if (!(isTreeScopeRoot(rootNode) || element->isDescendantOf(&root Node))) | |
341 continue; | |
340 if (selectorMatches(selector, *element, rootNode)) | 342 if (selectorMatches(selector, *element, rootNode)) |
341 matchedElements.append(element); | 343 matchedElements.append(element); |
342 } | 344 } |
343 return; | 345 return; |
344 } | 346 } |
345 Element* element = rootNode.treeScope().getElementById(idToMatch); | 347 Element* element = rootNode.treeScope().getElementById(idToMatch); |
346 if (!element || !(isTreeScopeRoot(rootNode) || element->isDescendantOf(& rootNode))) | 348 if (!element || !(isTreeScopeRoot(rootNode) || element->isDescendantOf(& rootNode))) |
347 return; | 349 return; |
348 if (selectorMatches(selector, *element, rootNode)) | 350 if (selectorMatches(selector, *element, rootNode)) |
349 matchedElements.append(element); | 351 matchedElements.append(element); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 | 458 |
457 // Fast path for querySelectorAll('#id'), querySelectorAll('tag#id'). | 459 // Fast path for querySelectorAll('#id'), querySelectorAll('tag#id'). |
458 if (const CSSSelector* idSelector = selectorForIdLookup(firstSelector)) { | 460 if (const CSSSelector* idSelector = selectorForIdLookup(firstSelector)) { |
459 const AtomicString& idToMatch = idSelector->value(); | 461 const AtomicString& idToMatch = idSelector->value(); |
460 if (rootNode.treeScope().containsMultipleElementsWithId(idToMatch)) { | 462 if (rootNode.treeScope().containsMultipleElementsWithId(idToMatch)) { |
461 const Vector<Element*>& elements = rootNode.treeScope().getAllElemen tsById(idToMatch); | 463 const Vector<Element*>& elements = rootNode.treeScope().getAllElemen tsById(idToMatch); |
462 size_t count = elements.size(); | 464 size_t count = elements.size(); |
463 for (size_t i = 0; i < count; ++i) { | 465 for (size_t i = 0; i < count; ++i) { |
464 Element* element = elements[i]; | 466 Element* element = elements[i]; |
465 ASSERT(element); | 467 ASSERT(element); |
468 if (!(isTreeScopeRoot(rootNode) || element->isDescendantOf(&root Node))) | |
Inactive
2014/01/05 20:46:33
FYI, I am planning on working on getting rid of th
| |
469 continue; | |
466 if (selectorMatches(selector, *element, rootNode)) | 470 if (selectorMatches(selector, *element, rootNode)) |
467 return element; | 471 return element; |
468 } | 472 } |
469 return 0; | 473 return 0; |
470 } | 474 } |
471 Element* element = rootNode.treeScope().getElementById(idToMatch); | 475 Element* element = rootNode.treeScope().getElementById(idToMatch); |
472 if (!element || !(isTreeScopeRoot(rootNode) || element->isDescendantOf(& rootNode))) | 476 if (!element || !(isTreeScopeRoot(rootNode) || element->isDescendantOf(& rootNode))) |
473 return 0; | 477 return 0; |
474 return selectorMatches(selector, *element, rootNode) ? element : 0; | 478 return selectorMatches(selector, *element, rootNode) ? element : 0; |
475 } | 479 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
555 m_entries.add(selectors, selectorQuery.release()); | 559 m_entries.add(selectors, selectorQuery.release()); |
556 return rawSelectorQuery; | 560 return rawSelectorQuery; |
557 } | 561 } |
558 | 562 |
559 void SelectorQueryCache::invalidate() | 563 void SelectorQueryCache::invalidate() |
560 { | 564 { |
561 m_entries.clear(); | 565 m_entries.clear(); |
562 } | 566 } |
563 | 567 |
564 } | 568 } |
OLD | NEW |