| 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 "mojo/services/view_manager/connection_manager.h" | 5 #include "mojo/services/view_manager/connection_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 10 #include "mojo/converters/input_events/input_events_type_converters.h" | 10 #include "mojo/converters/input_events/input_events_type_converters.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 WindowManagerInternal* wm_internal) | 113 WindowManagerInternal* wm_internal) |
| 114 : delegate_(delegate), | 114 : delegate_(delegate), |
| 115 window_manager_client_connection_(nullptr), | 115 window_manager_client_connection_(nullptr), |
| 116 next_connection_id_(1), | 116 next_connection_id_(1), |
| 117 display_manager_(display_manager.Pass()), | 117 display_manager_(display_manager.Pass()), |
| 118 root_(new ServerView(this, RootViewId())), | 118 root_(new ServerView(this, RootViewId())), |
| 119 wm_internal_(wm_internal), | 119 wm_internal_(wm_internal), |
| 120 current_change_(nullptr), | 120 current_change_(nullptr), |
| 121 in_destructor_(false) { | 121 in_destructor_(false) { |
| 122 root_->SetBounds(gfx::Rect(800, 600)); | 122 root_->SetBounds(gfx::Rect(800, 600)); |
| 123 root_->SetVisible(true); |
| 123 display_manager_->Init(this); | 124 display_manager_->Init(this); |
| 124 } | 125 } |
| 125 | 126 |
| 126 ConnectionManager::~ConnectionManager() { | 127 ConnectionManager::~ConnectionManager() { |
| 127 in_destructor_ = true; | 128 in_destructor_ = true; |
| 128 | 129 |
| 129 STLDeleteValues(&connection_map_); | 130 STLDeleteValues(&connection_map_); |
| 130 // All the connections should have been destroyed. | 131 // All the connections should have been destroyed. |
| 131 DCHECK(connection_map_.empty()); | 132 DCHECK(connection_map_.empty()); |
| 132 root_.reset(); | 133 root_.reset(); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 const ServerView* relative, | 378 const ServerView* relative, |
| 378 OrderDirection direction) { | 379 OrderDirection direction) { |
| 379 if (!in_destructor_) | 380 if (!in_destructor_) |
| 380 display_manager_->SchedulePaint(view, gfx::Rect(view->bounds().size())); | 381 display_manager_->SchedulePaint(view, gfx::Rect(view->bounds().size())); |
| 381 } | 382 } |
| 382 | 383 |
| 383 void ConnectionManager::OnWillChangeViewVisibility(ServerView* view) { | 384 void ConnectionManager::OnWillChangeViewVisibility(ServerView* view) { |
| 384 if (in_destructor_) | 385 if (in_destructor_) |
| 385 return; | 386 return; |
| 386 | 387 |
| 388 // Need to repaint if the view was drawn (which means it'll in the process of |
| 389 // hiding) or the view is transitioning to drawn. |
| 390 if (view->IsDrawn(root_.get()) || (!view->visible() && view->parent() && |
| 391 view->parent()->IsDrawn(root_.get()))) { |
| 392 display_manager_->SchedulePaint(view->parent(), view->bounds()); |
| 393 } |
| 394 |
| 387 if (view != root_.get() && view->id() != ClonedViewId() && | 395 if (view != root_.get() && view->id() != ClonedViewId() && |
| 388 root_->Contains(view) && view->IsDrawn(root_.get())) { | 396 root_->Contains(view) && view->IsDrawn(root_.get())) { |
| 389 // We're about to hide |view|, this would implicitly make any cloned views | 397 // We're about to hide |view|, this would implicitly make any cloned views |
| 390 // hide to. Reparent so that animations are still visible. | 398 // hide to. Reparent so that animations are still visible. |
| 391 ServerView* parent_above = view; | 399 ServerView* parent_above = view; |
| 392 ReparentClonedViews(view->parent(), &parent_above, view); | 400 ReparentClonedViews(view->parent(), &parent_above, view); |
| 393 } | 401 } |
| 394 | 402 |
| 395 for (auto& pair : connection_map_) { | 403 for (auto& pair : connection_map_) { |
| 396 pair.second->service()->ProcessWillChangeViewVisibility( | 404 pair.second->service()->ProcessWillChangeViewVisibility( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 gfx::Size new_size = size.To<gfx::Size>(); | 438 gfx::Size new_size = size.To<gfx::Size>(); |
| 431 display_manager_->SetViewportSize(new_size); | 439 display_manager_->SetViewportSize(new_size); |
| 432 } | 440 } |
| 433 | 441 |
| 434 void ConnectionManager::CloneAndAnimate(Id transport_view_id) { | 442 void ConnectionManager::CloneAndAnimate(Id transport_view_id) { |
| 435 CloneAndAnimate(ViewIdFromTransportId(transport_view_id)); | 443 CloneAndAnimate(ViewIdFromTransportId(transport_view_id)); |
| 436 } | 444 } |
| 437 | 445 |
| 438 } // namespace service | 446 } // namespace service |
| 439 } // namespace mojo | 447 } // namespace mojo |
| OLD | NEW |