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

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: tests added 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 client_->OnGestureEventAck( 547 client_->OnGestureEventAck(
543 gesture_event_filter_->GetGestureEventAwaitingAck(), ack_result); 548 gesture_event_filter_->GetGestureEventAwaitingAck(), ack_result);
544 gesture_event_filter_->ProcessGestureAck(processed, type); 549 gesture_event_filter_->ProcessGestureAck(processed, type);
545 } 550 }
546 551
547 void ImmediateInputRouter::ProcessTouchAck(InputEventAckState ack_result) { 552 void ImmediateInputRouter::ProcessTouchAck(InputEventAckState ack_result) {
548 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. 553 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate.
549 touch_event_queue_->ProcessTouchAck(ack_result); 554 touch_event_queue_->ProcessTouchAck(ack_result);
550 } 555 }
551 556
557 void ImmediateInputRouter::HandleGestureScroll(
558 const GestureEventWithLatencyInfo& gesture_event) {
559 if (!enable_no_touch_to_renderer_while_scrolling_)
560 return;
561
562 // Once scrolling is started stop forwarding touch move events to renderer.
563 if (gesture_event.event.type == WebInputEvent::GestureScrollUpdate)
sadrul 2013/08/13 19:40:04 Please consider using GestureScrollBegin instead o
Yufeng Shen (Slow to review) 2013/08/13 20:17:27 Done.
564 touch_event_queue_->set_no_touch_move_to_renderer(true);
565
566 if (gesture_event.event.type == WebInputEvent::GestureScrollEnd ||
567 gesture_event.event.type == WebInputEvent::GestureFlingStart) {
568 touch_event_queue_->set_no_touch_move_to_renderer(false);
569 }
570 }
571
552 } // namespace content 572 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698