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/gestures/gesture_provider_aura.h" | 5 #include "ui/events/gestures/gesture_provider_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
10 #include "ui/events/gesture_detection/gesture_configuration.h" | 10 #include "ui/events/gesture_detection/gesture_configuration.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 std::numeric_limits<unsigned long long>::max()) { | 23 std::numeric_limits<unsigned long long>::max()) { |
24 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); | 24 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); |
25 } | 25 } |
26 | 26 |
27 GestureProviderAura::~GestureProviderAura() {} | 27 GestureProviderAura::~GestureProviderAura() {} |
28 | 28 |
29 bool GestureProviderAura::OnTouchEvent(TouchEvent* event) { | 29 bool GestureProviderAura::OnTouchEvent(TouchEvent* event) { |
30 if (!pointer_state_.OnTouch(*event)) | 30 if (!pointer_state_.OnTouch(*event)) |
31 return false; | 31 return false; |
32 | 32 |
33 last_unique_touch_event_id_ = event->unique_event_id(); | 33 last_unique_touch_event_id_ = event->unique_touch_event_id(); |
34 last_touch_event_latency_info_ = *event->latency(); | 34 last_touch_event_latency_info_ = *event->latency(); |
35 | 35 |
36 auto result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); | 36 auto result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); |
37 if (!result.succeeded) | 37 if (!result.succeeded) |
38 return false; | 38 return false; |
39 | 39 |
40 event->set_may_cause_scrolling(result.did_generate_scroll); | 40 event->set_may_cause_scrolling(result.did_generate_scroll); |
41 pointer_state_.CleanupRemovedTouchPoints(*event); | 41 pointer_state_.CleanupRemovedTouchPoints(*event); |
42 return true; | 42 return true; |
43 } | 43 } |
44 | 44 |
45 void GestureProviderAura::OnAsyncTouchEventAck(bool event_consumed) { | 45 void GestureProviderAura::OnAsyncTouchEventAck(bool event_consumed) { |
46 DCHECK(pending_gestures_.empty()); | 46 DCHECK(pending_gestures_.empty()); |
47 DCHECK(!handling_event_); | 47 DCHECK(!handling_event_); |
48 base::AutoReset<bool> handling_event(&handling_event_, true); | 48 base::AutoReset<bool> handling_event(&handling_event_, true); |
49 filtered_gesture_provider_.OnAsyncTouchEventAck(event_consumed); | 49 filtered_gesture_provider_.OnAsyncTouchEventAck(event_consumed); |
50 last_touch_event_latency_info_.Clear(); | 50 last_touch_event_latency_info_.Clear(); |
51 } | 51 } |
52 | 52 |
53 void GestureProviderAura::OnSyncTouchEventAck(const uint64 unique_event_id, | 53 void GestureProviderAura::OnSyncTouchEventAck( |
54 bool event_consumed) { | 54 const uint64 unique_touch_event_id, bool event_consumed) { |
55 DCHECK_EQ(last_unique_touch_event_id_, unique_event_id); | 55 DCHECK_EQ(last_unique_touch_event_id_, unique_touch_event_id); |
56 DCHECK(pending_gestures_.empty()); | 56 DCHECK(pending_gestures_.empty()); |
57 DCHECK(!handling_event_); | 57 DCHECK(!handling_event_); |
58 base::AutoReset<bool> handling_event(&handling_event_, true); | 58 base::AutoReset<bool> handling_event(&handling_event_, true); |
59 filtered_gesture_provider_.OnSyncTouchEventAck(event_consumed); | 59 filtered_gesture_provider_.OnSyncTouchEventAck(event_consumed); |
60 last_touch_event_latency_info_.Clear(); | 60 last_touch_event_latency_info_.Clear(); |
61 } | 61 } |
62 | 62 |
63 void GestureProviderAura::OnGestureEvent( | 63 void GestureProviderAura::OnGestureEvent( |
64 const GestureEventData& gesture) { | 64 const GestureEventData& gesture) { |
65 GestureEventDetails details = gesture.details; | 65 GestureEventDetails details = gesture.details; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 float double_tap_slop_square = | 130 float double_tap_slop_square = |
131 GestureConfiguration::GetInstance() | 131 GestureConfiguration::GetInstance() |
132 ->max_distance_between_taps_for_double_tap(); | 132 ->max_distance_between_taps_for_double_tap(); |
133 double_tap_slop_square *= double_tap_slop_square; | 133 double_tap_slop_square *= double_tap_slop_square; |
134 const float delta_x = previous_tap.x - current_tap.x; | 134 const float delta_x = previous_tap.x - current_tap.x; |
135 const float delta_y = previous_tap.y - current_tap.y; | 135 const float delta_y = previous_tap.y - current_tap.y; |
136 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); | 136 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); |
137 } | 137 } |
138 | 138 |
139 } // namespace content | 139 } // namespace content |
OLD | NEW |