OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_ | 5 #ifndef COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_ |
6 #define COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_ | 6 #define COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_ |
7 | 7 |
8 #include "components/ui_devtools/DOM.h" | 8 #include "components/ui_devtools/DOM.h" |
9 #include "components/ui_devtools/devtools_base_agent.h" | 9 #include "components/ui_devtools/devtools_base_agent.h" |
10 #include "components/ui_devtools/views/ui_element_delegate.h" | 10 #include "components/ui_devtools/views/ui_element_delegate.h" |
11 #include "ui/aura/env_observer.h" | 11 #include "ui/aura/env_observer.h" |
| 12 #include "ui/events/event_handler.h" |
12 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
13 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
14 | 15 |
15 namespace aura { | 16 namespace aura { |
16 class Window; | 17 class Window; |
17 } | 18 } |
18 | 19 |
| 20 namespace ui { |
| 21 class MouseEvent; |
| 22 } |
| 23 |
19 namespace ui_devtools { | 24 namespace ui_devtools { |
20 | 25 |
| 26 class UIDevToolsOverlayAgent; |
21 class UIElement; | 27 class UIElement; |
22 | 28 |
23 class UIDevToolsDOMAgentObserver { | 29 class UIDevToolsDOMAgentObserver { |
24 public: | 30 public: |
25 // TODO(thanhph): Use UIElement* as input argument instead. | 31 // TODO(thanhph): Use UIElement* as input argument instead. |
26 virtual void OnNodeBoundsChanged(int node_id) = 0; | 32 virtual void OnNodeBoundsChanged(int node_id) = 0; |
27 }; | 33 }; |
28 | 34 |
29 class UIDevToolsDOMAgent : public ui_devtools::UiDevToolsBaseAgent< | 35 class UIDevToolsDOMAgent : public ui_devtools::UiDevToolsBaseAgent< |
30 ui_devtools::protocol::DOM::Metainfo>, | 36 ui_devtools::protocol::DOM::Metainfo>, |
31 public UIElementDelegate, | 37 public UIElementDelegate, |
32 public aura::EnvObserver { | 38 public aura::EnvObserver, |
| 39 public ui::EventHandler { |
33 public: | 40 public: |
34 UIDevToolsDOMAgent(); | 41 UIDevToolsDOMAgent(UIDevToolsOverlayAgent* overlay_agent); |
35 ~UIDevToolsDOMAgent() override; | 42 ~UIDevToolsDOMAgent() override; |
36 | 43 |
37 // DOM::Backend: | 44 // DOM::Backend: |
38 ui_devtools::protocol::Response disable() override; | 45 ui_devtools::protocol::Response disable() override; |
39 ui_devtools::protocol::Response getDocument( | 46 ui_devtools::protocol::Response getDocument( |
40 std::unique_ptr<ui_devtools::protocol::DOM::Node>* out_root) override; | 47 std::unique_ptr<ui_devtools::protocol::DOM::Node>* out_root) override; |
41 ui_devtools::protocol::Response highlightNode( | 48 ui_devtools::protocol::Response highlightNode( |
42 std::unique_ptr<ui_devtools::protocol::DOM::HighlightConfig> | 49 std::unique_ptr<ui_devtools::protocol::DOM::HighlightConfig> |
43 highlight_config, | 50 highlight_config, |
44 ui_devtools::protocol::Maybe<int> node_id) override; | 51 ui_devtools::protocol::Maybe<int> node_id) override; |
| 52 ui_devtools::protocol::Response setInspectMode( |
| 53 ui_devtools::protocol::Maybe<String> mode, |
| 54 std::unique_ptr<ui_devtools::protocol::DOM::HighlightConfig> |
| 55 highlight_config, |
| 56 ui_devtools::protocol::Maybe<int> node_id) override; |
45 ui_devtools::protocol::Response hideHighlight() override; | 57 ui_devtools::protocol::Response hideHighlight() override; |
46 | 58 |
47 // UIElementDelegate: | 59 // UIElementDelegate: |
48 void OnUIElementAdded(UIElement* parent, UIElement* child) override; | 60 void OnUIElementAdded(UIElement* parent, UIElement* child) override; |
49 void OnUIElementReordered(UIElement* parent, UIElement* child) override; | 61 void OnUIElementReordered(UIElement* parent, UIElement* child) override; |
50 void OnUIElementRemoved(UIElement* ui_element) override; | 62 void OnUIElementRemoved(UIElement* ui_element) override; |
51 void OnUIElementBoundsChanged(UIElement* ui_element) override; | 63 void OnUIElementBoundsChanged(UIElement* ui_element) override; |
52 bool IsHighlightingWindow(aura::Window* window) override; | 64 bool IsHighlightingWindow(aura::Window* window) override; |
53 | 65 |
| 66 // ui:EventHandler: |
| 67 void OnMouseEvent(ui::MouseEvent* event) override; |
| 68 |
54 void AddObserver(UIDevToolsDOMAgentObserver* observer); | 69 void AddObserver(UIDevToolsDOMAgentObserver* observer); |
55 void RemoveObserver(UIDevToolsDOMAgentObserver* observer); | 70 void RemoveObserver(UIDevToolsDOMAgentObserver* observer); |
56 UIElement* GetElementFromNodeId(int node_id); | 71 UIElement* GetElementFromNodeId(int node_id); |
57 UIElement* window_element_root() const { return window_element_root_.get(); }; | 72 UIElement* window_element_root() const { return window_element_root_.get(); }; |
58 const std::vector<aura::Window*>& root_windows() const { | 73 const std::vector<aura::Window*>& root_windows() const { |
59 return root_windows_; | 74 return root_windows_; |
60 }; | 75 }; |
61 | 76 |
62 private: | 77 private: |
63 // aura::EnvObserver: | 78 // aura::EnvObserver: |
(...skipping 18 matching lines...) Expand all Loading... |
82 void InitializeHighlightingWidget(); | 97 void InitializeHighlightingWidget(); |
83 void UpdateHighlight( | 98 void UpdateHighlight( |
84 const std::pair<aura::Window*, gfx::Rect>& window_and_bounds, | 99 const std::pair<aura::Window*, gfx::Rect>& window_and_bounds, |
85 SkColor background, | 100 SkColor background, |
86 SkColor border); | 101 SkColor border); |
87 ui_devtools::protocol::Response HighlightNode( | 102 ui_devtools::protocol::Response HighlightNode( |
88 std::unique_ptr<ui_devtools::protocol::DOM::HighlightConfig> | 103 std::unique_ptr<ui_devtools::protocol::DOM::HighlightConfig> |
89 highlight_config, | 104 highlight_config, |
90 int node_id); | 105 int node_id); |
91 | 106 |
| 107 UIDevToolsOverlayAgent* overlay_agent_; |
92 bool is_building_tree_; | 108 bool is_building_tree_; |
93 std::unique_ptr<UIElement> window_element_root_; | 109 std::unique_ptr<UIElement> window_element_root_; |
94 std::unordered_map<int, UIElement*> node_id_to_ui_element_; | 110 std::unordered_map<int, UIElement*> node_id_to_ui_element_; |
95 std::unique_ptr<views::Widget> widget_for_highlighting_; | 111 std::unique_ptr<views::Widget> widget_for_highlighting_; |
96 std::vector<aura::Window*> root_windows_; | 112 std::vector<aura::Window*> root_windows_; |
97 base::ObserverList<UIDevToolsDOMAgentObserver> observers_; | 113 base::ObserverList<UIDevToolsDOMAgentObserver> observers_; |
98 | 114 |
99 DISALLOW_COPY_AND_ASSIGN(UIDevToolsDOMAgent); | 115 DISALLOW_COPY_AND_ASSIGN(UIDevToolsDOMAgent); |
100 }; | 116 }; |
101 | 117 |
102 } // namespace ui_devtools | 118 } // namespace ui_devtools |
103 | 119 |
104 #endif // COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_ | 120 #endif // COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_ |
OLD | NEW |