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

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 again. 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 e2.GetId(), 349 e2.GetId(),
350 e2.GetEventTime(), 350 e2.GetEventTime(),
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 const gfx::RectF& bounding_box = GetBoundingBox(e2);
jdduke (slow) 2014/05/29 16:25:40 Wait, why are capturing a variable returned by val
tdresser 2014/05/30 14:05:37 Done.
359 GestureEventDetails scroll_details( 360 GestureEventDetails scroll_details(
360 ET_GESTURE_SCROLL_UPDATE, -distance_x, -distance_y); 361 ET_GESTURE_SCROLL_UPDATE, -distance_x, -distance_y);
361 provider_->Send( 362 provider_->Send(CreateGesture(ET_GESTURE_SCROLL_UPDATE,
362 CreateGesture(ET_GESTURE_SCROLL_UPDATE, e2, scroll_details)); 363 e2.GetId(),
364 e2.GetEventTime(),
365 bounding_box.CenterPoint().x(),
366 bounding_box.CenterPoint().y(),
367 e2.GetPointerCount(),
368 bounding_box,
369 scroll_details));
363 } 370 }
364 371
365 return true; 372 return true;
366 } 373 }
367 374
368 virtual bool OnFling(const MotionEvent& e1, 375 virtual bool OnFling(const MotionEvent& e1,
369 const MotionEvent& e2, 376 const MotionEvent& e2,
370 float velocity_x, 377 float velocity_x,
371 float velocity_y) OVERRIDE { 378 float velocity_y) OVERRIDE {
372 if (snap_scroll_controller_.IsSnappingScrolls()) { 379 if (snap_scroll_controller_.IsSnappingScrolls()) {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 } 648 }
642 EndTouchScrollIfNecessary(event, false); 649 EndTouchScrollIfNecessary(event, false);
643 650
644 GestureEventDetails fling_details( 651 GestureEventDetails fling_details(
645 ET_SCROLL_FLING_START, velocity_x, velocity_y); 652 ET_SCROLL_FLING_START, velocity_x, velocity_y);
646 Send(CreateGesture( 653 Send(CreateGesture(
647 ET_SCROLL_FLING_START, event, fling_details)); 654 ET_SCROLL_FLING_START, event, fling_details));
648 } 655 }
649 656
650 void GestureProvider::Send(const GestureEventData& gesture) { 657 void GestureProvider::Send(const GestureEventData& gesture) {
651 DCHECK(!gesture.time.is_null());
652 // The only valid events that should be sent without an active touch sequence 658 // The only valid events that should be sent without an active touch sequence
653 // are SHOW_PRESS and TAP, potentially triggered by the double-tap 659 // are SHOW_PRESS and TAP, potentially triggered by the double-tap
654 // delay timing out. 660 // delay timing out.
655 DCHECK(current_down_event_ || gesture.type == ET_GESTURE_TAP || 661 DCHECK(current_down_event_ || gesture.type == ET_GESTURE_TAP ||
656 gesture.type == ET_GESTURE_SHOW_PRESS); 662 gesture.type == ET_GESTURE_SHOW_PRESS);
657 663
658 switch (gesture.type) { 664 switch (gesture.type) {
659 case ET_GESTURE_LONG_PRESS: 665 case ET_GESTURE_LONG_PRESS:
660 DCHECK(!scale_gesture_listener_->IsScaleGestureDetectionInProgress()); 666 DCHECK(!scale_gesture_listener_->IsScaleGestureDetectionInProgress());
661 current_longpress_time_ = gesture.time; 667 current_longpress_time_ = gesture.time;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 switch (event.GetAction()) { 738 switch (event.GetAction()) {
733 case MotionEvent::ACTION_DOWN: 739 case MotionEvent::ACTION_DOWN:
734 current_down_event_ = event.Clone(); 740 current_down_event_ = event.Clone();
735 touch_scroll_in_progress_ = false; 741 touch_scroll_in_progress_ = false;
736 pinch_in_progress_ = false; 742 pinch_in_progress_ = false;
737 current_longpress_time_ = base::TimeTicks(); 743 current_longpress_time_ = base::TimeTicks();
738 if (gesture_begin_end_types_enabled_) 744 if (gesture_begin_end_types_enabled_)
739 Send(CreateGesture(ET_GESTURE_BEGIN, event)); 745 Send(CreateGesture(ET_GESTURE_BEGIN, event));
740 break; 746 break;
741 case MotionEvent::ACTION_POINTER_DOWN: 747 case MotionEvent::ACTION_POINTER_DOWN:
742 if (gesture_begin_end_types_enabled_) 748 if (gesture_begin_end_types_enabled_) {
743 Send(CreateGesture(ET_GESTURE_BEGIN, event)); 749 Send(CreateGesture(ET_GESTURE_BEGIN,
750 event.GetId(),
751 event.GetEventTime(),
752 event.GetX(event.GetActionIndex()),
753 event.GetY(event.GetActionIndex()),
754 event.GetPointerCount(),
755 GetBoundingBox(event)));
756 }
744 break; 757 break;
745 case MotionEvent::ACTION_POINTER_UP: 758 case MotionEvent::ACTION_POINTER_UP:
746 case MotionEvent::ACTION_UP: 759 case MotionEvent::ACTION_UP:
747 case MotionEvent::ACTION_CANCEL: 760 case MotionEvent::ACTION_CANCEL:
748 case MotionEvent::ACTION_MOVE: 761 case MotionEvent::ACTION_MOVE:
749 break; 762 break;
750 } 763 }
751 } 764 }
752 765
753 void GestureProvider::OnTouchEventHandlingEnd(const MotionEvent& event) { 766 void GestureProvider::OnTouchEventHandlingEnd(const MotionEvent& event) {
754 switch (event.GetAction()) { 767 switch (event.GetAction()) {
755 case MotionEvent::ACTION_UP: 768 case MotionEvent::ACTION_UP:
756 case MotionEvent::ACTION_CANCEL: 769 case MotionEvent::ACTION_CANCEL: {
757 // Note: This call will have no effect if a fling was just generated, as 770 // Note: This call will have no effect if a fling was just generated, as
758 // |Fling()| will have already signalled an end to touch-scrolling. 771 // |Fling()| will have already signalled an end to touch-scrolling.
759 EndTouchScrollIfNecessary(event, true); 772 EndTouchScrollIfNecessary(event, true);
760 773
761 if (gesture_begin_end_types_enabled_) 774 const gfx::RectF& bounding_box = GetBoundingBox(event);
762 Send(CreateGesture(ET_GESTURE_END, event)); 775
776 if (gesture_begin_end_types_enabled_) {
777 for (size_t i = 0; i < event.GetPointerCount(); ++i) {
778 Send(CreateGesture(ET_GESTURE_END,
779 event.GetId(),
780 event.GetEventTime(),
781 event.GetX(i),
782 event.GetY(i),
783 event.GetPointerCount() - i,
784 bounding_box));
785 }
786 }
763 787
764 current_down_event_.reset(); 788 current_down_event_.reset();
765 789
766 UpdateDoubleTapDetectionSupport(); 790 UpdateDoubleTapDetectionSupport();
767 break; 791 break;
792 }
768 case MotionEvent::ACTION_POINTER_UP: 793 case MotionEvent::ACTION_POINTER_UP:
769 if (gesture_begin_end_types_enabled_) 794 if (gesture_begin_end_types_enabled_)
770 Send(CreateGesture(ET_GESTURE_END, event)); 795 Send(CreateGesture(ET_GESTURE_END, event));
771 break; 796 break;
772 case MotionEvent::ACTION_DOWN: 797 case MotionEvent::ACTION_DOWN:
773 case MotionEvent::ACTION_POINTER_DOWN: 798 case MotionEvent::ACTION_POINTER_DOWN:
774 case MotionEvent::ACTION_MOVE: 799 case MotionEvent::ACTION_MOVE:
775 break; 800 break;
776 } 801 }
777 } 802 }
778 803
779 void GestureProvider::UpdateDoubleTapDetectionSupport() { 804 void GestureProvider::UpdateDoubleTapDetectionSupport() {
780 // The GestureDetector requires that any provided DoubleTapListener remain 805 // The GestureDetector requires that any provided DoubleTapListener remain
781 // attached to it for the duration of a touch sequence. Defer any potential 806 // attached to it for the duration of a touch sequence. Defer any potential
782 // null'ing of the listener until the sequence has ended. 807 // null'ing of the listener until the sequence has ended.
783 if (current_down_event_) 808 if (current_down_event_)
784 return; 809 return;
785 810
786 const bool double_tap_enabled = double_tap_support_for_page_ && 811 const bool double_tap_enabled = double_tap_support_for_page_ &&
787 double_tap_support_for_platform_; 812 double_tap_support_for_platform_;
788 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); 813 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled);
789 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); 814 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled);
790 } 815 }
791 816
792 } // namespace ui 817 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698