| OLD | NEW |
| 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 #include "ash/devtools/ash_devtools_dom_agent.h" | 5 #include "ash/devtools/ash_devtools_dom_agent.h" |
| 6 | 6 |
| 7 #include "ash/devtools/ui_element.h" | 7 #include "ash/devtools/ui_element.h" |
| 8 #include "ash/devtools/view_element.h" | 8 #include "ash/devtools/view_element.h" |
| 9 #include "ash/devtools/widget_element.h" | 9 #include "ash/devtools/widget_element.h" |
| 10 #include "ash/devtools/window_element.h" | 10 #include "ash/devtools/window_element.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 observer.OnNodeBoundsChanged(node_id); | 214 observer.OnNodeBoundsChanged(node_id); |
| 215 } | 215 } |
| 216 | 216 |
| 217 std::unique_ptr<ui::devtools::protocol::DOM::Node> | 217 std::unique_ptr<ui::devtools::protocol::DOM::Node> |
| 218 AshDevToolsDOMAgent::BuildInitialTree() { | 218 AshDevToolsDOMAgent::BuildInitialTree() { |
| 219 is_building_tree_ = true; | 219 is_building_tree_ = true; |
| 220 std::unique_ptr<Array<DOM::Node>> children = Array<DOM::Node>::create(); | 220 std::unique_ptr<Array<DOM::Node>> children = Array<DOM::Node>::create(); |
| 221 | 221 |
| 222 // TODO(thanhph): Root of UIElement tree shoudn't be WindowElement | 222 // TODO(thanhph): Root of UIElement tree shoudn't be WindowElement |
| 223 // but maybe a new different element type. | 223 // but maybe a new different element type. |
| 224 window_element_root_ = new WindowElement(nullptr, this, nullptr); | 224 window_element_root_ = |
| 225 base::MakeUnique<WindowElement>(nullptr, this, nullptr); |
| 225 | 226 |
| 226 for (aura::Window* window : Shell::GetAllRootWindows()) { | 227 for (aura::Window* window : Shell::GetAllRootWindows()) { |
| 227 UIElement* window_element = | 228 UIElement* window_element = |
| 228 new WindowElement(window, this, window_element_root_); | 229 new WindowElement(window, this, window_element_root_.get()); |
| 229 | 230 |
| 230 children->addItem(BuildTreeForUIElement(window_element)); | 231 children->addItem(BuildTreeForUIElement(window_element)); |
| 231 window_element_root_->AddChild(window_element); | 232 window_element_root_->AddChild(window_element); |
| 232 } | 233 } |
| 233 std::unique_ptr<ui::devtools::protocol::DOM::Node> root_node = BuildNode( | 234 std::unique_ptr<ui::devtools::protocol::DOM::Node> root_node = BuildNode( |
| 234 "root", nullptr, std::move(children), window_element_root_->node_id()); | 235 "root", nullptr, std::move(children), window_element_root_->node_id()); |
| 235 is_building_tree_ = false; | 236 is_building_tree_ = false; |
| 236 return root_node; | 237 return root_node; |
| 237 } | 238 } |
| 238 | 239 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 void AshDevToolsDOMAgent::RemoveDomNode(UIElement* ui_element) { | 317 void AshDevToolsDOMAgent::RemoveDomNode(UIElement* ui_element) { |
| 317 for (auto* child_element : ui_element->children()) | 318 for (auto* child_element : ui_element->children()) |
| 318 RemoveDomNode(child_element); | 319 RemoveDomNode(child_element); |
| 319 frontend()->childNodeRemoved(ui_element->parent()->node_id(), | 320 frontend()->childNodeRemoved(ui_element->parent()->node_id(), |
| 320 ui_element->node_id()); | 321 ui_element->node_id()); |
| 321 } | 322 } |
| 322 | 323 |
| 323 void AshDevToolsDOMAgent::Reset() { | 324 void AshDevToolsDOMAgent::Reset() { |
| 324 is_building_tree_ = false; | 325 is_building_tree_ = false; |
| 325 widget_for_highlighting_.reset(); | 326 widget_for_highlighting_.reset(); |
| 326 delete window_element_root_; | 327 window_element_root_.reset(); |
| 327 node_id_to_ui_element_.clear(); | 328 node_id_to_ui_element_.clear(); |
| 328 observers_.Clear(); | 329 observers_.Clear(); |
| 329 } | 330 } |
| 330 | 331 |
| 331 void AshDevToolsDOMAgent::InitializeHighlightingWidget() { | 332 void AshDevToolsDOMAgent::InitializeHighlightingWidget() { |
| 332 DCHECK(!widget_for_highlighting_); | 333 DCHECK(!widget_for_highlighting_); |
| 333 widget_for_highlighting_.reset(new views::Widget); | 334 widget_for_highlighting_.reset(new views::Widget); |
| 334 views::Widget::InitParams params; | 335 views::Widget::InitParams params; |
| 335 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; | 336 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; |
| 336 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; | 337 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 UpdateHighlight(window_and_bounds, content_color, border_color); | 386 UpdateHighlight(window_and_bounds, content_color, border_color); |
| 386 | 387 |
| 387 if (!widget_for_highlighting_->IsVisible()) | 388 if (!widget_for_highlighting_->IsVisible()) |
| 388 widget_for_highlighting_->Show(); | 389 widget_for_highlighting_->Show(); |
| 389 | 390 |
| 390 return ui::devtools::protocol::Response::OK(); | 391 return ui::devtools::protocol::Response::OK(); |
| 391 } | 392 } |
| 392 | 393 |
| 393 } // namespace devtools | 394 } // namespace devtools |
| 394 } // namespace ash | 395 } // namespace ash |
| OLD | NEW |