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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 62443007: Replace old with new synthetic gesture framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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 (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
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_target.h"
34 #include "content/browser/renderer_host/overscroll_controller.h" 36 #include "content/browser/renderer_host/overscroll_controller.h"
35 #include "content/browser/renderer_host/render_process_host_impl.h" 37 #include "content/browser/renderer_host/render_process_host_impl.h"
36 #include "content/browser/renderer_host/render_view_host_impl.h" 38 #include "content/browser/renderer_host/render_view_host_impl.h"
37 #include "content/browser/renderer_host/render_widget_helper.h" 39 #include "content/browser/renderer_host/render_widget_helper.h"
38 #include "content/browser/renderer_host/render_widget_host_delegate.h" 40 #include "content/browser/renderer_host/render_widget_host_delegate.h"
39 #include "content/common/accessibility_messages.h" 41 #include "content/common/accessibility_messages.h"
40 #include "content/common/content_constants_internal.h" 42 #include "content/common/content_constants_internal.h"
41 #include "content/common/gpu/gpu_messages.h" 43 #include "content/common/gpu/gpu_messages.h"
42 #include "content/common/input_messages.h" 44 #include "content/common/input_messages.h"
43 #include "content/common/view_messages.h" 45 #include "content/common/view_messages.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 379
378 last_view_screen_rect_ = view_->GetViewBounds(); 380 last_view_screen_rect_ = view_->GetViewBounds();
379 last_window_screen_rect_ = view_->GetBoundsInRootWindow(); 381 last_window_screen_rect_ = view_->GetBoundsInRootWindow();
380 Send(new ViewMsg_UpdateScreenRects( 382 Send(new ViewMsg_UpdateScreenRects(
381 GetRoutingID(), last_view_screen_rect_, last_window_screen_rect_)); 383 GetRoutingID(), last_view_screen_rect_, last_window_screen_rect_));
382 if (delegate_) 384 if (delegate_)
383 delegate_->DidSendScreenRects(this); 385 delegate_->DidSendScreenRects(this);
384 waiting_for_screen_rects_ack_ = true; 386 waiting_for_screen_rects_ack_ = true;
385 } 387 }
386 388
387 base::TimeDelta
388 RenderWidgetHostImpl::GetSyntheticGestureMessageInterval() const {
389 return synthetic_gesture_controller_.GetSyntheticGestureMessageInterval();
390 }
391
392 void RenderWidgetHostImpl::SetOverscrollControllerEnabled(bool enabled) { 389 void RenderWidgetHostImpl::SetOverscrollControllerEnabled(bool enabled) {
393 if (!enabled) 390 if (!enabled)
394 overscroll_controller_.reset(); 391 overscroll_controller_.reset();
395 else if (!overscroll_controller_) 392 else if (!overscroll_controller_)
396 overscroll_controller_.reset(new OverscrollController()); 393 overscroll_controller_.reset(new OverscrollController());
397 } 394 }
398 395
399 void RenderWidgetHostImpl::SuppressNextCharEvents() { 396 void RenderWidgetHostImpl::SuppressNextCharEvents() {
400 suppress_next_char_events_ = true; 397 suppress_next_char_events_ = true;
401 } 398 }
402 399
403 void RenderWidgetHostImpl::FlushInput() { 400 void RenderWidgetHostImpl::FlushInput() {
404 input_router_->Flush(); 401 input_router_->Flush();
402 if (synthetic_gesture_controller_)
jdduke (slow) 2013/11/18 16:32:55 So, I don't have a strong opinion whether the cont
403 synthetic_gesture_controller_->Flush(base::TimeTicks::Now());
405 } 404 }
406 405
407 void RenderWidgetHostImpl::SetNeedsFlush() { 406 void RenderWidgetHostImpl::SetNeedsFlush() {
408 if (view_) 407 if (view_)
409 view_->OnSetNeedsFlushInput(); 408 view_->OnSetNeedsFlushInput();
410 } 409 }
411 410
412 void RenderWidgetHostImpl::Init() { 411 void RenderWidgetHostImpl::Init() {
413 DCHECK(process_->HasConnection()); 412 DCHECK(process_->HasConnection());
414 413
(...skipping 26 matching lines...) Expand all
441 } 440 }
442 441
443 bool RenderWidgetHostImpl::IsRenderView() const { 442 bool RenderWidgetHostImpl::IsRenderView() const {
444 return false; 443 return false;
445 } 444 }
446 445
447 bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) { 446 bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) {
448 bool handled = true; 447 bool handled = true;
449 bool msg_is_ok = true; 448 bool msg_is_ok = true;
450 IPC_BEGIN_MESSAGE_MAP_EX(RenderWidgetHostImpl, msg, msg_is_ok) 449 IPC_BEGIN_MESSAGE_MAP_EX(RenderWidgetHostImpl, msg, msg_is_ok)
450 IPC_MESSAGE_HANDLER(InputHostMsg_QueueSyntheticGesture,
451 OnQueueSyntheticGesture)
451 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady) 452 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady)
452 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone) 453 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone)
453 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) 454 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose)
454 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScreenRects_ACK, 455 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScreenRects_ACK,
455 OnUpdateScreenRectsAck) 456 OnUpdateScreenRectsAck)
456 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) 457 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove)
457 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnSetTooltipText) 458 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnSetTooltipText)
458 IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnPaintAtSizeAck) 459 IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnPaintAtSizeAck)
459 #if defined(OS_MACOSX) 460 #if defined(OS_MACOSX)
460 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, 461 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped,
461 OnCompositorSurfaceBuffersSwapped) 462 OnCompositorSurfaceBuffersSwapped)
462 #endif 463 #endif
463 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_SwapCompositorFrame, 464 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_SwapCompositorFrame,
464 msg_is_ok = OnSwapCompositorFrame(msg)) 465 msg_is_ok = OnSwapCompositorFrame(msg))
465 IPC_MESSAGE_HANDLER(ViewHostMsg_DidOverscroll, OnOverscrolled) 466 IPC_MESSAGE_HANDLER(ViewHostMsg_DidOverscroll, OnOverscrolled)
466 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 467 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
467 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnUpdateIsDelayed) 468 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) 469 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus)
471 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) 470 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur)
472 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) 471 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor)
473 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, 472 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged,
474 OnTextInputTypeChanged) 473 OnTextInputTypeChanged)
475 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, 474 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition,
476 OnImeCancelComposition) 475 OnImeCancelComposition)
477 IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing, 476 IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing,
478 OnDidActivateAcceleratedCompositing) 477 OnDidActivateAcceleratedCompositing)
479 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) 478 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse)
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 in_flight_event_count_ = 0; 1272 in_flight_event_count_ = 0;
1274 1273
1275 if (view_) { 1274 if (view_) {
1276 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, 1275 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_,
1277 gfx::GLSurfaceHandle()); 1276 gfx::GLSurfaceHandle());
1278 view_->RenderProcessGone(status, exit_code); 1277 view_->RenderProcessGone(status, exit_code);
1279 view_ = NULL; // The View should be deleted by RenderProcessGone. 1278 view_ = NULL; // The View should be deleted by RenderProcessGone.
1280 } 1279 }
1281 1280
1282 BackingStoreManager::RemoveBackingStore(this); 1281 BackingStoreManager::RemoveBackingStore(this);
1282
1283 synthetic_gesture_controller_.reset();
1283 } 1284 }
1284 1285
1285 void RenderWidgetHostImpl::UpdateTextDirection(WebTextDirection direction) { 1286 void RenderWidgetHostImpl::UpdateTextDirection(WebTextDirection direction) {
1286 text_direction_updated_ = true; 1287 text_direction_updated_ = true;
1287 text_direction_ = direction; 1288 text_direction_ = direction;
1288 } 1289 }
1289 1290
1290 void RenderWidgetHostImpl::CancelUpdateTextDirection() { 1291 void RenderWidgetHostImpl::CancelUpdateTextDirection() {
1291 if (text_direction_updated_) 1292 if (text_direction_updated_)
1292 text_direction_canceled_ = true; 1293 text_direction_canceled_ = true;
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 // DidUpdateBackingStore() method. On platforms which have asynchronous 1706 // DidUpdateBackingStore() method. On platforms which have asynchronous
1706 // painting, such as Linux, this is the sum of MPArch.RWH_OnMsgUpdateRect, 1707 // painting, such as Linux, this is the sum of MPArch.RWH_OnMsgUpdateRect,
1707 // MPArch.RWH_DidUpdateBackingStore, and the time spent asynchronously 1708 // MPArch.RWH_DidUpdateBackingStore, and the time spent asynchronously
1708 // waiting for the paint to complete. 1709 // waiting for the paint to complete.
1709 // 1710 //
1710 // On other platforms, this will be equivalent to MPArch.RWH_OnMsgUpdateRect. 1711 // On other platforms, this will be equivalent to MPArch.RWH_OnMsgUpdateRect.
1711 delta = now - paint_start; 1712 delta = now - paint_start;
1712 UMA_HISTOGRAM_TIMES("MPArch.RWH_TotalPaintTime", delta); 1713 UMA_HISTOGRAM_TIMES("MPArch.RWH_TotalPaintTime", delta);
1713 } 1714 }
1714 1715
1715 void RenderWidgetHostImpl::OnBeginSmoothScroll( 1716 void RenderWidgetHostImpl::OnQueueSyntheticGesture(
1716 const ViewHostMsg_BeginSmoothScroll_Params& params) { 1717 const SyntheticGesturePacket& gesture_packet) {
1717 if (!view_) 1718 if (!synthetic_gesture_controller_) {
1718 return; 1719 if (!view_) {
1719 synthetic_gesture_controller_.BeginSmoothScroll(view_, params); 1720 LOG(WARNING) <<
jdduke (slow) 2013/11/18 16:32:55 Let's remove the warning and just early return.
Dominik Grewe 2013/11/18 17:48:05 Done.
1720 } 1721 "No view available for creating synthetic gesture controller";
1722 return;
1723 }
1724 synthetic_gesture_controller_.reset(
1725 new SyntheticGestureController(
1726 view_->CreateSyntheticGestureTarget().Pass()));
jdduke (slow) 2013/11/18 16:32:55 Hmm, I don't think you need the Pass(), do you? It
Dominik Grewe 2013/11/18 17:48:05 Yeah, you're right.
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()).Pass());
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698