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

Unified Diff: Source/core/dom/ContainerNode.cpp

Issue 138743008: Make sure the root node of selector queries is a ContainerNode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 11 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/ContainerNode.h ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index 7b16890ad209ea0002b0d0b750a6c7fd749dd882..2f162a0cb0305a279256f431cf7689ece6d524c5 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -35,6 +35,7 @@
#include "core/dom/NodeRareData.h"
#include "core/dom/NodeRenderStyle.h"
#include "core/dom/NodeTraversal.h"
+#include "core/dom/SelectorQuery.h"
#include "core/events/MutationEvent.h"
#include "core/events/ThreadLocalEventNames.h"
#include "core/html/HTMLCollection.h"
@@ -910,6 +911,32 @@ Node *ContainerNode::childNode(unsigned index) const
return n;
}
+PassRefPtr<Element> ContainerNode::querySelector(const AtomicString& selectors, ExceptionState& exceptionState)
+{
+ if (selectors.isEmpty()) {
+ exceptionState.throwDOMException(SyntaxError, "The provided selector is empty.");
+ return 0;
+ }
+
+ SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors, document(), exceptionState);
+ if (!selectorQuery)
+ return 0;
+ return selectorQuery->queryFirst(*this);
+}
+
+PassRefPtr<NodeList> ContainerNode::querySelectorAll(const AtomicString& selectors, ExceptionState& exceptionState)
+{
+ if (selectors.isEmpty()) {
+ exceptionState.throwDOMException(SyntaxError, "The provided selector is empty.");
+ return 0;
+ }
+
+ SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors, document(), exceptionState);
+ if (!selectorQuery)
+ return 0;
+ return selectorQuery->queryAll(*this);
+}
+
static void dispatchChildInsertionEvents(Node& child)
{
if (child.isInShadowTree())
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698