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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 618 |
619 SelectorQuery* SelectorQueryCache::add(const AtomicString& selectors, | 619 SelectorQuery* SelectorQueryCache::add(const AtomicString& selectors, |
620 const Document& document, | 620 const Document& document, |
621 ExceptionState& exceptionState) { | 621 ExceptionState& exceptionState) { |
622 HashMap<AtomicString, std::unique_ptr<SelectorQuery>>::iterator it = | 622 HashMap<AtomicString, std::unique_ptr<SelectorQuery>>::iterator it = |
623 m_entries.find(selectors); | 623 m_entries.find(selectors); |
624 if (it != m_entries.end()) | 624 if (it != m_entries.end()) |
625 return it->value.get(); | 625 return it->value.get(); |
626 | 626 |
627 CSSSelectorList selectorList = CSSParser::parseSelector( | 627 CSSSelectorList selectorList = CSSParser::parseSelector( |
628 CSSParserContext(document, nullptr, KURL(), emptyString(), | 628 CSSParserContext::create(document, KURL(), emptyString(), |
629 CSSParserContext::StaticProfile), | 629 CSSParserContext::StaticProfile), |
630 nullptr, selectors); | 630 nullptr, selectors); |
631 | 631 |
632 if (!selectorList.first()) { | 632 if (!selectorList.first()) { |
633 exceptionState.throwDOMException( | 633 exceptionState.throwDOMException( |
634 SyntaxError, "'" + selectors + "' is not a valid selector."); | 634 SyntaxError, "'" + selectors + "' is not a valid selector."); |
635 return nullptr; | 635 return nullptr; |
636 } | 636 } |
637 | 637 |
638 const unsigned maximumSelectorQueryCacheSize = 256; | 638 const unsigned maximumSelectorQueryCacheSize = 256; |
639 if (m_entries.size() == maximumSelectorQueryCacheSize) | 639 if (m_entries.size() == maximumSelectorQueryCacheSize) |
640 m_entries.remove(m_entries.begin()); | 640 m_entries.remove(m_entries.begin()); |
641 | 641 |
642 return m_entries.add(selectors, SelectorQuery::adopt(std::move(selectorList))) | 642 return m_entries.add(selectors, SelectorQuery::adopt(std::move(selectorList))) |
643 .storedValue->value.get(); | 643 .storedValue->value.get(); |
644 } | 644 } |
645 | 645 |
646 void SelectorQueryCache::invalidate() { | 646 void SelectorQueryCache::invalidate() { |
647 m_entries.clear(); | 647 m_entries.clear(); |
648 } | 648 } |
649 | 649 |
650 } // namespace blink | 650 } // namespace blink |
OLD | NEW |