| 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 "services/view_manager/server_view.h" | 5 #include "services/view_manager/server_view.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "services/view_manager/server_view_delegate.h" | 10 #include "services/view_manager/server_view_delegate.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ServerView::Add(ServerView* child) { | 49 void ServerView::Add(ServerView* child) { |
| 50 // We assume validation checks happened already. | 50 // We assume validation checks happened already. |
| 51 DCHECK(child); | 51 DCHECK(child); |
| 52 DCHECK(child != this); | 52 DCHECK(child != this); |
| 53 DCHECK(!child->Contains(this)); | 53 DCHECK(!child->Contains(this)); |
| 54 if (child->parent() == this) { | 54 if (child->parent() == this) { |
| 55 if (children_.size() == 1) | 55 if (children_.size() == 1) |
| 56 return; // Already in the right position. | 56 return; // Already in the right position. |
| 57 Reorder(child, children_.back(), mojo::ORDER_DIRECTION_ABOVE); | 57 Reorder(child, children_.back(), mojo::OrderDirection::ABOVE); |
| 58 return; | 58 return; |
| 59 } | 59 } |
| 60 | 60 |
| 61 ServerView* old_parent = child->parent(); | 61 ServerView* old_parent = child->parent(); |
| 62 child->delegate_->PrepareToChangeViewHierarchy(child, this, old_parent); | 62 child->delegate_->PrepareToChangeViewHierarchy(child, this, old_parent); |
| 63 FOR_EACH_OBSERVER(ServerViewObserver, child->observers_, | 63 FOR_EACH_OBSERVER(ServerViewObserver, child->observers_, |
| 64 OnWillChangeViewHierarchy(child, this, old_parent)); | 64 OnWillChangeViewHierarchy(child, this, old_parent)); |
| 65 | 65 |
| 66 if (child->parent()) | 66 if (child->parent()) |
| 67 child->parent()->RemoveImpl(child); | 67 child->parent()->RemoveImpl(child); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 88 | 88 |
| 89 void ServerView::Reorder(ServerView* child, | 89 void ServerView::Reorder(ServerView* child, |
| 90 ServerView* relative, | 90 ServerView* relative, |
| 91 mojo::OrderDirection direction) { | 91 mojo::OrderDirection direction) { |
| 92 // We assume validation checks happened else where. | 92 // We assume validation checks happened else where. |
| 93 DCHECK(child); | 93 DCHECK(child); |
| 94 DCHECK(child->parent() == this); | 94 DCHECK(child->parent() == this); |
| 95 DCHECK_GT(children_.size(), 1u); | 95 DCHECK_GT(children_.size(), 1u); |
| 96 children_.erase(std::find(children_.begin(), children_.end(), child)); | 96 children_.erase(std::find(children_.begin(), children_.end(), child)); |
| 97 Views::iterator i = std::find(children_.begin(), children_.end(), relative); | 97 Views::iterator i = std::find(children_.begin(), children_.end(), relative); |
| 98 if (direction == mojo::ORDER_DIRECTION_ABOVE) { | 98 if (direction == mojo::OrderDirection::ABOVE) { |
| 99 DCHECK(i != children_.end()); | 99 DCHECK(i != children_.end()); |
| 100 children_.insert(++i, child); | 100 children_.insert(++i, child); |
| 101 } else if (direction == mojo::ORDER_DIRECTION_BELOW) { | 101 } else if (direction == mojo::OrderDirection::BELOW) { |
| 102 DCHECK(i != children_.end()); | 102 DCHECK(i != children_.end()); |
| 103 children_.insert(i, child); | 103 children_.insert(i, child); |
| 104 } | 104 } |
| 105 FOR_EACH_OBSERVER(ServerViewObserver, observers_, | 105 FOR_EACH_OBSERVER(ServerViewObserver, observers_, |
| 106 OnViewReordered(this, relative, direction)); | 106 OnViewReordered(this, relative, direction)); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void ServerView::SetBounds(const gfx::Rect& bounds) { | 109 void ServerView::SetBounds(const gfx::Rect& bounds) { |
| 110 if (bounds_ == bounds) | 110 if (bounds_ == bounds) |
| 111 return; | 111 return; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 child->BuildDebugInfo(depth + " ", result); | 225 child->BuildDebugInfo(depth + " ", result); |
| 226 } | 226 } |
| 227 #endif | 227 #endif |
| 228 | 228 |
| 229 void ServerView::RemoveImpl(ServerView* view) { | 229 void ServerView::RemoveImpl(ServerView* view) { |
| 230 view->parent_ = NULL; | 230 view->parent_ = NULL; |
| 231 children_.erase(std::find(children_.begin(), children_.end(), view)); | 231 children_.erase(std::find(children_.begin(), children_.end(), view)); |
| 232 } | 232 } |
| 233 | 233 |
| 234 } // namespace view_manager | 234 } // namespace view_manager |
| OLD | NEW |