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

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

Issue 2493003003: Introduce CSS parser mode for distinguishing static/dynamic profile (Closed)
Patch Set: Address review comments Created 4 years, 1 month 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
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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 622
623 SelectorQuery* SelectorQueryCache::add(const AtomicString& selectors, 623 SelectorQuery* SelectorQueryCache::add(const AtomicString& selectors,
624 const Document& document, 624 const Document& document,
625 ExceptionState& exceptionState) { 625 ExceptionState& exceptionState) {
626 HashMap<AtomicString, std::unique_ptr<SelectorQuery>>::iterator it = 626 HashMap<AtomicString, std::unique_ptr<SelectorQuery>>::iterator it =
627 m_entries.find(selectors); 627 m_entries.find(selectors);
628 if (it != m_entries.end()) 628 if (it != m_entries.end())
629 return it->value.get(); 629 return it->value.get();
630 630
631 CSSSelectorList selectorList = CSSParser::parseSelector( 631 CSSSelectorList selectorList = CSSParser::parseSelector(
632 CSSParserContext(document, nullptr), nullptr, selectors); 632 CSSParserContext(document, nullptr, KURL(), emptyString(),
633 CSSParserContext::StaticProfile),
634 nullptr, selectors);
633 635
634 if (!selectorList.first()) { 636 if (!selectorList.first()) {
635 exceptionState.throwDOMException( 637 exceptionState.throwDOMException(
636 SyntaxError, "'" + selectors + "' is not a valid selector."); 638 SyntaxError, "'" + selectors + "' is not a valid selector.");
637 return nullptr; 639 return nullptr;
638 } 640 }
639 641
640 const unsigned maximumSelectorQueryCacheSize = 256; 642 const unsigned maximumSelectorQueryCacheSize = 256;
641 if (m_entries.size() == maximumSelectorQueryCacheSize) 643 if (m_entries.size() == maximumSelectorQueryCacheSize)
642 m_entries.remove(m_entries.begin()); 644 m_entries.remove(m_entries.begin());
643 645
644 return m_entries.add(selectors, SelectorQuery::adopt(std::move(selectorList))) 646 return m_entries.add(selectors, SelectorQuery::adopt(std::move(selectorList)))
645 .storedValue->value.get(); 647 .storedValue->value.get();
646 } 648 }
647 649
648 void SelectorQueryCache::invalidate() { 650 void SelectorQueryCache::invalidate() {
649 m_entries.clear(); 651 m_entries.clear();
650 } 652 }
651 653
652 } // namespace blink 654 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSParserMode.cpp ('k') | third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698