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

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: use ScrollBegin instead of ScrollUpdate as the indication of stop sending touch move & rebase 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 touch_event_queue_(new TouchEventQueue(this)), 86 touch_event_queue_(new TouchEventQueue(this)),
87 gesture_event_filter_(new GestureEventFilter(this)) { 87 gesture_event_filter_(new GestureEventFilter(this)) {
88 enable_no_touch_to_renderer_while_scrolling_ =
89 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
90 switches::kNoTouchToRendererWhileScrolling) == "1";
88 DCHECK(process); 91 DCHECK(process);
89 DCHECK(client); 92 DCHECK(client);
90 } 93 }
91 94
92 ImmediateInputRouter::~ImmediateInputRouter() { 95 ImmediateInputRouter::~ImmediateInputRouter() {
93 } 96 }
94 97
95 bool ImmediateInputRouter::SendInput(IPC::Message* message) { 98 bool ImmediateInputRouter::SendInput(IPC::Message* message) {
96 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart); 99 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart);
97 scoped_ptr<IPC::Message> scoped_message(message); 100 scoped_ptr<IPC::Message> scoped_message(message);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size()); 195 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size());
193 196
194 gesture_event_filter_->FlingHasBeenHalted(); 197 gesture_event_filter_->FlingHasBeenHalted();
195 198
196 // Only forward the non-native portions of our event. 199 // Only forward the non-native portions of our event.
197 FilterAndSendWebInputEvent(key_event, latency_info, is_shortcut); 200 FilterAndSendWebInputEvent(key_event, latency_info, is_shortcut);
198 } 201 }
199 202
200 void ImmediateInputRouter::SendGestureEvent( 203 void ImmediateInputRouter::SendGestureEvent(
201 const GestureEventWithLatencyInfo& gesture_event) { 204 const GestureEventWithLatencyInfo& gesture_event) {
205 HandleGestureScroll(gesture_event);
202 if (!client_->OnSendGestureEvent(gesture_event)) 206 if (!client_->OnSendGestureEvent(gesture_event))
203 return; 207 return;
204 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false); 208 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false);
205 } 209 }
206 210
207 void ImmediateInputRouter::SendTouchEvent( 211 void ImmediateInputRouter::SendTouchEvent(
208 const TouchEventWithLatencyInfo& touch_event) { 212 const TouchEventWithLatencyInfo& touch_event) {
209 // Always queue TouchEvents, even if the client request they be dropped. 213 // Always queue TouchEvents, even if the client request they be dropped.
210 client_->OnSendTouchEvent(touch_event); 214 client_->OnSendTouchEvent(touch_event);
211 touch_event_queue_->QueueEvent(touch_event); 215 touch_event_queue_->QueueEvent(touch_event);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 249
246 void ImmediateInputRouter::SendTouchEventImmediately( 250 void ImmediateInputRouter::SendTouchEventImmediately(
247 const TouchEventWithLatencyInfo& touch_event) { 251 const TouchEventWithLatencyInfo& touch_event) {
248 if (!client_->OnSendTouchEventImmediately(touch_event)) 252 if (!client_->OnSendTouchEventImmediately(touch_event))
249 return; 253 return;
250 FilterAndSendWebInputEvent(touch_event.event, touch_event.latency, false); 254 FilterAndSendWebInputEvent(touch_event.event, touch_event.latency, false);
251 } 255 }
252 256
253 void ImmediateInputRouter::SendGestureEventImmediately( 257 void ImmediateInputRouter::SendGestureEventImmediately(
254 const GestureEventWithLatencyInfo& gesture_event) { 258 const GestureEventWithLatencyInfo& gesture_event) {
259 HandleGestureScroll(gesture_event);
255 if (!client_->OnSendGestureEventImmediately(gesture_event)) 260 if (!client_->OnSendGestureEventImmediately(gesture_event))
256 return; 261 return;
257 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false); 262 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false);
258 } 263 }
259 264
260 const NativeWebKeyboardEvent* 265 const NativeWebKeyboardEvent*
261 ImmediateInputRouter::GetLastKeyboardEvent() const { 266 ImmediateInputRouter::GetLastKeyboardEvent() const {
262 if (key_queue_.empty()) 267 if (key_queue_.empty())
263 return NULL; 268 return NULL;
264 return &key_queue_.front(); 269 return &key_queue_.front();
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 gesture_event_filter_->ProcessGestureAck(processed, type); 554 gesture_event_filter_->ProcessGestureAck(processed, type);
550 } 555 }
551 556
552 void ImmediateInputRouter::ProcessTouchAck( 557 void ImmediateInputRouter::ProcessTouchAck(
553 InputEventAckState ack_result, 558 InputEventAckState ack_result,
554 const ui::LatencyInfo& latency_info) { 559 const ui::LatencyInfo& latency_info) {
555 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. 560 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate.
556 touch_event_queue_->ProcessTouchAck(ack_result, latency_info); 561 touch_event_queue_->ProcessTouchAck(ack_result, latency_info);
557 } 562 }
558 563
564 void ImmediateInputRouter::HandleGestureScroll(
565 const GestureEventWithLatencyInfo& gesture_event) {
566 if (!enable_no_touch_to_renderer_while_scrolling_)
567 return;
568
569 // Once scrolling is started stop forwarding touch move events to renderer.
570 if (gesture_event.event.type == WebInputEvent::GestureScrollBegin)
571 touch_event_queue_->set_no_touch_move_to_renderer(true);
572
573 if (gesture_event.event.type == WebInputEvent::GestureScrollEnd ||
574 gesture_event.event.type == WebInputEvent::GestureFlingStart) {
575 touch_event_queue_->set_no_touch_move_to_renderer(false);
576 }
577 }
578
559 } // namespace content 579 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698