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

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

Issue 2486543003: Add CSS agent for various window/widget/view attributes in devtools (Closed)
Patch Set: sadruls comments Created 4 years, 1 month 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
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_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ 5 #ifndef ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
6 #define ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ 6 #define ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
7 7
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "ash/common/wm_window_observer.h" 9 #include "ash/common/wm_window_observer.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.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/views/view.h"
14 #include "ui/views/widget/widget.h"
13 15
14 namespace ash { 16 namespace ash {
15 namespace devtools { 17 namespace devtools {
16 18
17 class ASH_EXPORT AshDevToolsDOMAgent 19 class ASH_EXPORT AshDevToolsDOMAgent
18 : public NON_EXPORTED_BASE(ui::devtools::UiDevToolsBaseAgent< 20 : public NON_EXPORTED_BASE(ui::devtools::UiDevToolsBaseAgent<
19 ui::devtools::protocol::DOM::Metainfo>), 21 ui::devtools::protocol::DOM::Metainfo>),
20 public WmWindowObserver { 22 public WmWindowObserver {
21 public: 23 public:
22 explicit AshDevToolsDOMAgent(ash::WmShell* shell); 24 explicit AshDevToolsDOMAgent(ash::WmShell* shell);
23 ~AshDevToolsDOMAgent() override; 25 ~AshDevToolsDOMAgent() override;
24 26
25 // DOM::Backend 27 // DOM::Backend
26 ui::devtools::protocol::Response disable() override; 28 ui::devtools::protocol::Response disable() override;
27 ui::devtools::protocol::Response getDocument( 29 ui::devtools::protocol::Response getDocument(
28 std::unique_ptr<ui::devtools::protocol::DOM::Node>* out_root) override; 30 std::unique_ptr<ui::devtools::protocol::DOM::Node>* out_root) override;
29 31
30 // WindowObserver 32 // WindowObserver
31 void OnWindowTreeChanging(WmWindow* window, 33 void OnWindowTreeChanging(WmWindow* window,
32 const TreeChangeParams& params) override; 34 const TreeChangeParams& params) override;
33 void OnWindowTreeChanged(WmWindow* window, 35 void OnWindowTreeChanged(WmWindow* window,
34 const TreeChangeParams& params) override; 36 const TreeChangeParams& params) override;
35 void OnWindowStackingChanged(WmWindow* window) override; 37 void OnWindowStackingChanged(WmWindow* window) override;
36 38
39 WmWindow* GetWindowFromNodeId(int nodeId);
40 views::Widget* GetWidgetFromNodeId(int nodeId);
41 views::View* GetViewFromNodeId(int nodeId);
42
43 int GetNodeIdFromWindow(WmWindow* window);
44 int GetNodeIdFromWidget(views::Widget* widget);
45 int GetNodeIdFromView(views::View* view);
46
37 private: 47 private:
48 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForView(
49 views::View* view);
50 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForRootWidget(
51 views::Widget* widget);
38 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForWindow( 52 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForWindow(
39 WmWindow* window); 53 WmWindow* window);
40 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildInitialTree(); 54 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildInitialTree();
41 void AddWindowNode(WmWindow* window); 55 void AddWindowNode(WmWindow* window);
42 void RemoveWindowNode(WmWindow* window); 56 void RemoveWindowNode(WmWindow* window);
57 void RemoveWidgetNode(views::Widget* widget);
58 void RemoveViewNode(views::View* view);
43 void RemoveObserverFromAllWindows(); 59 void RemoveObserverFromAllWindows();
44 void AddRootWindowObservers(); 60 void AddRootWindowObservers();
45 void Reset(); 61 void Reset();
46 62
47 ash::WmShell* shell_; 63 ash::WmShell* shell_;
48 64
49 using WindowToNodeIdMap = std::unordered_map<WmWindow*, int>; 65 using WindowToNodeIdMap = std::unordered_map<WmWindow*, int>;
50 WindowToNodeIdMap window_to_node_id_map_; 66 WindowToNodeIdMap window_to_node_id_map_;
67 using NodeIdToWindowMap = std::unordered_map<int, WmWindow*>;
68 NodeIdToWindowMap node_id_to_window_map_;
69
70 using WidgetToNodeIdMap = std::unordered_map<views::Widget*, int>;
71 WidgetToNodeIdMap widget_to_node_id_map_;
72 using NodeIdToWidgetMap = std::unordered_map<int, views::Widget*>;
73 NodeIdToWidgetMap node_id_to_widget_map_;
74
75 using ViewToNodeIdMap = std::unordered_map<views::View*, int>;
76 ViewToNodeIdMap view_to_node_id_map_;
77 using NodeIdToViewMap = std::unordered_map<int, views::View*>;
78 NodeIdToViewMap node_id_to_view_map_;
51 79
52 DISALLOW_COPY_AND_ASSIGN(AshDevToolsDOMAgent); 80 DISALLOW_COPY_AND_ASSIGN(AshDevToolsDOMAgent);
53 }; 81 };
54 82
55 } // namespace devtools 83 } // namespace devtools
56 } // namespace ash 84 } // namespace ash
57 85
58 #endif // ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ 86 #endif // ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
OLDNEW
« no previous file with comments | « ash/common/devtools/ash_devtools_css_agent.cc ('k') | ash/common/devtools/ash_devtools_dom_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698