Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: content/browser/frame_host/render_widget_host_view_child_frame.cc

Issue 2369793002: WIP: Propagate SurfaceID up window tree hierarchy
Patch Set: Fix input events: EventDispatcher ignores container windows Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 258
260 void RenderWidgetHostViewChildFrame::RenderProcessGone( 259 void RenderWidgetHostViewChildFrame::RenderProcessGone(
261 base::TerminationStatus status, 260 base::TerminationStatus status,
262 int error_code) { 261 int error_code) {
263 if (frame_connector_) 262 if (frame_connector_)
264 frame_connector_->RenderProcessGone(); 263 frame_connector_->RenderProcessGone();
265 Destroy(); 264 Destroy();
266 } 265 }
267 266
268 void RenderWidgetHostViewChildFrame::Destroy() { 267 void RenderWidgetHostViewChildFrame::Destroy() {
269 // SurfaceClientIds registered with RenderWidgetHostInputEventRouter 268 // FrameSinkIds registered with RenderWidgetHostInputEventRouter
270 // have already been cleared when RenderWidgetHostViewBase notified its 269 // have already been cleared when RenderWidgetHostViewBase notified its
271 // observers of our impending destruction. 270 // observers of our impending destruction.
272 if (frame_connector_) { 271 if (frame_connector_) {
273 frame_connector_->set_view(nullptr); 272 frame_connector_->set_view(nullptr);
274 SetCrossProcessFrameConnector(nullptr); 273 SetCrossProcessFrameConnector(nullptr);
275 } 274 }
276 275
277 // We notify our observers about shutdown here since we are about to release 276 // We notify our observers about shutdown here since we are about to release
278 // host_ and do not want any event calls coming from 277 // host_ and do not want any event calls coming from
279 // RenderWidgetHostInputEventRouter afterwards. 278 // RenderWidgetHostInputEventRouter afterwards.
(...skipping 21 matching lines...) Expand all
301 if (!frame_connector_) 300 if (!frame_connector_)
302 return nullptr; 301 return nullptr;
303 return frame_connector_->GetParentRenderWidgetHostView(); 302 return frame_connector_->GetParentRenderWidgetHostView();
304 } 303 }
305 304
306 void RenderWidgetHostViewChildFrame::RegisterSurfaceNamespaceId() { 305 void RenderWidgetHostViewChildFrame::RegisterSurfaceNamespaceId() {
307 // If Destroy() has been called before we get here, host_ may be null. 306 // If Destroy() has been called before we get here, host_ may be null.
308 if (host_ && host_->delegate() && host_->delegate()->GetInputEventRouter()) { 307 if (host_ && host_->delegate() && host_->delegate()->GetInputEventRouter()) {
309 RenderWidgetHostInputEventRouter* router = 308 RenderWidgetHostInputEventRouter* router =
310 host_->delegate()->GetInputEventRouter(); 309 host_->delegate()->GetInputEventRouter();
311 if (!router->is_registered(GetSurfaceClientId())) 310 if (!router->is_registered(GetFrameSinkId()))
312 router->AddSurfaceClientIdOwner(GetSurfaceClientId(), this); 311 router->AddFrameSinkIdOwner(GetFrameSinkId(), this);
313 } 312 }
314 } 313 }
315 314
316 void RenderWidgetHostViewChildFrame::UnregisterSurfaceNamespaceId() { 315 void RenderWidgetHostViewChildFrame::UnregisterSurfaceNamespaceId() {
317 DCHECK(host_); 316 DCHECK(host_);
318 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { 317 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) {
319 host_->delegate()->GetInputEventRouter()->RemoveSurfaceClientIdOwner( 318 host_->delegate()->GetInputEventRouter()->RemoveFrameSinkIdOwner(
320 GetSurfaceClientId()); 319 GetFrameSinkId());
321 } 320 }
322 } 321 }
323 322
324 void RenderWidgetHostViewChildFrame::GestureEventAck( 323 void RenderWidgetHostViewChildFrame::GestureEventAck(
325 const blink::WebGestureEvent& event, 324 const blink::WebGestureEvent& event,
326 InputEventAckState ack_result) { 325 InputEventAckState ack_result) {
327 bool not_consumed = ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED || 326 bool not_consumed = ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED ||
328 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; 327 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
329 // GestureScrollBegin is consumed by the target frame and not forwarded, 328 // GestureScrollBegin is consumed by the target frame and not forwarded,
330 // because we don't know whether we will need to bubble scroll until we 329 // 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
388 if (!surface_factory_) { 387 if (!surface_factory_) {
389 cc::SurfaceManager* manager = GetSurfaceManager(); 388 cc::SurfaceManager* manager = GetSurfaceManager();
390 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this); 389 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this);
391 } 390 }
392 391
393 if (surface_id_.is_null()) { 392 if (surface_id_.is_null()) {
394 surface_id_ = id_allocator_->GenerateId(); 393 surface_id_ = id_allocator_->GenerateId();
395 surface_factory_->Create(surface_id_); 394 surface_factory_->Create(surface_id_);
396 395
397 cc::SurfaceSequence sequence = cc::SurfaceSequence( 396 cc::SurfaceSequence sequence = cc::SurfaceSequence(
398 id_allocator_->client_id(), next_surface_sequence_++); 397 id_allocator_->frame_sink_id(), next_surface_sequence_++);
399 // The renderer process will satisfy this dependency when it creates a 398 // The renderer process will satisfy this dependency when it creates a
400 // SurfaceLayer. 399 // SurfaceLayer.
401 cc::SurfaceManager* manager = GetSurfaceManager(); 400 cc::SurfaceManager* manager = GetSurfaceManager();
402 manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence); 401 manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence);
403 frame_connector_->SetChildFrameSurface(surface_id_, frame_size, 402 frame_connector_->SetChildFrameSurface(surface_id_, frame_size,
404 scale_factor, sequence); 403 scale_factor, sequence);
405 } 404 }
406 405
407 cc::SurfaceFactory::DrawCallback ack_callback = 406 cc::SurfaceFactory::DrawCallback ack_callback =
408 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(), 407 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 frame_connector_->UnlockMouse(); 458 frame_connector_->UnlockMouse();
460 } 459 }
461 460
462 bool RenderWidgetHostViewChildFrame::IsMouseLocked() { 461 bool RenderWidgetHostViewChildFrame::IsMouseLocked() {
463 if (!host_->delegate()) 462 if (!host_->delegate())
464 return false; 463 return false;
465 464
466 return host_->delegate()->HasMouseLock(host_); 465 return host_->delegate()->HasMouseLock(host_);
467 } 466 }
468 467
469 uint32_t RenderWidgetHostViewChildFrame::GetSurfaceClientId() { 468 cc::FrameSinkId RenderWidgetHostViewChildFrame::GetFrameSinkId() {
470 return id_allocator_->client_id(); 469 return id_allocator_->frame_sink_id();
471 } 470 }
472 471
473 void RenderWidgetHostViewChildFrame::ProcessKeyboardEvent( 472 void RenderWidgetHostViewChildFrame::ProcessKeyboardEvent(
474 const NativeWebKeyboardEvent& event) { 473 const NativeWebKeyboardEvent& event) {
475 host_->ForwardKeyboardEvent(event); 474 host_->ForwardKeyboardEvent(event);
476 } 475 }
477 476
478 void RenderWidgetHostViewChildFrame::ProcessMouseEvent( 477 void RenderWidgetHostViewChildFrame::ProcessMouseEvent(
479 const blink::WebMouseEvent& event, 478 const blink::WebMouseEvent& event,
480 const ui::LatencyInfo& latency) { 479 const ui::LatencyInfo& latency) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 710
712 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { 711 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const {
713 return true; 712 return true;
714 } 713 }
715 714
716 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { 715 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const {
717 return surface_id_; 716 return surface_id_;
718 }; 717 };
719 718
720 } // namespace content 719 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698