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

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: nuke ifdefs 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 touch_move_pending_(false),
79 touch_event_is_queued_(false),
78 needs_repainting_on_restore_(false), 80 needs_repainting_on_restore_(false),
79 is_unresponsive_(false), 81 is_unresponsive_(false),
80 in_get_backing_store_(false), 82 in_get_backing_store_(false),
81 view_being_painted_(false), 83 view_being_painted_(false),
82 ignore_input_events_(false), 84 ignore_input_events_(false),
83 text_direction_updated_(false), 85 text_direction_updated_(false),
84 text_direction_(WebKit::WebTextDirectionLeftToRight), 86 text_direction_(WebKit::WebTextDirectionLeftToRight),
85 text_direction_canceled_(false), 87 text_direction_canceled_(false),
86 suppress_next_char_events_(false) { 88 suppress_next_char_events_(false) {
87 if (routing_id_ == MSG_ROUTING_NONE) 89 if (routing_id_ == MSG_ROUTING_NONE)
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 coalesced_mouse_wheel_events_.clear(); 638 coalesced_mouse_wheel_events_.clear();
637 639
638 // Any input event cancels a pending mouse move event. Note that 640 // 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| 641 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event|
640 // after this line. 642 // after this line.
641 next_mouse_move_.reset(); 643 next_mouse_move_.reset();
642 644
643 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); 645 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs));
644 } 646 }
645 647
646 #if defined(TOUCH_UI)
647 void RenderWidgetHost::ForwardTouchEvent( 648 void RenderWidgetHost::ForwardTouchEvent(
648 const WebKit::WebTouchEvent& touch_event) { 649 const WebKit::WebTouchEvent& touch_event) {
649 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardTouchEvent"); 650 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardTouchEvent");
651 if (ignore_input_events_ || process_->ignore_input_events())
652 return;
653
654 if (touch_event.type == WebInputEvent::TouchMove &&
655 touch_move_pending_) {
656 touch_event_is_queued_ = true;
657 queued_touch_event_ = touch_event;
658 return;
659 }
660
661 if (touch_event.type == WebInputEvent::TouchMove)
662 touch_move_pending_ = true;
663 else
664 touch_move_pending_ = false;
650 ForwardInputEvent(touch_event, sizeof(WebKit::WebTouchEvent), false); 665 ForwardInputEvent(touch_event, sizeof(WebKit::WebTouchEvent), false);
651 } 666 }
652 #endif
653 667
654 void RenderWidgetHost::RendererExited(base::TerminationStatus status, 668 void RenderWidgetHost::RendererExited(base::TerminationStatus status,
655 int exit_code) { 669 int exit_code) {
656 // Clearing this flag causes us to re-create the renderer when recovering 670 // Clearing this flag causes us to re-create the renderer when recovering
657 // from a crashed renderer. 671 // from a crashed renderer.
658 renderer_initialized_ = false; 672 renderer_initialized_ = false;
659 673
660 // Must reset these to ensure that mouse move/wheel events work with a new 674 // Must reset these to ensure that mouse move/wheel events work with a new
661 // renderer. 675 // renderer.
662 mouse_move_pending_ = false; 676 mouse_move_pending_ = false;
663 next_mouse_move_.reset(); 677 next_mouse_move_.reset();
664 mouse_wheel_pending_ = false; 678 mouse_wheel_pending_ = false;
665 coalesced_mouse_wheel_events_.clear(); 679 coalesced_mouse_wheel_events_.clear();
680 touch_move_pending_ = false;
681 touch_event_is_queued_ = false;
666 682
667 // Must reset these to ensure that keyboard events work with a new renderer. 683 // Must reset these to ensure that keyboard events work with a new renderer.
668 key_queue_.clear(); 684 key_queue_.clear();
669 suppress_next_char_events_ = false; 685 suppress_next_char_events_ = false;
670 686
671 // Reset some fields in preparation for recovering from a crash. 687 // Reset some fields in preparation for recovering from a crash.
672 resize_ack_pending_ = false; 688 resize_ack_pending_ = false;
673 repaint_ack_pending_ = false; 689 repaint_ack_pending_ = false;
674 690
675 in_flight_size_.SetSize(0, 0); 691 in_flight_size_.SetSize(0, 0);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 } else if (type == WebInputEvent::MouseWheel) { 1001 } else if (type == WebInputEvent::MouseWheel) {
986 ProcessWheelAck(); 1002 ProcessWheelAck();
987 } else if (WebInputEvent::isKeyboardEventType(type)) { 1003 } else if (WebInputEvent::isKeyboardEventType(type)) {
988 bool processed = false; 1004 bool processed = false;
989 if (!message.ReadBool(&iter, &processed)) { 1005 if (!message.ReadBool(&iter, &processed)) {
990 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH3")); 1006 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH3"));
991 process()->ReceivedBadMessage(); 1007 process()->ReceivedBadMessage();
992 } 1008 }
993 1009
994 ProcessKeyboardEventAck(type, processed); 1010 ProcessKeyboardEventAck(type, processed);
1011 } else if (type == WebInputEvent::TouchMove) {
1012 touch_move_pending_ = false;
1013 if (touch_event_is_queued_) {
1014 touch_event_is_queued_ = false;
1015 ForwardTouchEvent(queued_touch_event_);
1016 }
995 } 1017 }
996 // This is used only for testing. 1018 // This is used only for testing.
997 NotificationService::current()->Notify( 1019 NotificationService::current()->Notify(
998 NotificationType::RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, 1020 NotificationType::RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK,
999 Source<RenderWidgetHost>(this), 1021 Source<RenderWidgetHost>(this),
1000 Details<int>(&type)); 1022 Details<int>(&type));
1001 } 1023 }
1002 1024
1003 void RenderWidgetHost::ProcessWheelAck() { 1025 void RenderWidgetHost::ProcessWheelAck() {
1004 mouse_wheel_pending_ = false; 1026 mouse_wheel_pending_ = false;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 view_->CreatePluginContainer(deferred_plugin_handles_[i]); 1199 view_->CreatePluginContainer(deferred_plugin_handles_[i]);
1178 #endif 1200 #endif
1179 } 1201 }
1180 1202
1181 deferred_plugin_handles_.clear(); 1203 deferred_plugin_handles_.clear();
1182 } 1204 }
1183 1205
1184 void RenderWidgetHost::StartUserGesture() { 1206 void RenderWidgetHost::StartUserGesture() {
1185 OnUserGesture(); 1207 OnUserGesture();
1186 } 1208 }
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