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 "components/view_manager/connection_manager.h" | 5 #include "components/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 "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
10 #include "cc/quads/shared_quad_state.h" | 10 #include "cc/quads/shared_quad_state.h" |
11 #include "components/view_manager/client_connection.h" | 11 #include "components/view_manager/client_connection.h" |
12 #include "components/view_manager/connection_manager_delegate.h" | 12 #include "components/view_manager/connection_manager_delegate.h" |
13 #include "components/view_manager/focus_controller.h" | 13 #include "components/view_manager/focus_controller.h" |
14 #include "components/view_manager/server_view.h" | 14 #include "components/view_manager/server_view.h" |
15 #include "components/view_manager/view_coordinate_conversions.h" | 15 #include "components/view_manager/view_coordinate_conversions.h" |
16 #include "components/view_manager/view_tree_host_connection.h" | 16 #include "components/view_manager/view_tree_host_connection.h" |
17 #include "components/view_manager/view_tree_impl.h" | 17 #include "components/view_manager/view_tree_impl.h" |
18 #include "mojo/application/public/cpp/application_connection.h" | 18 #include "mojo/application/public/cpp/application_connection.h" |
19 #include "mojo/converters/geometry/geometry_type_converters.h" | 19 #include "mojo/converters/geometry/geometry_type_converters.h" |
20 #include "mojo/converters/input_events/input_events_type_converters.h" | 20 #include "mojo/converters/input_events/input_events_type_converters.h" |
21 #include "mojo/converters/surfaces/surfaces_type_converters.h" | 21 #include "mojo/converters/surfaces/surfaces_type_converters.h" |
| 22 #include "ui/gfx/geometry/size_conversions.h" |
22 | 23 |
23 using mojo::ConnectionSpecificId; | 24 using mojo::ConnectionSpecificId; |
24 | 25 |
25 namespace view_manager { | 26 namespace view_manager { |
26 namespace { | 27 namespace { |
27 | 28 |
28 // Creates a copy of |view|. The copied view has |delegate| as its delegate. | 29 // Creates a copy of |view|. The copied view has |delegate| as its delegate. |
29 // This does not recurse. | 30 // This does not recurse. |
30 ServerView* CloneView(const ServerView* view, ServerViewDelegate* delegate) { | 31 ServerView* CloneView(const ServerView* view, ServerViewDelegate* delegate) { |
31 ServerView* clone = new ServerView(delegate, ClonedViewId()); | 32 ServerView* clone = new ServerView(delegate, ClonedViewId()); |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 | 723 |
723 ViewTreeHostImpl* new_host = | 724 ViewTreeHostImpl* new_host = |
724 new_focused_view ? GetViewTreeHostByView(new_focused_view) : nullptr; | 725 new_focused_view ? GetViewTreeHostByView(new_focused_view) : nullptr; |
725 | 726 |
726 if (new_host) | 727 if (new_host) |
727 new_host->UpdateTextInputState(new_focused_view->text_input_state()); | 728 new_host->UpdateTextInputState(new_focused_view->text_input_state()); |
728 else if (old_host) | 729 else if (old_host) |
729 old_host->UpdateTextInputState(ui::TextInputState()); | 730 old_host->UpdateTextInputState(ui::TextInputState()); |
730 } | 731 } |
731 | 732 |
732 bool ConnectionManager::ConvertSurfaceDrawQuad(const mojo::QuadPtr& input, | 733 bool ConnectionManager::ConvertSurfaceDrawQuad( |
733 cc::SharedQuadState* sqs, | 734 const mojo::QuadPtr& input, |
734 cc::RenderPass* render_pass) { | 735 const mojo::CompositorFrameMetadataPtr& metadata, |
| 736 cc::SharedQuadState* sqs, |
| 737 cc::RenderPass* render_pass) { |
735 unsigned int id = static_cast<unsigned int>( | 738 unsigned int id = static_cast<unsigned int>( |
736 input->surface_quad_state->surface.To<cc::SurfaceId>().id); | 739 input->surface_quad_state->surface.To<cc::SurfaceId>().id); |
737 // TODO(fsamuel): Security check. | 740 // TODO(fsamuel): Security checks: |
| 741 // 1. We need to make sure the embedder can only position views it's allowed |
| 742 // to access. |
| 743 // 2. We need to make sure that the embedder cannot place views in areas |
| 744 // outside of its own bounds. |
738 ServerView* view = GetView(ViewIdFromTransportId(id)); | 745 ServerView* view = GetView(ViewIdFromTransportId(id)); |
739 // If a CompositorFrame message arrives late, say during a navigation, then | 746 // If a CompositorFrame message arrives late, say during a navigation, then |
740 // it may contain view IDs that no longer exist. | 747 // it may contain view IDs that no longer exist. |
741 if (!view) | 748 if (!view) |
742 return false; | 749 return false; |
743 gfx::Rect bounds(input->visible_rect.To<gfx::Rect>()); | 750 gfx::Rect bounds(input->visible_rect.To<gfx::Rect>()); |
744 gfx::Point p; | 751 gfx::Point p; |
745 sqs->quad_to_target_transform.TransformPoint(&p); | 752 sqs->quad_to_target_transform.TransformPoint(&p); |
746 bounds.set_origin(p); | 753 bounds.set_origin(p); |
| 754 // TODO(fsamuel): This seems like a crude way to set the size that probably |
| 755 // doesn't work correctly in the general case. We need to get transforms |
| 756 // working correctly in the general case. |
| 757 bounds.set_size(gfx::ToRoundedSize( |
| 758 gfx::ScaleSize(bounds.size(), metadata->device_scale_factor))); |
747 view->SetBounds(bounds); | 759 view->SetBounds(bounds); |
748 return true; | 760 return true; |
749 } | 761 } |
750 | 762 |
751 } // namespace view_manager | 763 } // namespace view_manager |
OLD | NEW |