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

Side by Side 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 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "headless/public/web_element.h"
6
7 #include "third_party/WebKit/public/platform/WebRect.h"
8 #include "third_party/WebKit/public/web/WebElement.h"
9
10 namespace headless {
11
12 WebElement::WebElement(const blink::WebElement& web_element)
13 : WebNode(web_element), attributes_(nullptr) {}
14
15 WebElement::WebElement(const WebElement& web_element)
16 : WebNode(web_element.web_node_), attributes_(nullptr) {}
17
18 WebElement::~WebElement() {}
19
20 std::string WebElement::TagName() const {
21 return web_element().tagName().utf8();
22 }
23
24 gfx::Rect WebElement::BoundingBox() const {
25 blink::WebElement& element = const_cast<blink::WebElement&>(web_element());
26 return element.boundsInViewportSpace();
27 }
28
29 const std::map<std::string, std::string>& WebElement::Attributes() const {
30 if (!attributes_) {
31 attributes_.reset(new std::map<std::string, std::string>());
32 for (size_t i = 0; i < web_element().attributeCount(); ++i) {
33 (*attributes_)[web_element().attributeLocalName(i).utf8()] =
34 web_element().attributeValue(i).utf8();
35 }
36 }
37 return *attributes_;
38 }
39
40 blink::WebElement& WebElement::web_element() {
41 return static_cast<blink::WebElement&>(web_node_);
42 }
43
44 const blink::WebElement& WebElement::web_element() const {
45 return static_cast<const blink::WebElement&>(web_node_);
46 }
47
48 } // namespace headless
OLDNEW
« 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