| 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 { | 540 { |
| 541 return m_selectors.queryFirst(rootNode); | 541 return m_selectors.queryFirst(rootNode); |
| 542 } | 542 } |
| 543 | 543 |
| 544 SelectorQuery* SelectorQueryCache::add(const AtomicString& selectors, const Docu
ment& document, ExceptionState& exceptionState) | 544 SelectorQuery* SelectorQueryCache::add(const AtomicString& selectors, const Docu
ment& document, ExceptionState& exceptionState) |
| 545 { | 545 { |
| 546 HashMap<AtomicString, OwnPtr<SelectorQuery>>::iterator it = m_entries.find(s
electors); | 546 HashMap<AtomicString, OwnPtr<SelectorQuery>>::iterator it = m_entries.find(s
electors); |
| 547 if (it != m_entries.end()) | 547 if (it != m_entries.end()) |
| 548 return it->value.get(); | 548 return it->value.get(); |
| 549 | 549 |
| 550 CSSSelectorList selectorList = CSSParser::parseSelector(CSSParserContext(doc
ument, nullptr), selectors); | 550 CSSSelectorList selectorList = CSSParser::parseSelector(CSSParserContext(doc
ument, nullptr), nullptr, selectors); |
| 551 | 551 |
| 552 if (!selectorList.first()) { | 552 if (!selectorList.first()) { |
| 553 exceptionState.throwDOMException(SyntaxError, "'" + selectors + "' is no
t a valid selector."); | 553 exceptionState.throwDOMException(SyntaxError, "'" + selectors + "' is no
t a valid selector."); |
| 554 return nullptr; | 554 return nullptr; |
| 555 } | 555 } |
| 556 | 556 |
| 557 // throw a NamespaceError if the selector includes any namespace prefixes. | |
| 558 if (selectorList.selectorsNeedNamespaceResolution()) { | |
| 559 exceptionState.throwDOMException(NamespaceError, "'" + selectors + "' co
ntains namespaces, which are not supported."); | |
| 560 return nullptr; | |
| 561 } | |
| 562 | |
| 563 const unsigned maximumSelectorQueryCacheSize = 256; | 557 const unsigned maximumSelectorQueryCacheSize = 256; |
| 564 if (m_entries.size() == maximumSelectorQueryCacheSize) | 558 if (m_entries.size() == maximumSelectorQueryCacheSize) |
| 565 m_entries.remove(m_entries.begin()); | 559 m_entries.remove(m_entries.begin()); |
| 566 | 560 |
| 567 return m_entries.add(selectors, SelectorQuery::adopt(std::move(selectorList)
)).storedValue->value.get(); | 561 return m_entries.add(selectors, SelectorQuery::adopt(std::move(selectorList)
)).storedValue->value.get(); |
| 568 } | 562 } |
| 569 | 563 |
| 570 void SelectorQueryCache::invalidate() | 564 void SelectorQueryCache::invalidate() |
| 571 { | 565 { |
| 572 m_entries.clear(); | 566 m_entries.clear(); |
| 573 } | 567 } |
| 574 | 568 |
| 575 } | 569 } |
| OLD | NEW |