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

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

Issue 228973003: Don't treat first touch move differently from future touch moves (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests. Created 6 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
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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 touch_filtering_state_(TOUCH_FILTERING_STATE_DEFAULT), 342 touch_filtering_state_(TOUCH_FILTERING_STATE_DEFAULT),
343 ack_timeout_enabled_(config.touch_ack_timeout_supported), 343 ack_timeout_enabled_(config.touch_ack_timeout_supported),
344 touchmove_slop_suppressor_(new TouchMoveSlopSuppressor( 344 touchmove_slop_suppressor_(new TouchMoveSlopSuppressor(
345 config.touchmove_slop_suppression_length_dips + 345 config.touchmove_slop_suppression_length_dips +
346 (config.touchmove_slop_suppression_region_includes_boundary 346 (config.touchmove_slop_suppression_region_includes_boundary
347 ? kSlopEpsilon 347 ? kSlopEpsilon
348 : -kSlopEpsilon))), 348 : -kSlopEpsilon))),
349 send_touch_events_async_(false), 349 send_touch_events_async_(false),
350 needs_async_touchmove_for_outer_slop_region_(false), 350 needs_async_touchmove_for_outer_slop_region_(false),
351 last_sent_touch_timestamp_sec_(0), 351 last_sent_touch_timestamp_sec_(0),
352 touch_scrolling_mode_(config.touch_scrolling_mode) { 352 touch_scrolling_mode_(config.touch_scrolling_mode),
353 seen_scroll_update_this_sequence_(false) {
353 DCHECK(client); 354 DCHECK(client);
354 if (ack_timeout_enabled_) { 355 if (ack_timeout_enabled_) {
355 timeout_handler_.reset( 356 timeout_handler_.reset(
356 new TouchTimeoutHandler(this, config.touch_ack_timeout_delay)); 357 new TouchTimeoutHandler(this, config.touch_ack_timeout_delay));
357 } 358 }
358 } 359 }
359 360
360 TouchEventQueue::~TouchEventQueue() { 361 TouchEventQueue::~TouchEventQueue() {
361 if (!touch_queue_.empty()) 362 if (!touch_queue_.empty())
362 STLDeleteElements(&touch_queue_); 363 STLDeleteElements(&touch_queue_);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 if (dispatching_touch_ && 528 if (dispatching_touch_ &&
528 touch_filtering_state_ == FORWARD_TOUCHES_UNTIL_TIMEOUT && 529 touch_filtering_state_ == FORWARD_TOUCHES_UNTIL_TIMEOUT &&
529 ShouldTouchTriggerTimeout(touch.event)) { 530 ShouldTouchTriggerTimeout(touch.event)) {
530 DCHECK(timeout_handler_); 531 DCHECK(timeout_handler_);
531 timeout_handler_->Start(touch); 532 timeout_handler_->Start(touch);
532 } 533 }
533 } 534 }
534 535
535 void TouchEventQueue::OnGestureScrollEvent( 536 void TouchEventQueue::OnGestureScrollEvent(
536 const GestureEventWithLatencyInfo& gesture_event) { 537 const GestureEventWithLatencyInfo& gesture_event) {
537 if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin) 538 if (gesture_event.event.type == blink::WebInputEvent::GestureScrollBegin &&
538 return; 539 touch_filtering_state_ != DROP_ALL_TOUCHES &&
539
540 if (touch_filtering_state_ != DROP_ALL_TOUCHES &&
541 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE) { 540 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE) {
542 DCHECK(!touchmove_slop_suppressor_->suppressing_touchmoves()) 541 DCHECK(!touchmove_slop_suppressor_->suppressing_touchmoves())
543 << "The renderer should be offered a touchmove before scrolling begins"; 542 << "The renderer should be offered a touchmove before scrolling begins";
544 } 543 }
545 544
546 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE) { 545 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE) {
547 if (touch_filtering_state_ != DROP_ALL_TOUCHES && 546 if (gesture_event.event.type == blink::WebInputEvent::GestureScrollBegin &&
547 touch_filtering_state_ != DROP_ALL_TOUCHES &&
548 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE) { 548 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE) {
549 // If no touch points have a consumer, prevent all subsequent touch events 549 // If no touch points have a consumer, prevent all subsequent touch events
550 // received during the scroll from reaching the renderer. This ensures 550 // received during the scroll from reaching the renderer. This ensures
551 // that the first touchstart the renderer sees in any given sequence can 551 // that the first touchstart the renderer sees in any given sequence can
552 // always be preventDefault'ed (cancelable == true). 552 // always be preventDefault'ed (cancelable == true).
553 // TODO(jdduke): Revisit if touchstarts during scroll are made cancelable. 553 // TODO(jdduke): Revisit if touchstarts during scroll are made cancelable.
554 if (touch_ack_states_.empty() || 554 if (touch_ack_states_.empty() ||
555 AllTouchAckStatesHaveState( 555 AllTouchAckStatesHaveState(
556 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS)) { 556 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS)) {
557 touch_filtering_state_ = DROP_TOUCHES_IN_SEQUENCE; 557 touch_filtering_state_ = DROP_TOUCHES_IN_SEQUENCE;
558 return; 558 return;
559 } 559 }
560 } 560 }
561 561
562 pending_async_touchmove_.reset(); 562 if (gesture_event.event.type == blink::WebInputEvent::GestureScrollBegin) {
563 send_touch_events_async_ = true; 563 seen_scroll_update_this_sequence_ = false;
564 needs_async_touchmove_for_outer_slop_region_ = true; 564 return;
565 }
566
567 if (gesture_event.event.type == blink::WebInputEvent::GestureScrollUpdate &&
568 !seen_scroll_update_this_sequence_) {
569 pending_async_touchmove_.reset();
570 send_touch_events_async_ = true;
571 needs_async_touchmove_for_outer_slop_region_ = true;
572 return;
573 }
574 }
575
576 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL ||
577 gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin) {
jdduke (slow) 2014/07/02 17:46:37 Hmm, I would think we also want the "first allowed
tdresser 2014/07/04 18:28:17 Done.
565 return; 578 return;
566 } 579 }
567 580
568 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL)
569 return;
570
571 // We assume that scroll events are generated synchronously from 581 // We assume that scroll events are generated synchronously from
572 // dispatching a touch event ack. This allows us to generate a synthetic 582 // dispatching a touch event ack. This allows us to generate a synthetic
573 // cancel event that has the same touch ids as the touch event that 583 // cancel event that has the same touch ids as the touch event that
574 // is being acked. Otherwise, we don't perform the touch-cancel optimization. 584 // is being acked. Otherwise, we don't perform the touch-cancel optimization.
575 if (!dispatching_touch_ack_) 585 if (!dispatching_touch_ack_)
576 return; 586 return;
577 587
578 if (touch_filtering_state_ == DROP_TOUCHES_IN_SEQUENCE) 588 if (touch_filtering_state_ == DROP_TOUCHES_IN_SEQUENCE)
579 return; 589 return;
580 590
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 iter != end; 823 iter != end;
814 ++iter) { 824 ++iter) {
815 if (iter->second != ack_state) 825 if (iter->second != ack_state)
816 return false; 826 return false;
817 } 827 }
818 828
819 return true; 829 return true;
820 } 830 }
821 831
822 } // namespace content 832 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698