| 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> |
| 9 |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "ui/events/event_constants.h" | 11 #include "ui/events/event_constants.h" |
| 10 #include "ui/events/events_base_export.h" | 12 #include "ui/events/events_base_export.h" |
| 11 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 12 #include "ui/gfx/geometry/rect_conversions.h" | 14 #include "ui/gfx/geometry/rect_conversions.h" |
| 13 | 15 |
| 16 namespace IPC { |
| 17 template <class P> struct ParamTraits; |
| 18 } |
| 19 |
| 14 namespace ui { | 20 namespace ui { |
| 15 | 21 |
| 16 struct EVENTS_BASE_EXPORT GestureEventDetails { | 22 struct EVENTS_BASE_EXPORT GestureEventDetails { |
| 17 public: | 23 public: |
| 18 GestureEventDetails(); | 24 GestureEventDetails(); |
| 19 explicit GestureEventDetails(EventType type); | 25 explicit GestureEventDetails(EventType type); |
| 20 GestureEventDetails(EventType type, float delta_x, float delta_y); | 26 GestureEventDetails(EventType type, float delta_x, float delta_y); |
| 21 | 27 |
| 22 // The caller is responsible for ensuring that the gesture data from |other| | 28 // The caller is responsible for ensuring that the gesture data from |other| |
| 23 // is compatible and sufficient for that expected by gestures of |type|. | 29 // is compatible and sufficient for that expected by gestures of |type|. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 void mark_previous_scroll_update_in_sequence_prevented() { | 136 void mark_previous_scroll_update_in_sequence_prevented() { |
| 131 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); | 137 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); |
| 132 data_.scroll_update.previous_update_in_sequence_prevented = true; | 138 data_.scroll_update.previous_update_in_sequence_prevented = true; |
| 133 } | 139 } |
| 134 | 140 |
| 135 bool previous_scroll_update_in_sequence_prevented() const { | 141 bool previous_scroll_update_in_sequence_prevented() const { |
| 136 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); | 142 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); |
| 137 return data_.scroll_update.previous_update_in_sequence_prevented; | 143 return data_.scroll_update.previous_update_in_sequence_prevented; |
| 138 } | 144 } |
| 139 | 145 |
| 146 // Supports comparison over internal structures for testing. |
| 147 bool operator==(const GestureEventDetails& other) const { |
| 148 return type_ == other.type_ && |
| 149 !memcmp(&data_, &other.data_, sizeof(Details)) && |
| 150 touch_points_ == other.touch_points_ && |
| 151 bounding_box_ == other.bounding_box_; |
| 152 } |
| 153 |
| 140 private: | 154 private: |
| 141 EventType type_; | 155 EventType type_; |
| 142 union Details { | 156 union Details { |
| 143 Details(); | 157 Details(); |
| 144 struct { // SCROLL start details. | 158 struct { // SCROLL start details. |
| 145 // Distance that caused the scroll to start. Generally redundant with | 159 // Distance that caused the scroll to start. Generally redundant with |
| 146 // the x/y values from the first scroll_update. | 160 // the x/y values from the first scroll_update. |
| 147 float x_hint; | 161 float x_hint; |
| 148 float y_hint; | 162 float y_hint; |
| 149 } scroll_begin; | 163 } scroll_begin; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 175 bool right; | 189 bool right; |
| 176 bool up; | 190 bool up; |
| 177 bool down; | 191 bool down; |
| 178 } swipe; | 192 } swipe; |
| 179 | 193 |
| 180 // Tap information must be set for ET_GESTURE_TAP, | 194 // Tap information must be set for ET_GESTURE_TAP, |
| 181 // ET_GESTURE_TAP_UNCONFIRMED, and ET_GESTURE_DOUBLE_TAP events. | 195 // ET_GESTURE_TAP_UNCONFIRMED, and ET_GESTURE_DOUBLE_TAP events. |
| 182 int tap_count; // TAP repeat count. | 196 int tap_count; // TAP repeat count. |
| 183 } data_; | 197 } data_; |
| 184 | 198 |
| 199 // For mojo native implementation of (de)serialization. |
| 200 friend struct IPC::ParamTraits<ui::GestureEventDetails>; |
| 201 friend struct IPC::ParamTraits<ui::GestureEventDetails::Details>; |
| 202 |
| 185 int touch_points_; // Number of active touch points in the gesture. | 203 int touch_points_; // Number of active touch points in the gesture. |
| 186 | 204 |
| 187 // Bounding box is an axis-aligned rectangle that contains all the | 205 // Bounding box is an axis-aligned rectangle that contains all the |
| 188 // enclosing rectangles of the touch-points in the gesture. | 206 // enclosing rectangles of the touch-points in the gesture. |
| 189 gfx::RectF bounding_box_; | 207 gfx::RectF bounding_box_; |
| 190 }; | 208 }; |
| 191 | 209 |
| 192 } // namespace ui | 210 } // namespace ui |
| 193 | 211 |
| 194 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 212 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
| OLD | NEW |