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