Chromium Code Reviews| Index: services/view_manager/connection_manager.cc |
| diff --git a/services/view_manager/connection_manager.cc b/services/view_manager/connection_manager.cc |
| index 190c061aedf21f06ddf5a438d4ed1b8d58a8cc31..7d44b6f5d8ba00ad7396e6c21a849f74e4c19c5a 100644 |
| --- a/services/view_manager/connection_manager.cc |
| +++ b/services/view_manager/connection_manager.cc |
| @@ -116,7 +116,7 @@ ConnectionManager::ConnectionManager(ConnectionManagerDelegate* delegate, |
| window_manager_client_connection_(nullptr), |
| next_connection_id_(1), |
| display_manager_(display_manager.Pass()), |
| - root_(new ServerView(this, RootViewId())), |
| + root_(CreateServerView(RootViewId())), |
| wm_internal_(wm_internal), |
| current_change_(nullptr), |
| in_destructor_(false), |
| @@ -135,6 +135,12 @@ ConnectionManager::~ConnectionManager() { |
| root_.reset(); |
| } |
| +ServerView* ConnectionManager::CreateServerView(const ViewId& id) { |
| + ServerView* view = new ServerView(this, id); |
| + view->AddObserver(this); |
| + return view; |
| +} |
| + |
| ConnectionSpecificId ConnectionManager::GetAndAdvanceNextConnectionId() { |
| const ConnectionSpecificId id = next_connection_id_++; |
| DCHECK_LT(id, next_connection_id_); |
| @@ -340,7 +346,7 @@ void ConnectionManager::AddConnection(ClientConnection* connection) { |
| connection_map_[connection->service()->id()] = connection; |
| } |
| -void ConnectionManager::OnWillDestroyView(ServerView* view) { |
| +void ConnectionManager::PrepareToDestroyView(ServerView* view) { |
| if (!in_destructor_ && root_->Contains(view) && view != root_.get() && |
| view->id() != ClonedViewId()) { |
| // We're about to destroy a view. Any cloned views need to be reparented |
| @@ -353,14 +359,9 @@ void ConnectionManager::OnWillDestroyView(ServerView* view) { |
| animation_runner_.CancelAnimationForView(view); |
| } |
| -void ConnectionManager::OnViewDestroyed(const ServerView* view) { |
| - if (!in_destructor_) |
| - ProcessViewDeleted(view->id()); |
| -} |
| - |
| -void ConnectionManager::OnWillChangeViewHierarchy(ServerView* view, |
| - ServerView* new_parent, |
| - ServerView* old_parent) { |
| +void ConnectionManager::PrepareToChangeViewHierarchy(ServerView* view, |
| + ServerView* new_parent, |
| + ServerView* old_parent) { |
| if (view->id() == ClonedViewId() || in_destructor_) |
| return; |
| @@ -373,11 +374,47 @@ void ConnectionManager::OnWillChangeViewHierarchy(ServerView* view, |
| ReparentClonedViews(view->parent(), &parent_above, view); |
| } |
| - ProcessWillChangeViewHierarchy(view, new_parent, old_parent); |
| - |
| animation_runner_.CancelAnimationForView(view); |
| } |
| +void ConnectionManager::PrepareToChangeViewVisibility(ServerView* view) { |
| + if (in_destructor_) |
| + return; |
| + |
| + if (view != root_.get() && view->id() != ClonedViewId() && |
| + root_->Contains(view) && view->IsDrawn(root_.get())) { |
| + // We're about to hide |view|, this would implicitly make any cloned views |
| + // hide to. Reparent so that animations are still visible. |
|
Ben Goodger (Google)
2015/04/13 23:09:00
hide too
|
| + ServerView* parent_above = view; |
| + ReparentClonedViews(view->parent(), &parent_above, view); |
| + } |
| + |
| + const bool is_parent_drawn = |
| + view->parent() && view->parent()->IsDrawn(root_.get()); |
| + if (!is_parent_drawn || !view->visible()) |
| + animation_runner_.CancelAnimationForView(view); |
| +} |
| + |
| +void ConnectionManager::OnScheduleViewPaint(const ServerView* view) { |
| + if (!in_destructor_) |
| + display_manager_->SchedulePaint(view, gfx::Rect(view->bounds().size())); |
| +} |
| + |
| +void ConnectionManager::OnViewDestroyed(const ServerView* view) { |
| + if (!in_destructor_) |
| + ProcessViewDeleted(view->id()); |
| +} |
| + |
| +void ConnectionManager::OnWillChangeViewHierarchy( |
| + const ServerView* view, |
| + const ServerView* new_parent, |
| + const ServerView* old_parent) { |
| + if (view->id() == ClonedViewId() || in_destructor_) |
| + return; |
| + |
| + ProcessWillChangeViewHierarchy(view, new_parent, old_parent); |
| +} |
| + |
| void ConnectionManager::OnViewHierarchyChanged(const ServerView* view, |
| const ServerView* new_parent, |
| const ServerView* old_parent) { |
| @@ -412,11 +449,6 @@ void ConnectionManager::OnViewBoundsChanged(const ServerView* view, |
| display_manager_->SchedulePaint(view->parent(), new_bounds); |
| } |
| -void ConnectionManager::OnViewSurfaceIdChanged(const ServerView* view) { |
| - if (!in_destructor_) |
| - display_manager_->SchedulePaint(view, gfx::Rect(view->bounds().size())); |
| -} |
| - |
| void ConnectionManager::OnViewReordered(const ServerView* view, |
| const ServerView* relative, |
| mojo::OrderDirection direction) { |
| @@ -424,34 +456,21 @@ void ConnectionManager::OnViewReordered(const ServerView* view, |
| display_manager_->SchedulePaint(view, gfx::Rect(view->bounds().size())); |
| } |
| -void ConnectionManager::OnWillChangeViewVisibility(ServerView* view) { |
| +void ConnectionManager::OnWillChangeViewVisibility(const ServerView* view) { |
| if (in_destructor_) |
| return; |
| - // Need to repaint if the view was drawn (which means it'll in the process of |
| + // Need to repaint if the view was drawn (which means it's in the process of |
| // hiding) or the view is transitioning to drawn. |
| if (view->IsDrawn(root_.get()) || (!view->visible() && view->parent() && |
| view->parent()->IsDrawn(root_.get()))) { |
| display_manager_->SchedulePaint(view->parent(), view->bounds()); |
| } |
| - if (view != root_.get() && view->id() != ClonedViewId() && |
| - root_->Contains(view) && view->IsDrawn(root_.get())) { |
| - // We're about to hide |view|, this would implicitly make any cloned views |
| - // hide to. Reparent so that animations are still visible. |
| - ServerView* parent_above = view; |
| - ReparentClonedViews(view->parent(), &parent_above, view); |
| - } |
| - |
| for (auto& pair : connection_map_) { |
| pair.second->service()->ProcessWillChangeViewVisibility( |
| view, IsChangeSource(pair.first)); |
| } |
| - |
| - const bool is_parent_drawn = |
| - view->parent() && view->parent()->IsDrawn(root_.get()); |
| - if (!is_parent_drawn || !view->visible()) |
| - animation_runner_.CancelAnimationForView(view); |
| } |
| void ConnectionManager::OnViewSharedPropertyChanged( |
| @@ -464,11 +483,6 @@ void ConnectionManager::OnViewSharedPropertyChanged( |
| } |
| } |
| -void ConnectionManager::OnScheduleViewPaint(const ServerView* view) { |
| - if (!in_destructor_) |
| - display_manager_->SchedulePaint(view, gfx::Rect(view->bounds().size())); |
| -} |
| - |
| void ConnectionManager::DispatchInputEventToView(mojo::Id transport_view_id, |
| mojo::EventPtr event) { |
| const ViewId view_id(ViewIdFromTransportId(transport_view_id)); |