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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |