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

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

Issue 330713003: Update SelectorQuery constructor to adopt CSSSelectorList object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename to adopt Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/SelectorQuery.h ('k') | no next file » | 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW
« no previous file with comments | « Source/core/dom/SelectorQuery.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698