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

Unified Diff: third_party/WebKit/Source/core/dom/query/SelectorTagMatcher.cpp

Issue 1496533003: Implement a simple version of SelectorQuery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert change to SelectorFilter.h Created 5 years 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 | « third_party/WebKit/Source/core/dom/query/SelectorTagMatcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/query/SelectorTagMatcher.cpp
diff --git a/third_party/WebKit/Source/core/dom/query/SelectorTagMatcher.cpp b/third_party/WebKit/Source/core/dom/query/SelectorTagMatcher.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e8b645b2d56cb0b217b8446dcaa4663c5cac0852
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/query/SelectorTagMatcher.cpp
@@ -0,0 +1,36 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/dom/query/SelectorTagMatcher.h"
+
+#include "core/dom/ContainerNode.h"
+#include "core/dom/Element.h"
+
+namespace blink {
+
+SelectorTagMatcher::SelectorTagMatcher(const QualifiedName& tagName)
+ : m_tagName(tagName)
+{
+ ASSERT(m_tagName != anyQName());
+}
+
+SelectorTagMatcher::~SelectorTagMatcher()
+{
+}
+
+bool SelectorTagMatcher::match(Element& element, ContainerNode& rootNode) const
+{
+ if (element.hasLocalName(m_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. Compare the upper case converted names
+ // instead to allow matching SVG elements like foreignObject.
+ if (!element.isHTMLElement() && element.document().isHTMLDocument())
+ return element.tagQName().localNameUpper() == m_tagName.localNameUpper();
+ return false;
+}
+
+}
« no previous file with comments | « third_party/WebKit/Source/core/dom/query/SelectorTagMatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698