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

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

Issue 510793003: Remove ui::TouchEvent -> blink::WebTouchEvent conversion methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix broken test. Created 5 years, 11 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
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_( 18 filtered_gesture_provider_(
19 GetGestureProviderConfig(GestureProviderConfigType::CURRENT_PLATFORM), 19 GetGestureProviderConfig(GestureProviderConfigType::CURRENT_PLATFORM),
20 this), 20 this),
21 handling_event_(false), 21 handling_event_(false),
22 last_unique_touch_event_id_( 22 last_unique_touch_event_id_(
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 DCHECK(event); 30 if (!pointer_state_.OnTouch(*event))
31 return false;
32
31 last_unique_touch_event_id_ = event->unique_event_id(); 33 last_unique_touch_event_id_ = event->unique_event_id();
32 int index = pointer_state_.FindPointerIndexOfId(event->touch_id());
33 bool pointer_id_is_active = index != -1;
34
35 if (event->type() == ET_TOUCH_PRESSED && pointer_id_is_active) {
36 // Ignore touch press events if we already believe the pointer is down.
37 return false;
38 } else if (event->type() != ET_TOUCH_PRESSED && !pointer_id_is_active) {
39 // We could have an active touch stream transfered to us, resulting in touch
40 // move or touch up events without associated touch down events. Ignore
41 // them.
42 return false;
43 }
44
45 // If this is a touchmove event, and it isn't different from the last
46 // event, ignore it.
47 if (event->type() == ET_TOUCH_MOVED &&
48 event->x() == pointer_state_.GetX(index) &&
49 event->y() == pointer_state_.GetY(index)) {
50 return false;
51 }
52
53 last_touch_event_latency_info_ = *event->latency(); 34 last_touch_event_latency_info_ = *event->latency();
54 pointer_state_.OnTouch(*event);
55 35
56 auto result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); 36 auto result = filtered_gesture_provider_.OnTouchEvent(pointer_state_);
57 if (!result.succeeded) 37 if (!result.succeeded)
58 return false; 38 return false;
59 39
60 event->set_may_cause_scrolling(result.did_generate_scroll); 40 event->set_may_cause_scrolling(result.did_generate_scroll);
61 pointer_state_.CleanupRemovedTouchPoints(*event); 41 pointer_state_.CleanupRemovedTouchPoints(*event);
62 return true; 42 return true;
63 } 43 }
64 44
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 float double_tap_slop_square = 130 float double_tap_slop_square =
151 GestureConfiguration::GetInstance() 131 GestureConfiguration::GetInstance()
152 ->max_distance_between_taps_for_double_tap(); 132 ->max_distance_between_taps_for_double_tap();
153 double_tap_slop_square *= double_tap_slop_square; 133 double_tap_slop_square *= double_tap_slop_square;
154 const float delta_x = previous_tap.x - current_tap.x; 134 const float delta_x = previous_tap.x - current_tap.x;
155 const float delta_y = previous_tap.y - current_tap.y; 135 const float delta_y = previous_tap.y - current_tap.y;
156 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);
157 } 137 }
158 138
159 } // namespace content 139 } // namespace content
OLDNEW
« no previous file with comments | « ui/aura/gestures/gesture_recognizer_unittest.cc ('k') | ui/events/gestures/gesture_provider_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698