| 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/lib/view_manager_client_impl.h" | 5 #include "view_manager/public/cpp/lib/view_manager_client_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 View* parent, | 29 View* parent, |
| 30 const ViewDataPtr& view_data) { | 30 const ViewDataPtr& view_data) { |
| 31 // We don't use the ctor that takes a ViewManager here, since it will call | 31 // We don't use the ctor that takes a ViewManager here, since it will call |
| 32 // back to the service and attempt to create a new view. | 32 // back to the service and attempt to create a new view. |
| 33 View* view = ViewPrivate::LocalCreate(); | 33 View* view = ViewPrivate::LocalCreate(); |
| 34 ViewPrivate private_view(view); | 34 ViewPrivate private_view(view); |
| 35 private_view.set_view_manager(client); | 35 private_view.set_view_manager(client); |
| 36 private_view.set_id(view_data->view_id); | 36 private_view.set_id(view_data->view_id); |
| 37 private_view.set_visible(view_data->visible); | 37 private_view.set_visible(view_data->visible); |
| 38 private_view.set_drawn(view_data->drawn); | 38 private_view.set_drawn(view_data->drawn); |
| 39 private_view.set_viewport_metrics(view_data->viewport_metrics.Pass()); | 39 private_view.LocalSetViewportMetrics(ViewportMetrics(), |
| 40 *view_data->viewport_metrics); |
| 40 private_view.set_properties( | 41 private_view.set_properties( |
| 41 view_data->properties.To<std::map<std::string, std::vector<uint8_t>>>()); | 42 view_data->properties.To<std::map<std::string, std::vector<uint8_t>>>()); |
| 42 client->AddView(view); | 43 client->AddView(view); |
| 43 private_view.LocalSetBounds(Rect(), *view_data->bounds); | 44 private_view.LocalSetBounds(Rect(), *view_data->bounds); |
| 44 if (parent) | 45 if (parent) |
| 45 ViewPrivate(parent).LocalAddChild(view); | 46 ViewPrivate(parent).LocalAddChild(view); |
| 46 return view; | 47 return view; |
| 47 } | 48 } |
| 48 | 49 |
| 49 View* BuildViewTree(ViewManagerClientImpl* client, | 50 View* BuildViewTree(ViewManagerClientImpl* client, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 } | 290 } |
| 290 } | 291 } |
| 291 | 292 |
| 292 void ViewManagerClientImpl::OnViewBoundsChanged(Id view_id, | 293 void ViewManagerClientImpl::OnViewBoundsChanged(Id view_id, |
| 293 RectPtr old_bounds, | 294 RectPtr old_bounds, |
| 294 RectPtr new_bounds) { | 295 RectPtr new_bounds) { |
| 295 View* view = GetViewById(view_id); | 296 View* view = GetViewById(view_id); |
| 296 ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds); | 297 ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds); |
| 297 } | 298 } |
| 298 | 299 |
| 300 void ViewManagerClientImpl::OnViewViewportMetricsChanged( |
| 301 Id view_id, |
| 302 ViewportMetricsPtr old_metrics, |
| 303 ViewportMetricsPtr new_metrics) { |
| 304 View* view = GetViewById(view_id); |
| 305 ViewPrivate(view).LocalSetViewportMetrics(*old_metrics, *new_metrics); |
| 306 } |
| 307 |
| 299 void ViewManagerClientImpl::OnViewHierarchyChanged( | 308 void ViewManagerClientImpl::OnViewHierarchyChanged( |
| 300 Id view_id, | 309 Id view_id, |
| 301 Id new_parent_id, | 310 Id new_parent_id, |
| 302 Id old_parent_id, | 311 Id old_parent_id, |
| 303 mojo::Array<ViewDataPtr> views) { | 312 mojo::Array<ViewDataPtr> views) { |
| 304 View* initial_parent = views.size() ? | 313 View* initial_parent = views.size() ? |
| 305 GetViewById(views[0]->parent_id) : NULL; | 314 GetViewById(views[0]->parent_id) : NULL; |
| 306 | 315 |
| 307 BuildViewTree(this, views, initial_parent); | 316 BuildViewTree(this, views, initial_parent); |
| 308 | 317 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 uint32 active_view_id) { | 477 uint32 active_view_id) { |
| 469 if (GetViewById(focused_view_id) != focused_view_) | 478 if (GetViewById(focused_view_id) != focused_view_) |
| 470 OnFocusChanged(focused_view_ ? focused_view_->id() : 0, focused_view_id); | 479 OnFocusChanged(focused_view_ ? focused_view_->id() : 0, focused_view_id); |
| 471 if (GetViewById(active_view_id) != activated_view_) { | 480 if (GetViewById(active_view_id) != activated_view_) { |
| 472 OnActiveWindowChanged(activated_view_ ? activated_view_->id() : 0, | 481 OnActiveWindowChanged(activated_view_ ? activated_view_->id() : 0, |
| 473 active_view_id); | 482 active_view_id); |
| 474 } | 483 } |
| 475 } | 484 } |
| 476 | 485 |
| 477 } // namespace mojo | 486 } // namespace mojo |
| OLD | NEW |