Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: Source/core/dom/SelectorQuery.cpp

Issue 1099963003: Support type selector for camel-cased SVG elements in HTML. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed review issues. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Element.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 matchesTagName(const QualifiedName& tagName, const Element& element)
179 {
180 if (tagName == anyQName())
181 return true;
182 if (element.hasLocalName(tagName.localName()))
183 return true;
184 // Non-html elements in html documents are normalized to their camel-cased
185 // version during parsing if applicable. Yet, type selectors are lower-cased
186 // for selectors in html documents. Try a case-insensitive match below to
187 // allow type selector matching for such elements.
188 if (!element.isHTMLElement() && element.document().isHTMLDocument())
189 return equalIgnoringCase(tagName.localName(), element.localName());
190 return false;
191 }
192
178 template <typename SelectorQueryTrait> 193 template <typename SelectorQueryTrait>
179 void SelectorDataList::collectElementsByTagName(ContainerNode& rootNode, const Q ualifiedName& tagName, typename SelectorQueryTrait::OutputType& output) const 194 void SelectorDataList::collectElementsByTagName(ContainerNode& rootNode, const Q ualifiedName& tagName, typename SelectorQueryTrait::OutputType& output) const
180 { 195 {
181 for (Element& element : ElementTraversal::descendantsOf(rootNode)) { 196 for (Element& element : ElementTraversal::descendantsOf(rootNode)) {
182 // querySelector*() doesn't allow namespaces and throws before it gets 197 // querySelector*() doesn't allow namespaces and throws before it gets
183 // here so we can ignore them. 198 // here so we can ignore them.
184 ASSERT(tagName.namespaceURI() == starAtom); 199 ASSERT(tagName.namespaceURI() == starAtom);
185 if (tagName == anyQName() || element.hasLocalName(tagName.localName())) { 200 if (matchesTagName(tagName, element)) {
186 SelectorQueryTrait::appendElement(output, element); 201 SelectorQueryTrait::appendElement(output, element);
187 if (SelectorQueryTrait::shouldOnlyMatchFirstElement) 202 if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
188 return; 203 return;
189 } 204 }
190 } 205 }
191 } 206 }
192 207
193 inline bool SelectorDataList::canUseFastQuery(const ContainerNode& rootNode) con st 208 inline bool SelectorDataList::canUseFastQuery(const ContainerNode& rootNode) con st
194 { 209 {
195 return m_selectors.size() == 1 && !m_crossesTreeBoundary && rootNode.inDocum ent() && !rootNode.document().inQuirksMode(); 210 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
538 553
539 return m_entries.add(selectors, SelectorQuery::adopt(selectorList)).storedVa lue->value.get(); 554 return m_entries.add(selectors, SelectorQuery::adopt(selectorList)).storedVa lue->value.get();
540 } 555 }
541 556
542 void SelectorQueryCache::invalidate() 557 void SelectorQueryCache::invalidate()
543 { 558 {
544 m_entries.clear(); 559 m_entries.clear();
545 } 560 }
546 561
547 } 562 }
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698