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

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

Issue 398523002: Reland: Don't treat first touch move differently from future touch moves (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove seen_scroll_update_this_sequence_. Created 6 years, 5 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
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_event_queue_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 DCHECK(client); 353 DCHECK(client);
354 if (ack_timeout_enabled_) { 354 if (ack_timeout_enabled_) {
355 timeout_handler_.reset( 355 timeout_handler_.reset(
356 new TouchTimeoutHandler(this, config.touch_ack_timeout_delay)); 356 new TouchTimeoutHandler(this, config.touch_ack_timeout_delay));
357 } 357 }
358 } 358 }
359 359
360 TouchEventQueue::~TouchEventQueue() { 360 TouchEventQueue::~TouchEventQueue() {
361 if (!touch_queue_.empty()) 361 if (!touch_queue_.empty())
362 STLDeleteElements(&touch_queue_); 362 STLDeleteElements(&touch_queue_);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 if (dispatching_touch_ && 527 if (dispatching_touch_ &&
528 touch_filtering_state_ == FORWARD_TOUCHES_UNTIL_TIMEOUT && 528 touch_filtering_state_ == FORWARD_TOUCHES_UNTIL_TIMEOUT &&
529 ShouldTouchTriggerTimeout(touch.event)) { 529 ShouldTouchTriggerTimeout(touch.event)) {
530 DCHECK(timeout_handler_); 530 DCHECK(timeout_handler_);
531 timeout_handler_->Start(touch); 531 timeout_handler_->Start(touch);
532 } 532 }
533 } 533 }
534 534
535 void TouchEventQueue::OnGestureScrollEvent( 535 void TouchEventQueue::OnGestureScrollEvent(
536 const GestureEventWithLatencyInfo& gesture_event) { 536 const GestureEventWithLatencyInfo& gesture_event) {
537 if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin) 537 if (gesture_event.event.type == blink::WebInputEvent::GestureScrollBegin) {
538 return;
539
540 if (touch_filtering_state_ != DROP_ALL_TOUCHES &&
541 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE) {
542 DCHECK(!touchmove_slop_suppressor_->suppressing_touchmoves())
543 << "The renderer should be offered a touchmove before scrolling begins";
544 }
545
546 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE) {
547 if (touch_filtering_state_ != DROP_ALL_TOUCHES && 538 if (touch_filtering_state_ != DROP_ALL_TOUCHES &&
548 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE) { 539 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE) {
540 DCHECK(!touchmove_slop_suppressor_->suppressing_touchmoves())
541 << "The renderer should be offered a touchmove before scrolling "
542 "begins";
543 }
544
545 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE &&
546 touch_filtering_state_ != DROP_ALL_TOUCHES &&
547 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE &&
548 (touch_ack_states_.empty() ||
549 AllTouchAckStatesHaveState(
550 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS))) {
549 // If no touch points have a consumer, prevent all subsequent touch events 551 // If no touch points have a consumer, prevent all subsequent touch events
550 // received during the scroll from reaching the renderer. This ensures 552 // received during the scroll from reaching the renderer. This ensures
551 // that the first touchstart the renderer sees in any given sequence can 553 // that the first touchstart the renderer sees in any given sequence can
552 // always be preventDefault'ed (cancelable == true). 554 // always be preventDefault'ed (cancelable == true).
553 // TODO(jdduke): Revisit if touchstarts during scroll are made cancelable. 555 // TODO(jdduke): Revisit if touchstarts during scroll are made cancelable.
554 if (touch_ack_states_.empty() || 556 touch_filtering_state_ = DROP_TOUCHES_IN_SEQUENCE;
555 AllTouchAckStatesHaveState(
556 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS)) {
557 touch_filtering_state_ = DROP_TOUCHES_IN_SEQUENCE;
558 return;
559 }
560 } 557 }
561 558
562 pending_async_touchmove_.reset(); 559 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE) {
563 send_touch_events_async_ = true; 560 needs_async_touchmove_for_outer_slop_region_ = true;
564 needs_async_touchmove_for_outer_slop_region_ = true; 561 pending_async_touchmove_.reset();
562 }
563
565 return; 564 return;
566 } 565 }
567 566
567 if (gesture_event.event.type != blink::WebInputEvent::GestureScrollUpdate)
568 return;
569
570 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE)
571 send_touch_events_async_ = true;
572
568 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL) 573 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL)
569 return; 574 return;
570 575
571 // We assume that scroll events are generated synchronously from 576 // We assume that scroll events are generated synchronously from
572 // dispatching a touch event ack. This allows us to generate a synthetic 577 // 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 578 // 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. 579 // is being acked. Otherwise, we don't perform the touch-cancel optimization.
575 if (!dispatching_touch_ack_) 580 if (!dispatching_touch_ack_)
576 return; 581 return;
577 582
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 iter != end; 818 iter != end;
814 ++iter) { 819 ++iter) {
815 if (iter->second != ack_state) 820 if (iter->second != ack_state)
816 return false; 821 return false;
817 } 822 }
818 823
819 return true; 824 return true;
820 } 825 }
821 826
822 } // namespace content 827 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_event_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698