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

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

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

Powered by Google App Engine
This is Rietveld 408576698