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

Unified Diff: Source/web/WebNode.cpp

Issue 1345423002: Introduce WebNode::querySelectorAll. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | « no previous file | Source/web/WebNodeTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebNode.cpp
diff --git a/Source/web/WebNode.cpp b/Source/web/WebNode.cpp
index e1a768f8d84da5bacabf4e56ab4f4e1741940400..1fafc90fbd23ca0b8a3d01115a09fc2cbde97d75 100644
--- a/Source/web/WebNode.cpp
+++ b/Source/web/WebNode.cpp
@@ -36,6 +36,7 @@
#include "core/dom/Element.h"
#include "core/dom/Node.h"
#include "core/dom/NodeList.h"
+#include "core/dom/StaticNodeList.h"
#include "core/dom/TagCollection.h"
#include "core/editing/serializers/Serialization.h"
#include "core/events/Event.h"
@@ -241,16 +242,32 @@ WebElementCollection WebNode::getElementsByHTMLTagName(const WebString& tag) con
return WebElementCollection();
}
-WebElement WebNode::querySelector(const WebString& tag, WebExceptionCode& ec) const
+WebElement WebNode::querySelector(const WebString& selector, WebExceptionCode& ec) const
{
+ if (!m_private->isContainerNode())
+ return WebElement();
TrackExceptionState exceptionState;
- WebElement element;
- if (m_private->isContainerNode())
- element = toContainerNode(m_private.get())->querySelector(tag, exceptionState);
+ WebElement element = toContainerNode(m_private.get())->querySelector(selector, exceptionState);
ec = exceptionState.code();
return element;
}
+void WebNode::querySelectorAll(const WebString& selector, WebExceptionCode& ec, WebVector<WebElement>& results) const
+{
+ if (!m_private->isContainerNode())
+ return;
+ TrackExceptionState exceptionState;
+ RefPtrWillBeRawPtr<StaticElementList> elements = toContainerNode(m_private.get())->querySelectorAll(selector, exceptionState);
+ ec = exceptionState.code();
+ if (exceptionState.hadException())
+ return;
+ Vector<WebElement> temp;
+ temp.reserveCapacity(elements->length());
+ for (unsigned i = 0; i < elements->length(); ++i)
+ temp.append(WebElement(elements->item(i)));
+ results.assign(temp);
+}
+
bool WebNode::focused() const
{
return m_private->focused();
« no previous file with comments | « no previous file | Source/web/WebNodeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698