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

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

Issue 394523004: Revert of Don't treat first touch move differently from future touch moves (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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) {
354 DCHECK(client); 353 DCHECK(client);
355 if (ack_timeout_enabled_) { 354 if (ack_timeout_enabled_) {
356 timeout_handler_.reset( 355 timeout_handler_.reset(
357 new TouchTimeoutHandler(this, config.touch_ack_timeout_delay)); 356 new TouchTimeoutHandler(this, config.touch_ack_timeout_delay));
358 } 357 }
359 } 358 }
360 359
361 TouchEventQueue::~TouchEventQueue() { 360 TouchEventQueue::~TouchEventQueue() {
362 if (!touch_queue_.empty()) 361 if (!touch_queue_.empty())
363 STLDeleteElements(&touch_queue_); 362 STLDeleteElements(&touch_queue_);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 if (dispatching_touch_ && 527 if (dispatching_touch_ &&
529 touch_filtering_state_ == FORWARD_TOUCHES_UNTIL_TIMEOUT && 528 touch_filtering_state_ == FORWARD_TOUCHES_UNTIL_TIMEOUT &&
530 ShouldTouchTriggerTimeout(touch.event)) { 529 ShouldTouchTriggerTimeout(touch.event)) {
531 DCHECK(timeout_handler_); 530 DCHECK(timeout_handler_);
532 timeout_handler_->Start(touch); 531 timeout_handler_->Start(touch);
533 } 532 }
534 } 533 }
535 534
536 void TouchEventQueue::OnGestureScrollEvent( 535 void TouchEventQueue::OnGestureScrollEvent(
537 const GestureEventWithLatencyInfo& gesture_event) { 536 const GestureEventWithLatencyInfo& gesture_event) {
538 if (gesture_event.event.type == blink::WebInputEvent::GestureScrollBegin) { 537 if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin)
539 seen_scroll_update_this_sequence_ = false; 538 return;
540 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) {
541 if (touch_filtering_state_ != DROP_ALL_TOUCHES && 547 if (touch_filtering_state_ != DROP_ALL_TOUCHES &&
542 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE) { 548 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE) {
543 DCHECK(!touchmove_slop_suppressor_->suppressing_touchmoves())
544 << "The renderer should be offered a touchmove before scrolling "
545 "begins";
546 }
547
548 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE &&
549 touch_filtering_state_ != DROP_ALL_TOUCHES &&
550 touch_filtering_state_ != DROP_TOUCHES_IN_SEQUENCE &&
551 (touch_ack_states_.empty() ||
552 AllTouchAckStatesHaveState(
553 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS))) {
554 // 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
555 // received during the scroll from reaching the renderer. This ensures 550 // received during the scroll from reaching the renderer. This ensures
556 // 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
557 // always be preventDefault'ed (cancelable == true). 552 // always be preventDefault'ed (cancelable == true).
558 // TODO(jdduke): Revisit if touchstarts during scroll are made cancelable. 553 // TODO(jdduke): Revisit if touchstarts during scroll are made cancelable.
559 touch_filtering_state_ = DROP_TOUCHES_IN_SEQUENCE; 554 if (touch_ack_states_.empty() ||
555 AllTouchAckStatesHaveState(
556 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS)) {
557 touch_filtering_state_ = DROP_TOUCHES_IN_SEQUENCE;
558 return;
559 }
560 } 560 }
561 return;
562 }
563 561
564 if (gesture_event.event.type != blink::WebInputEvent::GestureScrollUpdate ||
565 seen_scroll_update_this_sequence_)
566 return;
567
568 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE) {
569 pending_async_touchmove_.reset(); 562 pending_async_touchmove_.reset();
570 send_touch_events_async_ = true; 563 send_touch_events_async_ = true;
571 needs_async_touchmove_for_outer_slop_region_ = true; 564 needs_async_touchmove_for_outer_slop_region_ = true;
572 return; 565 return;
573 } 566 }
574 567
575 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL) 568 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL)
576 return; 569 return;
577 570
578 // We assume that scroll events are generated synchronously from 571 // We assume that scroll events are generated synchronously from
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 iter != end; 813 iter != end;
821 ++iter) { 814 ++iter) {
822 if (iter->second != ack_state) 815 if (iter->second != ack_state)
823 return false; 816 return false;
824 } 817 }
825 818
826 return true; 819 return true;
827 } 820 }
828 821
829 } // namespace content 822 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698