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 |