| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 case MotionEvent::ACTION_POINTER_UP: | 35 case MotionEvent::ACTION_POINTER_UP: |
| 36 return "ACTION_POINTER_UP"; | 36 return "ACTION_POINTER_UP"; |
| 37 case MotionEvent::ACTION_DOWN: | 37 case MotionEvent::ACTION_DOWN: |
| 38 return "ACTION_DOWN"; | 38 return "ACTION_DOWN"; |
| 39 case MotionEvent::ACTION_UP: | 39 case MotionEvent::ACTION_UP: |
| 40 return "ACTION_UP"; | 40 return "ACTION_UP"; |
| 41 case MotionEvent::ACTION_CANCEL: | 41 case MotionEvent::ACTION_CANCEL: |
| 42 return "ACTION_CANCEL"; | 42 return "ACTION_CANCEL"; |
| 43 case MotionEvent::ACTION_MOVE: | 43 case MotionEvent::ACTION_MOVE: |
| 44 return "ACTION_MOVE"; | 44 return "ACTION_MOVE"; |
| 45 case MotionEvent::ACTION_HOVER_ENTER: |
| 46 return "ACTION_HOVER_ENTER"; |
| 47 case MotionEvent::ACTION_HOVER_EXIT: |
| 48 return "ACTION_HOVER_EXIT"; |
| 49 case MotionEvent::ACTION_HOVER_MOVE: |
| 50 return "ACTION_HOVER_MOVE"; |
| 51 case MotionEvent::ACTION_BUTTON_PRESS: |
| 52 return "ACTION_BUTTON_PRESS"; |
| 53 case MotionEvent::ACTION_BUTTON_RELEASE: |
| 54 return "ACTION_BUTTON_RELEASE"; |
| 45 } | 55 } |
| 46 return ""; | 56 return ""; |
| 47 } | 57 } |
| 48 | 58 |
| 49 gfx::RectF ClampBoundingBox(const gfx::RectF& bounds, | 59 gfx::RectF ClampBoundingBox(const gfx::RectF& bounds, |
| 50 float min_length, | 60 float min_length, |
| 51 float max_length) { | 61 float max_length) { |
| 52 float width = bounds.width(); | 62 float width = bounds.width(); |
| 53 float height = bounds.height(); | 63 float height = bounds.height(); |
| 54 if (min_length) { | 64 if (min_length) { |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 gesture_listener_->GetBoundingBox(event, ET_GESTURE_BEGIN), | 856 gesture_listener_->GetBoundingBox(event, ET_GESTURE_BEGIN), |
| 847 event.GetFlags())); | 857 event.GetFlags())); |
| 848 } | 858 } |
| 849 break; | 859 break; |
| 850 case MotionEvent::ACTION_POINTER_UP: | 860 case MotionEvent::ACTION_POINTER_UP: |
| 851 case MotionEvent::ACTION_UP: | 861 case MotionEvent::ACTION_UP: |
| 852 case MotionEvent::ACTION_CANCEL: | 862 case MotionEvent::ACTION_CANCEL: |
| 853 case MotionEvent::ACTION_MOVE: | 863 case MotionEvent::ACTION_MOVE: |
| 854 break; | 864 break; |
| 855 case MotionEvent::ACTION_NONE: | 865 case MotionEvent::ACTION_NONE: |
| 866 case MotionEvent::ACTION_HOVER_ENTER: |
| 867 case MotionEvent::ACTION_HOVER_EXIT: |
| 868 case MotionEvent::ACTION_HOVER_MOVE: |
| 869 case MotionEvent::ACTION_BUTTON_PRESS: |
| 870 case MotionEvent::ACTION_BUTTON_RELEASE: |
| 856 NOTREACHED(); | 871 NOTREACHED(); |
| 857 break; | 872 break; |
| 858 } | 873 } |
| 859 } | 874 } |
| 860 | 875 |
| 861 void GestureProvider::OnTouchEventHandlingEnd(const MotionEvent& event) { | 876 void GestureProvider::OnTouchEventHandlingEnd(const MotionEvent& event) { |
| 862 switch (event.GetAction()) { | 877 switch (event.GetAction()) { |
| 863 case MotionEvent::ACTION_UP: | 878 case MotionEvent::ACTION_UP: |
| 864 case MotionEvent::ACTION_CANCEL: { | 879 case MotionEvent::ACTION_CANCEL: { |
| 865 if (gesture_begin_end_types_enabled_) | 880 if (gesture_begin_end_types_enabled_) |
| 866 gesture_listener_->Send( | 881 gesture_listener_->Send( |
| 867 gesture_listener_->CreateGesture(ET_GESTURE_END, event)); | 882 gesture_listener_->CreateGesture(ET_GESTURE_END, event)); |
| 868 | 883 |
| 869 current_down_event_.reset(); | 884 current_down_event_.reset(); |
| 870 | 885 |
| 871 UpdateDoubleTapDetectionSupport(); | 886 UpdateDoubleTapDetectionSupport(); |
| 872 break; | 887 break; |
| 873 } | 888 } |
| 874 case MotionEvent::ACTION_POINTER_UP: | 889 case MotionEvent::ACTION_POINTER_UP: |
| 875 if (gesture_begin_end_types_enabled_) | 890 if (gesture_begin_end_types_enabled_) |
| 876 gesture_listener_->Send( | 891 gesture_listener_->Send( |
| 877 gesture_listener_->CreateGesture(ET_GESTURE_END, event)); | 892 gesture_listener_->CreateGesture(ET_GESTURE_END, event)); |
| 878 break; | 893 break; |
| 879 case MotionEvent::ACTION_DOWN: | 894 case MotionEvent::ACTION_DOWN: |
| 880 case MotionEvent::ACTION_POINTER_DOWN: | 895 case MotionEvent::ACTION_POINTER_DOWN: |
| 881 case MotionEvent::ACTION_MOVE: | 896 case MotionEvent::ACTION_MOVE: |
| 882 break; | 897 break; |
| 883 case MotionEvent::ACTION_NONE: | 898 case MotionEvent::ACTION_NONE: |
| 899 case MotionEvent::ACTION_HOVER_ENTER: |
| 900 case MotionEvent::ACTION_HOVER_EXIT: |
| 901 case MotionEvent::ACTION_HOVER_MOVE: |
| 902 case MotionEvent::ACTION_BUTTON_PRESS: |
| 903 case MotionEvent::ACTION_BUTTON_RELEASE: |
| 884 NOTREACHED(); | 904 NOTREACHED(); |
| 885 break; | 905 break; |
| 886 } | 906 } |
| 887 } | 907 } |
| 888 | 908 |
| 889 void GestureProvider::UpdateDoubleTapDetectionSupport() { | 909 void GestureProvider::UpdateDoubleTapDetectionSupport() { |
| 890 // The GestureDetector requires that any provided DoubleTapListener remain | 910 // The GestureDetector requires that any provided DoubleTapListener remain |
| 891 // attached to it for the duration of a touch sequence. Defer any potential | 911 // attached to it for the duration of a touch sequence. Defer any potential |
| 892 // null'ing of the listener until the sequence has ended. | 912 // null'ing of the listener until the sequence has ended. |
| 893 if (current_down_event_) | 913 if (current_down_event_) |
| 894 return; | 914 return; |
| 895 | 915 |
| 896 const bool double_tap_enabled = | 916 const bool double_tap_enabled = |
| 897 double_tap_support_for_page_ && double_tap_support_for_platform_; | 917 double_tap_support_for_page_ && double_tap_support_for_platform_; |
| 898 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); | 918 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); |
| 899 } | 919 } |
| 900 | 920 |
| 901 } // namespace ui | 921 } // namespace ui |
| OLD | NEW |