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/gesture_event_details.h" | 5 #include "ui/events/gesture_event_details.h" |
6 | 6 |
7 namespace ui { | 7 namespace ui { |
8 | 8 |
9 GestureEventDetails::GestureEventDetails() | 9 GestureEventDetails::GestureEventDetails() |
10 : type_(ET_UNKNOWN), | 10 : type_(ET_UNKNOWN), |
11 device_type_(GestureDeviceType::DEVICE_UNKNOWN), | 11 device_type_(GestureDeviceType::DEVICE_UNKNOWN), |
| 12 primary_pointer_type_(EventPointerType::POINTER_TYPE_UNKNOWN), |
12 touch_points_(0) {} | 13 touch_points_(0) {} |
13 | 14 |
14 GestureEventDetails::GestureEventDetails(ui::EventType type) | 15 GestureEventDetails::GestureEventDetails(ui::EventType type) |
15 : type_(type), | 16 : type_(type), |
16 device_type_(GestureDeviceType::DEVICE_UNKNOWN), | 17 device_type_(GestureDeviceType::DEVICE_UNKNOWN), |
| 18 primary_pointer_type_(EventPointerType::POINTER_TYPE_UNKNOWN), |
17 touch_points_(1) { | 19 touch_points_(1) { |
18 DCHECK_GE(type, ET_GESTURE_TYPE_START); | 20 DCHECK_GE(type, ET_GESTURE_TYPE_START); |
19 DCHECK_LE(type, ET_GESTURE_TYPE_END); | 21 DCHECK_LE(type, ET_GESTURE_TYPE_END); |
20 } | 22 } |
21 | 23 |
22 GestureEventDetails::GestureEventDetails(ui::EventType type, | 24 GestureEventDetails::GestureEventDetails(ui::EventType type, |
23 float delta_x, | 25 float delta_x, |
24 float delta_y, | 26 float delta_y, |
25 ScrollUnits units) | 27 ScrollUnits units) |
26 : type_(type), | 28 : type_(type), |
27 device_type_(GestureDeviceType::DEVICE_UNKNOWN), | 29 device_type_(GestureDeviceType::DEVICE_UNKNOWN), |
| 30 primary_pointer_type_(EventPointerType::POINTER_TYPE_UNKNOWN), |
28 touch_points_(1) { | 31 touch_points_(1) { |
29 DCHECK_GE(type, ET_GESTURE_TYPE_START); | 32 DCHECK_GE(type, ET_GESTURE_TYPE_START); |
30 DCHECK_LE(type, ET_GESTURE_TYPE_END); | 33 DCHECK_LE(type, ET_GESTURE_TYPE_END); |
31 switch (type_) { | 34 switch (type_) { |
32 case ui::ET_GESTURE_SCROLL_BEGIN: | 35 case ui::ET_GESTURE_SCROLL_BEGIN: |
33 data_.scroll_begin.x_hint = delta_x; | 36 data_.scroll_begin.x_hint = delta_x; |
34 data_.scroll_begin.y_hint = delta_y; | 37 data_.scroll_begin.y_hint = delta_y; |
35 data_.scroll_begin.delta_hint_units = units; | 38 data_.scroll_begin.delta_hint_units = units; |
36 break; | 39 break; |
37 | 40 |
(...skipping 23 matching lines...) Expand all Loading... |
61 default: | 64 default: |
62 NOTREACHED() << "Invalid event type for constructor: " << type; | 65 NOTREACHED() << "Invalid event type for constructor: " << type; |
63 } | 66 } |
64 } | 67 } |
65 | 68 |
66 GestureEventDetails::GestureEventDetails(ui::EventType type, | 69 GestureEventDetails::GestureEventDetails(ui::EventType type, |
67 const GestureEventDetails& other) | 70 const GestureEventDetails& other) |
68 : type_(type), | 71 : type_(type), |
69 data_(other.data_), | 72 data_(other.data_), |
70 device_type_(other.device_type_), | 73 device_type_(other.device_type_), |
| 74 primary_pointer_type_(other.primary_pointer_type_), |
71 touch_points_(other.touch_points_), | 75 touch_points_(other.touch_points_), |
72 bounding_box_(other.bounding_box_) { | 76 bounding_box_(other.bounding_box_) { |
73 DCHECK_GE(type, ET_GESTURE_TYPE_START); | 77 DCHECK_GE(type, ET_GESTURE_TYPE_START); |
74 DCHECK_LE(type, ET_GESTURE_TYPE_END); | 78 DCHECK_LE(type, ET_GESTURE_TYPE_END); |
75 switch (type) { | 79 switch (type) { |
76 case ui::ET_GESTURE_SCROLL_BEGIN: | 80 case ui::ET_GESTURE_SCROLL_BEGIN: |
77 // Synthetic creation of SCROLL_BEGIN from PINCH_BEGIN is explicitly | 81 // Synthetic creation of SCROLL_BEGIN from PINCH_BEGIN is explicitly |
78 // allowed as an exception. | 82 // allowed as an exception. |
79 if (other.type() == ui::ET_GESTURE_PINCH_BEGIN) | 83 if (other.type() == ui::ET_GESTURE_PINCH_BEGIN) |
80 break; | 84 break; |
81 case ui::ET_GESTURE_SCROLL_UPDATE: | 85 case ui::ET_GESTURE_SCROLL_UPDATE: |
82 case ui::ET_SCROLL_FLING_START: | 86 case ui::ET_SCROLL_FLING_START: |
83 case ui::ET_GESTURE_SWIPE: | 87 case ui::ET_GESTURE_SWIPE: |
84 case ui::ET_GESTURE_PINCH_UPDATE: | 88 case ui::ET_GESTURE_PINCH_UPDATE: |
85 DCHECK_EQ(type, other.type()) << " - Invalid gesture conversion from " | 89 DCHECK_EQ(type, other.type()) << " - Invalid gesture conversion from " |
86 << other.type() << " to " << type; | 90 << other.type() << " to " << type; |
87 break; | 91 break; |
88 default: | 92 default: |
89 break; | 93 break; |
90 } | 94 } |
91 } | 95 } |
92 | 96 |
93 GestureEventDetails::Details::Details() { | 97 GestureEventDetails::Details::Details() { |
94 memset(this, 0, sizeof(Details)); | 98 memset(this, 0, sizeof(Details)); |
95 } | 99 } |
96 | 100 |
97 } // namespace ui | 101 } // namespace ui |
OLD | NEW |