| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "view_manager/public/cpp/view.h" | 5 #include "view_manager/public/cpp/view.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/application/service_provider_impl.h" | 10 #include "mojo/public/cpp/application/service_provider_impl.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 OrderDirection direction) { | 122 OrderDirection direction) { |
| 123 DCHECK(relative); | 123 DCHECK(relative); |
| 124 DCHECK_NE(view, relative); | 124 DCHECK_NE(view, relative); |
| 125 DCHECK_EQ(view->parent(), relative->parent()); | 125 DCHECK_EQ(view->parent(), relative->parent()); |
| 126 | 126 |
| 127 const size_t child_i = | 127 const size_t child_i = |
| 128 std::find(children->begin(), children->end(), view) - children->begin(); | 128 std::find(children->begin(), children->end(), view) - children->begin(); |
| 129 const size_t target_i = | 129 const size_t target_i = |
| 130 std::find(children->begin(), children->end(), relative) - | 130 std::find(children->begin(), children->end(), relative) - |
| 131 children->begin(); | 131 children->begin(); |
| 132 if ((direction == ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || | 132 if ((direction == OrderDirection::ABOVE && child_i == target_i + 1) || |
| 133 (direction == ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { | 133 (direction == OrderDirection::BELOW && child_i + 1 == target_i)) { |
| 134 return false; | 134 return false; |
| 135 } | 135 } |
| 136 | 136 |
| 137 ScopedOrderChangedNotifier notifier(view, relative, direction); | 137 ScopedOrderChangedNotifier notifier(view, relative, direction); |
| 138 | 138 |
| 139 const size_t dest_i = direction == ORDER_DIRECTION_ABOVE | 139 const size_t dest_i = direction == OrderDirection::ABOVE |
| 140 ? (child_i < target_i ? target_i : target_i + 1) | 140 ? (child_i < target_i ? target_i : target_i + 1) |
| 141 : (child_i < target_i ? target_i - 1 : target_i); | 141 : (child_i < target_i ? target_i - 1 : target_i); |
| 142 children->erase(children->begin() + child_i); | 142 children->erase(children->begin() + child_i); |
| 143 children->insert(children->begin() + dest_i, view); | 143 children->insert(children->begin() + dest_i, view); |
| 144 | 144 |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 | 147 |
| 148 class ScopedSetBoundsNotifier { | 148 class ScopedSetBoundsNotifier { |
| 149 public: | 149 public: |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 LocalRemoveChild(child); | 302 LocalRemoveChild(child); |
| 303 if (manager_) { | 303 if (manager_) { |
| 304 static_cast<ViewManagerClientImpl*>(manager_)->RemoveChild(child->id(), | 304 static_cast<ViewManagerClientImpl*>(manager_)->RemoveChild(child->id(), |
| 305 id_); | 305 id_); |
| 306 } | 306 } |
| 307 } | 307 } |
| 308 | 308 |
| 309 void View::MoveToFront() { | 309 void View::MoveToFront() { |
| 310 if (!parent_ || parent_->children_.back() == this) | 310 if (!parent_ || parent_->children_.back() == this) |
| 311 return; | 311 return; |
| 312 Reorder(parent_->children_.back(), ORDER_DIRECTION_ABOVE); | 312 Reorder(parent_->children_.back(), OrderDirection::ABOVE); |
| 313 } | 313 } |
| 314 | 314 |
| 315 void View::MoveToBack() { | 315 void View::MoveToBack() { |
| 316 if (!parent_ || parent_->children_.front() == this) | 316 if (!parent_ || parent_->children_.front() == this) |
| 317 return; | 317 return; |
| 318 Reorder(parent_->children_.front(), ORDER_DIRECTION_BELOW); | 318 Reorder(parent_->children_.front(), OrderDirection::BELOW); |
| 319 } | 319 } |
| 320 | 320 |
| 321 void View::Reorder(View* relative, OrderDirection direction) { | 321 void View::Reorder(View* relative, OrderDirection direction) { |
| 322 if (!LocalReorder(relative, direction)) | 322 if (!LocalReorder(relative, direction)) |
| 323 return; | 323 return; |
| 324 if (manager_) { | 324 if (manager_) { |
| 325 static_cast<ViewManagerClientImpl*>(manager_)->Reorder(id_, | 325 static_cast<ViewManagerClientImpl*>(manager_)->Reorder(id_, |
| 326 relative->id(), | 326 relative->id(), |
| 327 direction); | 327 direction); |
| 328 } | 328 } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 bool View::PrepareForEmbed() { | 593 bool View::PrepareForEmbed() { |
| 594 if (!OwnsView(manager_, this)) | 594 if (!OwnsView(manager_, this)) |
| 595 return false; | 595 return false; |
| 596 | 596 |
| 597 while (!children_.empty()) | 597 while (!children_.empty()) |
| 598 RemoveChild(children_[0]); | 598 RemoveChild(children_[0]); |
| 599 return true; | 599 return true; |
| 600 } | 600 } |
| 601 | 601 |
| 602 } // namespace mojo | 602 } // namespace mojo |
| OLD | NEW |