| 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 "cc/surfaces/surface.h" | 7 #include "cc/surfaces/surface.h" |
| 8 #include "cc/surfaces/surface_manager.h" | 8 #include "cc/surfaces/surface_manager.h" |
| 9 #include "content/browser/compositor/surface_utils.h" | 9 #include "content/browser/compositor/surface_utils.h" |
| 10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // Detach ourselves from the previous |view_|. | 56 // Detach ourselves from the previous |view_|. |
| 57 if (view_) | 57 if (view_) |
| 58 view_->set_cross_process_frame_connector(NULL); | 58 view_->set_cross_process_frame_connector(NULL); |
| 59 | 59 |
| 60 view_ = view; | 60 view_ = view; |
| 61 | 61 |
| 62 // Attach ourselves to the new view and size it appropriately. | 62 // Attach ourselves to the new view and size it appropriately. |
| 63 if (view_) { | 63 if (view_) { |
| 64 view_->set_cross_process_frame_connector(this); | 64 view_->set_cross_process_frame_connector(this); |
| 65 SetDeviceScaleFactor(device_scale_factor_); | 65 SetDeviceScaleFactor(device_scale_factor_); |
| 66 SetSize(child_frame_rect_); | 66 SetRect(child_frame_rect_); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 void CrossProcessFrameConnector::RenderProcessGone() { | 70 void CrossProcessFrameConnector::RenderProcessGone() { |
| 71 frame_proxy_in_parent_renderer_->Send(new FrameMsg_ChildFrameProcessGone( | 71 frame_proxy_in_parent_renderer_->Send(new FrameMsg_ChildFrameProcessGone( |
| 72 frame_proxy_in_parent_renderer_->GetRoutingID())); | 72 frame_proxy_in_parent_renderer_->GetRoutingID())); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void CrossProcessFrameConnector::SetChildFrameSurface( | 75 void CrossProcessFrameConnector::SetChildFrameSurface( |
| 76 const cc::SurfaceId& surface_id, | 76 const cc::SurfaceId& surface_id, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 101 } | 101 } |
| 102 surface->AddDestructionDependency(sequence); | 102 surface->AddDestructionDependency(sequence); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void CrossProcessFrameConnector::OnInitializeChildFrame(gfx::Rect frame_rect, | 105 void CrossProcessFrameConnector::OnInitializeChildFrame(gfx::Rect frame_rect, |
| 106 float scale_factor) { | 106 float scale_factor) { |
| 107 if (scale_factor != device_scale_factor_) | 107 if (scale_factor != device_scale_factor_) |
| 108 SetDeviceScaleFactor(scale_factor); | 108 SetDeviceScaleFactor(scale_factor); |
| 109 | 109 |
| 110 if (!frame_rect.size().IsEmpty()) | 110 if (!frame_rect.size().IsEmpty()) |
| 111 SetSize(frame_rect); | 111 SetRect(frame_rect); |
| 112 } | 112 } |
| 113 | 113 |
| 114 gfx::Rect CrossProcessFrameConnector::ChildFrameRect() { | 114 gfx::Rect CrossProcessFrameConnector::ChildFrameRect() { |
| 115 return child_frame_rect_; | 115 return child_frame_rect_; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void CrossProcessFrameConnector::GetScreenInfo(blink::WebScreenInfo* results) { | 118 void CrossProcessFrameConnector::GetScreenInfo(blink::WebScreenInfo* results) { |
| 119 // Inner WebContents's root FrameTreeNode does not have a parent(), so | 119 // Inner WebContents's root FrameTreeNode does not have a parent(), so |
| 120 // GetRenderWidgetHostView() call below will fail. | 120 // GetRenderWidgetHostView() call below will fail. |
| 121 // TODO(lazyboy): Fix this. | 121 // TODO(lazyboy): Fix this. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 if (event->type == blink::WebInputEvent::MouseWheel) { | 203 if (event->type == blink::WebInputEvent::MouseWheel) { |
| 204 view_->ProcessMouseWheelEvent( | 204 view_->ProcessMouseWheelEvent( |
| 205 *static_cast<const blink::WebMouseWheelEvent*>(event)); | 205 *static_cast<const blink::WebMouseWheelEvent*>(event)); |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| 210 void CrossProcessFrameConnector::OnFrameRectChanged( | 210 void CrossProcessFrameConnector::OnFrameRectChanged( |
| 211 const gfx::Rect& frame_rect) { | 211 const gfx::Rect& frame_rect) { |
| 212 if (!frame_rect.size().IsEmpty()) | 212 if (!frame_rect.size().IsEmpty()) |
| 213 SetSize(frame_rect); | 213 SetRect(frame_rect); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void CrossProcessFrameConnector::OnVisibilityChanged(bool visible) { | 216 void CrossProcessFrameConnector::OnVisibilityChanged(bool visible) { |
| 217 if (!view_) | 217 if (!view_) |
| 218 return; | 218 return; |
| 219 | 219 |
| 220 // If there is an inner WebContents, it should be notified of the change in | 220 // If there is an inner WebContents, it should be notified of the change in |
| 221 // the visibility. The Show/Hide methods will not be called if an inner | 221 // the visibility. The Show/Hide methods will not be called if an inner |
| 222 // WebContents exists since the corresponding WebContents will itself call | 222 // WebContents exists since the corresponding WebContents will itself call |
| 223 // Show/Hide on all the RenderWidgetHostViews (including this) one. | 223 // Show/Hide on all the RenderWidgetHostViews (including this) one. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 239 void CrossProcessFrameConnector::SetDeviceScaleFactor(float scale_factor) { | 239 void CrossProcessFrameConnector::SetDeviceScaleFactor(float scale_factor) { |
| 240 device_scale_factor_ = scale_factor; | 240 device_scale_factor_ = scale_factor; |
| 241 // The RenderWidgetHost is null in unit tests. | 241 // The RenderWidgetHost is null in unit tests. |
| 242 if (view_ && view_->GetRenderWidgetHost()) { | 242 if (view_ && view_->GetRenderWidgetHost()) { |
| 243 RenderWidgetHostImpl* child_widget = | 243 RenderWidgetHostImpl* child_widget = |
| 244 RenderWidgetHostImpl::From(view_->GetRenderWidgetHost()); | 244 RenderWidgetHostImpl::From(view_->GetRenderWidgetHost()); |
| 245 child_widget->NotifyScreenInfoChanged(); | 245 child_widget->NotifyScreenInfoChanged(); |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 void CrossProcessFrameConnector::SetSize(gfx::Rect frame_rect) { | 249 void CrossProcessFrameConnector::SetRect(const gfx::Rect& frame_rect) { |
| 250 child_frame_rect_ = frame_rect; | 250 child_frame_rect_ = frame_rect; |
| 251 if (view_) | 251 if (view_) |
| 252 view_->SetSize(frame_rect.size()); | 252 view_->SetBounds(frame_rect); |
| 253 } | 253 } |
| 254 | 254 |
| 255 RenderWidgetHostViewBase* | 255 RenderWidgetHostViewBase* |
| 256 CrossProcessFrameConnector::GetRootRenderWidgetHostView() { | 256 CrossProcessFrameConnector::GetRootRenderWidgetHostView() { |
| 257 RenderFrameHostImpl* top_host = frame_proxy_in_parent_renderer_-> | 257 RenderFrameHostImpl* top_host = frame_proxy_in_parent_renderer_-> |
| 258 frame_tree_node()->frame_tree()->root()->current_frame_host(); | 258 frame_tree_node()->frame_tree()->root()->current_frame_host(); |
| 259 | 259 |
| 260 // This method should return the root RWHV from the top-level WebContents, | 260 // This method should return the root RWHV from the top-level WebContents, |
| 261 // in the case of nested WebContents. | 261 // in the case of nested WebContents. |
| 262 while (top_host->frame_tree_node()->render_manager()->ForInnerDelegate()) { | 262 while (top_host->frame_tree_node()->render_manager()->ForInnerDelegate()) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 284 | 284 |
| 285 if (parent) { | 285 if (parent) { |
| 286 return static_cast<RenderWidgetHostViewBase*>( | 286 return static_cast<RenderWidgetHostViewBase*>( |
| 287 parent->current_frame_host()->GetView()); | 287 parent->current_frame_host()->GetView()); |
| 288 } | 288 } |
| 289 | 289 |
| 290 return nullptr; | 290 return nullptr; |
| 291 } | 291 } |
| 292 | 292 |
| 293 } // namespace content | 293 } // namespace content |
| OLD | NEW |