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

Unified Diff: ash/common/devtools/ash_devtools_dom_agent.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/devtools/ash_devtools_dom_agent.h ('k') | ash/common/wm_shell.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/devtools/ash_devtools_dom_agent.cc
diff --git a/ash/common/devtools/ash_devtools_dom_agent.cc b/ash/common/devtools/ash_devtools_dom_agent.cc
index 1741ab306080d8adf40abb8982cca178f815b762..40a1a6cd95267afe6c153eac2b90e08125ef7ece 100644
--- a/ash/common/devtools/ash_devtools_dom_agent.cc
+++ b/ash/common/devtools/ash_devtools_dom_agent.cc
@@ -6,8 +6,6 @@
#include "ash/common/wm_window.h"
#include "components/ui_devtools/devtools_server.h"
-#include "ui/views/view.h"
-#include "ui/views/widget/widget.h"
namespace ash {
namespace devtools {
@@ -57,19 +55,6 @@ std::unique_ptr<Array<std::string>> GetAttributes(const views::View* view) {
return attributes;
}
-std::unique_ptr<DOM::Node> BuildTreeForView(views::View* view) {
- std::unique_ptr<Array<DOM::Node>> children = Array<DOM::Node>::create();
- for (int i = 0, count = view->child_count(); i < count; i++) {
- children->addItem(BuildTreeForView(view->child_at(i)));
- }
- return BuildNode("View", GetAttributes(view), std::move(children));
-}
-
-std::unique_ptr<DOM::Node> BuildTreeForRootWidget(views::Widget* widget) {
- std::unique_ptr<Array<DOM::Node>> children = Array<DOM::Node>::create();
- children->addItem(BuildTreeForView(widget->GetRootView()));
- return BuildNode("Widget", GetAttributes(widget), std::move(children));
-}
WmWindow* FindPreviousSibling(WmWindow* window) {
std::vector<WmWindow*> siblings = window->GetParent()->GetChildren();
@@ -131,6 +116,43 @@ void AshDevToolsDOMAgent::OnWindowStackingChanged(WmWindow* window) {
AddWindowNode(window);
}
+WmWindow* AshDevToolsDOMAgent::GetWindowFromNodeId(int nodeId) {
+ return node_id_to_window_map_.count(nodeId) ? node_id_to_window_map_[nodeId]
+ : nullptr;
+}
+
+views::Widget* AshDevToolsDOMAgent::GetWidgetFromNodeId(int nodeId) {
+ return node_id_to_widget_map_.count(nodeId) ? node_id_to_widget_map_[nodeId]
+ : nullptr;
+}
+
+views::View* AshDevToolsDOMAgent::GetViewFromNodeId(int nodeId) {
+ return node_id_to_view_map_.count(nodeId) ? node_id_to_view_map_[nodeId]
+ : nullptr;
+}
+
+std::unique_ptr<DOM::Node> AshDevToolsDOMAgent::BuildTreeForView(
+ views::View* view) {
+ std::unique_ptr<Array<DOM::Node>> children = Array<DOM::Node>::create();
+ for (int i = 0, count = view->child_count(); i < count; i++) {
+ children->addItem(BuildTreeForView(view->child_at(i)));
+ }
+ std::unique_ptr<ui::devtools::protocol::DOM::Node> node =
+ BuildNode("View", GetAttributes(view), std::move(children));
+ node_id_to_view_map_[node->getNodeId()] = view;
+ return node;
+}
+
+std::unique_ptr<DOM::Node> AshDevToolsDOMAgent::BuildTreeForRootWidget(
+ views::Widget* widget) {
+ std::unique_ptr<Array<DOM::Node>> children = Array<DOM::Node>::create();
+ children->addItem(BuildTreeForView(widget->GetRootView()));
+ std::unique_ptr<ui::devtools::protocol::DOM::Node> node =
+ BuildNode("Widget", GetAttributes(widget), std::move(children));
+ node_id_to_widget_map_[node->getNodeId()] = widget;
+ return node;
+}
+
std::unique_ptr<DOM::Node> AshDevToolsDOMAgent::BuildTreeForWindow(
ash::WmWindow* window) {
std::unique_ptr<Array<DOM::Node>> children = Array<DOM::Node>::create();
@@ -146,6 +168,7 @@ std::unique_ptr<DOM::Node> AshDevToolsDOMAgent::BuildTreeForWindow(
if (!window_to_node_id_map_.count(window))
window->AddObserver(this);
window_to_node_id_map_[window] = node->getNodeId();
+ node_id_to_window_map_[node->getNodeId()] = window;
return node;
}
@@ -193,6 +216,9 @@ void AshDevToolsDOMAgent::RemoveObserverFromAllWindows() {
void AshDevToolsDOMAgent::Reset() {
RemoveObserverFromAllWindows();
window_to_node_id_map_.clear();
+ node_id_to_window_map_.clear();
+ node_id_to_widget_map_.clear();
+ node_id_to_view_map_.clear();
node_ids = 1;
}
« no previous file with comments | « ash/common/devtools/ash_devtools_dom_agent.h ('k') | ash/common/wm_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698