Chromium Code Reviews| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/events/gesture_detection/gesture_config_helper.h" | 9 #include "ui/events/gesture_detection/gesture_config_helper.h" |
| 10 #include "ui/events/gesture_detection/gesture_event_data.h" | 10 #include "ui/events/gesture_detection/gesture_event_data.h" |
| 11 #include "ui/events/gestures/gesture_configuration.h" | 11 #include "ui/events/gestures/gesture_configuration.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 | 14 |
| 15 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client) | 15 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client) |
| 16 : client_(client), | 16 : client_(client), |
| 17 filtered_gesture_provider_(ui::DefaultGestureProviderConfig(), this) { | 17 filtered_gesture_provider_(ui::DefaultGestureProviderConfig(), this) { |
| 18 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); | 18 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); |
| 19 } | 19 } |
| 20 | 20 |
| 21 GestureProviderAura::~GestureProviderAura() {} | 21 GestureProviderAura::~GestureProviderAura() {} |
| 22 | 22 |
| 23 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { | 23 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { |
| 24 last_touch_event_flags_ = event.flags(); | 24 last_touch_event_flags_ = event.flags(); |
|
jdduke (slow)
2014/06/02 17:27:24
Hmm, should we move these |last_foo_ = event.foo()
tdresser
2014/06/02 17:33:23
Done.
| |
| 25 last_touch_event_latency_info_ = *event.latency(); | |
| 25 bool pointer_id_is_active = false; | 26 bool pointer_id_is_active = false; |
| 26 for (size_t i = 0; i < pointer_state_.GetPointerCount(); ++i) { | 27 for (size_t i = 0; i < pointer_state_.GetPointerCount(); ++i) { |
| 27 if (event.touch_id() != pointer_state_.GetPointerId(i)) | 28 if (event.touch_id() != pointer_state_.GetPointerId(i)) |
| 28 continue; | 29 continue; |
| 29 pointer_id_is_active = true; | 30 pointer_id_is_active = true; |
| 30 break; | 31 break; |
| 31 } | 32 } |
| 32 | 33 |
| 33 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { | 34 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { |
| 34 // Ignore touch press events if we already believe the pointer is down. | 35 // Ignore touch press events if we already believe the pointer is down. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 gesture.x, | 74 gesture.x, |
| 74 gesture.y, | 75 gesture.y, |
| 75 last_touch_event_flags_, | 76 last_touch_event_flags_, |
| 76 gesture.time - base::TimeTicks(), | 77 gesture.time - base::TimeTicks(), |
| 77 details, | 78 details, |
| 78 // ui::GestureEvent stores a bitfield indicating the | 79 // ui::GestureEvent stores a bitfield indicating the |
| 79 // ids of active touch points. This is currently only | 80 // ids of active touch points. This is currently only |
| 80 // used when one finger is down, and will eventually | 81 // used when one finger is down, and will eventually |
| 81 // be cleaned up. See crbug.com/366707. | 82 // be cleaned up. See crbug.com/366707. |
| 82 1 << gesture.motion_event_id); | 83 1 << gesture.motion_event_id); |
| 84 | |
| 85 ui::LatencyInfo* gesture_latency = event.latency(); | |
| 86 gesture_latency->CopyLatencyFrom( | |
| 87 last_touch_event_latency_info_, | |
| 88 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); | |
| 89 gesture_latency->CopyLatencyFrom( | |
| 90 last_touch_event_latency_info_, | |
| 91 ui::INPUT_EVENT_LATENCY_UI_COMPONENT); | |
| 92 gesture_latency->CopyLatencyFrom( | |
| 93 last_touch_event_latency_info_, | |
| 94 ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT); | |
| 95 | |
| 83 client_->OnGestureEvent(&event); | 96 client_->OnGestureEvent(&event); |
| 84 } | 97 } |
| 85 | 98 |
| 86 bool GestureProviderAura::IsConsideredDoubleTap( | 99 bool GestureProviderAura::IsConsideredDoubleTap( |
| 87 const GestureEventData& previous_tap, | 100 const GestureEventData& previous_tap, |
| 88 const GestureEventData& current_tap) const { | 101 const GestureEventData& current_tap) const { |
| 89 if (current_tap.time - previous_tap.time > | 102 if (current_tap.time - previous_tap.time > |
| 90 base::TimeDelta::FromMilliseconds( | 103 base::TimeDelta::FromMilliseconds( |
| 91 ui::GestureConfiguration::max_seconds_between_double_click() * | 104 ui::GestureConfiguration::max_seconds_between_double_click() * |
| 92 1000)) { | 105 1000)) { |
| 93 return false; | 106 return false; |
| 94 } | 107 } |
| 95 | 108 |
| 96 double double_tap_slop_square = | 109 double double_tap_slop_square = |
| 97 GestureConfiguration::max_distance_between_taps_for_double_tap(); | 110 GestureConfiguration::max_distance_between_taps_for_double_tap(); |
| 98 double_tap_slop_square *= double_tap_slop_square; | 111 double_tap_slop_square *= double_tap_slop_square; |
| 99 const float delta_x = previous_tap.x - current_tap.x; | 112 const float delta_x = previous_tap.x - current_tap.x; |
| 100 const float delta_y = previous_tap.y - current_tap.y; | 113 const float delta_y = previous_tap.y - current_tap.y; |
| 101 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); | 114 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); |
| 102 } | 115 } |
| 103 | 116 |
| 104 } // namespace content | 117 } // namespace content |
| OLD | NEW |