| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 { | 493 { |
| 494 HashMap<AtomicString, OwnPtr<SelectorQuery> >::iterator it = m_entries.find(
selectors); | 494 HashMap<AtomicString, OwnPtr<SelectorQuery> >::iterator it = m_entries.find(
selectors); |
| 495 if (it != m_entries.end()) | 495 if (it != m_entries.end()) |
| 496 return it->value.get(); | 496 return it->value.get(); |
| 497 | 497 |
| 498 CSSParser parser(document); | 498 CSSParser parser(document); |
| 499 CSSSelectorList selectorList; | 499 CSSSelectorList selectorList; |
| 500 parser.parseSelector(selectors, selectorList); | 500 parser.parseSelector(selectors, selectorList); |
| 501 | 501 |
| 502 if (!selectorList.first()) { | 502 if (!selectorList.first()) { |
| 503 exceptionState.throwDOMException(SyntaxError, "Failed to execute query:
'" + selectors + "' is not a valid selector."); | 503 exceptionState.throwDOMException(SyntaxError, "'" + selectors + "' is no
t a valid selector."); |
| 504 return 0; | 504 return 0; |
| 505 } | 505 } |
| 506 | 506 |
| 507 // throw a NamespaceError if the selector includes any namespace prefixes. | 507 // throw a NamespaceError if the selector includes any namespace prefixes. |
| 508 if (selectorList.selectorsNeedNamespaceResolution()) { | 508 if (selectorList.selectorsNeedNamespaceResolution()) { |
| 509 exceptionState.throwDOMException(NamespaceError, "Failed to execute quer
y: '" + selectors + "' contains namespaces, which are not supported."); | 509 exceptionState.throwDOMException(NamespaceError, "'" + selectors + "' co
ntains namespaces, which are not supported."); |
| 510 return 0; | 510 return 0; |
| 511 } | 511 } |
| 512 | 512 |
| 513 const unsigned maximumSelectorQueryCacheSize = 256; | 513 const unsigned maximumSelectorQueryCacheSize = 256; |
| 514 if (m_entries.size() == maximumSelectorQueryCacheSize) | 514 if (m_entries.size() == maximumSelectorQueryCacheSize) |
| 515 m_entries.remove(m_entries.begin()); | 515 m_entries.remove(m_entries.begin()); |
| 516 | 516 |
| 517 OwnPtr<SelectorQuery> selectorQuery = adoptPtr(new SelectorQuery(selectorLis
t)); | 517 OwnPtr<SelectorQuery> selectorQuery = adoptPtr(new SelectorQuery(selectorLis
t)); |
| 518 SelectorQuery* rawSelectorQuery = selectorQuery.get(); | 518 SelectorQuery* rawSelectorQuery = selectorQuery.get(); |
| 519 m_entries.add(selectors, selectorQuery.release()); | 519 m_entries.add(selectors, selectorQuery.release()); |
| 520 return rawSelectorQuery; | 520 return rawSelectorQuery; |
| 521 } | 521 } |
| 522 | 522 |
| 523 void SelectorQueryCache::invalidate() | 523 void SelectorQueryCache::invalidate() |
| 524 { | 524 { |
| 525 m_entries.clear(); | 525 m_entries.clear(); |
| 526 } | 526 } |
| 527 | 527 |
| 528 } | 528 } |
| OLD | NEW |