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

Side by Side Diff: components/ui_devtools/views/ui_devtools_overlay_agent.cc

Issue 2959263002: Show corresponding window/widget/view in UIElement tree when clicking on a UI element. (Closed)
Patch Set: set handled for cancelable event mouse click Created 3 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 "components/ui_devtools/views/ui_devtools_overlay_agent.h"
6
7 #include "ui/aura/env.h"
8
9 namespace ui_devtools {
10
11 UIDevToolsOverlayAgent::UIDevToolsOverlayAgent(UIDevToolsDOMAgent* dom_agent)
12 : dom_agent_(dom_agent) {
13 DCHECK(dom_agent_);
14 }
15
16 UIDevToolsOverlayAgent::~UIDevToolsOverlayAgent() {}
17
18 ui_devtools::protocol::Response UIDevToolsOverlayAgent::enable() {
19 dom_agent_->AddObserver(this);
20 return ui_devtools::protocol::Response::OK();
21 }
22
23 ui_devtools::protocol::Response UIDevToolsOverlayAgent::disable() {
24 dom_agent_->RemoveObserver(this);
25 return ui_devtools::protocol::Response::OK();
26 }
27
28 ui_devtools::protocol::Response UIDevToolsOverlayAgent::setInspectMode(
29 const String& in_mode,
30 protocol::Maybe<protocol::Overlay::HighlightConfig> in_highlightConfig) {
31 if (in_mode.compare("searchForNode") == 0)
32 aura::Env::GetInstance()->PrependPreTargetHandler(this);
33 else if (in_mode.compare("none") == 0)
34 aura::Env::GetInstance()->RemovePreTargetHandler(this);
35 return ui_devtools::protocol::Response::OK();
36 }
37
38 ui_devtools::protocol::Response UIDevToolsOverlayAgent::highlightNode(
39 std::unique_ptr<ui_devtools::protocol::Overlay::HighlightConfig>
40 highlight_config,
41 ui_devtools::protocol::Maybe<int> node_id) {
42 return dom_agent_->HighlightNode(std::move(highlight_config),
43 node_id.fromJust());
44 }
45
46 ui_devtools::protocol::Response UIDevToolsOverlayAgent::hideHighlight() {
47 return dom_agent_->hideHighlight();
48 }
49
50 void UIDevToolsOverlayAgent::OnNodeBoundsChanged(int node_id) {}
51
52 void UIDevToolsOverlayAgent::OnMouseEvent(ui::MouseEvent* event) {
53 if (!dom_agent_->window_element_root())
54 return;
55
56 // Find node id of element whose bounds contain the mouse pointer location.
57 int element_id = 0;
58 dom_agent_->FindElementByEventHandler(event->root_location(), &element_id);
59
60 if (event->type() == ui::ET_MOUSE_PRESSED) {
61 event->SetHandled();
62 aura::Env::GetInstance()->RemovePreTargetHandler(this);
63 if (element_id) {
64 frontend()->inspectNodeRequested(element_id);
65 dom_agent_->setInspectedNode(element_id);
66 }
67 } else if (element_id) {
68 frontend()->nodeHighlightRequested(element_id);
69 }
70 }
71
72 } // namespace ui_devtools
OLDNEW
« no previous file with comments | « components/ui_devtools/views/ui_devtools_overlay_agent.h ('k') | components/ui_devtools/views/ui_devtools_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698