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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 { | 213 { |
214 HashMap<AtomicString, OwnPtr<SelectorQuery> >::iterator it = m_entries.find(
selectors); | 214 HashMap<AtomicString, OwnPtr<SelectorQuery> >::iterator it = m_entries.find(
selectors); |
215 if (it != m_entries.end()) | 215 if (it != m_entries.end()) |
216 return it->value.get(); | 216 return it->value.get(); |
217 | 217 |
218 CSSParser parser(document); | 218 CSSParser parser(document); |
219 CSSSelectorList selectorList; | 219 CSSSelectorList selectorList; |
220 parser.parseSelector(selectors, selectorList); | 220 parser.parseSelector(selectors, selectorList); |
221 | 221 |
222 if (!selectorList.first() || selectorList.hasInvalidSelector()) { | 222 if (!selectorList.first() || selectorList.hasInvalidSelector()) { |
223 ec = SYNTAX_ERR; | 223 ec = SyntaxError; |
224 return 0; | 224 return 0; |
225 } | 225 } |
226 | 226 |
227 // throw a NAMESPACE_ERR if the selector includes any namespace prefixes. | 227 // throw a NamespaceError if the selector includes any namespace prefixes. |
228 if (selectorList.selectorsNeedNamespaceResolution()) { | 228 if (selectorList.selectorsNeedNamespaceResolution()) { |
229 ec = NAMESPACE_ERR; | 229 ec = NamespaceError; |
230 return 0; | 230 return 0; |
231 } | 231 } |
232 | 232 |
233 const int maximumSelectorQueryCacheSize = 256; | 233 const int maximumSelectorQueryCacheSize = 256; |
234 if (m_entries.size() == maximumSelectorQueryCacheSize) | 234 if (m_entries.size() == maximumSelectorQueryCacheSize) |
235 m_entries.remove(m_entries.begin()); | 235 m_entries.remove(m_entries.begin()); |
236 | 236 |
237 OwnPtr<SelectorQuery> selectorQuery = adoptPtr(new SelectorQuery(selectorLis
t)); | 237 OwnPtr<SelectorQuery> selectorQuery = adoptPtr(new SelectorQuery(selectorLis
t)); |
238 SelectorQuery* rawSelectorQuery = selectorQuery.get(); | 238 SelectorQuery* rawSelectorQuery = selectorQuery.get(); |
239 m_entries.add(selectors, selectorQuery.release()); | 239 m_entries.add(selectors, selectorQuery.release()); |
240 return rawSelectorQuery; | 240 return rawSelectorQuery; |
241 } | 241 } |
242 | 242 |
243 void SelectorQueryCache::invalidate() | 243 void SelectorQueryCache::invalidate() |
244 { | 244 { |
245 m_entries.clear(); | 245 m_entries.clear(); |
246 } | 246 } |
247 | 247 |
248 } | 248 } |
OLD | NEW |