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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Element.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/SelectorQuery.cpp
diff --git a/Source/core/dom/SelectorQuery.cpp b/Source/core/dom/SelectorQuery.cpp
index 6a5d428934d4258c09430f6dfa83f20f63bad1f4..58dcfb0b4b8e24fc33651b97abf29ff231add77e 100644
--- a/Source/core/dom/SelectorQuery.cpp
+++ b/Source/core/dom/SelectorQuery.cpp
@@ -175,6 +175,21 @@ void SelectorDataList::collectElementsByClassName(ContainerNode& rootNode, const
}
}
+inline bool matchesTagName(const QualifiedName& tagName, const Element& element)
+{
+ if (tagName == anyQName())
+ return true;
+ if (element.hasLocalName(tagName.localName()))
+ return true;
+ // Non-html elements in html documents are normalized to their camel-cased
+ // version during parsing if applicable. Yet, type selectors are lower-cased
+ // for selectors in html documents. Try a case-insensitive match below to
+ // allow type selector matching for such elements.
+ if (!element.isHTMLElement() && element.document().isHTMLDocument())
+ return equalIgnoringCase(tagName.localName(), element.localName());
+ return false;
+}
+
template <typename SelectorQueryTrait>
void SelectorDataList::collectElementsByTagName(ContainerNode& rootNode, const QualifiedName& tagName, typename SelectorQueryTrait::OutputType& output) const
{
@@ -182,7 +197,7 @@ void SelectorDataList::collectElementsByTagName(ContainerNode& rootNode, const Q
// querySelector*() doesn't allow namespaces and throws before it gets
// here so we can ignore them.
ASSERT(tagName.namespaceURI() == starAtom);
- if (tagName == anyQName() || element.hasLocalName(tagName.localName())) {
+ if (matchesTagName(tagName, element)) {
SelectorQueryTrait::appendElement(output, element);
if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
return;
« 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