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

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

Issue 306483003: Prepare for Unified Gesture Recognizer landing in Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable UGR. 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 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 e1.GetX(), 351 e1.GetX(),
352 e1.GetY(), 352 e1.GetY(),
353 e2.GetPointerCount(), 353 e2.GetPointerCount(),
354 GetBoundingBox(e2), 354 GetBoundingBox(e2),
355 scroll_details)); 355 scroll_details));
356 } 356 }
357 357
358 if (distance_x || distance_y) { 358 if (distance_x || distance_y) {
359 GestureEventDetails scroll_details( 359 GestureEventDetails scroll_details(
360 ET_GESTURE_SCROLL_UPDATE, -distance_x, -distance_y); 360 ET_GESTURE_SCROLL_UPDATE, -distance_x, -distance_y);
361 provider_->Send( 361 provider_->Send(CreateGesture(ET_GESTURE_SCROLL_UPDATE,
jdduke (slow) 2014/05/28 16:26:00 Please cache GetBoundingBox(e2) before using.
tdresser 2014/05/29 14:26:21 Done.
362 CreateGesture(ET_GESTURE_SCROLL_UPDATE, e2, scroll_details)); 362 e2.GetId(),
363 e2.GetEventTime(),
364 GetBoundingBox(e2).CenterPoint().x(),
jdduke (slow) 2014/05/28 16:26:00 Just curious, why was this change necessary? Does
tdresser 2014/05/29 14:26:21 Multi-finger window dragging uses the scroll updat
jdduke (slow) 2014/05/29 16:25:40 sgtm.
365 GetBoundingBox(e2).CenterPoint().y(),
366 e2.GetPointerCount(),
367 GetBoundingBox(e2),
368 scroll_details));
363 } 369 }
364 370
365 return true; 371 return true;
366 } 372 }
367 373
368 virtual bool OnFling(const MotionEvent& e1, 374 virtual bool OnFling(const MotionEvent& e1,
369 const MotionEvent& e2, 375 const MotionEvent& e2,
370 float velocity_x, 376 float velocity_x,
371 float velocity_y) OVERRIDE { 377 float velocity_y) OVERRIDE {
372 if (snap_scroll_controller_.IsSnappingScrolls()) { 378 if (snap_scroll_controller_.IsSnappingScrolls()) {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 } 649 }
644 EndTouchScrollIfNecessary(event, false); 650 EndTouchScrollIfNecessary(event, false);
645 651
646 GestureEventDetails fling_details( 652 GestureEventDetails fling_details(
647 ET_SCROLL_FLING_START, velocity_x, velocity_y); 653 ET_SCROLL_FLING_START, velocity_x, velocity_y);
648 Send(CreateGesture( 654 Send(CreateGesture(
649 ET_SCROLL_FLING_START, event, fling_details)); 655 ET_SCROLL_FLING_START, event, fling_details));
650 } 656 }
651 657
652 void GestureProvider::Send(const GestureEventData& gesture) { 658 void GestureProvider::Send(const GestureEventData& gesture) {
653 DCHECK(!gesture.time.is_null());
jdduke (slow) 2014/05/28 16:26:00 Why was this removed?
tdresser 2014/05/29 14:26:21 There are a whole pile of tests which synthesize g
jdduke (slow) 2014/05/29 16:25:40 My only worry here is that gesture detection is *v
tdresser 2014/05/30 14:05:37 Done.
654 // The only valid events that should be sent without an active touch sequence 659 // The only valid events that should be sent without an active touch sequence
655 // are SHOW_PRESS and TAP, potentially triggered by the double-tap 660 // are SHOW_PRESS and TAP, potentially triggered by the double-tap
656 // delay timing out. 661 // delay timing out.
657 DCHECK(current_down_event_ || gesture.type == ET_GESTURE_TAP || 662 DCHECK(current_down_event_ || gesture.type == ET_GESTURE_TAP ||
658 gesture.type == ET_GESTURE_SHOW_PRESS); 663 gesture.type == ET_GESTURE_SHOW_PRESS);
659 664
660 switch (gesture.type) { 665 switch (gesture.type) {
661 case ET_GESTURE_LONG_PRESS: 666 case ET_GESTURE_LONG_PRESS:
662 DCHECK(!scale_gesture_listener_->IsScaleGestureDetectionInProgress()); 667 DCHECK(!scale_gesture_listener_->IsScaleGestureDetectionInProgress());
663 current_longpress_time_ = gesture.time; 668 current_longpress_time_ = gesture.time;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 switch (event.GetAction()) { 739 switch (event.GetAction()) {
735 case MotionEvent::ACTION_DOWN: 740 case MotionEvent::ACTION_DOWN:
736 current_down_event_ = event.Clone(); 741 current_down_event_ = event.Clone();
737 touch_scroll_in_progress_ = false; 742 touch_scroll_in_progress_ = false;
738 pinch_in_progress_ = false; 743 pinch_in_progress_ = false;
739 current_longpress_time_ = base::TimeTicks(); 744 current_longpress_time_ = base::TimeTicks();
740 if (gesture_begin_end_types_enabled_) 745 if (gesture_begin_end_types_enabled_)
741 Send(CreateGesture(ET_GESTURE_BEGIN, event)); 746 Send(CreateGesture(ET_GESTURE_BEGIN, event));
742 break; 747 break;
743 case MotionEvent::ACTION_POINTER_DOWN: 748 case MotionEvent::ACTION_POINTER_DOWN:
744 if (gesture_begin_end_types_enabled_) 749 if (gesture_begin_end_types_enabled_) {
745 Send(CreateGesture(ET_GESTURE_BEGIN, event)); 750 Send(CreateGesture(ET_GESTURE_BEGIN,
751 event.GetId(),
752 event.GetEventTime(),
753 event.GetX(event.GetActionIndex()),
754 event.GetY(event.GetActionIndex()),
755 event.GetPointerCount(),
756 GetBoundingBox(event)));
757 }
746 break; 758 break;
747 case MotionEvent::ACTION_POINTER_UP: 759 case MotionEvent::ACTION_POINTER_UP:
748 case MotionEvent::ACTION_UP: 760 case MotionEvent::ACTION_UP:
749 case MotionEvent::ACTION_CANCEL: 761 case MotionEvent::ACTION_CANCEL:
750 case MotionEvent::ACTION_MOVE: 762 case MotionEvent::ACTION_MOVE:
751 break; 763 break;
752 } 764 }
753 } 765 }
754 766
755 void GestureProvider::OnTouchEventHandlingEnd(const MotionEvent& event) { 767 void GestureProvider::OnTouchEventHandlingEnd(const MotionEvent& event) {
756 switch (event.GetAction()) { 768 switch (event.GetAction()) {
757 case MotionEvent::ACTION_UP: 769 case MotionEvent::ACTION_UP:
758 case MotionEvent::ACTION_CANCEL: 770 case MotionEvent::ACTION_CANCEL:
759 // Note: This call will have no effect if a fling was just generated, as 771 // Note: This call will have no effect if a fling was just generated, as
760 // |Fling()| will have already signalled an end to touch-scrolling. 772 // |Fling()| will have already signalled an end to touch-scrolling.
761 EndTouchScrollIfNecessary(event, true); 773 EndTouchScrollIfNecessary(event, true);
762 774
763 if (gesture_begin_end_types_enabled_) 775 if (gesture_begin_end_types_enabled_) {
764 Send(CreateGesture(ET_GESTURE_END, event)); 776 for (size_t i = 0; i < event.GetPointerCount(); ++i) {
777 Send(CreateGesture(ET_GESTURE_END,
778 event.GetId(),
779 event.GetEventTime(),
780 event.GetX(i),
781 event.GetY(i),
782 event.GetPointerCount() - i,
783 GetBoundingBox(event)));
jdduke (slow) 2014/05/28 16:26:00 Cache GetBoundingBox?
tdresser 2014/05/29 14:26:21 Done.
784 }
785 }
765 786
766 current_down_event_.reset(); 787 current_down_event_.reset();
767 788
768 UpdateDoubleTapDetectionSupport(); 789 UpdateDoubleTapDetectionSupport();
769 break; 790 break;
770 case MotionEvent::ACTION_POINTER_UP: 791 case MotionEvent::ACTION_POINTER_UP:
771 if (gesture_begin_end_types_enabled_) 792 if (gesture_begin_end_types_enabled_)
772 Send(CreateGesture(ET_GESTURE_END, event)); 793 Send(CreateGesture(ET_GESTURE_END, event));
773 break; 794 break;
774 case MotionEvent::ACTION_DOWN: 795 case MotionEvent::ACTION_DOWN:
(...skipping 10 matching lines...) Expand all
785 if (current_down_event_) 806 if (current_down_event_)
786 return; 807 return;
787 808
788 const bool double_tap_enabled = double_tap_support_for_page_ && 809 const bool double_tap_enabled = double_tap_support_for_page_ &&
789 double_tap_support_for_platform_; 810 double_tap_support_for_platform_;
790 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); 811 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled);
791 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); 812 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled);
792 } 813 }
793 814
794 } // namespace ui 815 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698