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

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

Issue 7044096: Throttle the touch move events sent to the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/render_widget_host.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "content/browser/renderer_host/render_widget_host.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 view_(NULL), 68 view_(NULL),
69 process_(process), 69 process_(process),
70 routing_id_(routing_id), 70 routing_id_(routing_id),
71 is_loading_(false), 71 is_loading_(false),
72 is_hidden_(false), 72 is_hidden_(false),
73 is_accelerated_compositing_active_(false), 73 is_accelerated_compositing_active_(false),
74 repaint_ack_pending_(false), 74 repaint_ack_pending_(false),
75 resize_ack_pending_(false), 75 resize_ack_pending_(false),
76 mouse_move_pending_(false), 76 mouse_move_pending_(false),
77 mouse_wheel_pending_(false), 77 mouse_wheel_pending_(false),
78 #if defined(TOUCH_UI)
79 touch_move_pending_(false),
80 touch_event_is_queued_(false),
81 #endif
78 needs_repainting_on_restore_(false), 82 needs_repainting_on_restore_(false),
79 is_unresponsive_(false), 83 is_unresponsive_(false),
80 in_get_backing_store_(false), 84 in_get_backing_store_(false),
81 view_being_painted_(false), 85 view_being_painted_(false),
82 ignore_input_events_(false), 86 ignore_input_events_(false),
83 text_direction_updated_(false), 87 text_direction_updated_(false),
84 text_direction_(WebKit::WebTextDirectionLeftToRight), 88 text_direction_(WebKit::WebTextDirectionLeftToRight),
85 text_direction_canceled_(false), 89 text_direction_canceled_(false),
86 suppress_next_char_events_(false) { 90 suppress_next_char_events_(false) {
87 if (routing_id_ == MSG_ROUTING_NONE) 91 if (routing_id_ == MSG_ROUTING_NONE)
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 coalesced_mouse_wheel_events_.clear(); 640 coalesced_mouse_wheel_events_.clear();
637 641
638 // Any input event cancels a pending mouse move event. Note that 642 // Any input event cancels a pending mouse move event. Note that
639 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event| 643 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event|
640 // after this line. 644 // after this line.
641 next_mouse_move_.reset(); 645 next_mouse_move_.reset();
642 646
643 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); 647 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs));
644 } 648 }
645 649
646 #if defined(TOUCH_UI) 650 #if defined(TOUCH_UI)
sky 2011/06/09 21:58:12 De we need the ifdefs? If you're not on a touch de
sadrul 2011/06/09 22:15:45 ifdef's removed!
647 void RenderWidgetHost::ForwardTouchEvent( 651 void RenderWidgetHost::ForwardTouchEvent(
648 const WebKit::WebTouchEvent& touch_event) { 652 const WebKit::WebTouchEvent& touch_event) {
649 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardTouchEvent"); 653 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardTouchEvent");
654 if (ignore_input_events_ || process_->ignore_input_events())
655 return;
656
657 if (touch_event.type == WebInputEvent::TouchMove &&
658 touch_move_pending_) {
659 touch_event_is_queued_ = true;
660 queued_touch_event_ = touch_event;
661 return;
662 }
663
664 if (touch_event.type == WebInputEvent::TouchMove)
665 touch_move_pending_ = true;
666 else
667 touch_move_pending_ = false;
650 ForwardInputEvent(touch_event, sizeof(WebKit::WebTouchEvent), false); 668 ForwardInputEvent(touch_event, sizeof(WebKit::WebTouchEvent), false);
651 } 669 }
652 #endif 670 #endif
653 671
654 void RenderWidgetHost::RendererExited(base::TerminationStatus status, 672 void RenderWidgetHost::RendererExited(base::TerminationStatus status,
655 int exit_code) { 673 int exit_code) {
656 // Clearing this flag causes us to re-create the renderer when recovering 674 // Clearing this flag causes us to re-create the renderer when recovering
657 // from a crashed renderer. 675 // from a crashed renderer.
658 renderer_initialized_ = false; 676 renderer_initialized_ = false;
659 677
660 // Must reset these to ensure that mouse move/wheel events work with a new 678 // Must reset these to ensure that mouse move/wheel events work with a new
661 // renderer. 679 // renderer.
662 mouse_move_pending_ = false; 680 mouse_move_pending_ = false;
663 next_mouse_move_.reset(); 681 next_mouse_move_.reset();
664 mouse_wheel_pending_ = false; 682 mouse_wheel_pending_ = false;
665 coalesced_mouse_wheel_events_.clear(); 683 coalesced_mouse_wheel_events_.clear();
666 684
685 #if defined(TOUCH_UI)
686 touch_move_pending_ = false;
687 touch_event_is_queued_ = false;
688 #endif
689
667 // Must reset these to ensure that keyboard events work with a new renderer. 690 // Must reset these to ensure that keyboard events work with a new renderer.
668 key_queue_.clear(); 691 key_queue_.clear();
669 suppress_next_char_events_ = false; 692 suppress_next_char_events_ = false;
670 693
671 // Reset some fields in preparation for recovering from a crash. 694 // Reset some fields in preparation for recovering from a crash.
672 resize_ack_pending_ = false; 695 resize_ack_pending_ = false;
673 repaint_ack_pending_ = false; 696 repaint_ack_pending_ = false;
674 697
675 in_flight_size_.SetSize(0, 0); 698 in_flight_size_.SetSize(0, 0);
676 in_flight_reserved_rect_.SetRect(0, 0, 0, 0); 699 in_flight_reserved_rect_.SetRect(0, 0, 0, 0);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 } else if (type == WebInputEvent::MouseWheel) { 1008 } else if (type == WebInputEvent::MouseWheel) {
986 ProcessWheelAck(); 1009 ProcessWheelAck();
987 } else if (WebInputEvent::isKeyboardEventType(type)) { 1010 } else if (WebInputEvent::isKeyboardEventType(type)) {
988 bool processed = false; 1011 bool processed = false;
989 if (!message.ReadBool(&iter, &processed)) { 1012 if (!message.ReadBool(&iter, &processed)) {
990 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH3")); 1013 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH3"));
991 process()->ReceivedBadMessage(); 1014 process()->ReceivedBadMessage();
992 } 1015 }
993 1016
994 ProcessKeyboardEventAck(type, processed); 1017 ProcessKeyboardEventAck(type, processed);
1018 #if defined(TOUCH_UI)
1019 } else if (type == WebInputEvent::TouchMove) {
1020 touch_move_pending_ = false;
1021 if (touch_event_is_queued_) {
1022 touch_event_is_queued_ = false;
1023 ForwardTouchEvent(queued_touch_event_);
1024 }
1025 #endif
995 } 1026 }
996 // This is used only for testing. 1027 // This is used only for testing.
997 NotificationService::current()->Notify( 1028 NotificationService::current()->Notify(
998 NotificationType::RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, 1029 NotificationType::RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK,
999 Source<RenderWidgetHost>(this), 1030 Source<RenderWidgetHost>(this),
1000 Details<int>(&type)); 1031 Details<int>(&type));
1001 } 1032 }
1002 1033
1003 void RenderWidgetHost::ProcessWheelAck() { 1034 void RenderWidgetHost::ProcessWheelAck() {
1004 mouse_wheel_pending_ = false; 1035 mouse_wheel_pending_ = false;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 view_->CreatePluginContainer(deferred_plugin_handles_[i]); 1208 view_->CreatePluginContainer(deferred_plugin_handles_[i]);
1178 #endif 1209 #endif
1179 } 1210 }
1180 1211
1181 deferred_plugin_handles_.clear(); 1212 deferred_plugin_handles_.clear();
1182 } 1213 }
1183 1214
1184 void RenderWidgetHost::StartUserGesture() { 1215 void RenderWidgetHost::StartUserGesture() {
1185 OnUserGesture(); 1216 OnUserGesture();
1186 } 1217 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698