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