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

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: rebase 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
37 private: 43 private:
44 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForView(
45 views::View* view);
46 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForRootWidget(
47 views::Widget* widget);
38 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForWindow( 48 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForWindow(
39 WmWindow* window); 49 WmWindow* window);
40 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildInitialTree(); 50 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildInitialTree();
41 void AddWindowNode(WmWindow* window); 51 void AddWindowNode(WmWindow* window);
42 void RemoveWindowNode(WmWindow* window, WmWindow* old_parent); 52 void RemoveWindowNode(WmWindow* window, WmWindow* old_parent);
43 void RemoveObserverFromAllWindows(); 53 void RemoveObserverFromAllWindows();
44 void AddRootWindowObservers(); 54 void AddRootWindowObservers();
45 void Reset(); 55 void Reset();
46 56
47 ash::WmShell* shell_; 57 ash::WmShell* shell_;
48 58
49 using WindowToNodeIdMap = std::unordered_map<WmWindow*, int>; 59 using WindowToNodeIdMap = std::unordered_map<WmWindow*, int>;
50 WindowToNodeIdMap window_to_node_id_map_; 60 WindowToNodeIdMap window_to_node_id_map_;
51 61
62 std::unordered_map<int, WmWindow*> node_id_to_window_map_;
63 std::unordered_map<int, views::Widget*> node_id_to_widget_map_;
64 std::unordered_map<int, views::View*> node_id_to_view_map_;
65
52 DISALLOW_COPY_AND_ASSIGN(AshDevToolsDOMAgent); 66 DISALLOW_COPY_AND_ASSIGN(AshDevToolsDOMAgent);
53 }; 67 };
54 68
55 } // namespace devtools 69 } // namespace devtools
56 } // namespace ash 70 } // namespace ash
57 71
58 #endif // ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ 72 #endif // ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698