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

Side by Side Diff: content/browser/renderer_host/input/immediate_input_router.cc

Issue 16114003: Don't send touch move to renderer while scrolling (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase/switch to model of "no-touch-while-scrolling & touch-end after scrolling stops" Created 7 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/input/immediate_input_router.h" 5 #include "content/browser/renderer_host/input/immediate_input_router.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "content/browser/renderer_host/input/gesture_event_filter.h" 9 #include "content/browser/renderer_host/input/gesture_event_filter.h"
10 #include "content/browser/renderer_host/input/input_router_client.h" 10 #include "content/browser/renderer_host/input/input_router_client.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 InputRouterClient* client, 76 InputRouterClient* client,
77 int routing_id) 77 int routing_id)
78 : process_(process), 78 : process_(process),
79 client_(client), 79 client_(client),
80 routing_id_(routing_id), 80 routing_id_(routing_id),
81 select_range_pending_(false), 81 select_range_pending_(false),
82 move_caret_pending_(false), 82 move_caret_pending_(false),
83 mouse_move_pending_(false), 83 mouse_move_pending_(false),
84 mouse_wheel_pending_(false), 84 mouse_wheel_pending_(false),
85 has_touch_handler_(false), 85 has_touch_handler_(false),
86 no_touch_to_renderer_while_scrolling_(false),
86 touch_event_queue_(new TouchEventQueue(this)), 87 touch_event_queue_(new TouchEventQueue(this)),
87 gesture_event_filter_(new GestureEventFilter(this)) { 88 gesture_event_filter_(new GestureEventFilter(this)) {
88 DCHECK(process); 89 DCHECK(process);
89 DCHECK(client); 90 DCHECK(client);
90 } 91 }
91 92
92 ImmediateInputRouter::~ImmediateInputRouter() { 93 ImmediateInputRouter::~ImmediateInputRouter() {
93 } 94 }
94 95
95 bool ImmediateInputRouter::SendInput(IPC::Message* message) { 96 bool ImmediateInputRouter::SendInput(IPC::Message* message) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size()); 193 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size());
193 194
194 gesture_event_filter_->FlingHasBeenHalted(); 195 gesture_event_filter_->FlingHasBeenHalted();
195 196
196 // Only forward the non-native portions of our event. 197 // Only forward the non-native portions of our event.
197 FilterAndSendWebInputEvent(key_event, latency_info, is_shortcut); 198 FilterAndSendWebInputEvent(key_event, latency_info, is_shortcut);
198 } 199 }
199 200
200 void ImmediateInputRouter::SendGestureEvent( 201 void ImmediateInputRouter::SendGestureEvent(
201 const GestureEventWithLatencyInfo& gesture_event) { 202 const GestureEventWithLatencyInfo& gesture_event) {
203 HandleGestureScroll(gesture_event);
202 if (!client_->OnSendGestureEvent(gesture_event)) 204 if (!client_->OnSendGestureEvent(gesture_event))
203 return; 205 return;
204 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false); 206 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false);
205 } 207 }
206 208
207 void ImmediateInputRouter::SendTouchEvent( 209 void ImmediateInputRouter::SendTouchEvent(
208 const TouchEventWithLatencyInfo& touch_event) { 210 const TouchEventWithLatencyInfo& touch_event) {
209 // Always queue TouchEvents, even if the client request they be dropped. 211 // Always queue TouchEvents, even if the client request they be dropped.
210 client_->OnSendTouchEvent(touch_event); 212 client_->OnSendTouchEvent(touch_event);
211 touch_event_queue_->QueueEvent(touch_event); 213 touch_event_queue_->QueueEvent(touch_event);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 247
246 void ImmediateInputRouter::SendTouchEventImmediately( 248 void ImmediateInputRouter::SendTouchEventImmediately(
247 const TouchEventWithLatencyInfo& touch_event) { 249 const TouchEventWithLatencyInfo& touch_event) {
248 if (!client_->OnSendTouchEventImmediately(touch_event)) 250 if (!client_->OnSendTouchEventImmediately(touch_event))
249 return; 251 return;
250 FilterAndSendWebInputEvent(touch_event.event, touch_event.latency, false); 252 FilterAndSendWebInputEvent(touch_event.event, touch_event.latency, false);
251 } 253 }
252 254
253 void ImmediateInputRouter::SendGestureEventImmediately( 255 void ImmediateInputRouter::SendGestureEventImmediately(
254 const GestureEventWithLatencyInfo& gesture_event) { 256 const GestureEventWithLatencyInfo& gesture_event) {
257 HandleGestureScroll(gesture_event);
255 if (!client_->OnSendGestureEventImmediately(gesture_event)) 258 if (!client_->OnSendGestureEventImmediately(gesture_event))
256 return; 259 return;
257 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false); 260 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false);
258 } 261 }
259 262
260 const NativeWebKeyboardEvent* 263 const NativeWebKeyboardEvent*
261 ImmediateInputRouter::GetLastKeyboardEvent() const { 264 ImmediateInputRouter::GetLastKeyboardEvent() const {
262 if (key_queue_.empty()) 265 if (key_queue_.empty())
263 return NULL; 266 return NULL;
264 return &key_queue_.front(); 267 return &key_queue_.front();
265 } 268 }
266 269
267 bool ImmediateInputRouter::ShouldForwardTouchEvent() const { 270 bool ImmediateInputRouter::ShouldForwardTouchEvent() const {
271 // 1. Scroll update is in progress:
272 // Don't send any touch events to the renderer
273 // 2. Scroll update is not in progress:
268 // Always send a touch event if the renderer has a touch-event handler. It is 274 // Always send a touch event if the renderer has a touch-event handler. It is
269 // possible that a renderer stops listening to touch-events while there are 275 // possible that a renderer stops listening to touch-events while there are
270 // still events in the touch-queue. In such cases, the new events should still 276 // still events in the touch-queue. In such cases, the new events should still
271 // get into the queue. 277 // get into the queue.
272 return has_touch_handler_ || !touch_event_queue_->empty(); 278 return (has_touch_handler_ || !touch_event_queue_->empty()) &&
279 !no_touch_to_renderer_while_scrolling_;
Rick Byers 2013/08/07 14:01:33 This will queue the event rather than discard it,
273 } 280 }
274 281
275 bool ImmediateInputRouter::ShouldForwardGestureEvent( 282 bool ImmediateInputRouter::ShouldForwardGestureEvent(
276 const GestureEventWithLatencyInfo& touch_event) const { 283 const GestureEventWithLatencyInfo& touch_event) const {
277 return gesture_event_filter_->ShouldForward(touch_event); 284 return gesture_event_filter_->ShouldForward(touch_event);
278 } 285 }
279 286
280 bool ImmediateInputRouter::HasQueuedGestureEvents() const { 287 bool ImmediateInputRouter::HasQueuedGestureEvents() const {
281 return gesture_event_filter_->HasQueuedGestureEvents(); 288 return gesture_event_filter_->HasQueuedGestureEvents();
282 } 289 }
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 client_->OnGestureEventAck( 549 client_->OnGestureEventAck(
543 gesture_event_filter_->GetGestureEventAwaitingAck(), ack_result); 550 gesture_event_filter_->GetGestureEventAwaitingAck(), ack_result);
544 gesture_event_filter_->ProcessGestureAck(processed, type); 551 gesture_event_filter_->ProcessGestureAck(processed, type);
545 } 552 }
546 553
547 void ImmediateInputRouter::ProcessTouchAck(InputEventAckState ack_result) { 554 void ImmediateInputRouter::ProcessTouchAck(InputEventAckState ack_result) {
548 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. 555 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate.
549 touch_event_queue_->ProcessTouchAck(ack_result); 556 touch_event_queue_->ProcessTouchAck(ack_result);
550 } 557 }
551 558
559 void ImmediateInputRouter::HandleGestureScroll(
Rick Byers 2013/08/07 14:01:33 It does seem unfortunate to have the input router
560 const GestureEventWithLatencyInfo& gesture_event) {
561 if (CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
562 switches::kNoTouchToRendererWhileScrolling) == "1") {
sadrul 2013/08/06 19:34:19 Can you use a static bool here? static bool stop
563 // Once scrolling is started stop forwarding touch events to renderer.
564 if (gesture_event.event.type == WebInputEvent::GestureScrollUpdate &&
565 ShouldForwardTouchEvent() &&
566 !no_touch_to_renderer_while_scrolling_) {
sadrul 2013/08/06 19:34:19 ShouldForwardTouchEvent() already implies !no_touc
567 no_touch_to_renderer_while_scrolling_ = true;
sadrul 2013/08/06 19:34:19 What happens to the touch-events that may already
568 }
569
570 if (gesture_event.event.type == WebInputEvent::GestureScrollEnd ||
571 gesture_event.event.type == WebInputEvent::GestureFlingStart) {
572 if (no_touch_to_renderer_while_scrolling_) {
573 no_touch_to_renderer_while_scrolling_ = false;
574 if (ShouldForwardTouchEvent())
575 touch_event_queue_->OnGestureScrollEnd();
576 }
577 }
578 }
579 }
580
552 } // namespace content 581 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698