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

Side by Side Diff: ash/devtools/ash_devtools_dom_agent.h

Issue 2865713003: Remove ash dependency. (Closed)
Patch Set: nits Created 3 years, 6 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
« no previous file with comments | « no previous file | ash/devtools/ash_devtools_dom_agent.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ 5 #ifndef ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
6 #define ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ 6 #define ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/devtools/ui_element_delegate.h" 9 #include "ash/devtools/ui_element_delegate.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "components/ui_devtools/DOM.h" 11 #include "components/ui_devtools/DOM.h"
12 #include "components/ui_devtools/devtools_base_agent.h" 12 #include "components/ui_devtools/devtools_base_agent.h"
13 #include "ui/aura/env_observer.h"
13 #include "ui/views/view.h" 14 #include "ui/views/view.h"
14 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
15 16
16 namespace aura { 17 namespace aura {
17 class Window; 18 class Window;
18 } 19 }
19 20
20 namespace ash { 21 namespace ash {
21 namespace devtools { 22 namespace devtools {
22 23
23 class UIElement; 24 class UIElement;
24 25
25 class ASH_EXPORT AshDevToolsDOMAgentObserver { 26 class ASH_EXPORT AshDevToolsDOMAgentObserver {
26 public: 27 public:
27 // TODO(thanhph): Use UIElement* as input argument instead. 28 // TODO(thanhph): Use UIElement* as input argument instead.
28 virtual void OnNodeBoundsChanged(int node_id) = 0; 29 virtual void OnNodeBoundsChanged(int node_id) = 0;
29 }; 30 };
30 31
31 class ASH_EXPORT AshDevToolsDOMAgent 32 class ASH_EXPORT AshDevToolsDOMAgent
32 : public NON_EXPORTED_BASE(ui::devtools::UiDevToolsBaseAgent< 33 : public NON_EXPORTED_BASE(ui::devtools::UiDevToolsBaseAgent<
33 ui::devtools::protocol::DOM::Metainfo>), 34 ui::devtools::protocol::DOM::Metainfo>),
34 public UIElementDelegate { 35 public UIElementDelegate,
36 public aura::EnvObserver {
35 public: 37 public:
36 AshDevToolsDOMAgent(); 38 AshDevToolsDOMAgent();
37 ~AshDevToolsDOMAgent() override; 39 ~AshDevToolsDOMAgent() override;
38 40
39 // DOM::Backend: 41 // DOM::Backend:
40 ui::devtools::protocol::Response disable() override; 42 ui::devtools::protocol::Response disable() override;
41 ui::devtools::protocol::Response getDocument( 43 ui::devtools::protocol::Response getDocument(
42 std::unique_ptr<ui::devtools::protocol::DOM::Node>* out_root) override; 44 std::unique_ptr<ui::devtools::protocol::DOM::Node>* out_root) override;
43 ui::devtools::protocol::Response highlightNode( 45 ui::devtools::protocol::Response highlightNode(
44 std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig> 46 std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig>
45 highlight_config, 47 highlight_config,
46 ui::devtools::protocol::Maybe<int> node_id) override; 48 ui::devtools::protocol::Maybe<int> node_id) override;
47 ui::devtools::protocol::Response hideHighlight() override; 49 ui::devtools::protocol::Response hideHighlight() override;
48 50
49 // UIElementDelegate: 51 // UIElementDelegate:
50 void OnUIElementAdded(UIElement* parent, UIElement* child) override; 52 void OnUIElementAdded(UIElement* parent, UIElement* child) override;
51 void OnUIElementReordered(UIElement* parent, UIElement* child) override; 53 void OnUIElementReordered(UIElement* parent, UIElement* child) override;
52 void OnUIElementRemoved(UIElement* ui_element) override; 54 void OnUIElementRemoved(UIElement* ui_element) override;
53 void OnUIElementBoundsChanged(UIElement* ui_element) override; 55 void OnUIElementBoundsChanged(UIElement* ui_element) override;
54 bool IsHighlightingWindow(aura::Window* window) override; 56 bool IsHighlightingWindow(aura::Window* window) override;
55 57
56 void AddObserver(AshDevToolsDOMAgentObserver* observer); 58 void AddObserver(AshDevToolsDOMAgentObserver* observer);
57 void RemoveObserver(AshDevToolsDOMAgentObserver* observer); 59 void RemoveObserver(AshDevToolsDOMAgentObserver* observer);
58 UIElement* GetElementFromNodeId(int node_id); 60 UIElement* GetElementFromNodeId(int node_id);
59 UIElement* window_element_root() const { return window_element_root_.get(); }; 61 UIElement* window_element_root() const { return window_element_root_.get(); };
62 const std::vector<aura::Window*>& root_windows() const {
63 return root_windows_;
64 };
60 65
61 private: 66 private:
67 // aura::EnvObserver:
68 void OnWindowInitialized(aura::Window* window) override {}
69 void OnHostInitialized(aura::WindowTreeHost* host) override;
70
62 void OnNodeBoundsChanged(int node_id); 71 void OnNodeBoundsChanged(int node_id);
63
64 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildInitialTree(); 72 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildInitialTree();
65 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForUIElement( 73 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForUIElement(
66 UIElement* ui_element); 74 UIElement* ui_element);
67 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForWindow( 75 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForWindow(
68 UIElement* window_element_root, 76 UIElement* window_element_root,
69 aura::Window* window); 77 aura::Window* window);
70 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForRootWidget( 78 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForRootWidget(
71 UIElement* widget_element, 79 UIElement* widget_element,
72 views::Widget* widget); 80 views::Widget* widget);
73 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForView( 81 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForView(
74 UIElement* view_element, 82 UIElement* view_element,
75 views::View* view); 83 views::View* view);
76 void RemoveDomNode(UIElement* ui_element); 84 void RemoveDomNode(UIElement* ui_element);
77 void Reset(); 85 void Reset();
78 void InitializeHighlightingWidget(); 86 void InitializeHighlightingWidget();
79 void UpdateHighlight( 87 void UpdateHighlight(
80 const std::pair<aura::Window*, gfx::Rect>& window_and_bounds, 88 const std::pair<aura::Window*, gfx::Rect>& window_and_bounds,
81 SkColor background, 89 SkColor background,
82 SkColor border); 90 SkColor border);
83 ui::devtools::protocol::Response HighlightNode( 91 ui::devtools::protocol::Response HighlightNode(
84 std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig> 92 std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig>
85 highlight_config, 93 highlight_config,
86 int node_id); 94 int node_id);
87 95
88 bool is_building_tree_; 96 bool is_building_tree_;
89 std::unique_ptr<UIElement> window_element_root_; 97 std::unique_ptr<UIElement> window_element_root_;
90 std::unordered_map<int, UIElement*> node_id_to_ui_element_; 98 std::unordered_map<int, UIElement*> node_id_to_ui_element_;
91 std::unique_ptr<views::Widget> widget_for_highlighting_; 99 std::unique_ptr<views::Widget> widget_for_highlighting_;
100 std::vector<aura::Window*> root_windows_;
92 base::ObserverList<AshDevToolsDOMAgentObserver> observers_; 101 base::ObserverList<AshDevToolsDOMAgentObserver> observers_;
93 102
94 DISALLOW_COPY_AND_ASSIGN(AshDevToolsDOMAgent); 103 DISALLOW_COPY_AND_ASSIGN(AshDevToolsDOMAgent);
95 }; 104 };
96 105
97 } // namespace devtools 106 } // namespace devtools
98 } // namespace ash 107 } // namespace ash
99 108
100 #endif // ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ 109 #endif // ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
OLDNEW
« no previous file with comments | « no previous file | ash/devtools/ash_devtools_dom_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698