| 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 "The provided selector is empty."); | 583 "The provided selector is empty."); |
| 584 return nullptr; | 584 return nullptr; |
| 585 } | 585 } |
| 586 | 586 |
| 587 HashMap<AtomicString, std::unique_ptr<SelectorQuery>>::iterator it = | 587 HashMap<AtomicString, std::unique_ptr<SelectorQuery>>::iterator it = |
| 588 m_entries.find(selectors); | 588 m_entries.find(selectors); |
| 589 if (it != m_entries.end()) | 589 if (it != m_entries.end()) |
| 590 return it->value.get(); | 590 return it->value.get(); |
| 591 | 591 |
| 592 CSSSelectorList selectorList = CSSParser::parseSelector( | 592 CSSSelectorList selectorList = CSSParser::parseSelector( |
| 593 CSSParserContext::create(document, KURL(), emptyString, | 593 CSSParserContext::create(document, document.baseURL(), |
| 594 document.getReferrerPolicy(), emptyString, |
| 594 CSSParserContext::StaticProfile), | 595 CSSParserContext::StaticProfile), |
| 595 nullptr, selectors); | 596 nullptr, selectors); |
| 596 | 597 |
| 597 if (!selectorList.first()) { | 598 if (!selectorList.first()) { |
| 598 exceptionState.throwDOMException( | 599 exceptionState.throwDOMException( |
| 599 SyntaxError, "'" + selectors + "' is not a valid selector."); | 600 SyntaxError, "'" + selectors + "' is not a valid selector."); |
| 600 return nullptr; | 601 return nullptr; |
| 601 } | 602 } |
| 602 | 603 |
| 603 const unsigned maximumSelectorQueryCacheSize = 256; | 604 const unsigned maximumSelectorQueryCacheSize = 256; |
| 604 if (m_entries.size() == maximumSelectorQueryCacheSize) | 605 if (m_entries.size() == maximumSelectorQueryCacheSize) |
| 605 m_entries.erase(m_entries.begin()); | 606 m_entries.erase(m_entries.begin()); |
| 606 | 607 |
| 607 return m_entries | 608 return m_entries |
| 608 .insert(selectors, SelectorQuery::adopt(std::move(selectorList))) | 609 .insert(selectors, SelectorQuery::adopt(std::move(selectorList))) |
| 609 .storedValue->value.get(); | 610 .storedValue->value.get(); |
| 610 } | 611 } |
| 611 | 612 |
| 612 void SelectorQueryCache::invalidate() { | 613 void SelectorQueryCache::invalidate() { |
| 613 m_entries.clear(); | 614 m_entries.clear(); |
| 614 } | 615 } |
| 615 | 616 |
| 616 } // namespace blink | 617 } // namespace blink |
| OLD | NEW |