Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/event.h" | 5 #include "ui/events/event.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 | 10 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 CASE_TYPE(ET_UMA_DATA); | 132 CASE_TYPE(ET_UMA_DATA); |
| 133 case ui::ET_LAST: NOTREACHED(); return std::string(); | 133 case ui::ET_LAST: NOTREACHED(); return std::string(); |
| 134 // Don't include default, so that we get an error when new type is added. | 134 // Don't include default, so that we get an error when new type is added. |
| 135 } | 135 } |
| 136 #undef CASE_TYPE | 136 #undef CASE_TYPE |
| 137 | 137 |
| 138 NOTREACHED(); | 138 NOTREACHED(); |
| 139 return std::string(); | 139 return std::string(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 ui::SourceEventType EventTypeToLatencySourceEventType(ui::EventType type) { | |
| 143 switch (type) { | |
| 144 case ui::ET_UNKNOWN: | |
| 145 // SourceEventType for PointerEvents/GestureEvents can be either TOUCH or | |
| 146 // WHEEL. The proper value is assigned in the Constructors. | |
|
sky
2016/09/15 17:56:34
nit: 'C' -> 'c'.
sahel
2016/09/15 18:58:07
Done.
| |
| 147 case ui::ET_POINTER_DOWN: | |
| 148 case ui::ET_POINTER_MOVED: | |
| 149 case ui::ET_POINTER_UP: | |
| 150 case ui::ET_POINTER_CANCELLED: | |
| 151 case ui::ET_POINTER_ENTERED: | |
| 152 case ui::ET_POINTER_EXITED: | |
| 153 case ui::ET_POINTER_CAPTURE_CHANGED: | |
| 154 case ui::ET_GESTURE_SCROLL_BEGIN: | |
| 155 case ui::ET_GESTURE_SCROLL_END: | |
| 156 case ui::ET_GESTURE_SCROLL_UPDATE: | |
| 157 case ui::ET_GESTURE_TAP: | |
| 158 case ui::ET_GESTURE_TAP_DOWN: | |
| 159 case ui::ET_GESTURE_TAP_CANCEL: | |
| 160 case ui::ET_GESTURE_TAP_UNCONFIRMED: | |
| 161 case ui::ET_GESTURE_DOUBLE_TAP: | |
| 162 case ui::ET_GESTURE_BEGIN: | |
| 163 case ui::ET_GESTURE_END: | |
| 164 case ui::ET_GESTURE_TWO_FINGER_TAP: | |
| 165 case ui::ET_GESTURE_PINCH_BEGIN: | |
| 166 case ui::ET_GESTURE_PINCH_END: | |
| 167 case ui::ET_GESTURE_PINCH_UPDATE: | |
| 168 case ui::ET_GESTURE_LONG_PRESS: | |
| 169 case ui::ET_GESTURE_LONG_TAP: | |
| 170 case ui::ET_GESTURE_SWIPE: | |
| 171 case ui::ET_GESTURE_SHOW_PRESS: | |
| 172 // Flings can be GestureEvents too. | |
| 173 case ui::ET_SCROLL_FLING_START: | |
| 174 case ui::ET_SCROLL_FLING_CANCEL: | |
| 175 return ui::SourceEventType::UNKNOWN; | |
| 176 | |
| 177 case ui::ET_MOUSE_PRESSED: | |
| 178 case ui::ET_MOUSE_DRAGGED: | |
| 179 case ui::ET_MOUSE_RELEASED: | |
| 180 case ui::ET_MOUSE_MOVED: | |
| 181 case ui::ET_MOUSE_ENTERED: | |
| 182 case ui::ET_MOUSE_EXITED: | |
| 183 case ui::ET_KEY_PRESSED: | |
| 184 case ui::ET_KEY_RELEASED: | |
| 185 case ui::ET_MOUSE_CAPTURE_CHANGED: | |
| 186 case ui::ET_DROP_TARGET_EVENT: | |
| 187 case ui::ET_CANCEL_MODE: | |
| 188 case ui::ET_UMA_DATA: | |
| 189 return ui::SourceEventType::OTHER; | |
| 190 | |
| 191 case ui::ET_TOUCH_RELEASED: | |
| 192 case ui::ET_TOUCH_PRESSED: | |
| 193 case ui::ET_TOUCH_MOVED: | |
| 194 case ui::ET_TOUCH_CANCELLED: | |
| 195 return ui::SourceEventType::TOUCH; | |
| 196 | |
| 197 case ui::ET_MOUSEWHEEL: | |
| 198 case ui::ET_POINTER_WHEEL_CHANGED: | |
| 199 case ui::ET_SCROLL: | |
| 200 return ui::SourceEventType::WHEEL; | |
| 201 | |
| 202 default: | |
|
sky
2016/09/15 17:56:34
If you have this and we add a new type it'll be mi
sahel
2016/09/15 18:58:07
Done.
| |
| 203 NOTREACHED(); | |
| 204 return ui::SourceEventType::UNKNOWN; | |
| 205 } | |
| 206 } | |
| 207 | |
| 142 bool IsX11SendEventTrue(const base::NativeEvent& event) { | 208 bool IsX11SendEventTrue(const base::NativeEvent& event) { |
| 143 #if defined(USE_X11) | 209 #if defined(USE_X11) |
| 144 return event && event->xany.send_event; | 210 return event && event->xany.send_event; |
| 145 #else | 211 #else |
| 146 return false; | 212 return false; |
| 147 #endif | 213 #endif |
| 148 } | 214 } |
| 149 | 215 |
| 150 bool X11EventHasNonStandardState(const base::NativeEvent& event) { | 216 bool X11EventHasNonStandardState(const base::NativeEvent& event) { |
| 151 #if defined(USE_X11) | 217 #if defined(USE_X11) |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 : type_(type), | 392 : type_(type), |
| 327 time_stamp_(time_stamp), | 393 time_stamp_(time_stamp), |
| 328 flags_(flags), | 394 flags_(flags), |
| 329 native_event_(base::NativeEvent()), | 395 native_event_(base::NativeEvent()), |
| 330 delete_native_event_(false), | 396 delete_native_event_(false), |
| 331 cancelable_(true), | 397 cancelable_(true), |
| 332 target_(NULL), | 398 target_(NULL), |
| 333 phase_(EP_PREDISPATCH), | 399 phase_(EP_PREDISPATCH), |
| 334 result_(ER_UNHANDLED), | 400 result_(ER_UNHANDLED), |
| 335 source_device_id_(ED_UNKNOWN_DEVICE) { | 401 source_device_id_(ED_UNKNOWN_DEVICE) { |
| 336 if (type_ < ET_LAST) | 402 if (type_ < ET_LAST) { |
| 403 latency()->set_source_event_type(EventTypeToLatencySourceEventType(type)); | |
| 337 name_ = EventTypeName(type_); | 404 name_ = EventTypeName(type_); |
| 405 } | |
| 338 } | 406 } |
| 339 | 407 |
| 340 Event::Event(const base::NativeEvent& native_event, | 408 Event::Event(const base::NativeEvent& native_event, |
| 341 EventType type, | 409 EventType type, |
| 342 int flags) | 410 int flags) |
| 343 : type_(type), | 411 : type_(type), |
| 344 time_stamp_(EventTimeFromNative(native_event)), | 412 time_stamp_(EventTimeFromNative(native_event)), |
| 345 flags_(flags), | 413 flags_(flags), |
| 346 native_event_(native_event), | 414 native_event_(native_event), |
| 347 delete_native_event_(false), | 415 delete_native_event_(false), |
| 348 cancelable_(true), | 416 cancelable_(true), |
| 349 target_(NULL), | 417 target_(NULL), |
| 350 phase_(EP_PREDISPATCH), | 418 phase_(EP_PREDISPATCH), |
| 351 result_(ER_UNHANDLED), | 419 result_(ER_UNHANDLED), |
| 352 source_device_id_(ED_UNKNOWN_DEVICE) { | 420 source_device_id_(ED_UNKNOWN_DEVICE) { |
| 353 base::TimeDelta delta = EventTimeForNow() - time_stamp_; | 421 base::TimeDelta delta = EventTimeForNow() - time_stamp_; |
| 354 if (type_ < ET_LAST) | 422 if (type_ < ET_LAST) { |
| 423 latency()->set_source_event_type(EventTypeToLatencySourceEventType(type)); | |
| 355 name_ = EventTypeName(type_); | 424 name_ = EventTypeName(type_); |
| 425 } | |
| 356 base::HistogramBase::Sample delta_sample = | 426 base::HistogramBase::Sample delta_sample = |
| 357 static_cast<base::HistogramBase::Sample>(delta.InMicroseconds()); | 427 static_cast<base::HistogramBase::Sample>(delta.InMicroseconds()); |
| 358 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", delta_sample, 1, 1000000, | 428 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", delta_sample, 1, 1000000, |
| 359 100); | 429 100); |
| 360 ComputeEventLatencyOS(native_event); | 430 ComputeEventLatencyOS(native_event); |
| 361 | 431 |
| 362 // Though it seems inefficient to generate the string twice, the first | 432 // Though it seems inefficient to generate the string twice, the first |
| 363 // instance will be used only for DCHECK builds and the second won't be | 433 // instance will be used only for DCHECK builds and the second won't be |
| 364 // executed at all if the histogram was previously accessed here. | 434 // executed at all if the histogram was previously accessed here. |
| 365 STATIC_HISTOGRAM_POINTER_GROUP( | 435 STATIC_HISTOGRAM_POINTER_GROUP( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 396 result_(ER_UNHANDLED), | 466 result_(ER_UNHANDLED), |
| 397 source_device_id_(copy.source_device_id_) { | 467 source_device_id_(copy.source_device_id_) { |
| 398 if (type_ < ET_LAST) | 468 if (type_ < ET_LAST) |
| 399 name_ = EventTypeName(type_); | 469 name_ = EventTypeName(type_); |
| 400 } | 470 } |
| 401 | 471 |
| 402 void Event::SetType(EventType type) { | 472 void Event::SetType(EventType type) { |
| 403 if (type_ < ET_LAST) | 473 if (type_ < ET_LAST) |
| 404 name_ = std::string(); | 474 name_ = std::string(); |
| 405 type_ = type; | 475 type_ = type; |
| 406 if (type_ < ET_LAST) | 476 if (type_ < ET_LAST) { |
| 407 name_ = EventTypeName(type_); | 477 name_ = EventTypeName(type_); |
| 478 latency()->set_source_event_type(EventTypeToLatencySourceEventType(type)); | |
| 479 } | |
|
sky
2016/09/15 17:56:34
Shouldn't you handle the else case here? What if t
sahel
2016/09/15 18:58:07
The default value is UNKNOWN, and it would take ca
| |
| 408 } | 480 } |
| 409 | 481 |
| 410 //////////////////////////////////////////////////////////////////////////////// | 482 //////////////////////////////////////////////////////////////////////////////// |
| 411 // CancelModeEvent | 483 // CancelModeEvent |
| 412 | 484 |
| 413 CancelModeEvent::CancelModeEvent() | 485 CancelModeEvent::CancelModeEvent() |
| 414 : Event(ET_CANCEL_MODE, base::TimeTicks(), 0) { | 486 : Event(ET_CANCEL_MODE, base::TimeTicks(), 0) { |
| 415 set_cancelable(false); | 487 set_cancelable(false); |
| 416 } | 488 } |
| 417 | 489 |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 return true; | 951 return true; |
| 880 default: | 952 default: |
| 881 return false; | 953 return false; |
| 882 } | 954 } |
| 883 } | 955 } |
| 884 | 956 |
| 885 PointerEvent::PointerEvent(const PointerEvent& pointer_event) | 957 PointerEvent::PointerEvent(const PointerEvent& pointer_event) |
| 886 : LocatedEvent(pointer_event), | 958 : LocatedEvent(pointer_event), |
| 887 pointer_id_(pointer_event.pointer_id()), | 959 pointer_id_(pointer_event.pointer_id()), |
| 888 changed_button_flags_(pointer_event.changed_button_flags()), | 960 changed_button_flags_(pointer_event.changed_button_flags()), |
| 889 details_(pointer_event.pointer_details()) {} | 961 details_(pointer_event.pointer_details()) { |
| 962 if (details_.pointer_type == EventPointerType::POINTER_TYPE_TOUCH) | |
| 963 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | |
| 964 else if (pointer_event.type() == ET_POINTER_WHEEL_CHANGED) | |
| 965 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 966 else | |
| 967 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 968 } | |
| 890 | 969 |
| 891 PointerEvent::PointerEvent(const MouseEvent& mouse_event) | 970 PointerEvent::PointerEvent(const MouseEvent& mouse_event) |
| 892 : LocatedEvent(mouse_event), | 971 : LocatedEvent(mouse_event), |
| 893 pointer_id_(kMousePointerId), | 972 pointer_id_(kMousePointerId), |
| 894 changed_button_flags_(mouse_event.changed_button_flags()), | 973 changed_button_flags_(mouse_event.changed_button_flags()), |
| 895 details_(mouse_event.pointer_details()) { | 974 details_(mouse_event.pointer_details()) { |
| 896 DCHECK(CanConvertFrom(mouse_event)); | 975 DCHECK(CanConvertFrom(mouse_event)); |
| 897 switch (mouse_event.type()) { | 976 switch (mouse_event.type()) { |
| 898 case ET_MOUSE_PRESSED: | 977 case ET_MOUSE_PRESSED: |
| 899 SetType(ET_POINTER_DOWN); | 978 SetType(ET_POINTER_DOWN); |
| 979 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 900 break; | 980 break; |
| 901 | 981 |
| 902 case ET_MOUSE_DRAGGED: | 982 case ET_MOUSE_DRAGGED: |
| 903 case ET_MOUSE_MOVED: | 983 case ET_MOUSE_MOVED: |
| 904 SetType(ET_POINTER_MOVED); | 984 SetType(ET_POINTER_MOVED); |
| 985 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 905 break; | 986 break; |
| 906 | 987 |
| 907 case ET_MOUSE_ENTERED: | 988 case ET_MOUSE_ENTERED: |
| 908 SetType(ET_POINTER_ENTERED); | 989 SetType(ET_POINTER_ENTERED); |
| 990 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 909 break; | 991 break; |
| 910 | 992 |
| 911 case ET_MOUSE_EXITED: | 993 case ET_MOUSE_EXITED: |
| 912 SetType(ET_POINTER_EXITED); | 994 SetType(ET_POINTER_EXITED); |
| 995 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 913 break; | 996 break; |
| 914 | 997 |
| 915 case ET_MOUSE_RELEASED: | 998 case ET_MOUSE_RELEASED: |
| 916 SetType(ET_POINTER_UP); | 999 SetType(ET_POINTER_UP); |
| 1000 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 917 break; | 1001 break; |
| 918 | 1002 |
| 919 case ET_MOUSEWHEEL: | 1003 case ET_MOUSEWHEEL: |
| 920 SetType(ET_POINTER_WHEEL_CHANGED); | 1004 SetType(ET_POINTER_WHEEL_CHANGED); |
| 921 details_ = PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, | 1005 details_ = PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, |
| 922 mouse_event.AsMouseWheelEvent()->offset()); | 1006 mouse_event.AsMouseWheelEvent()->offset()); |
| 1007 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 923 break; | 1008 break; |
| 924 | 1009 |
| 925 case ET_MOUSE_CAPTURE_CHANGED: | 1010 case ET_MOUSE_CAPTURE_CHANGED: |
| 926 SetType(ET_POINTER_CAPTURE_CHANGED); | 1011 SetType(ET_POINTER_CAPTURE_CHANGED); |
| 927 break; | 1012 break; |
| 928 | 1013 |
| 929 default: | 1014 default: |
| 930 NOTREACHED(); | 1015 NOTREACHED(); |
| 931 } | 1016 } |
| 932 } | 1017 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 950 SetType(ET_POINTER_UP); | 1035 SetType(ET_POINTER_UP); |
| 951 break; | 1036 break; |
| 952 | 1037 |
| 953 case ET_TOUCH_CANCELLED: | 1038 case ET_TOUCH_CANCELLED: |
| 954 SetType(ET_POINTER_CANCELLED); | 1039 SetType(ET_POINTER_CANCELLED); |
| 955 break; | 1040 break; |
| 956 | 1041 |
| 957 default: | 1042 default: |
| 958 NOTREACHED(); | 1043 NOTREACHED(); |
| 959 } | 1044 } |
| 1045 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | |
| 960 } | 1046 } |
| 961 | 1047 |
| 962 PointerEvent::PointerEvent(EventType type, | 1048 PointerEvent::PointerEvent(EventType type, |
| 963 const gfx::Point& location, | 1049 const gfx::Point& location, |
| 964 const gfx::Point& root_location, | 1050 const gfx::Point& root_location, |
| 965 int flags, | 1051 int flags, |
| 966 int pointer_id, | 1052 int pointer_id, |
| 967 int changed_button_flags, | 1053 int changed_button_flags, |
| 968 const PointerDetails& pointer_details, | 1054 const PointerDetails& pointer_details, |
| 969 base::TimeTicks time_stamp) | 1055 base::TimeTicks time_stamp) |
| 970 : LocatedEvent(type, | 1056 : LocatedEvent(type, |
| 971 gfx::PointF(location), | 1057 gfx::PointF(location), |
| 972 gfx::PointF(root_location), | 1058 gfx::PointF(root_location), |
| 973 time_stamp, | 1059 time_stamp, |
| 974 flags), | 1060 flags), |
| 975 pointer_id_(pointer_id), | 1061 pointer_id_(pointer_id), |
| 976 changed_button_flags_(changed_button_flags), | 1062 changed_button_flags_(changed_button_flags), |
| 977 details_(pointer_details) {} | 1063 details_(pointer_details) { |
| 1064 if (details_.pointer_type == EventPointerType::POINTER_TYPE_TOUCH) | |
| 1065 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | |
| 1066 else if (type == ET_POINTER_WHEEL_CHANGED) | |
| 1067 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 1068 else | |
| 1069 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 1070 } | |
| 978 | 1071 |
| 979 const int PointerEvent::kMousePointerId = std::numeric_limits<int32_t>::max(); | 1072 const int PointerEvent::kMousePointerId = std::numeric_limits<int32_t>::max(); |
| 980 | 1073 |
| 981 //////////////////////////////////////////////////////////////////////////////// | 1074 //////////////////////////////////////////////////////////////////////////////// |
| 982 // KeyEvent | 1075 // KeyEvent |
| 983 | 1076 |
| 984 // static | 1077 // static |
| 985 KeyEvent* KeyEvent::last_key_event_ = NULL; | 1078 KeyEvent* KeyEvent::last_key_event_ = NULL; |
| 986 | 1079 |
| 987 // static | 1080 // static |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 } | 1183 } |
| 1091 | 1184 |
| 1092 KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) { | 1185 KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) { |
| 1093 if (this != &rhs) { | 1186 if (this != &rhs) { |
| 1094 Event::operator=(rhs); | 1187 Event::operator=(rhs); |
| 1095 key_code_ = rhs.key_code_; | 1188 key_code_ = rhs.key_code_; |
| 1096 code_ = rhs.code_; | 1189 code_ = rhs.code_; |
| 1097 key_ = rhs.key_; | 1190 key_ = rhs.key_; |
| 1098 is_char_ = rhs.is_char_; | 1191 is_char_ = rhs.is_char_; |
| 1099 } | 1192 } |
| 1193 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 1100 return *this; | 1194 return *this; |
| 1101 } | 1195 } |
| 1102 | 1196 |
| 1103 KeyEvent::~KeyEvent() {} | 1197 KeyEvent::~KeyEvent() {} |
| 1104 | 1198 |
| 1105 void KeyEvent::ApplyLayout() const { | 1199 void KeyEvent::ApplyLayout() const { |
| 1106 ui::DomCode code = code_; | 1200 ui::DomCode code = code_; |
| 1107 if (code == DomCode::NONE) { | 1201 if (code == DomCode::NONE) { |
| 1108 // Catch old code that tries to do layout without a physical key, and try | 1202 // Catch old code that tries to do layout without a physical key, and try |
| 1109 // to recover using the KeyboardCode. Once key events are fully defined | 1203 // to recover using the KeyboardCode. Once key events are fully defined |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1266 } else if (type() == ET_SCROLL_FLING_START || | 1360 } else if (type() == ET_SCROLL_FLING_START || |
| 1267 type() == ET_SCROLL_FLING_CANCEL) { | 1361 type() == ET_SCROLL_FLING_CANCEL) { |
| 1268 GetFlingData(native_event, | 1362 GetFlingData(native_event, |
| 1269 &x_offset_, &y_offset_, | 1363 &x_offset_, &y_offset_, |
| 1270 &x_offset_ordinal_, &y_offset_ordinal_, | 1364 &x_offset_ordinal_, &y_offset_ordinal_, |
| 1271 NULL); | 1365 NULL); |
| 1272 } else { | 1366 } else { |
| 1273 NOTREACHED() << "Unexpected event type " << type() | 1367 NOTREACHED() << "Unexpected event type " << type() |
| 1274 << " when constructing a ScrollEvent."; | 1368 << " when constructing a ScrollEvent."; |
| 1275 } | 1369 } |
| 1370 if (IsScrollEvent()) | |
| 1371 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 1372 else | |
| 1373 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | |
| 1276 } | 1374 } |
| 1277 | 1375 |
| 1278 ScrollEvent::ScrollEvent(EventType type, | 1376 ScrollEvent::ScrollEvent(EventType type, |
| 1279 const gfx::Point& location, | 1377 const gfx::Point& location, |
| 1280 base::TimeTicks time_stamp, | 1378 base::TimeTicks time_stamp, |
| 1281 int flags, | 1379 int flags, |
| 1282 float x_offset, | 1380 float x_offset, |
| 1283 float y_offset, | 1381 float y_offset, |
| 1284 float x_offset_ordinal, | 1382 float x_offset_ordinal, |
| 1285 float y_offset_ordinal, | 1383 float y_offset_ordinal, |
| 1286 int finger_count) | 1384 int finger_count) |
| 1287 : MouseEvent(type, location, location, time_stamp, flags, 0), | 1385 : MouseEvent(type, location, location, time_stamp, flags, 0), |
| 1288 x_offset_(x_offset), | 1386 x_offset_(x_offset), |
| 1289 y_offset_(y_offset), | 1387 y_offset_(y_offset), |
| 1290 x_offset_ordinal_(x_offset_ordinal), | 1388 x_offset_ordinal_(x_offset_ordinal), |
| 1291 y_offset_ordinal_(y_offset_ordinal), | 1389 y_offset_ordinal_(y_offset_ordinal), |
| 1292 finger_count_(finger_count) { | 1390 finger_count_(finger_count) { |
| 1293 CHECK(IsScrollEvent()); | 1391 CHECK(IsScrollEvent()); |
| 1392 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 1294 } | 1393 } |
| 1295 | 1394 |
| 1296 void ScrollEvent::Scale(const float factor) { | 1395 void ScrollEvent::Scale(const float factor) { |
| 1297 x_offset_ *= factor; | 1396 x_offset_ *= factor; |
| 1298 y_offset_ *= factor; | 1397 y_offset_ *= factor; |
| 1299 x_offset_ordinal_ *= factor; | 1398 x_offset_ordinal_ *= factor; |
| 1300 y_offset_ordinal_ *= factor; | 1399 y_offset_ordinal_ *= factor; |
| 1301 } | 1400 } |
| 1302 | 1401 |
| 1303 //////////////////////////////////////////////////////////////////////////////// | 1402 //////////////////////////////////////////////////////////////////////////////// |
| 1304 // GestureEvent | 1403 // GestureEvent |
| 1305 | 1404 |
| 1306 GestureEvent::GestureEvent(float x, | 1405 GestureEvent::GestureEvent(float x, |
| 1307 float y, | 1406 float y, |
| 1308 int flags, | 1407 int flags, |
| 1309 base::TimeTicks time_stamp, | 1408 base::TimeTicks time_stamp, |
| 1310 const GestureEventDetails& details, | 1409 const GestureEventDetails& details, |
| 1311 uint32_t unique_touch_event_id) | 1410 uint32_t unique_touch_event_id) |
| 1312 : LocatedEvent(details.type(), | 1411 : LocatedEvent(details.type(), |
| 1313 gfx::PointF(x, y), | 1412 gfx::PointF(x, y), |
| 1314 gfx::PointF(x, y), | 1413 gfx::PointF(x, y), |
| 1315 time_stamp, | 1414 time_stamp, |
| 1316 flags | EF_FROM_TOUCH), | 1415 flags | EF_FROM_TOUCH), |
| 1317 details_(details), | 1416 details_(details), |
| 1318 unique_touch_event_id_(unique_touch_event_id) {} | 1417 unique_touch_event_id_(unique_touch_event_id) { |
| 1418 if ((flags | EF_FROM_TOUCH) || | |
| 1419 (details.device_type() == ui::GestureDeviceType::DEVICE_TOUCHSCREEN)) { | |
| 1420 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | |
| 1421 } else if (details.device_type() == ui::GestureDeviceType::DEVICE_TOUCHPAD) { | |
| 1422 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 1423 } | |
| 1424 } | |
| 1319 | 1425 |
| 1320 GestureEvent::~GestureEvent() { | 1426 GestureEvent::~GestureEvent() { |
| 1321 } | 1427 } |
| 1322 | 1428 |
| 1323 } // namespace ui | 1429 } // namespace ui |
| OLD | NEW |