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 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
| 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
| 7 | 7 |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "ui/events/event_constants.h" | 11 #include "ui/events/event_constants.h" |
| 12 #include "ui/events/events_base_export.h" | 12 #include "ui/events/events_base_export.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 14 #include "ui/gfx/geometry/rect_conversions.h" | 14 #include "ui/gfx/geometry/rect_conversions.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 | 17 |
| 18 struct EVENTS_BASE_EXPORT GestureEventDetails { | 18 struct EVENTS_BASE_EXPORT GestureEventDetails { |
| 19 public: | 19 public: |
| 20 // The definition of ScrollUnits below is consistent with that in | |
| 21 // //src/third_party/WebKit/public/platform/WebGestureEvent.h | |
| 22 enum class ScrollUnits { | |
| 23 PRECISE_PIXELS = 0, // generated by high precision devices. | |
| 24 PIXELS, // large pixel jump duration; should animate to delta. | |
| 25 PAGE // page (visible viewport) based scrolling. | |
| 26 }; | |
| 27 | |
| 20 GestureEventDetails(); | 28 GestureEventDetails(); |
| 21 explicit GestureEventDetails(EventType type); | 29 explicit GestureEventDetails(EventType type); |
| 22 GestureEventDetails(EventType type, float delta_x, float delta_y); | 30 GestureEventDetails(EventType type, |
| 31 float delta_x, | |
| 32 float delta_y, | |
| 33 ScrollUnits units = ScrollUnits::PRECISE_PIXELS); | |
|
Bret
2017/02/17 21:06:03
nit: add a short comment saying this is the defaul
chengx
2017/02/17 21:57:45
Done.
| |
| 23 | 34 |
| 24 // The caller is responsible for ensuring that the gesture data from |other| | 35 // The caller is responsible for ensuring that the gesture data from |other| |
| 25 // is compatible and sufficient for that expected by gestures of |type|. | 36 // is compatible and sufficient for that expected by gestures of |type|. |
| 26 GestureEventDetails(EventType type, const GestureEventDetails& other); | 37 GestureEventDetails(EventType type, const GestureEventDetails& other); |
| 27 | 38 |
| 28 EventType type() const { return type_; } | 39 EventType type() const { return type_; } |
| 29 | 40 |
| 30 GestureDeviceType device_type() const { return device_type_; } | 41 GestureDeviceType device_type() const { return device_type_; } |
| 31 void set_device_type(GestureDeviceType device_type) { | 42 void set_device_type(GestureDeviceType device_type) { |
| 32 device_type_ = device_type; | 43 device_type_ = device_type; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 51 float scroll_x_hint() const { | 62 float scroll_x_hint() const { |
| 52 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); | 63 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); |
| 53 return data_.scroll_begin.x_hint; | 64 return data_.scroll_begin.x_hint; |
| 54 } | 65 } |
| 55 | 66 |
| 56 float scroll_y_hint() const { | 67 float scroll_y_hint() const { |
| 57 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); | 68 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); |
| 58 return data_.scroll_begin.y_hint; | 69 return data_.scroll_begin.y_hint; |
| 59 } | 70 } |
| 60 | 71 |
| 72 ScrollUnits scroll_begin_units() const { | |
| 73 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); | |
| 74 return data_.scroll_begin.delta_hint_units; | |
| 75 } | |
| 76 | |
| 61 float scroll_x() const { | 77 float scroll_x() const { |
| 62 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); | 78 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); |
| 63 return data_.scroll_update.x; | 79 return data_.scroll_update.x; |
| 64 } | 80 } |
| 65 | 81 |
| 66 float scroll_y() const { | 82 float scroll_y() const { |
| 67 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); | 83 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); |
| 68 return data_.scroll_update.y; | 84 return data_.scroll_update.y; |
| 69 } | 85 } |
| 70 | 86 |
| 87 ScrollUnits scroll_update_units() const { | |
| 88 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); | |
| 89 return data_.scroll_update.delta_units; | |
| 90 } | |
| 91 | |
| 71 float velocity_x() const { | 92 float velocity_x() const { |
| 72 DCHECK_EQ(ET_SCROLL_FLING_START, type_); | 93 DCHECK_EQ(ET_SCROLL_FLING_START, type_); |
| 73 return data_.fling_velocity.x; | 94 return data_.fling_velocity.x; |
| 74 } | 95 } |
| 75 | 96 |
| 76 float velocity_y() const { | 97 float velocity_y() const { |
| 77 DCHECK_EQ(ET_SCROLL_FLING_START, type_); | 98 DCHECK_EQ(ET_SCROLL_FLING_START, type_); |
| 78 return data_.fling_velocity.y; | 99 return data_.fling_velocity.y; |
| 79 } | 100 } |
| 80 | 101 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 | 176 |
| 156 private: | 177 private: |
| 157 EventType type_; | 178 EventType type_; |
| 158 union Details { | 179 union Details { |
| 159 Details(); | 180 Details(); |
| 160 struct { // SCROLL start details. | 181 struct { // SCROLL start details. |
| 161 // Distance that caused the scroll to start. Generally redundant with | 182 // Distance that caused the scroll to start. Generally redundant with |
| 162 // the x/y values from the first scroll_update. | 183 // the x/y values from the first scroll_update. |
| 163 float x_hint; | 184 float x_hint; |
| 164 float y_hint; | 185 float y_hint; |
| 186 ScrollUnits delta_hint_units; | |
| 165 } scroll_begin; | 187 } scroll_begin; |
| 166 | 188 |
| 167 struct { // SCROLL delta. | 189 struct { // SCROLL delta. |
| 168 float x; | 190 float x; |
| 169 float y; | 191 float y; |
| 192 ScrollUnits delta_units; | |
| 170 // Whether any previous scroll update in the current scroll sequence was | 193 // Whether any previous scroll update in the current scroll sequence was |
| 171 // suppressed because the underlying touch was consumed. | 194 // suppressed because the underlying touch was consumed. |
| 172 bool previous_update_in_sequence_prevented; | 195 bool previous_update_in_sequence_prevented; |
| 173 } scroll_update; | 196 } scroll_update; |
| 174 | 197 |
| 175 float scale; // PINCH scale. | 198 float scale; // PINCH scale. |
| 176 | 199 |
| 177 struct { // FLING velocity. | 200 struct { // FLING velocity. |
| 178 float x; | 201 float x; |
| 179 float y; | 202 float y; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 203 int touch_points_; // Number of active touch points in the gesture. | 226 int touch_points_; // Number of active touch points in the gesture. |
| 204 | 227 |
| 205 // Bounding box is an axis-aligned rectangle that contains all the | 228 // Bounding box is an axis-aligned rectangle that contains all the |
| 206 // enclosing rectangles of the touch-points in the gesture. | 229 // enclosing rectangles of the touch-points in the gesture. |
| 207 gfx::RectF bounding_box_; | 230 gfx::RectF bounding_box_; |
| 208 }; | 231 }; |
| 209 | 232 |
| 210 } // namespace ui | 233 } // namespace ui |
| 211 | 234 |
| 212 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 235 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
| OLD | NEW |