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 "content/browser/frame_host/cross_process_frame_connector.h" | 5 #include "content/browser/frame_host/cross_process_frame_connector.h" |
6 | 6 |
7 #include "content/browser/frame_host/render_frame_host_impl.h" | 7 #include "content/browser/frame_host/render_frame_host_impl.h" |
8 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 8 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
9 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
10 #include "content/browser/renderer_host/render_widget_host_impl.h" | 10 #include "content/browser/renderer_host/render_widget_host_impl.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 | 48 |
49 void CrossProcessFrameConnector::set_view( | 49 void CrossProcessFrameConnector::set_view( |
50 RenderWidgetHostViewChildFrame* view) { | 50 RenderWidgetHostViewChildFrame* view) { |
51 // Detach ourselves from the previous |view_|. | 51 // Detach ourselves from the previous |view_|. |
52 if (view_) | 52 if (view_) |
53 view_->set_cross_process_frame_connector(NULL); | 53 view_->set_cross_process_frame_connector(NULL); |
54 | 54 |
55 view_ = view; | 55 view_ = view; |
56 | 56 |
57 // Attach ourselves to the new view. | 57 // Attach ourselves to the new view and size it appropriately. |
58 if (view_) | 58 if (view_) { |
59 view_->set_cross_process_frame_connector(this); | 59 view_->set_cross_process_frame_connector(this); |
| 60 SetDeveiceScaleFactor(device_scale_factor_); |
| 61 SetSize(child_frame_rect_); |
| 62 } |
60 } | 63 } |
61 | 64 |
62 void CrossProcessFrameConnector::RenderProcessGone() { | 65 void CrossProcessFrameConnector::RenderProcessGone() { |
63 frame_proxy_in_parent_renderer_->Send(new FrameMsg_ChildFrameProcessGone( | 66 frame_proxy_in_parent_renderer_->Send(new FrameMsg_ChildFrameProcessGone( |
64 frame_proxy_in_parent_renderer_->routing_id())); | 67 frame_proxy_in_parent_renderer_->routing_id())); |
65 } | 68 } |
66 | 69 |
67 void CrossProcessFrameConnector::ChildFrameBuffersSwapped( | 70 void CrossProcessFrameConnector::ChildFrameBuffersSwapped( |
68 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& gpu_params, | 71 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& gpu_params, |
69 int gpu_host_id) { | 72 int gpu_host_id) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void CrossProcessFrameConnector::OnReclaimCompositorResources( | 120 void CrossProcessFrameConnector::OnReclaimCompositorResources( |
118 const FrameHostMsg_ReclaimCompositorResources_Params& params) { | 121 const FrameHostMsg_ReclaimCompositorResources_Params& params) { |
119 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id, | 122 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id, |
120 params.output_surface_id, | 123 params.output_surface_id, |
121 params.renderer_host_id, | 124 params.renderer_host_id, |
122 params.ack); | 125 params.ack); |
123 } | 126 } |
124 | 127 |
125 void CrossProcessFrameConnector::OnInitializeChildFrame(gfx::Rect frame_rect, | 128 void CrossProcessFrameConnector::OnInitializeChildFrame(gfx::Rect frame_rect, |
126 float scale_factor) { | 129 float scale_factor) { |
127 if (scale_factor != device_scale_factor_) { | 130 if (scale_factor != device_scale_factor_) |
128 device_scale_factor_ = scale_factor; | 131 SetDeveiceScaleFactor(scale_factor); |
129 if (view_) { | |
130 RenderWidgetHostImpl* child_widget = | |
131 RenderWidgetHostImpl::From(view_->GetRenderWidgetHost()); | |
132 child_widget->NotifyScreenInfoChanged(); | |
133 } | |
134 } | |
135 | 132 |
136 if (!frame_rect.size().IsEmpty()) { | 133 if (!frame_rect.size().IsEmpty()) |
137 child_frame_rect_ = frame_rect; | 134 SetSize(frame_rect); |
138 if (view_) | |
139 view_->SetSize(frame_rect.size()); | |
140 } | |
141 } | 135 } |
142 | 136 |
143 gfx::Rect CrossProcessFrameConnector::ChildFrameRect() { | 137 gfx::Rect CrossProcessFrameConnector::ChildFrameRect() { |
144 return child_frame_rect_; | 138 return child_frame_rect_; |
145 } | 139 } |
146 | 140 |
147 void CrossProcessFrameConnector::OnForwardInputEvent( | 141 void CrossProcessFrameConnector::OnForwardInputEvent( |
148 const blink::WebInputEvent* event) { | 142 const blink::WebInputEvent* event) { |
149 if (!view_) | 143 if (!view_) |
150 return; | 144 return; |
(...skipping 18 matching lines...) Expand all Loading... |
169 return; | 163 return; |
170 } | 164 } |
171 | 165 |
172 if (event->type == blink::WebInputEvent::MouseWheel) { | 166 if (event->type == blink::WebInputEvent::MouseWheel) { |
173 child_widget->ForwardWheelEvent( | 167 child_widget->ForwardWheelEvent( |
174 *static_cast<const blink::WebMouseWheelEvent*>(event)); | 168 *static_cast<const blink::WebMouseWheelEvent*>(event)); |
175 return; | 169 return; |
176 } | 170 } |
177 } | 171 } |
178 | 172 |
| 173 void CrossProcessFrameConnector::SetDeveiceScaleFactor(float scale_factor) { |
| 174 device_scale_factor_ = scale_factor; |
| 175 if (view_) { |
| 176 RenderWidgetHostImpl* child_widget = |
| 177 RenderWidgetHostImpl::From(view_->GetRenderWidgetHost()); |
| 178 child_widget->NotifyScreenInfoChanged(); |
| 179 } |
| 180 } |
| 181 |
| 182 void CrossProcessFrameConnector::SetSize(gfx::Rect frame_rect) { |
| 183 child_frame_rect_ = frame_rect; |
| 184 if (view_) |
| 185 view_->SetSize(frame_rect.size()); |
| 186 } |
| 187 |
179 } // namespace content | 188 } // namespace content |
OLD | NEW |