| 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/render_widget_host_view_child_frame.h" | 5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( | 42 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( |
| 43 RenderWidgetHost* widget_host) | 43 RenderWidgetHost* widget_host) |
| 44 : host_(RenderWidgetHostImpl::From(widget_host)), | 44 : host_(RenderWidgetHostImpl::From(widget_host)), |
| 45 next_surface_sequence_(1u), | 45 next_surface_sequence_(1u), |
| 46 last_compositor_frame_sink_id_(0), | 46 last_compositor_frame_sink_id_(0), |
| 47 current_surface_scale_factor_(1.f), | 47 current_surface_scale_factor_(1.f), |
| 48 ack_pending_count_(0), | 48 ack_pending_count_(0), |
| 49 frame_connector_(nullptr), | 49 frame_connector_(nullptr), |
| 50 begin_frame_source_(nullptr), | 50 begin_frame_source_(nullptr), |
| 51 parent_surface_client_id_(0), | |
| 52 weak_factory_(this) { | 51 weak_factory_(this) { |
| 53 id_allocator_.reset(new cc::SurfaceIdAllocator(AllocateSurfaceClientId())); | 52 id_allocator_.reset(new cc::SurfaceIdAllocator(AllocateFrameSinkId())); |
| 54 GetSurfaceManager()->RegisterSurfaceClientId(id_allocator_->client_id()); | 53 GetSurfaceManager()->RegisterFrameSinkId(id_allocator_->frame_sink_id()); |
| 55 RegisterSurfaceNamespaceId(); | 54 RegisterSurfaceNamespaceId(); |
| 56 | 55 |
| 57 host_->SetView(this); | 56 host_->SetView(this); |
| 58 GetTextInputManager(); | 57 GetTextInputManager(); |
| 59 } | 58 } |
| 60 | 59 |
| 61 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { | 60 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { |
| 62 if (!surface_id_.is_null()) | 61 if (!surface_id_.is_null()) |
| 63 surface_factory_->Destroy(surface_id_); | 62 surface_factory_->Destroy(surface_id_); |
| 64 | 63 |
| 65 if (GetSurfaceManager()) | 64 if (GetSurfaceManager()) |
| 66 GetSurfaceManager()->InvalidateSurfaceClientId(id_allocator_->client_id()); | 65 GetSurfaceManager()->InvalidateFrameSinkId(id_allocator_->frame_sink_id()); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void RenderWidgetHostViewChildFrame::SetCrossProcessFrameConnector( | 68 void RenderWidgetHostViewChildFrame::SetCrossProcessFrameConnector( |
| 70 CrossProcessFrameConnector* frame_connector) { | 69 CrossProcessFrameConnector* frame_connector) { |
| 71 if (frame_connector_ == frame_connector) | 70 if (frame_connector_ == frame_connector) |
| 72 return; | 71 return; |
| 73 | 72 |
| 74 if (frame_connector_) { | 73 if (frame_connector_) { |
| 75 if (parent_surface_client_id_) { | 74 if (!parent_frame_sink_id_.is_null()) { |
| 76 GetSurfaceManager()->UnregisterSurfaceNamespaceHierarchy( | 75 GetSurfaceManager()->UnregisterFrameSinkHierarchy(parent_frame_sink_id_, |
| 77 parent_surface_client_id_, GetSurfaceClientId()); | 76 GetFrameSinkId()); |
| 78 } | 77 } |
| 79 // Unregister the client here, as it is not guaranteed in tests that the | 78 // Unregister the client here, as it is not guaranteed in tests that the |
| 80 // destructor will be called. | 79 // destructor will be called. |
| 81 GetSurfaceManager()->UnregisterSurfaceFactoryClient( | 80 GetSurfaceManager()->UnregisterSurfaceFactoryClient( |
| 82 id_allocator_->client_id()); | 81 id_allocator_->frame_sink_id()); |
| 83 | 82 |
| 84 parent_surface_client_id_ = 0; | 83 parent_frame_sink_id_ = cc::FrameSinkId(); |
| 85 | 84 |
| 86 // After the RenderWidgetHostViewChildFrame loses the frame_connector, it | 85 // After the RenderWidgetHostViewChildFrame loses the frame_connector, it |
| 87 // won't be able to walk up the frame tree anymore. Clean up anything that | 86 // won't be able to walk up the frame tree anymore. Clean up anything that |
| 88 // needs to be done through the CrossProcessFrameConnector before it's gone. | 87 // needs to be done through the CrossProcessFrameConnector before it's gone. |
| 89 | 88 |
| 90 // Unlocks the mouse if this RenderWidgetHostView holds the lock. | 89 // Unlocks the mouse if this RenderWidgetHostView holds the lock. |
| 91 UnlockMouse(); | 90 UnlockMouse(); |
| 92 } | 91 } |
| 93 frame_connector_ = frame_connector; | 92 frame_connector_ = frame_connector; |
| 94 if (frame_connector_) { | 93 if (frame_connector_) { |
| 95 GetSurfaceManager()->RegisterSurfaceFactoryClient( | 94 GetSurfaceManager()->RegisterSurfaceFactoryClient( |
| 96 id_allocator_->client_id(), this); | 95 id_allocator_->frame_sink_id(), this); |
| 97 RenderWidgetHostViewBase* parent_view = | 96 RenderWidgetHostViewBase* parent_view = |
| 98 frame_connector_->GetParentRenderWidgetHostView(); | 97 frame_connector_->GetParentRenderWidgetHostView(); |
| 99 if (parent_view) { | 98 if (parent_view) { |
| 100 parent_surface_client_id_ = parent_view->GetSurfaceClientId(); | 99 parent_frame_sink_id_ = parent_view->GetFrameSinkId(); |
| 101 DCHECK_NE(parent_surface_client_id_, 0u); | 100 DCHECK(!parent_frame_sink_id_.is_null()); |
| 102 GetSurfaceManager()->RegisterSurfaceNamespaceHierarchy( | 101 GetSurfaceManager()->RegisterFrameSinkHierarchy(parent_frame_sink_id_, |
| 103 parent_surface_client_id_, GetSurfaceClientId()); | 102 GetFrameSinkId()); |
| 104 } | 103 } |
| 105 } | 104 } |
| 106 } | 105 } |
| 107 | 106 |
| 108 void RenderWidgetHostViewChildFrame::InitAsChild( | 107 void RenderWidgetHostViewChildFrame::InitAsChild( |
| 109 gfx::NativeView parent_view) { | 108 gfx::NativeView parent_view) { |
| 110 NOTREACHED(); | 109 NOTREACHED(); |
| 111 } | 110 } |
| 112 | 111 |
| 113 RenderWidgetHost* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const { | 112 RenderWidgetHost* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 261 |
| 263 void RenderWidgetHostViewChildFrame::RenderProcessGone( | 262 void RenderWidgetHostViewChildFrame::RenderProcessGone( |
| 264 base::TerminationStatus status, | 263 base::TerminationStatus status, |
| 265 int error_code) { | 264 int error_code) { |
| 266 if (frame_connector_) | 265 if (frame_connector_) |
| 267 frame_connector_->RenderProcessGone(); | 266 frame_connector_->RenderProcessGone(); |
| 268 Destroy(); | 267 Destroy(); |
| 269 } | 268 } |
| 270 | 269 |
| 271 void RenderWidgetHostViewChildFrame::Destroy() { | 270 void RenderWidgetHostViewChildFrame::Destroy() { |
| 272 // SurfaceClientIds registered with RenderWidgetHostInputEventRouter | 271 // FrameSinkIds registered with RenderWidgetHostInputEventRouter |
| 273 // have already been cleared when RenderWidgetHostViewBase notified its | 272 // have already been cleared when RenderWidgetHostViewBase notified its |
| 274 // observers of our impending destruction. | 273 // observers of our impending destruction. |
| 275 if (frame_connector_) { | 274 if (frame_connector_) { |
| 276 frame_connector_->set_view(nullptr); | 275 frame_connector_->set_view(nullptr); |
| 277 SetCrossProcessFrameConnector(nullptr); | 276 SetCrossProcessFrameConnector(nullptr); |
| 278 } | 277 } |
| 279 | 278 |
| 280 // We notify our observers about shutdown here since we are about to release | 279 // We notify our observers about shutdown here since we are about to release |
| 281 // host_ and do not want any event calls coming from | 280 // host_ and do not want any event calls coming from |
| 282 // RenderWidgetHostInputEventRouter afterwards. | 281 // RenderWidgetHostInputEventRouter afterwards. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 304 if (!frame_connector_) | 303 if (!frame_connector_) |
| 305 return nullptr; | 304 return nullptr; |
| 306 return frame_connector_->GetParentRenderWidgetHostView(); | 305 return frame_connector_->GetParentRenderWidgetHostView(); |
| 307 } | 306 } |
| 308 | 307 |
| 309 void RenderWidgetHostViewChildFrame::RegisterSurfaceNamespaceId() { | 308 void RenderWidgetHostViewChildFrame::RegisterSurfaceNamespaceId() { |
| 310 // If Destroy() has been called before we get here, host_ may be null. | 309 // If Destroy() has been called before we get here, host_ may be null. |
| 311 if (host_ && host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 310 if (host_ && host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
| 312 RenderWidgetHostInputEventRouter* router = | 311 RenderWidgetHostInputEventRouter* router = |
| 313 host_->delegate()->GetInputEventRouter(); | 312 host_->delegate()->GetInputEventRouter(); |
| 314 if (!router->is_registered(GetSurfaceClientId())) | 313 if (!router->is_registered(GetFrameSinkId())) |
| 315 router->AddSurfaceClientIdOwner(GetSurfaceClientId(), this); | 314 router->AddFrameSinkIdOwner(GetFrameSinkId(), this); |
| 316 } | 315 } |
| 317 } | 316 } |
| 318 | 317 |
| 319 void RenderWidgetHostViewChildFrame::UnregisterSurfaceNamespaceId() { | 318 void RenderWidgetHostViewChildFrame::UnregisterSurfaceNamespaceId() { |
| 320 DCHECK(host_); | 319 DCHECK(host_); |
| 321 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 320 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
| 322 host_->delegate()->GetInputEventRouter()->RemoveSurfaceClientIdOwner( | 321 host_->delegate()->GetInputEventRouter()->RemoveFrameSinkIdOwner( |
| 323 GetSurfaceClientId()); | 322 GetFrameSinkId()); |
| 324 } | 323 } |
| 325 } | 324 } |
| 326 | 325 |
| 327 void RenderWidgetHostViewChildFrame::GestureEventAck( | 326 void RenderWidgetHostViewChildFrame::GestureEventAck( |
| 328 const blink::WebGestureEvent& event, | 327 const blink::WebGestureEvent& event, |
| 329 InputEventAckState ack_result) { | 328 InputEventAckState ack_result) { |
| 330 bool not_consumed = ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED || | 329 bool not_consumed = ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED || |
| 331 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 330 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; |
| 332 // GestureScrollBegin is consumed by the target frame and not forwarded, | 331 // GestureScrollBegin is consumed by the target frame and not forwarded, |
| 333 // because we don't know whether we will need to bubble scroll until we | 332 // because we don't know whether we will need to bubble scroll until we |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 if (!surface_factory_) { | 390 if (!surface_factory_) { |
| 392 cc::SurfaceManager* manager = GetSurfaceManager(); | 391 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 393 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this); | 392 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this); |
| 394 } | 393 } |
| 395 | 394 |
| 396 if (surface_id_.is_null()) { | 395 if (surface_id_.is_null()) { |
| 397 surface_id_ = id_allocator_->GenerateId(); | 396 surface_id_ = id_allocator_->GenerateId(); |
| 398 surface_factory_->Create(surface_id_); | 397 surface_factory_->Create(surface_id_); |
| 399 | 398 |
| 400 cc::SurfaceSequence sequence = cc::SurfaceSequence( | 399 cc::SurfaceSequence sequence = cc::SurfaceSequence( |
| 401 id_allocator_->client_id(), next_surface_sequence_++); | 400 id_allocator_->frame_sink_id(), next_surface_sequence_++); |
| 402 // The renderer process will satisfy this dependency when it creates a | 401 // The renderer process will satisfy this dependency when it creates a |
| 403 // SurfaceLayer. | 402 // SurfaceLayer. |
| 404 cc::SurfaceManager* manager = GetSurfaceManager(); | 403 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 405 manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence); | 404 manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence); |
| 406 frame_connector_->SetChildFrameSurface(surface_id_, frame_size, | 405 frame_connector_->SetChildFrameSurface(surface_id_, frame_size, |
| 407 scale_factor, sequence); | 406 scale_factor, sequence); |
| 408 } | 407 } |
| 409 | 408 |
| 410 cc::SurfaceFactory::DrawCallback ack_callback = | 409 cc::SurfaceFactory::DrawCallback ack_callback = |
| 411 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(), | 410 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 frame_connector_->UnlockMouse(); | 461 frame_connector_->UnlockMouse(); |
| 463 } | 462 } |
| 464 | 463 |
| 465 bool RenderWidgetHostViewChildFrame::IsMouseLocked() { | 464 bool RenderWidgetHostViewChildFrame::IsMouseLocked() { |
| 466 if (!host_->delegate()) | 465 if (!host_->delegate()) |
| 467 return false; | 466 return false; |
| 468 | 467 |
| 469 return host_->delegate()->HasMouseLock(host_); | 468 return host_->delegate()->HasMouseLock(host_); |
| 470 } | 469 } |
| 471 | 470 |
| 472 uint32_t RenderWidgetHostViewChildFrame::GetSurfaceClientId() { | 471 cc::FrameSinkId RenderWidgetHostViewChildFrame::GetFrameSinkId() { |
| 473 return id_allocator_->client_id(); | 472 return id_allocator_->frame_sink_id(); |
| 474 } | 473 } |
| 475 | 474 |
| 476 void RenderWidgetHostViewChildFrame::ProcessKeyboardEvent( | 475 void RenderWidgetHostViewChildFrame::ProcessKeyboardEvent( |
| 477 const NativeWebKeyboardEvent& event) { | 476 const NativeWebKeyboardEvent& event) { |
| 478 host_->ForwardKeyboardEvent(event); | 477 host_->ForwardKeyboardEvent(event); |
| 479 } | 478 } |
| 480 | 479 |
| 481 void RenderWidgetHostViewChildFrame::ProcessMouseEvent( | 480 void RenderWidgetHostViewChildFrame::ProcessMouseEvent( |
| 482 const blink::WebMouseEvent& event, | 481 const blink::WebMouseEvent& event, |
| 483 const ui::LatencyInfo& latency) { | 482 const ui::LatencyInfo& latency) { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 | 713 |
| 715 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { | 714 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { |
| 716 return true; | 715 return true; |
| 717 } | 716 } |
| 718 | 717 |
| 719 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { | 718 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { |
| 720 return surface_id_; | 719 return surface_id_; |
| 721 }; | 720 }; |
| 722 | 721 |
| 723 } // namespace content | 722 } // namespace content |
| OLD | NEW |