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

Side by Side Diff: ui/events/gesture_detection/gesture_provider.cc

Issue 393953012: Eager Gesture Recognition on Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/events/gesture_detection/gesture_provider.h" 5 #include "ui/events/gesture_detection/gesture_provider.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 config.disable_click_delay, 632 config.disable_click_delay,
633 this)); 633 this));
634 634
635 scale_gesture_listener_.reset( 635 scale_gesture_listener_.reset(
636 new ScaleGestureListenerImpl(config.scale_gesture_detector_config, this)); 636 new ScaleGestureListenerImpl(config.scale_gesture_detector_config, this));
637 637
638 UpdateDoubleTapDetectionSupport(); 638 UpdateDoubleTapDetectionSupport();
639 } 639 }
640 640
641 bool GestureProvider::CanHandle(const MotionEvent& event) const { 641 bool GestureProvider::CanHandle(const MotionEvent& event) const {
642 return event.GetAction() == MotionEvent::ACTION_DOWN || current_down_event_; 642 // Aura requires one cancel event per touch point, whereas Android requires
643 // one cancel event per touch sequence. Thus we need to allow extra cancel
644 // events.
645 return event.GetAction() == MotionEvent::ACTION_DOWN || current_down_event_ ||
646 event.GetAction() == MotionEvent::ACTION_CANCEL;
643 } 647 }
644 648
645 void GestureProvider::Fling(const MotionEvent& event, 649 void GestureProvider::Fling(const MotionEvent& event,
646 float velocity_x, 650 float velocity_x,
647 float velocity_y) { 651 float velocity_y) {
648 if (!velocity_x && !velocity_y) { 652 if (!velocity_x && !velocity_y) {
649 EndTouchScrollIfNecessary(event, true); 653 EndTouchScrollIfNecessary(event, true);
650 return; 654 return;
651 } 655 }
652 656
(...skipping 12 matching lines...) Expand all
665 ET_SCROLL_FLING_START, velocity_x, velocity_y); 669 ET_SCROLL_FLING_START, velocity_x, velocity_y);
666 Send(CreateGesture(fling_details, event)); 670 Send(CreateGesture(fling_details, event));
667 } 671 }
668 672
669 void GestureProvider::Send(GestureEventData gesture) { 673 void GestureProvider::Send(GestureEventData gesture) {
670 DCHECK(!gesture.time.is_null()); 674 DCHECK(!gesture.time.is_null());
671 // The only valid events that should be sent without an active touch sequence 675 // The only valid events that should be sent without an active touch sequence
672 // are SHOW_PRESS and TAP, potentially triggered by the double-tap 676 // are SHOW_PRESS and TAP, potentially triggered by the double-tap
673 // delay timing out. 677 // delay timing out.
674 DCHECK(current_down_event_ || gesture.type() == ET_GESTURE_TAP || 678 DCHECK(current_down_event_ || gesture.type() == ET_GESTURE_TAP ||
675 gesture.type() == ET_GESTURE_SHOW_PRESS); 679 gesture.type() == ET_GESTURE_SHOW_PRESS ||
680 gesture.type() == ET_GESTURE_END);
676 681
677 // TODO(jdduke): Provide a way of skipping this clamping for stylus and/or 682 // TODO(jdduke): Provide a way of skipping this clamping for stylus and/or
678 // mouse-based input, perhaps by exposing the source type on MotionEvent. 683 // mouse-based input, perhaps by exposing the source type on MotionEvent.
679 gesture.details.set_bounding_box( 684 gesture.details.set_bounding_box(
680 ClampBoundingBox(gesture.details.bounding_box_f(), 685 ClampBoundingBox(gesture.details.bounding_box_f(),
681 min_gesture_bounds_length_, 686 min_gesture_bounds_length_,
682 max_gesture_bounds_length_)); 687 max_gesture_bounds_length_));
683 688
684 switch (gesture.type()) { 689 switch (gesture.type()) {
685 case ET_GESTURE_LONG_PRESS: 690 case ET_GESTURE_LONG_PRESS:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 switch (event.GetAction()) { 783 switch (event.GetAction()) {
779 case MotionEvent::ACTION_UP: 784 case MotionEvent::ACTION_UP:
780 case MotionEvent::ACTION_CANCEL: { 785 case MotionEvent::ACTION_CANCEL: {
781 // Note: This call will have no effect if a fling was just generated, as 786 // Note: This call will have no effect if a fling was just generated, as
782 // |Fling()| will have already signalled an end to touch-scrolling. 787 // |Fling()| will have already signalled an end to touch-scrolling.
783 EndTouchScrollIfNecessary(event, true); 788 EndTouchScrollIfNecessary(event, true);
784 789
785 const gfx::RectF bounding_box = GetBoundingBox(event); 790 const gfx::RectF bounding_box = GetBoundingBox(event);
786 791
787 if (gesture_begin_end_types_enabled_) { 792 if (gesture_begin_end_types_enabled_) {
788 for (size_t i = 0; i < event.GetPointerCount(); ++i) { 793 Send(CreateGesture(ET_GESTURE_END,
jdduke (slow) 2014/07/30 15:29:32 Can this just be |CreateGesture(ET_GESTURE_END, ev
tdresser 2014/07/31 15:33:31 Thanks. Done.
789 Send(CreateGesture(ET_GESTURE_END, 794 event.GetId(),
790 event.GetId(), 795 event.GetEventTime(),
791 event.GetEventTime(), 796 event.GetX(),
792 event.GetX(i), 797 event.GetY(),
793 event.GetY(i), 798 event.GetRawX(),
794 event.GetRawX(i), 799 event.GetRawY(),
795 event.GetRawY(i), 800 event.GetPointerCount(),
796 event.GetPointerCount() - i, 801 bounding_box));
797 bounding_box));
798 }
799 } 802 }
800 803
801 current_down_event_.reset(); 804 current_down_event_.reset();
802 805
803 UpdateDoubleTapDetectionSupport(); 806 UpdateDoubleTapDetectionSupport();
804 break; 807 break;
805 } 808 }
806 case MotionEvent::ACTION_POINTER_UP: 809 case MotionEvent::ACTION_POINTER_UP:
807 if (gesture_begin_end_types_enabled_) 810 if (gesture_begin_end_types_enabled_)
808 Send(CreateGesture(ET_GESTURE_END, event)); 811 Send(CreateGesture(ET_GESTURE_END, event));
(...skipping 12 matching lines...) Expand all
821 if (current_down_event_) 824 if (current_down_event_)
822 return; 825 return;
823 826
824 const bool double_tap_enabled = double_tap_support_for_page_ && 827 const bool double_tap_enabled = double_tap_support_for_page_ &&
825 double_tap_support_for_platform_; 828 double_tap_support_for_platform_;
826 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); 829 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled);
827 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); 830 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled);
828 } 831 }
829 832
830 } // namespace ui 833 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698