| OLD | NEW |
| 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 collectElementsByTagName<SelectorQueryTrait>(rootNode, firstSelector
.tagQName(), output); | 458 collectElementsByTagName<SelectorQueryTrait>(rootNode, firstSelector
.tagQName(), output); |
| 459 return; | 459 return; |
| 460 default: | 460 default: |
| 461 break; // If we need another fast path, add here. | 461 break; // If we need another fast path, add here. |
| 462 } | 462 } |
| 463 } | 463 } |
| 464 | 464 |
| 465 findTraverseRootsAndExecute<SelectorQueryTrait>(rootNode, output); | 465 findTraverseRootsAndExecute<SelectorQueryTrait>(rootNode, output); |
| 466 } | 466 } |
| 467 | 467 |
| 468 SelectorQuery::SelectorQuery(const CSSSelectorList& selectorList) | 468 PassOwnPtr<SelectorQuery> SelectorQuery::adopt(CSSSelectorList& selectorList) |
| 469 : m_selectorList(selectorList) | |
| 470 { | 469 { |
| 470 return adoptPtr(new SelectorQuery(selectorList)); |
| 471 } |
| 472 |
| 473 SelectorQuery::SelectorQuery(CSSSelectorList& selectorList) |
| 474 { |
| 475 m_selectorList.adopt(selectorList); |
| 471 m_selectors.initialize(m_selectorList); | 476 m_selectors.initialize(m_selectorList); |
| 472 } | 477 } |
| 473 | 478 |
| 474 bool SelectorQuery::matches(Element& element) const | 479 bool SelectorQuery::matches(Element& element) const |
| 475 { | 480 { |
| 476 return m_selectors.matches(element); | 481 return m_selectors.matches(element); |
| 477 } | 482 } |
| 478 | 483 |
| 479 PassRefPtrWillBeRawPtr<NodeList> SelectorQuery::queryAll(ContainerNode& rootNode
) const | 484 PassRefPtrWillBeRawPtr<NodeList> SelectorQuery::queryAll(ContainerNode& rootNode
) const |
| 480 { | 485 { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 504 // throw a NamespaceError if the selector includes any namespace prefixes. | 509 // throw a NamespaceError if the selector includes any namespace prefixes. |
| 505 if (selectorList.selectorsNeedNamespaceResolution()) { | 510 if (selectorList.selectorsNeedNamespaceResolution()) { |
| 506 exceptionState.throwDOMException(NamespaceError, "'" + selectors + "' co
ntains namespaces, which are not supported."); | 511 exceptionState.throwDOMException(NamespaceError, "'" + selectors + "' co
ntains namespaces, which are not supported."); |
| 507 return 0; | 512 return 0; |
| 508 } | 513 } |
| 509 | 514 |
| 510 const unsigned maximumSelectorQueryCacheSize = 256; | 515 const unsigned maximumSelectorQueryCacheSize = 256; |
| 511 if (m_entries.size() == maximumSelectorQueryCacheSize) | 516 if (m_entries.size() == maximumSelectorQueryCacheSize) |
| 512 m_entries.remove(m_entries.begin()); | 517 m_entries.remove(m_entries.begin()); |
| 513 | 518 |
| 514 OwnPtr<SelectorQuery> selectorQuery = adoptPtr(new SelectorQuery(selectorLis
t)); | 519 return m_entries.add(selectors, SelectorQuery::adopt(selectorList)).storedVa
lue->value.get(); |
| 515 SelectorQuery* rawSelectorQuery = selectorQuery.get(); | |
| 516 m_entries.add(selectors, selectorQuery.release()); | |
| 517 return rawSelectorQuery; | |
| 518 } | 520 } |
| 519 | 521 |
| 520 void SelectorQueryCache::invalidate() | 522 void SelectorQueryCache::invalidate() |
| 521 { | 523 { |
| 522 m_entries.clear(); | 524 m_entries.clear(); |
| 523 } | 525 } |
| 524 | 526 |
| 525 } | 527 } |
| OLD | NEW |