| 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 25 matching lines...) Expand all Loading... |
| 36 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( | 36 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( |
| 37 RenderWidgetHost* widget_host) | 37 RenderWidgetHost* widget_host) |
| 38 : host_(RenderWidgetHostImpl::From(widget_host)), | 38 : host_(RenderWidgetHostImpl::From(widget_host)), |
| 39 next_surface_sequence_(1u), | 39 next_surface_sequence_(1u), |
| 40 last_output_surface_id_(0), | 40 last_output_surface_id_(0), |
| 41 current_surface_scale_factor_(1.f), | 41 current_surface_scale_factor_(1.f), |
| 42 ack_pending_count_(0), | 42 ack_pending_count_(0), |
| 43 frame_connector_(nullptr), | 43 frame_connector_(nullptr), |
| 44 weak_factory_(this) { | 44 weak_factory_(this) { |
| 45 id_allocator_ = CreateSurfaceIdAllocator(); | 45 id_allocator_ = CreateSurfaceIdAllocator(); |
| 46 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 46 RegisterSurfaceNamespaceId(); |
| 47 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner( | |
| 48 GetSurfaceIdNamespace(), this); | |
| 49 } | |
| 50 | 47 |
| 51 host_->SetView(this); | 48 host_->SetView(this); |
| 52 } | 49 } |
| 53 | 50 |
| 54 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { | 51 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { |
| 55 if (!surface_id_.is_null()) | 52 if (!surface_id_.is_null()) |
| 56 surface_factory_->Destroy(surface_id_); | 53 surface_factory_->Destroy(surface_id_); |
| 57 } | 54 } |
| 58 | 55 |
| 59 void RenderWidgetHostViewChildFrame::InitAsChild( | 56 void RenderWidgetHostViewChildFrame::InitAsChild( |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 243 } |
| 247 | 244 |
| 248 void RenderWidgetHostViewChildFrame::LockCompositingSurface() { | 245 void RenderWidgetHostViewChildFrame::LockCompositingSurface() { |
| 249 NOTIMPLEMENTED(); | 246 NOTIMPLEMENTED(); |
| 250 } | 247 } |
| 251 | 248 |
| 252 void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() { | 249 void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() { |
| 253 NOTIMPLEMENTED(); | 250 NOTIMPLEMENTED(); |
| 254 } | 251 } |
| 255 | 252 |
| 253 void RenderWidgetHostViewChildFrame::RegisterSurfaceNamespaceId() { |
| 254 DCHECK(host_); |
| 255 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
| 256 RenderWidgetHostInputEventRouter* router = |
| 257 host_->delegate()->GetInputEventRouter(); |
| 258 if (!router->is_registered(GetSurfaceIdNamespace())) |
| 259 router->AddSurfaceIdNamespaceOwner(GetSurfaceIdNamespace(), this); |
| 260 } |
| 261 } |
| 262 |
| 263 void RenderWidgetHostViewChildFrame::UnregisterSurfaceNamespaceId() { |
| 264 DCHECK(host_); |
| 265 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
| 266 host_->delegate()->GetInputEventRouter()->RemoveSurfaceIdNamespaceOwner( |
| 267 GetSurfaceIdNamespace()); |
| 268 } |
| 269 } |
| 270 |
| 256 void RenderWidgetHostViewChildFrame::SurfaceDrawn(uint32_t output_surface_id, | 271 void RenderWidgetHostViewChildFrame::SurfaceDrawn(uint32_t output_surface_id, |
| 257 cc::SurfaceDrawStatus drawn) { | 272 cc::SurfaceDrawStatus drawn) { |
| 258 cc::CompositorFrameAck ack; | 273 cc::CompositorFrameAck ack; |
| 259 DCHECK_GT(ack_pending_count_, 0U); | 274 DCHECK_GT(ack_pending_count_, 0U); |
| 260 if (!surface_returned_resources_.empty()) | 275 if (!surface_returned_resources_.empty()) |
| 261 ack.resources.swap(surface_returned_resources_); | 276 ack.resources.swap(surface_returned_resources_); |
| 262 if (host_) { | 277 if (host_) { |
| 263 host_->Send(new ViewMsg_SwapCompositorFrameAck(host_->GetRoutingID(), | 278 host_->Send(new ViewMsg_SwapCompositorFrameAck(host_->GetRoutingID(), |
| 264 output_surface_id, ack)); | 279 output_surface_id, ack)); |
| 265 } | 280 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 RenderWidgetHostViewBase* root_view = | 372 RenderWidgetHostViewBase* root_view = |
| 358 frame_connector_->GetRootRenderWidgetHostView(); | 373 frame_connector_->GetRootRenderWidgetHostView(); |
| 359 | 374 |
| 360 // The root_view can be null in tests when using a TestWebContents. | 375 // The root_view can be null in tests when using a TestWebContents. |
| 361 if (root_view) | 376 if (root_view) |
| 362 rect = root_view->GetBoundsInRootWindow(); | 377 rect = root_view->GetBoundsInRootWindow(); |
| 363 } | 378 } |
| 364 return rect; | 379 return rect; |
| 365 } | 380 } |
| 366 | 381 |
| 367 #if defined(USE_AURA) | |
| 368 void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent( | 382 void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent( |
| 369 const TouchEventWithLatencyInfo& touch, | 383 const TouchEventWithLatencyInfo& touch, |
| 370 InputEventAckState ack_result) { | 384 InputEventAckState ack_result) { |
| 385 if (!frame_connector_) |
| 386 return; |
| 387 |
| 388 frame_connector_->ForwardProcessAckedTouchEvent(touch, ack_result); |
| 371 } | 389 } |
| 372 #endif // defined(USE_AURA) | |
| 373 | 390 |
| 374 bool RenderWidgetHostViewChildFrame::LockMouse() { | 391 bool RenderWidgetHostViewChildFrame::LockMouse() { |
| 375 return false; | 392 return false; |
| 376 } | 393 } |
| 377 | 394 |
| 378 void RenderWidgetHostViewChildFrame::UnlockMouse() { | 395 void RenderWidgetHostViewChildFrame::UnlockMouse() { |
| 379 } | 396 } |
| 380 | 397 |
| 381 uint32_t RenderWidgetHostViewChildFrame::GetSurfaceIdNamespace() { | 398 uint32_t RenderWidgetHostViewChildFrame::GetSurfaceIdNamespace() { |
| 382 return id_allocator_->id_namespace(); | 399 return id_allocator_->id_namespace(); |
| 383 } | 400 } |
| 384 | 401 |
| 385 void RenderWidgetHostViewChildFrame::ProcessKeyboardEvent( | 402 void RenderWidgetHostViewChildFrame::ProcessKeyboardEvent( |
| 386 const NativeWebKeyboardEvent& event) { | 403 const NativeWebKeyboardEvent& event) { |
| 387 host_->ForwardKeyboardEvent(event); | 404 host_->ForwardKeyboardEvent(event); |
| 388 } | 405 } |
| 389 | 406 |
| 390 void RenderWidgetHostViewChildFrame::ProcessMouseEvent( | 407 void RenderWidgetHostViewChildFrame::ProcessMouseEvent( |
| 391 const blink::WebMouseEvent& event) { | 408 const blink::WebMouseEvent& event) { |
| 392 host_->ForwardMouseEvent(event); | 409 host_->ForwardMouseEvent(event); |
| 393 } | 410 } |
| 394 | 411 |
| 395 void RenderWidgetHostViewChildFrame::ProcessMouseWheelEvent( | 412 void RenderWidgetHostViewChildFrame::ProcessMouseWheelEvent( |
| 396 const blink::WebMouseWheelEvent& event) { | 413 const blink::WebMouseWheelEvent& event) { |
| 397 if (event.deltaX != 0 || event.deltaY != 0) | 414 if (event.deltaX != 0 || event.deltaY != 0) |
| 398 host_->ForwardWheelEvent(event); | 415 host_->ForwardWheelEvent(event); |
| 399 } | 416 } |
| 400 | 417 |
| 418 void RenderWidgetHostViewChildFrame::ProcessTouchEvent( |
| 419 const blink::WebTouchEvent& event, |
| 420 const ui::LatencyInfo& latency) { |
| 421 if (event.type == blink::WebInputEvent::TouchStart && |
| 422 frame_connector_ && !frame_connector_->HasFocus()) { |
| 423 frame_connector_->FocusRootView(); |
| 424 } |
| 425 |
| 426 host_->ForwardTouchEventWithLatencyInfo(event, latency); |
| 427 } |
| 428 |
| 401 gfx::Point RenderWidgetHostViewChildFrame::TransformPointToRootCoordSpace( | 429 gfx::Point RenderWidgetHostViewChildFrame::TransformPointToRootCoordSpace( |
| 402 const gfx::Point& point) { | 430 const gfx::Point& point) { |
| 403 if (!frame_connector_) | 431 if (!frame_connector_) |
| 404 return point; | 432 return point; |
| 405 | 433 |
| 406 return frame_connector_->TransformPointToRootCoordSpace(point, surface_id_); | 434 return frame_connector_->TransformPointToRootCoordSpace(point, surface_id_); |
| 407 } | 435 } |
| 408 | 436 |
| 409 #if defined(OS_MACOSX) | 437 #if defined(OS_MACOSX) |
| 410 void RenderWidgetHostViewChildFrame::SetActive(bool active) { | 438 void RenderWidgetHostViewChildFrame::SetActive(bool active) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 if (surface_factory_ && !surface_id_.is_null()) | 571 if (surface_factory_ && !surface_id_.is_null()) |
| 544 surface_factory_->Destroy(surface_id_); | 572 surface_factory_->Destroy(surface_id_); |
| 545 surface_id_ = cc::SurfaceId(); | 573 surface_id_ = cc::SurfaceId(); |
| 546 } | 574 } |
| 547 | 575 |
| 548 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { | 576 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { |
| 549 return surface_id_; | 577 return surface_id_; |
| 550 }; | 578 }; |
| 551 | 579 |
| 552 } // namespace content | 580 } // namespace content |
| OLD | NEW |