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

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

Issue 872633005: Stop sending an async touchmove for the app slop region (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment Created 5 years, 11 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/touch_event_queue.h" 5 #include "content/browser/renderer_host/input/touch_event_queue.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "content/browser/renderer_host/input/timeout_monitor.h" 10 #include "content/browser/renderer_host/input/timeout_monitor.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 : touch_scrolling_mode(TOUCH_SCROLLING_MODE_DEFAULT), 357 : touch_scrolling_mode(TOUCH_SCROLLING_MODE_DEFAULT),
358 touch_ack_timeout_delay(base::TimeDelta::FromMilliseconds(200)), 358 touch_ack_timeout_delay(base::TimeDelta::FromMilliseconds(200)),
359 touch_ack_timeout_supported(false) { 359 touch_ack_timeout_supported(false) {
360 } 360 }
361 361
362 TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client, 362 TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client,
363 const Config& config) 363 const Config& config)
364 : client_(client), 364 : client_(client),
365 dispatching_touch_ack_(NULL), 365 dispatching_touch_ack_(NULL),
366 dispatching_touch_(false), 366 dispatching_touch_(false),
367 processing_touch_ack_(false),
367 has_handlers_(true), 368 has_handlers_(true),
368 drop_remaining_touches_in_sequence_(false), 369 drop_remaining_touches_in_sequence_(false),
369 touchmove_slop_suppressor_(new TouchMoveSlopSuppressor), 370 touchmove_slop_suppressor_(new TouchMoveSlopSuppressor),
370 send_touch_events_async_(false), 371 send_touch_events_async_(false),
371 needs_async_touchmove_for_outer_slop_region_(false), 372 needs_async_touchmove_for_outer_slop_region_(false),
372 last_sent_touch_timestamp_sec_(0), 373 last_sent_touch_timestamp_sec_(0),
373 touch_scrolling_mode_(config.touch_scrolling_mode) { 374 touch_scrolling_mode_(config.touch_scrolling_mode) {
374 DCHECK(client); 375 DCHECK(client);
375 if (config.touch_ack_timeout_supported) { 376 if (config.touch_ack_timeout_supported) {
376 timeout_handler_.reset( 377 timeout_handler_.reset(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 CoalescedWebTouchEvent* last_event = touch_queue_.back(); 414 CoalescedWebTouchEvent* last_event = touch_queue_.back();
414 if (last_event->CoalesceEventIfPossible(event)) 415 if (last_event->CoalesceEventIfPossible(event))
415 return; 416 return;
416 } 417 }
417 touch_queue_.push_back(new CoalescedWebTouchEvent(event, false)); 418 touch_queue_.push_back(new CoalescedWebTouchEvent(event, false));
418 } 419 }
419 420
420 void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result, 421 void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result,
421 const LatencyInfo& latency_info) { 422 const LatencyInfo& latency_info) {
422 TRACE_EVENT0("input", "TouchEventQueue::ProcessTouchAck"); 423 TRACE_EVENT0("input", "TouchEventQueue::ProcessTouchAck");
424 base::AutoReset<bool> processing_touch_ack(&processing_touch_ack_, true);
423 425
424 DCHECK(!dispatching_touch_ack_); 426 DCHECK(!dispatching_touch_ack_);
425 dispatching_touch_ = false; 427 dispatching_touch_ = false;
426 428
427 if (timeout_handler_ && timeout_handler_->ConfirmTouchEvent(ack_result)) 429 if (timeout_handler_ && timeout_handler_->ConfirmTouchEvent(ack_result))
428 return; 430 return;
429 431
430 touchmove_slop_suppressor_->ConfirmTouchEvent(ack_result); 432 touchmove_slop_suppressor_->ConfirmTouchEvent(ack_result);
431 433
432 if (touch_queue_.empty()) 434 if (touch_queue_.empty())
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 DCHECK(!dispatching_touch_); 466 DCHECK(!dispatching_touch_);
465 TouchEventWithLatencyInfo touch = touch_queue_.front()->coalesced_event(); 467 TouchEventWithLatencyInfo touch = touch_queue_.front()->coalesced_event();
466 468
467 if (send_touch_events_async_ && 469 if (send_touch_events_async_ &&
468 touch.event.type == WebInputEvent::TouchMove) { 470 touch.event.type == WebInputEvent::TouchMove) {
469 // Throttling touchmove's in a continuous touchmove stream while scrolling 471 // Throttling touchmove's in a continuous touchmove stream while scrolling
470 // reduces the risk of jank. However, it's still important that the web 472 // reduces the risk of jank. However, it's still important that the web
471 // application be sent touches at key points in the gesture stream, 473 // application be sent touches at key points in the gesture stream,
472 // e.g., when the application slop region is exceeded or touchmove 474 // e.g., when the application slop region is exceeded or touchmove
473 // coalescing fails because of different modifiers. 475 // coalescing fails because of different modifiers.
474 const bool send_touchmove_now = 476 bool send_touchmove_now = size() > 1;
475 size() > 1 || 477 send_touchmove_now |= pending_async_touchmove_ &&
476 (touch.event.timeStampSeconds >= 478 !pending_async_touchmove_->CanCoalesceWith(touch);
477 last_sent_touch_timestamp_sec_ + kAsyncTouchMoveIntervalSec) || 479 // Avoid async touch dispatch immediately after receipt of a touch ack. This
478 (needs_async_touchmove_for_outer_slop_region_ && 480 // reduces the likelihood of the async touch contending with gestures
479 OutsideApplicationSlopRegion(touch.event, 481 // (and gesture side effects) triggered by the touch ack.
480 touch_sequence_start_position_)) || 482 if (!processing_touch_ack_) {
481 (pending_async_touchmove_ && 483 send_touchmove_now |=
482 !pending_async_touchmove_->CanCoalesceWith(touch)); 484 touch.event.timeStampSeconds >=
485 last_sent_touch_timestamp_sec_ + kAsyncTouchMoveIntervalSec;
486 send_touchmove_now |= needs_async_touchmove_for_outer_slop_region_ &&
487 OutsideApplicationSlopRegion(
488 touch.event, touch_sequence_start_position_);
489 }
483 490
484 if (!send_touchmove_now) { 491 if (!send_touchmove_now) {
485 if (!pending_async_touchmove_) { 492 if (!pending_async_touchmove_) {
486 pending_async_touchmove_.reset(new TouchEventWithLatencyInfo(touch)); 493 pending_async_touchmove_.reset(new TouchEventWithLatencyInfo(touch));
487 } else { 494 } else {
488 DCHECK(pending_async_touchmove_->CanCoalesceWith(touch)); 495 DCHECK(pending_async_touchmove_->CanCoalesceWith(touch));
489 pending_async_touchmove_->CoalesceWith(touch); 496 pending_async_touchmove_->CoalesceWith(touch);
490 } 497 }
491 DCHECK_EQ(1U, size()); 498 DCHECK_EQ(1U, size());
492 PopTouchEventToClient(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 499 PopTouchEventToClient(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 if (ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) 778 if (ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS)
772 touch_consumer_states_.mark_bit(point.id); 779 touch_consumer_states_.mark_bit(point.id);
773 else 780 else
774 touch_consumer_states_.clear_bit(point.id); 781 touch_consumer_states_.clear_bit(point.id);
775 } 782 }
776 } 783 }
777 } 784 }
778 } 785 }
779 786
780 } // namespace content 787 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698