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

Unified Diff: headless/lib/web_node.cc

Issue 1430673002: Headless demo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better javascript Created 5 years, 1 month 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 | « headless/lib/web_frame_impl.cc ('k') | headless/public/headless_browser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/web_node.cc
diff --git a/headless/lib/web_node.cc b/headless/lib/web_node.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7f353f05d15440f248f00e2ae331291de2cf0bd4
--- /dev/null
+++ b/headless/lib/web_node.cc
@@ -0,0 +1,68 @@
+// 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 "headless/public/web_node.h"
+
+#include "headless/public/web_document.h"
+#include "headless/public/web_element.h"
+#include "third_party/WebKit/public/web/WebDocument.h"
+#include "third_party/WebKit/public/web/WebElement.h"
+
+namespace headless {
+
+WebNode::WebNode(const blink::WebNode& web_node) : web_node_(web_node) {}
+
+bool WebNode::IsDocument() const {
+ return web_node_.isDocumentNode();
+}
+
+bool WebNode::IsElement() const {
+ return web_node_.isElementNode();
+}
+
+WebDocument WebNode::AsDocument() const {
+ return WebDocument(static_cast<const blink::WebDocument&>(web_node_));
+}
+
+WebElement WebNode::AsElement() const {
+ return WebElement(static_cast<const blink::WebElement&>(web_node_));
+}
+
+std::string WebNode::Value() const {
+ return web_node_.nodeValue().utf8();
+}
+
+WebNode WebNode::Parent() const {
+ return WebNode(web_node_.parentNode());
+}
+
+WebNode WebNode::FirstChild() const {
+ return WebNode(web_node_.firstChild());
+}
+
+WebNode WebNode::LastChild() const {
+ return WebNode(web_node_.lastChild());
+}
+
+WebNode WebNode::NextSibling() const {
+ return WebNode(web_node_.nextSibling());
+}
+
+WebNode WebNode::PreviousSibling() const {
+ return WebNode(web_node_.previousSibling());
+}
+
+bool WebNode::HasChildNodes() const {
+ return web_node_.hasChildNodes();
+}
+
+blink::WebNode& WebNode::web_node() {
+ return web_node_;
+}
+
+const blink::WebNode& WebNode::web_node() const {
+ return web_node_;
+}
+
+} // namespace headless
« no previous file with comments | « headless/lib/web_frame_impl.cc ('k') | headless/public/headless_browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698