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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 { | 168 { |
169 for (Element& element : ElementTraversal::descendantsOf(rootNode)) { | 169 for (Element& element : ElementTraversal::descendantsOf(rootNode)) { |
170 if (element.hasClass() && element.classNames().contains(className)) { | 170 if (element.hasClass() && element.classNames().contains(className)) { |
171 SelectorQueryTrait::appendElement(output, element); | 171 SelectorQueryTrait::appendElement(output, element); |
172 if (SelectorQueryTrait::shouldOnlyMatchFirstElement) | 172 if (SelectorQueryTrait::shouldOnlyMatchFirstElement) |
173 return; | 173 return; |
174 } | 174 } |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 inline bool tagNameMatches(const QualifiedName& tagName, const Element& element) | |
esprehn
2015/05/07 02:21:27
Can you add a comment for what this is about? (her
rune
2015/05/07 07:59:48
Done.
| |
179 { | |
180 if (tagName == anyQName()) | |
181 return true; | |
182 if (element.hasLocalName(tagName.localName())) | |
183 return true; | |
184 if (element.isHTMLElement() || !element.document().isHTMLDocument()) | |
185 return false; | |
186 return equalIgnoringCase(tagName.localName(), element.localName()); | |
187 } | |
188 | |
178 template <typename SelectorQueryTrait> | 189 template <typename SelectorQueryTrait> |
179 void SelectorDataList::collectElementsByTagName(ContainerNode& rootNode, const Q ualifiedName& tagName, typename SelectorQueryTrait::OutputType& output) const | 190 void SelectorDataList::collectElementsByTagName(ContainerNode& rootNode, const Q ualifiedName& tagName, typename SelectorQueryTrait::OutputType& output) const |
180 { | 191 { |
181 for (Element& element : ElementTraversal::descendantsOf(rootNode)) { | 192 for (Element& element : ElementTraversal::descendantsOf(rootNode)) { |
182 // querySelector*() doesn't allow namespaces and throws before it gets | 193 // querySelector*() doesn't allow namespaces and throws before it gets |
183 // here so we can ignore them. | 194 // here so we can ignore them. |
184 ASSERT(tagName.namespaceURI() == starAtom); | 195 ASSERT(tagName.namespaceURI() == starAtom); |
185 if (tagName == anyQName() || element.hasLocalName(tagName.localName())) { | 196 if (tagNameMatches(tagName, element)) { |
186 SelectorQueryTrait::appendElement(output, element); | 197 SelectorQueryTrait::appendElement(output, element); |
187 if (SelectorQueryTrait::shouldOnlyMatchFirstElement) | 198 if (SelectorQueryTrait::shouldOnlyMatchFirstElement) |
188 return; | 199 return; |
189 } | 200 } |
190 } | 201 } |
191 } | 202 } |
192 | 203 |
193 inline bool SelectorDataList::canUseFastQuery(const ContainerNode& rootNode) con st | 204 inline bool SelectorDataList::canUseFastQuery(const ContainerNode& rootNode) con st |
194 { | 205 { |
195 return m_selectors.size() == 1 && !m_crossesTreeBoundary && rootNode.inDocum ent() && !rootNode.document().inQuirksMode(); | 206 return m_selectors.size() == 1 && !m_crossesTreeBoundary && rootNode.inDocum ent() && !rootNode.document().inQuirksMode(); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 | 549 |
539 return m_entries.add(selectors, SelectorQuery::adopt(selectorList)).storedVa lue->value.get(); | 550 return m_entries.add(selectors, SelectorQuery::adopt(selectorList)).storedVa lue->value.get(); |
540 } | 551 } |
541 | 552 |
542 void SelectorQueryCache::invalidate() | 553 void SelectorQueryCache::invalidate() |
543 { | 554 { |
544 m_entries.clear(); | 555 m_entries.clear(); |
545 } | 556 } |
546 | 557 |
547 } | 558 } |
OLD | NEW |