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

Side by Side Diff: ui/events/gestures/gesture_provider_aura.cc

Issue 679633005: Expose native, desktop and mobile gesture detection defaults (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 6 years 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
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/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"
11 #include "ui/events/gesture_detection/gesture_event_data.h" 11 #include "ui/events/gesture_detection/gesture_event_data.h"
12 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" 12 #include "ui/events/gesture_detection/gesture_provider_config_helper.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client) 16 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client)
17 : client_(client), 17 : client_(client),
18 filtered_gesture_provider_(DefaultGestureProviderConfig(), this), 18 filtered_gesture_provider_(
19 GetGestureProviderConfig(GestureProviderConfigType::CURRENT_PLATFORM),
20 this),
19 handling_event_(false), 21 handling_event_(false),
20 last_unique_touch_event_id_( 22 last_unique_touch_event_id_(
21 std::numeric_limits<unsigned long long>::max()) { 23 std::numeric_limits<unsigned long long>::max()) {
22 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); 24 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false);
23 } 25 }
24 26
25 GestureProviderAura::~GestureProviderAura() {} 27 GestureProviderAura::~GestureProviderAura() {}
26 28
27 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { 29 bool GestureProviderAura::OnTouchEvent(TouchEvent* event) {
28 last_unique_touch_event_id_ = event.unique_event_id(); 30 DCHECK(event);
29 int index = pointer_state_.FindPointerIndexOfId(event.touch_id()); 31 last_unique_touch_event_id_ = event->unique_event_id();
32 int index = pointer_state_.FindPointerIndexOfId(event->touch_id());
30 bool pointer_id_is_active = index != -1; 33 bool pointer_id_is_active = index != -1;
31 34
32 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { 35 if (event->type() == ET_TOUCH_PRESSED && pointer_id_is_active) {
33 // Ignore touch press events if we already believe the pointer is down. 36 // Ignore touch press events if we already believe the pointer is down.
34 return false; 37 return false;
35 } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { 38 } else if (event->type() != ET_TOUCH_PRESSED && !pointer_id_is_active) {
36 // We could have an active touch stream transfered to us, resulting in touch 39 // We could have an active touch stream transfered to us, resulting in touch
37 // move or touch up events without associated touch down events. Ignore 40 // move or touch up events without associated touch down events. Ignore
38 // them. 41 // them.
39 return false; 42 return false;
40 } 43 }
41 44
42 // If this is a touchmove event, and it isn't different from the last 45 // If this is a touchmove event, and it isn't different from the last
43 // event, ignore it. 46 // event, ignore it.
44 if (event.type() == ET_TOUCH_MOVED && 47 if (event->type() == ET_TOUCH_MOVED &&
45 event.x() == pointer_state_.GetX(index) && 48 event->x() == pointer_state_.GetX(index) &&
46 event.y() == pointer_state_.GetY(index)) { 49 event->y() == pointer_state_.GetY(index)) {
47 return false; 50 return false;
48 } 51 }
49 52
50 last_touch_event_latency_info_ = *event.latency(); 53 last_touch_event_latency_info_ = *event->latency();
51 pointer_state_.OnTouch(event); 54 pointer_state_.OnTouch(*event);
52 55
53 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); 56 auto result = filtered_gesture_provider_.OnTouchEvent(pointer_state_);
54 pointer_state_.CleanupRemovedTouchPoints(event); 57 if (!result.succeeded)
55 return result; 58 return false;
59
60 event->set_may_cause_scrolling(result.did_generate_scroll);
61 pointer_state_.CleanupRemovedTouchPoints(*event);
62 return true;
56 } 63 }
57 64
58 void GestureProviderAura::OnAsyncTouchEventAck(bool event_consumed) { 65 void GestureProviderAura::OnAsyncTouchEventAck(bool event_consumed) {
59 DCHECK(pending_gestures_.empty()); 66 DCHECK(pending_gestures_.empty());
60 DCHECK(!handling_event_); 67 DCHECK(!handling_event_);
61 base::AutoReset<bool> handling_event(&handling_event_, true); 68 base::AutoReset<bool> handling_event(&handling_event_, true);
62 filtered_gesture_provider_.OnAsyncTouchEventAck(event_consumed); 69 filtered_gesture_provider_.OnAsyncTouchEventAck(event_consumed);
63 last_touch_event_latency_info_.Clear(); 70 last_touch_event_latency_info_.Clear();
64 } 71 }
65 72
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 float double_tap_slop_square = 150 float double_tap_slop_square =
144 GestureConfiguration::GetInstance() 151 GestureConfiguration::GetInstance()
145 ->max_distance_between_taps_for_double_tap(); 152 ->max_distance_between_taps_for_double_tap();
146 double_tap_slop_square *= double_tap_slop_square; 153 double_tap_slop_square *= double_tap_slop_square;
147 const float delta_x = previous_tap.x - current_tap.x; 154 const float delta_x = previous_tap.x - current_tap.x;
148 const float delta_y = previous_tap.y - current_tap.y; 155 const float delta_y = previous_tap.y - current_tap.y;
149 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); 156 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square);
150 } 157 }
151 158
152 } // namespace content 159 } // namespace content
OLDNEW
« no previous file with comments | « ui/events/gestures/gesture_provider_aura.h ('k') | ui/events/gestures/gesture_provider_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698