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

Unified Diff: third_party/WebKit/Source/core/dom/SelectorQuery.cpp

Issue 1932673002: querySelector* fast-path missing namespace check for no namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nullAtom not emptyAtom Created 4 years, 8 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 | « third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/namespaced-elements-and-selectors-expected.txt ('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/SelectorQuery.cpp
diff --git a/third_party/WebKit/Source/core/dom/SelectorQuery.cpp b/third_party/WebKit/Source/core/dom/SelectorQuery.cpp
index 76151d5b7a6e76c76c574bdb5273c2663968327e..5966fc9fa287ef261c8085db318979a91b5e0f98 100644
--- a/third_party/WebKit/Source/core/dom/SelectorQuery.cpp
+++ b/third_party/WebKit/Source/core/dom/SelectorQuery.cpp
@@ -205,10 +205,8 @@ inline bool matchesTagName(const QualifiedName& tagName, const Element& element)
template <typename SelectorQueryTrait>
void SelectorDataList::collectElementsByTagName(ContainerNode& rootNode, const QualifiedName& tagName, typename SelectorQueryTrait::OutputType& output) const
{
+ DCHECK_EQ(tagName.namespaceURI(), starAtom);
for (Element& element : ElementTraversal::descendantsOf(rootNode)) {
- // querySelector*() doesn't allow namespaces and throws before it gets
- // here so we can ignore them.
- DCHECK_EQ(tagName.namespaceURI(), starAtom);
if (matchesTagName(tagName, element)) {
SelectorQueryTrait::appendElement(output, element);
if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
@@ -510,8 +508,15 @@ void SelectorDataList::execute(ContainerNode& rootNode, typename SelectorQueryTr
collectElementsByClassName<SelectorQueryTrait>(rootNode, firstSelector.value(), output);
return;
case CSSSelector::Tag:
- collectElementsByTagName<SelectorQueryTrait>(rootNode, firstSelector.tagQName(), output);
- return;
+ if (firstSelector.tagQName().namespaceURI() == starAtom) {
+ collectElementsByTagName<SelectorQueryTrait>(rootNode, firstSelector.tagQName(), output);
+ return;
+ }
+ // querySelector*() doesn't allow namespace prefix resolution and
+ // throws before we get here, but we still may have selectors for
+ // elements without a namespace.
+ DCHECK_EQ(firstSelector.tagQName().namespaceURI(), nullAtom);
+ break;
default:
break; // If we need another fast path, add here.
}
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/namespaced-elements-and-selectors-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698