OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ui_element.h" | 5 #include "components/ui_devtools/views/ui_element.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/devtools/ui_element_delegate.h" | 9 #include "components/ui_devtools/views/ui_element_delegate.h" |
10 #include "ash/devtools/view_element.h" | 10 #include "components/ui_devtools/views/view_element.h" |
11 #include "ash/devtools/widget_element.h" | 11 #include "components/ui_devtools/views/widget_element.h" |
12 #include "ash/devtools/window_element.h" | 12 #include "components/ui_devtools/views/window_element.h" |
13 | 13 |
14 namespace ash { | 14 namespace ui { |
15 namespace devtools { | 15 namespace devtools { |
16 namespace { | 16 namespace { |
17 | 17 |
18 static int node_ids = 0; | 18 static int node_ids = 0; |
19 | 19 |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 UIElement::~UIElement() { | 22 UIElement::~UIElement() { |
23 for (auto* child : children_) | 23 for (auto* child : children_) |
24 delete child; | 24 delete child; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 children_.erase(iter); | 56 children_.erase(iter); |
57 } | 57 } |
58 | 58 |
59 void UIElement::ReorderChild(UIElement* child, int new_index) { | 59 void UIElement::ReorderChild(UIElement* child, int new_index) { |
60 // Remove |child| out of vector |children_|. | 60 // Remove |child| out of vector |children_|. |
61 auto iter = std::find(children_.begin(), children_.end(), child); | 61 auto iter = std::find(children_.begin(), children_.end(), child); |
62 DCHECK(iter != children_.end()); | 62 DCHECK(iter != children_.end()); |
63 children_.erase(iter); | 63 children_.erase(iter); |
64 | 64 |
65 // Move child to new position |new_index| in vector |children_|. | 65 // Move child to new position |new_index| in vector |children_|. |
66 new_index = std::min(children_.size() - 1, static_cast<size_t>(new_index)); | 66 new_index = std::min(static_cast<int>(children_.size()) - 1, new_index); |
67 iter = children_.begin() + new_index; | 67 iter = children_.begin() + new_index; |
68 children_.insert(iter, child); | 68 children_.insert(iter, child); |
69 delegate()->OnUIElementReordered(child->parent(), child); | 69 delegate()->OnUIElementReordered(child->parent(), child); |
70 } | 70 } |
71 | 71 |
72 UIElement::UIElement(const UIElementType type, | 72 UIElement::UIElement(const UIElementType type, |
73 UIElementDelegate* delegate, | 73 UIElementDelegate* delegate, |
74 UIElement* parent) | 74 UIElement* parent) |
75 : node_id_(++node_ids), type_(type), parent_(parent), delegate_(delegate) { | 75 : node_id_(++node_ids), type_(type), parent_(parent), delegate_(delegate) { |
76 delegate_->OnUIElementAdded(0, this); | 76 delegate_->OnUIElementAdded(0, this); |
77 } | 77 } |
78 | 78 |
79 } // namespace devtools | 79 } // namespace devtools |
80 } // namespace ash | 80 } // namespace ui |
OLD | NEW |