| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "cc/output/compositor_frame_ack.h" | 24 #include "cc/output/compositor_frame_ack.h" |
| 25 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 25 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 26 #include "content/browser/gpu/compositor_util.h" | 26 #include "content/browser/gpu/compositor_util.h" |
| 27 #include "content/browser/gpu/gpu_process_host.h" | 27 #include "content/browser/gpu/gpu_process_host.h" |
| 28 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 28 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 29 #include "content/browser/gpu/gpu_surface_tracker.h" | 29 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 30 #include "content/browser/renderer_host/backing_store.h" | 30 #include "content/browser/renderer_host/backing_store.h" |
| 31 #include "content/browser/renderer_host/backing_store_manager.h" | 31 #include "content/browser/renderer_host/backing_store_manager.h" |
| 32 #include "content/browser/renderer_host/dip_util.h" | 32 #include "content/browser/renderer_host/dip_util.h" |
| 33 #include "content/browser/renderer_host/input/immediate_input_router.h" | 33 #include "content/browser/renderer_host/input/immediate_input_router.h" |
| 34 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
| 35 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |
| 36 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
| 34 #include "content/browser/renderer_host/overscroll_controller.h" | 37 #include "content/browser/renderer_host/overscroll_controller.h" |
| 35 #include "content/browser/renderer_host/render_process_host_impl.h" | 38 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 36 #include "content/browser/renderer_host/render_view_host_impl.h" | 39 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 37 #include "content/browser/renderer_host/render_widget_helper.h" | 40 #include "content/browser/renderer_host/render_widget_helper.h" |
| 38 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 41 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 39 #include "content/common/accessibility_messages.h" | 42 #include "content/common/accessibility_messages.h" |
| 40 #include "content/common/content_constants_internal.h" | 43 #include "content/common/content_constants_internal.h" |
| 41 #include "content/common/gpu/gpu_messages.h" | 44 #include "content/common/gpu/gpu_messages.h" |
| 42 #include "content/common/input_messages.h" | 45 #include "content/common/input_messages.h" |
| 43 #include "content/common/view_messages.h" | 46 #include "content/common/view_messages.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 return rwh->AsRenderWidgetHostImpl(); | 312 return rwh->AsRenderWidgetHostImpl(); |
| 310 } | 313 } |
| 311 | 314 |
| 312 void RenderWidgetHostImpl::SetView(RenderWidgetHostView* view) { | 315 void RenderWidgetHostImpl::SetView(RenderWidgetHostView* view) { |
| 313 view_ = RenderWidgetHostViewPort::FromRWHV(view); | 316 view_ = RenderWidgetHostViewPort::FromRWHV(view); |
| 314 | 317 |
| 315 if (!view_) { | 318 if (!view_) { |
| 316 GpuSurfaceTracker::Get()->SetSurfaceHandle( | 319 GpuSurfaceTracker::Get()->SetSurfaceHandle( |
| 317 surface_id_, gfx::GLSurfaceHandle()); | 320 surface_id_, gfx::GLSurfaceHandle()); |
| 318 } | 321 } |
| 322 |
| 323 synthetic_gesture_controller_.reset(); |
| 319 } | 324 } |
| 320 | 325 |
| 321 RenderProcessHost* RenderWidgetHostImpl::GetProcess() const { | 326 RenderProcessHost* RenderWidgetHostImpl::GetProcess() const { |
| 322 return process_; | 327 return process_; |
| 323 } | 328 } |
| 324 | 329 |
| 325 int RenderWidgetHostImpl::GetRoutingID() const { | 330 int RenderWidgetHostImpl::GetRoutingID() const { |
| 326 return routing_id_; | 331 return routing_id_; |
| 327 } | 332 } |
| 328 | 333 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 382 |
| 378 last_view_screen_rect_ = view_->GetViewBounds(); | 383 last_view_screen_rect_ = view_->GetViewBounds(); |
| 379 last_window_screen_rect_ = view_->GetBoundsInRootWindow(); | 384 last_window_screen_rect_ = view_->GetBoundsInRootWindow(); |
| 380 Send(new ViewMsg_UpdateScreenRects( | 385 Send(new ViewMsg_UpdateScreenRects( |
| 381 GetRoutingID(), last_view_screen_rect_, last_window_screen_rect_)); | 386 GetRoutingID(), last_view_screen_rect_, last_window_screen_rect_)); |
| 382 if (delegate_) | 387 if (delegate_) |
| 383 delegate_->DidSendScreenRects(this); | 388 delegate_->DidSendScreenRects(this); |
| 384 waiting_for_screen_rects_ack_ = true; | 389 waiting_for_screen_rects_ack_ = true; |
| 385 } | 390 } |
| 386 | 391 |
| 387 base::TimeDelta | |
| 388 RenderWidgetHostImpl::GetSyntheticGestureMessageInterval() const { | |
| 389 return synthetic_gesture_controller_.GetSyntheticGestureMessageInterval(); | |
| 390 } | |
| 391 | |
| 392 void RenderWidgetHostImpl::SetOverscrollControllerEnabled(bool enabled) { | 392 void RenderWidgetHostImpl::SetOverscrollControllerEnabled(bool enabled) { |
| 393 if (!enabled) | 393 if (!enabled) |
| 394 overscroll_controller_.reset(); | 394 overscroll_controller_.reset(); |
| 395 else if (!overscroll_controller_) | 395 else if (!overscroll_controller_) |
| 396 overscroll_controller_.reset(new OverscrollController()); | 396 overscroll_controller_.reset(new OverscrollController()); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void RenderWidgetHostImpl::SuppressNextCharEvents() { | 399 void RenderWidgetHostImpl::SuppressNextCharEvents() { |
| 400 suppress_next_char_events_ = true; | 400 suppress_next_char_events_ = true; |
| 401 } | 401 } |
| 402 | 402 |
| 403 void RenderWidgetHostImpl::FlushInput() { | 403 void RenderWidgetHostImpl::FlushInput() { |
| 404 input_router_->Flush(); | 404 input_router_->Flush(); |
| 405 if (synthetic_gesture_controller_) |
| 406 synthetic_gesture_controller_->Flush(base::TimeTicks::Now()); |
| 405 } | 407 } |
| 406 | 408 |
| 407 void RenderWidgetHostImpl::SetNeedsFlush() { | 409 void RenderWidgetHostImpl::SetNeedsFlush() { |
| 408 if (view_) | 410 if (view_) |
| 409 view_->OnSetNeedsFlushInput(); | 411 view_->OnSetNeedsFlushInput(); |
| 410 } | 412 } |
| 411 | 413 |
| 412 void RenderWidgetHostImpl::Init() { | 414 void RenderWidgetHostImpl::Init() { |
| 413 DCHECK(process_->HasConnection()); | 415 DCHECK(process_->HasConnection()); |
| 414 | 416 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 441 } | 443 } |
| 442 | 444 |
| 443 bool RenderWidgetHostImpl::IsRenderView() const { | 445 bool RenderWidgetHostImpl::IsRenderView() const { |
| 444 return false; | 446 return false; |
| 445 } | 447 } |
| 446 | 448 |
| 447 bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) { | 449 bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) { |
| 448 bool handled = true; | 450 bool handled = true; |
| 449 bool msg_is_ok = true; | 451 bool msg_is_ok = true; |
| 450 IPC_BEGIN_MESSAGE_MAP_EX(RenderWidgetHostImpl, msg, msg_is_ok) | 452 IPC_BEGIN_MESSAGE_MAP_EX(RenderWidgetHostImpl, msg, msg_is_ok) |
| 453 IPC_MESSAGE_HANDLER(InputHostMsg_QueueSyntheticGesture, |
| 454 OnQueueSyntheticGesture) |
| 451 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady) | 455 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady) |
| 452 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone) | 456 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone) |
| 453 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) | 457 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) |
| 454 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScreenRects_ACK, | 458 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScreenRects_ACK, |
| 455 OnUpdateScreenRectsAck) | 459 OnUpdateScreenRectsAck) |
| 456 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) | 460 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) |
| 457 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnSetTooltipText) | 461 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnSetTooltipText) |
| 458 IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnPaintAtSizeAck) | 462 IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnPaintAtSizeAck) |
| 459 #if defined(OS_MACOSX) | 463 #if defined(OS_MACOSX) |
| 460 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, | 464 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, |
| 461 OnCompositorSurfaceBuffersSwapped) | 465 OnCompositorSurfaceBuffersSwapped) |
| 462 #endif | 466 #endif |
| 463 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_SwapCompositorFrame, | 467 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_SwapCompositorFrame, |
| 464 msg_is_ok = OnSwapCompositorFrame(msg)) | 468 msg_is_ok = OnSwapCompositorFrame(msg)) |
| 465 IPC_MESSAGE_HANDLER(ViewHostMsg_DidOverscroll, OnOverscrolled) | 469 IPC_MESSAGE_HANDLER(ViewHostMsg_DidOverscroll, OnOverscrolled) |
| 466 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) | 470 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) |
| 467 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnUpdateIsDelayed) | 471 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnUpdateIsDelayed) |
| 468 IPC_MESSAGE_HANDLER(ViewHostMsg_BeginSmoothScroll, OnBeginSmoothScroll) | |
| 469 IPC_MESSAGE_HANDLER(ViewHostMsg_BeginPinch, OnBeginPinch) | |
| 470 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) | 472 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) |
| 471 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) | 473 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) |
| 472 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) | 474 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) |
| 473 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, | 475 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, |
| 474 OnTextInputTypeChanged) | 476 OnTextInputTypeChanged) |
| 475 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, | 477 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, |
| 476 OnImeCancelComposition) | 478 OnImeCancelComposition) |
| 477 IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing, | 479 IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing, |
| 478 OnDidActivateAcceleratedCompositing) | 480 OnDidActivateAcceleratedCompositing) |
| 479 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) | 481 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 in_flight_event_count_ = 0; | 1275 in_flight_event_count_ = 0; |
| 1274 | 1276 |
| 1275 if (view_) { | 1277 if (view_) { |
| 1276 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, | 1278 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, |
| 1277 gfx::GLSurfaceHandle()); | 1279 gfx::GLSurfaceHandle()); |
| 1278 view_->RenderProcessGone(status, exit_code); | 1280 view_->RenderProcessGone(status, exit_code); |
| 1279 view_ = NULL; // The View should be deleted by RenderProcessGone. | 1281 view_ = NULL; // The View should be deleted by RenderProcessGone. |
| 1280 } | 1282 } |
| 1281 | 1283 |
| 1282 BackingStoreManager::RemoveBackingStore(this); | 1284 BackingStoreManager::RemoveBackingStore(this); |
| 1285 |
| 1286 synthetic_gesture_controller_.reset(); |
| 1283 } | 1287 } |
| 1284 | 1288 |
| 1285 void RenderWidgetHostImpl::UpdateTextDirection(WebTextDirection direction) { | 1289 void RenderWidgetHostImpl::UpdateTextDirection(WebTextDirection direction) { |
| 1286 text_direction_updated_ = true; | 1290 text_direction_updated_ = true; |
| 1287 text_direction_ = direction; | 1291 text_direction_ = direction; |
| 1288 } | 1292 } |
| 1289 | 1293 |
| 1290 void RenderWidgetHostImpl::CancelUpdateTextDirection() { | 1294 void RenderWidgetHostImpl::CancelUpdateTextDirection() { |
| 1291 if (text_direction_updated_) | 1295 if (text_direction_updated_) |
| 1292 text_direction_canceled_ = true; | 1296 text_direction_canceled_ = true; |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 // DidUpdateBackingStore() method. On platforms which have asynchronous | 1709 // DidUpdateBackingStore() method. On platforms which have asynchronous |
| 1706 // painting, such as Linux, this is the sum of MPArch.RWH_OnMsgUpdateRect, | 1710 // painting, such as Linux, this is the sum of MPArch.RWH_OnMsgUpdateRect, |
| 1707 // MPArch.RWH_DidUpdateBackingStore, and the time spent asynchronously | 1711 // MPArch.RWH_DidUpdateBackingStore, and the time spent asynchronously |
| 1708 // waiting for the paint to complete. | 1712 // waiting for the paint to complete. |
| 1709 // | 1713 // |
| 1710 // On other platforms, this will be equivalent to MPArch.RWH_OnMsgUpdateRect. | 1714 // On other platforms, this will be equivalent to MPArch.RWH_OnMsgUpdateRect. |
| 1711 delta = now - paint_start; | 1715 delta = now - paint_start; |
| 1712 UMA_HISTOGRAM_TIMES("MPArch.RWH_TotalPaintTime", delta); | 1716 UMA_HISTOGRAM_TIMES("MPArch.RWH_TotalPaintTime", delta); |
| 1713 } | 1717 } |
| 1714 | 1718 |
| 1715 void RenderWidgetHostImpl::OnBeginSmoothScroll( | 1719 void RenderWidgetHostImpl::OnQueueSyntheticGesture( |
| 1716 const ViewHostMsg_BeginSmoothScroll_Params& params) { | 1720 const SyntheticGesturePacket& gesture_packet) { |
| 1717 if (!view_) | 1721 if (!synthetic_gesture_controller_) { |
| 1718 return; | 1722 if (!view_) |
| 1719 synthetic_gesture_controller_.BeginSmoothScroll(view_, params); | 1723 return; |
| 1720 } | 1724 synthetic_gesture_controller_.reset( |
| 1725 new SyntheticGestureController( |
| 1726 view_->CreateSyntheticGestureTarget().Pass())); |
| 1727 } |
| 1721 | 1728 |
| 1722 void RenderWidgetHostImpl::OnBeginPinch( | 1729 synthetic_gesture_controller_->QueueSyntheticGesture( |
| 1723 const ViewHostMsg_BeginPinch_Params& params) { | 1730 SyntheticGesture::Create(*gesture_packet.gesture_params())); |
| 1724 if (!view_) | |
| 1725 return; | |
| 1726 synthetic_gesture_controller_.BeginPinch(view_, params); | |
| 1727 } | 1731 } |
| 1728 | 1732 |
| 1729 void RenderWidgetHostImpl::OnFocus() { | 1733 void RenderWidgetHostImpl::OnFocus() { |
| 1730 // Only RenderViewHost can deal with that message. | 1734 // Only RenderViewHost can deal with that message. |
| 1731 RecordAction(UserMetricsAction("BadMessageTerminate_RWH4")); | 1735 RecordAction(UserMetricsAction("BadMessageTerminate_RWH4")); |
| 1732 GetProcess()->ReceivedBadMessage(); | 1736 GetProcess()->ReceivedBadMessage(); |
| 1733 } | 1737 } |
| 1734 | 1738 |
| 1735 void RenderWidgetHostImpl::OnBlur() { | 1739 void RenderWidgetHostImpl::OnBlur() { |
| 1736 // Only RenderViewHost can deal with that message. | 1740 // Only RenderViewHost can deal with that message. |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2477 continue; | 2481 continue; |
| 2478 } | 2482 } |
| 2479 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); | 2483 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); |
| 2480 if (rwhi_set.insert(rwhi).second) | 2484 if (rwhi_set.insert(rwhi).second) |
| 2481 rwhi->FrameSwapped(latency_info); | 2485 rwhi->FrameSwapped(latency_info); |
| 2482 } | 2486 } |
| 2483 } | 2487 } |
| 2484 } | 2488 } |
| 2485 | 2489 |
| 2486 } // namespace content | 2490 } // namespace content |
| OLD | NEW |