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

Unified Diff: ash/devtools/ash_devtools_dom_agent.cc

Issue 2865713003: Remove ash dependency. (Closed)
Patch Set: nits Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/devtools/ash_devtools_dom_agent.h ('k') | ash/devtools/ash_devtools_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/devtools/ash_devtools_dom_agent.cc
diff --git a/ash/devtools/ash_devtools_dom_agent.cc b/ash/devtools/ash_devtools_dom_agent.cc
index 3a6831a8e2e25ea8073ea354302fe3a99dd1cda3..ce290b5e49e1e0a577e598ec162d5872321cead4 100644
--- a/ash/devtools/ash_devtools_dom_agent.cc
+++ b/ash/devtools/ash_devtools_dom_agent.cc
@@ -9,12 +9,14 @@
#include "ash/devtools/widget_element.h"
#include "ash/devtools/window_element.h"
#include "ash/public/cpp/shell_window_ids.h"
-#include "ash/root_window_controller.h"
-#include "ash/shell.h"
#include "components/ui_devtools/devtools_server.h"
#include "third_party/skia/include/core/SkColor.h"
+#include "ui/aura/client/screen_position_client.h"
+#include "ui/aura/env.h"
#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host.h"
#include "ui/display/display.h"
+#include "ui/display/screen.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/view.h"
@@ -116,9 +118,12 @@ std::unique_ptr<DOM::Node> BuildDomNodeFromUIElement(UIElement* root) {
} // namespace
-AshDevToolsDOMAgent::AshDevToolsDOMAgent() : is_building_tree_(false) {}
+AshDevToolsDOMAgent::AshDevToolsDOMAgent() : is_building_tree_(false) {
+ aura::Env::GetInstance()->AddObserver(this);
+}
AshDevToolsDOMAgent::~AshDevToolsDOMAgent() {
+ aura::Env::GetInstance()->RemoveObserver(this);
Reset();
}
@@ -209,6 +214,10 @@ UIElement* AshDevToolsDOMAgent::GetElementFromNodeId(int node_id) {
return node_id_to_ui_element_[node_id];
}
+void AshDevToolsDOMAgent::OnHostInitialized(aura::WindowTreeHost* host) {
+ root_windows_.push_back(host->window());
+}
+
void AshDevToolsDOMAgent::OnNodeBoundsChanged(int node_id) {
for (auto& observer : observers_)
observer.OnNodeBoundsChanged(node_id);
@@ -224,7 +233,7 @@ AshDevToolsDOMAgent::BuildInitialTree() {
window_element_root_ =
base::MakeUnique<WindowElement>(nullptr, this, nullptr);
- for (aura::Window* window : Shell::GetAllRootWindows()) {
+ for (aura::Window* window : root_windows()) {
UIElement* window_element =
new WindowElement(window, this, window_element_root_.get());
@@ -338,10 +347,6 @@ void AshDevToolsDOMAgent::InitializeHighlightingWidget() {
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.opacity = views::Widget::InitParams::WindowOpacity::TRANSLUCENT_WINDOW;
params.name = "HighlightingWidget";
- Shell::GetPrimaryRootWindowController()
- ->ConfigureWidgetInitParamsForContainer(widget_for_highlighting_.get(),
- kShellWindowId_OverlayContainer,
- &params);
params.keep_on_top = true;
params.accept_events = false;
widget_for_highlighting_->Init(params);
@@ -359,8 +364,18 @@ void AshDevToolsDOMAgent::UpdateHighlight(
display::Display display =
display::Screen::GetScreen()->GetDisplayNearestWindow(
window_and_bounds.first);
- widget_for_highlighting_->GetNativeWindow()->SetBoundsInScreen(
- window_and_bounds.second, display);
+ aura::Window* root = window_and_bounds.first->GetRootWindow();
+ if (root != widget_for_highlighting_->GetNativeWindow()->GetRootWindow())
+ root->AddChild(widget_for_highlighting_->GetNativeWindow());
+
+ aura::client::ScreenPositionClient* screen_position_client =
+ aura::client::GetScreenPositionClient(root);
+
+ gfx::Rect bounds(window_and_bounds.second);
+ gfx::Point origin = bounds.origin();
+ screen_position_client->ConvertPointFromScreen(root, &origin);
+ bounds.set_origin(origin);
+ widget_for_highlighting_->GetNativeWindow()->SetBounds(bounds);
}
ui::devtools::protocol::Response AshDevToolsDOMAgent::HighlightNode(
« no previous file with comments | « ash/devtools/ash_devtools_dom_agent.h ('k') | ash/devtools/ash_devtools_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698