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/Overlay.h" |
9 #include "components/ui_devtools/devtools_base_agent.h" | 10 #include "components/ui_devtools/devtools_base_agent.h" |
10 #include "components/ui_devtools/views/ui_element_delegate.h" | 11 #include "components/ui_devtools/views/ui_element_delegate.h" |
11 #include "ui/aura/env_observer.h" | 12 #include "ui/aura/env_observer.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 |
(...skipping 12 matching lines...) Expand all Loading... |
31 public UIElementDelegate, | 32 public UIElementDelegate, |
32 public aura::EnvObserver { | 33 public aura::EnvObserver { |
33 public: | 34 public: |
34 UIDevToolsDOMAgent(); | 35 UIDevToolsDOMAgent(); |
35 ~UIDevToolsDOMAgent() override; | 36 ~UIDevToolsDOMAgent() override; |
36 | 37 |
37 // DOM::Backend: | 38 // DOM::Backend: |
38 ui_devtools::protocol::Response disable() override; | 39 ui_devtools::protocol::Response disable() override; |
39 ui_devtools::protocol::Response getDocument( | 40 ui_devtools::protocol::Response getDocument( |
40 std::unique_ptr<ui_devtools::protocol::DOM::Node>* out_root) override; | 41 std::unique_ptr<ui_devtools::protocol::DOM::Node>* out_root) override; |
41 ui_devtools::protocol::Response highlightNode( | |
42 std::unique_ptr<ui_devtools::protocol::DOM::HighlightConfig> | |
43 highlight_config, | |
44 ui_devtools::protocol::Maybe<int> node_id) override; | |
45 ui_devtools::protocol::Response hideHighlight() override; | 42 ui_devtools::protocol::Response hideHighlight() override; |
| 43 ui_devtools::protocol::Response pushNodesByBackendIdsToFrontend( |
| 44 std::unique_ptr<protocol::Array<int>> backend_node_ids, |
| 45 std::unique_ptr<protocol::Array<int>>* result) override; |
| 46 ui_devtools::protocol::Response setInspectedNode(int node_id) override; |
46 | 47 |
47 // UIElementDelegate: | 48 // UIElementDelegate: |
48 void OnUIElementAdded(UIElement* parent, UIElement* child) override; | 49 void OnUIElementAdded(UIElement* parent, UIElement* child) override; |
49 void OnUIElementReordered(UIElement* parent, UIElement* child) override; | 50 void OnUIElementReordered(UIElement* parent, UIElement* child) override; |
50 void OnUIElementRemoved(UIElement* ui_element) override; | 51 void OnUIElementRemoved(UIElement* ui_element) override; |
51 void OnUIElementBoundsChanged(UIElement* ui_element) override; | 52 void OnUIElementBoundsChanged(UIElement* ui_element) override; |
52 | 53 |
53 void AddObserver(UIDevToolsDOMAgentObserver* observer); | 54 void AddObserver(UIDevToolsDOMAgentObserver* observer); |
54 void RemoveObserver(UIDevToolsDOMAgentObserver* observer); | 55 void RemoveObserver(UIDevToolsDOMAgentObserver* observer); |
55 UIElement* GetElementFromNodeId(int node_id); | 56 UIElement* GetElementFromNodeId(int node_id); |
56 UIElement* window_element_root() const { return window_element_root_.get(); }; | 57 UIElement* window_element_root() const { return window_element_root_.get(); }; |
57 const std::vector<aura::Window*>& root_windows() const { | 58 const std::vector<aura::Window*>& root_windows() const { |
58 return root_windows_; | 59 return root_windows_; |
59 }; | 60 }; |
| 61 ui_devtools::protocol::Response HighlightNode( |
| 62 std::unique_ptr<ui_devtools::protocol::Overlay::HighlightConfig> |
| 63 highlight_config, |
| 64 int node_id); |
| 65 void FindElementByEventHandler(const gfx::Point& p, int* element_id); |
60 | 66 |
61 private: | 67 private: |
62 // aura::EnvObserver: | 68 // aura::EnvObserver: |
63 void OnWindowInitialized(aura::Window* window) override {} | 69 void OnWindowInitialized(aura::Window* window) override {} |
64 void OnHostInitialized(aura::WindowTreeHost* host) override; | 70 void OnHostInitialized(aura::WindowTreeHost* host) override; |
65 | 71 |
66 void OnNodeBoundsChanged(int node_id); | 72 void OnNodeBoundsChanged(int node_id); |
67 std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildInitialTree(); | 73 std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildInitialTree(); |
68 std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForUIElement( | 74 std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForUIElement( |
69 UIElement* ui_element); | 75 UIElement* ui_element); |
70 std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForWindow( | 76 std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForWindow( |
71 UIElement* window_element_root, | 77 UIElement* window_element_root, |
72 aura::Window* window); | 78 aura::Window* window); |
73 std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForRootWidget( | 79 std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForRootWidget( |
74 UIElement* widget_element, | 80 UIElement* widget_element, |
75 views::Widget* widget); | 81 views::Widget* widget); |
76 std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForView( | 82 std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForView( |
77 UIElement* view_element, | 83 UIElement* view_element, |
78 views::View* view); | 84 views::View* view); |
79 void RemoveDomNode(UIElement* ui_element); | 85 void RemoveDomNode(UIElement* ui_element); |
80 void Reset(); | 86 void Reset(); |
81 void InitializeHighlightingWidget(); | |
82 void UpdateHighlight( | 87 void UpdateHighlight( |
83 const std::pair<aura::Window*, gfx::Rect>& window_and_bounds, | 88 const std::pair<aura::Window*, gfx::Rect>& window_and_bounds, |
84 SkColor background); | 89 SkColor background); |
85 ui_devtools::protocol::Response HighlightNode( | |
86 std::unique_ptr<ui_devtools::protocol::DOM::HighlightConfig> | |
87 highlight_config, | |
88 int node_id); | |
89 | 90 |
90 bool is_building_tree_; | 91 bool is_building_tree_; |
91 std::unique_ptr<UIElement> window_element_root_; | 92 std::unique_ptr<UIElement> window_element_root_; |
92 std::unordered_map<int, UIElement*> node_id_to_ui_element_; | 93 std::unordered_map<int, UIElement*> node_id_to_ui_element_; |
93 std::unique_ptr<ui::Layer> layer_for_highlighting_; | 94 std::unique_ptr<ui::Layer> layer_for_highlighting_; |
94 std::vector<aura::Window*> root_windows_; | 95 std::vector<aura::Window*> root_windows_; |
95 base::ObserverList<UIDevToolsDOMAgentObserver> observers_; | 96 base::ObserverList<UIDevToolsDOMAgentObserver> observers_; |
96 | 97 |
97 DISALLOW_COPY_AND_ASSIGN(UIDevToolsDOMAgent); | 98 DISALLOW_COPY_AND_ASSIGN(UIDevToolsDOMAgent); |
98 }; | 99 }; |
99 | 100 |
100 } // namespace ui_devtools | 101 } // namespace ui_devtools |
101 | 102 |
102 #endif // COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_ | 103 #endif // COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_ |
OLD | NEW |