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_element.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_document.cc ('k') | headless/lib/web_frame_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/web_element.cc
diff --git a/headless/lib/web_element.cc b/headless/lib/web_element.cc
new file mode 100644
index 0000000000000000000000000000000000000000..848e354b50db6421fd5f5aff0054badedd90edfc
--- /dev/null
+++ b/headless/lib/web_element.cc
@@ -0,0 +1,48 @@
+// 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_element.h"
+
+#include "third_party/WebKit/public/platform/WebRect.h"
+#include "third_party/WebKit/public/web/WebElement.h"
+
+namespace headless {
+
+WebElement::WebElement(const blink::WebElement& web_element)
+ : WebNode(web_element), attributes_(nullptr) {}
+
+WebElement::WebElement(const WebElement& web_element)
+ : WebNode(web_element.web_node_), attributes_(nullptr) {}
+
+WebElement::~WebElement() {}
+
+std::string WebElement::TagName() const {
+ return web_element().tagName().utf8();
+}
+
+gfx::Rect WebElement::BoundingBox() const {
+ blink::WebElement& element = const_cast<blink::WebElement&>(web_element());
+ return element.boundsInViewportSpace();
+}
+
+const std::map<std::string, std::string>& WebElement::Attributes() const {
+ if (!attributes_) {
+ attributes_.reset(new std::map<std::string, std::string>());
+ for (size_t i = 0; i < web_element().attributeCount(); ++i) {
+ (*attributes_)[web_element().attributeLocalName(i).utf8()] =
+ web_element().attributeValue(i).utf8();
+ }
+ }
+ return *attributes_;
+}
+
+blink::WebElement& WebElement::web_element() {
+ return static_cast<blink::WebElement&>(web_node_);
+}
+
+const blink::WebElement& WebElement::web_element() const {
+ return static_cast<const blink::WebElement&>(web_node_);
+}
+
+} // namespace headless
« no previous file with comments | « headless/lib/web_document.cc ('k') | headless/lib/web_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698