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. | |
| 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 case ui::ET_LAST: | |
| 203 NOTREACHED(); | |
| 204 return ui::SourceEventType::UNKNOWN; | |
| 205 } | |
| 206 NOTREACHED(); | |
| 207 return ui::SourceEventType::UNKNOWN; | |
| 208 } | |
| 209 | |
| 142 bool IsX11SendEventTrue(const base::NativeEvent& event) { | 210 bool IsX11SendEventTrue(const base::NativeEvent& event) { |
| 143 #if defined(USE_X11) | 211 #if defined(USE_X11) |
| 144 return event && event->xany.send_event; | 212 return event && event->xany.send_event; |
| 145 #else | 213 #else |
| 146 return false; | 214 return false; |
| 147 #endif | 215 #endif |
| 148 } | 216 } |
| 149 | 217 |
| 150 bool X11EventHasNonStandardState(const base::NativeEvent& event) { | 218 bool X11EventHasNonStandardState(const base::NativeEvent& event) { |
| 151 #if defined(USE_X11) | 219 #if defined(USE_X11) |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 : type_(type), | 394 : type_(type), |
| 327 time_stamp_(time_stamp), | 395 time_stamp_(time_stamp), |
| 328 flags_(flags), | 396 flags_(flags), |
| 329 native_event_(base::NativeEvent()), | 397 native_event_(base::NativeEvent()), |
| 330 delete_native_event_(false), | 398 delete_native_event_(false), |
| 331 cancelable_(true), | 399 cancelable_(true), |
| 332 target_(NULL), | 400 target_(NULL), |
| 333 phase_(EP_PREDISPATCH), | 401 phase_(EP_PREDISPATCH), |
| 334 result_(ER_UNHANDLED), | 402 result_(ER_UNHANDLED), |
| 335 source_device_id_(ED_UNKNOWN_DEVICE) { | 403 source_device_id_(ED_UNKNOWN_DEVICE) { |
| 336 if (type_ < ET_LAST) | 404 if (type_ < ET_LAST) { |
| 405 latency()->set_source_event_type(EventTypeToLatencySourceEventType(type)); | |
| 337 name_ = EventTypeName(type_); | 406 name_ = EventTypeName(type_); |
| 407 } | |
| 338 } | 408 } |
| 339 | 409 |
| 340 Event::Event(const base::NativeEvent& native_event, | 410 Event::Event(const base::NativeEvent& native_event, |
| 341 EventType type, | 411 EventType type, |
| 342 int flags) | 412 int flags) |
| 343 : type_(type), | 413 : type_(type), |
| 344 time_stamp_(EventTimeFromNative(native_event)), | 414 time_stamp_(EventTimeFromNative(native_event)), |
| 345 flags_(flags), | 415 flags_(flags), |
| 346 native_event_(native_event), | 416 native_event_(native_event), |
| 347 delete_native_event_(false), | 417 delete_native_event_(false), |
| 348 cancelable_(true), | 418 cancelable_(true), |
| 349 target_(NULL), | 419 target_(NULL), |
| 350 phase_(EP_PREDISPATCH), | 420 phase_(EP_PREDISPATCH), |
| 351 result_(ER_UNHANDLED), | 421 result_(ER_UNHANDLED), |
| 352 source_device_id_(ED_UNKNOWN_DEVICE) { | 422 source_device_id_(ED_UNKNOWN_DEVICE) { |
| 353 base::TimeDelta delta = EventTimeForNow() - time_stamp_; | 423 base::TimeDelta delta = EventTimeForNow() - time_stamp_; |
| 354 if (type_ < ET_LAST) | 424 if (type_ < ET_LAST) { |
| 425 latency()->set_source_event_type(EventTypeToLatencySourceEventType(type)); | |
| 355 name_ = EventTypeName(type_); | 426 name_ = EventTypeName(type_); |
| 427 } | |
| 356 base::HistogramBase::Sample delta_sample = | 428 base::HistogramBase::Sample delta_sample = |
| 357 static_cast<base::HistogramBase::Sample>(delta.InMicroseconds()); | 429 static_cast<base::HistogramBase::Sample>(delta.InMicroseconds()); |
| 358 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", delta_sample, 1, 1000000, | 430 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", delta_sample, 1, 1000000, |
| 359 100); | 431 100); |
| 360 ComputeEventLatencyOS(native_event); | 432 ComputeEventLatencyOS(native_event); |
| 361 | 433 |
| 362 // Though it seems inefficient to generate the string twice, the first | 434 // 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 | 435 // 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. | 436 // executed at all if the histogram was previously accessed here. |
| 365 STATIC_HISTOGRAM_POINTER_GROUP( | 437 STATIC_HISTOGRAM_POINTER_GROUP( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 396 result_(ER_UNHANDLED), | 468 result_(ER_UNHANDLED), |
| 397 source_device_id_(copy.source_device_id_) { | 469 source_device_id_(copy.source_device_id_) { |
| 398 if (type_ < ET_LAST) | 470 if (type_ < ET_LAST) |
| 399 name_ = EventTypeName(type_); | 471 name_ = EventTypeName(type_); |
| 400 } | 472 } |
| 401 | 473 |
| 402 void Event::SetType(EventType type) { | 474 void Event::SetType(EventType type) { |
| 403 if (type_ < ET_LAST) | 475 if (type_ < ET_LAST) |
| 404 name_ = std::string(); | 476 name_ = std::string(); |
| 405 type_ = type; | 477 type_ = type; |
| 406 if (type_ < ET_LAST) | 478 if (type_ < ET_LAST) { |
| 407 name_ = EventTypeName(type_); | 479 name_ = EventTypeName(type_); |
| 480 latency()->set_source_event_type(EventTypeToLatencySourceEventType(type)); | |
| 481 } | |
| 408 } | 482 } |
| 409 | 483 |
| 410 //////////////////////////////////////////////////////////////////////////////// | 484 //////////////////////////////////////////////////////////////////////////////// |
| 411 // CancelModeEvent | 485 // CancelModeEvent |
| 412 | 486 |
| 413 CancelModeEvent::CancelModeEvent() | 487 CancelModeEvent::CancelModeEvent() |
| 414 : Event(ET_CANCEL_MODE, base::TimeTicks(), 0) { | 488 : Event(ET_CANCEL_MODE, base::TimeTicks(), 0) { |
| 415 set_cancelable(false); | 489 set_cancelable(false); |
| 416 } | 490 } |
| 417 | 491 |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 return true; | 953 return true; |
| 880 default: | 954 default: |
| 881 return false; | 955 return false; |
| 882 } | 956 } |
| 883 } | 957 } |
| 884 | 958 |
| 885 PointerEvent::PointerEvent(const PointerEvent& pointer_event) | 959 PointerEvent::PointerEvent(const PointerEvent& pointer_event) |
| 886 : LocatedEvent(pointer_event), | 960 : LocatedEvent(pointer_event), |
| 887 pointer_id_(pointer_event.pointer_id()), | 961 pointer_id_(pointer_event.pointer_id()), |
| 888 changed_button_flags_(pointer_event.changed_button_flags()), | 962 changed_button_flags_(pointer_event.changed_button_flags()), |
| 889 details_(pointer_event.pointer_details()) {} | 963 details_(pointer_event.pointer_details()) { |
| 964 if (details_.pointer_type == EventPointerType::POINTER_TYPE_TOUCH) | |
| 965 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | |
| 966 else if (pointer_event.type() == ET_POINTER_WHEEL_CHANGED) | |
| 967 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 968 else | |
| 969 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 970 } | |
| 890 | 971 |
| 891 PointerEvent::PointerEvent(const MouseEvent& mouse_event) | 972 PointerEvent::PointerEvent(const MouseEvent& mouse_event) |
| 892 : LocatedEvent(mouse_event), | 973 : LocatedEvent(mouse_event), |
| 893 pointer_id_(kMousePointerId), | 974 pointer_id_(kMousePointerId), |
| 894 changed_button_flags_(mouse_event.changed_button_flags()), | 975 changed_button_flags_(mouse_event.changed_button_flags()), |
| 895 details_(mouse_event.pointer_details()) { | 976 details_(mouse_event.pointer_details()) { |
| 896 DCHECK(CanConvertFrom(mouse_event)); | 977 DCHECK(CanConvertFrom(mouse_event)); |
| 897 switch (mouse_event.type()) { | 978 switch (mouse_event.type()) { |
| 898 case ET_MOUSE_PRESSED: | 979 case ET_MOUSE_PRESSED: |
| 899 SetType(ET_POINTER_DOWN); | 980 SetType(ET_POINTER_DOWN); |
| 981 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 900 break; | 982 break; |
| 901 | 983 |
| 902 case ET_MOUSE_DRAGGED: | 984 case ET_MOUSE_DRAGGED: |
| 903 case ET_MOUSE_MOVED: | 985 case ET_MOUSE_MOVED: |
| 904 SetType(ET_POINTER_MOVED); | 986 SetType(ET_POINTER_MOVED); |
| 987 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 905 break; | 988 break; |
| 906 | 989 |
| 907 case ET_MOUSE_ENTERED: | 990 case ET_MOUSE_ENTERED: |
| 908 SetType(ET_POINTER_ENTERED); | 991 SetType(ET_POINTER_ENTERED); |
| 992 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 909 break; | 993 break; |
| 910 | 994 |
| 911 case ET_MOUSE_EXITED: | 995 case ET_MOUSE_EXITED: |
| 912 SetType(ET_POINTER_EXITED); | 996 SetType(ET_POINTER_EXITED); |
| 997 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 913 break; | 998 break; |
| 914 | 999 |
| 915 case ET_MOUSE_RELEASED: | 1000 case ET_MOUSE_RELEASED: |
| 916 SetType(ET_POINTER_UP); | 1001 SetType(ET_POINTER_UP); |
| 1002 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 917 break; | 1003 break; |
| 918 | 1004 |
| 919 case ET_MOUSEWHEEL: | 1005 case ET_MOUSEWHEEL: |
| 920 SetType(ET_POINTER_WHEEL_CHANGED); | 1006 SetType(ET_POINTER_WHEEL_CHANGED); |
| 921 details_ = PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, | 1007 details_ = PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, |
| 922 mouse_event.AsMouseWheelEvent()->offset()); | 1008 mouse_event.AsMouseWheelEvent()->offset()); |
| 1009 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 923 break; | 1010 break; |
| 924 | 1011 |
| 925 case ET_MOUSE_CAPTURE_CHANGED: | 1012 case ET_MOUSE_CAPTURE_CHANGED: |
| 926 SetType(ET_POINTER_CAPTURE_CHANGED); | 1013 SetType(ET_POINTER_CAPTURE_CHANGED); |
| 927 break; | 1014 break; |
| 928 | 1015 |
| 929 default: | 1016 default: |
| 930 NOTREACHED(); | 1017 NOTREACHED(); |
| 931 } | 1018 } |
| 932 } | 1019 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 950 SetType(ET_POINTER_UP); | 1037 SetType(ET_POINTER_UP); |
| 951 break; | 1038 break; |
| 952 | 1039 |
| 953 case ET_TOUCH_CANCELLED: | 1040 case ET_TOUCH_CANCELLED: |
| 954 SetType(ET_POINTER_CANCELLED); | 1041 SetType(ET_POINTER_CANCELLED); |
| 955 break; | 1042 break; |
| 956 | 1043 |
| 957 default: | 1044 default: |
| 958 NOTREACHED(); | 1045 NOTREACHED(); |
| 959 } | 1046 } |
| 1047 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | |
| 960 } | 1048 } |
| 961 | 1049 |
| 962 PointerEvent::PointerEvent(EventType type, | 1050 PointerEvent::PointerEvent(EventType type, |
| 963 const gfx::Point& location, | 1051 const gfx::Point& location, |
| 964 const gfx::Point& root_location, | 1052 const gfx::Point& root_location, |
| 965 int flags, | 1053 int flags, |
| 966 int pointer_id, | 1054 int pointer_id, |
| 967 int changed_button_flags, | 1055 int changed_button_flags, |
| 968 const PointerDetails& pointer_details, | 1056 const PointerDetails& pointer_details, |
| 969 base::TimeTicks time_stamp) | 1057 base::TimeTicks time_stamp) |
| 970 : LocatedEvent(type, | 1058 : LocatedEvent(type, |
| 971 gfx::PointF(location), | 1059 gfx::PointF(location), |
| 972 gfx::PointF(root_location), | 1060 gfx::PointF(root_location), |
| 973 time_stamp, | 1061 time_stamp, |
| 974 flags), | 1062 flags), |
| 975 pointer_id_(pointer_id), | 1063 pointer_id_(pointer_id), |
| 976 changed_button_flags_(changed_button_flags), | 1064 changed_button_flags_(changed_button_flags), |
| 977 details_(pointer_details) {} | 1065 details_(pointer_details) { |
| 1066 if (details_.pointer_type == EventPointerType::POINTER_TYPE_TOUCH) | |
| 1067 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | |
| 1068 else if (type == ET_POINTER_WHEEL_CHANGED) | |
| 1069 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 1070 else | |
| 1071 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 1072 } | |
| 978 | 1073 |
| 979 const int PointerEvent::kMousePointerId = std::numeric_limits<int32_t>::max(); | 1074 const int PointerEvent::kMousePointerId = std::numeric_limits<int32_t>::max(); |
| 980 | 1075 |
| 981 //////////////////////////////////////////////////////////////////////////////// | 1076 //////////////////////////////////////////////////////////////////////////////// |
| 982 // KeyEvent | 1077 // KeyEvent |
| 983 | 1078 |
| 984 // static | 1079 // static |
| 985 KeyEvent* KeyEvent::last_key_event_ = NULL; | 1080 KeyEvent* KeyEvent::last_key_event_ = NULL; |
| 986 | 1081 |
| 987 // static | 1082 // static |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 } | 1185 } |
| 1091 | 1186 |
| 1092 KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) { | 1187 KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) { |
| 1093 if (this != &rhs) { | 1188 if (this != &rhs) { |
| 1094 Event::operator=(rhs); | 1189 Event::operator=(rhs); |
| 1095 key_code_ = rhs.key_code_; | 1190 key_code_ = rhs.key_code_; |
| 1096 code_ = rhs.code_; | 1191 code_ = rhs.code_; |
| 1097 key_ = rhs.key_; | 1192 key_ = rhs.key_; |
| 1098 is_char_ = rhs.is_char_; | 1193 is_char_ = rhs.is_char_; |
| 1099 } | 1194 } |
| 1195 latency()->set_source_event_type(ui::SourceEventType::OTHER); | |
| 1100 return *this; | 1196 return *this; |
| 1101 } | 1197 } |
| 1102 | 1198 |
| 1103 KeyEvent::~KeyEvent() {} | 1199 KeyEvent::~KeyEvent() {} |
| 1104 | 1200 |
| 1105 void KeyEvent::ApplyLayout() const { | 1201 void KeyEvent::ApplyLayout() const { |
| 1106 ui::DomCode code = code_; | 1202 ui::DomCode code = code_; |
| 1107 if (code == DomCode::NONE) { | 1203 if (code == DomCode::NONE) { |
| 1108 // Catch old code that tries to do layout without a physical key, and try | 1204 // 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 | 1205 // 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 || | 1362 } else if (type() == ET_SCROLL_FLING_START || |
| 1267 type() == ET_SCROLL_FLING_CANCEL) { | 1363 type() == ET_SCROLL_FLING_CANCEL) { |
| 1268 GetFlingData(native_event, | 1364 GetFlingData(native_event, |
| 1269 &x_offset_, &y_offset_, | 1365 &x_offset_, &y_offset_, |
| 1270 &x_offset_ordinal_, &y_offset_ordinal_, | 1366 &x_offset_ordinal_, &y_offset_ordinal_, |
| 1271 NULL); | 1367 NULL); |
| 1272 } else { | 1368 } else { |
| 1273 NOTREACHED() << "Unexpected event type " << type() | 1369 NOTREACHED() << "Unexpected event type " << type() |
| 1274 << " when constructing a ScrollEvent."; | 1370 << " when constructing a ScrollEvent."; |
| 1275 } | 1371 } |
| 1372 if (IsScrollEvent()) | |
| 1373 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 1374 else | |
| 1375 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | |
| 1276 } | 1376 } |
| 1277 | 1377 |
| 1278 ScrollEvent::ScrollEvent(EventType type, | 1378 ScrollEvent::ScrollEvent(EventType type, |
| 1279 const gfx::Point& location, | 1379 const gfx::Point& location, |
| 1280 base::TimeTicks time_stamp, | 1380 base::TimeTicks time_stamp, |
| 1281 int flags, | 1381 int flags, |
| 1282 float x_offset, | 1382 float x_offset, |
| 1283 float y_offset, | 1383 float y_offset, |
| 1284 float x_offset_ordinal, | 1384 float x_offset_ordinal, |
| 1285 float y_offset_ordinal, | 1385 float y_offset_ordinal, |
| 1286 int finger_count) | 1386 int finger_count) |
| 1287 : MouseEvent(type, location, location, time_stamp, flags, 0), | 1387 : MouseEvent(type, location, location, time_stamp, flags, 0), |
| 1288 x_offset_(x_offset), | 1388 x_offset_(x_offset), |
| 1289 y_offset_(y_offset), | 1389 y_offset_(y_offset), |
| 1290 x_offset_ordinal_(x_offset_ordinal), | 1390 x_offset_ordinal_(x_offset_ordinal), |
| 1291 y_offset_ordinal_(y_offset_ordinal), | 1391 y_offset_ordinal_(y_offset_ordinal), |
| 1292 finger_count_(finger_count) { | 1392 finger_count_(finger_count) { |
| 1293 CHECK(IsScrollEvent()); | 1393 CHECK(IsScrollEvent()); |
| 1394 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 1294 } | 1395 } |
| 1295 | 1396 |
| 1296 void ScrollEvent::Scale(const float factor) { | 1397 void ScrollEvent::Scale(const float factor) { |
| 1297 x_offset_ *= factor; | 1398 x_offset_ *= factor; |
| 1298 y_offset_ *= factor; | 1399 y_offset_ *= factor; |
| 1299 x_offset_ordinal_ *= factor; | 1400 x_offset_ordinal_ *= factor; |
| 1300 y_offset_ordinal_ *= factor; | 1401 y_offset_ordinal_ *= factor; |
| 1301 } | 1402 } |
| 1302 | 1403 |
| 1303 //////////////////////////////////////////////////////////////////////////////// | 1404 //////////////////////////////////////////////////////////////////////////////// |
| 1304 // GestureEvent | 1405 // GestureEvent |
| 1305 | 1406 |
| 1306 GestureEvent::GestureEvent(float x, | 1407 GestureEvent::GestureEvent(float x, |
| 1307 float y, | 1408 float y, |
| 1308 int flags, | 1409 int flags, |
| 1309 base::TimeTicks time_stamp, | 1410 base::TimeTicks time_stamp, |
| 1310 const GestureEventDetails& details, | 1411 const GestureEventDetails& details, |
| 1311 uint32_t unique_touch_event_id) | 1412 uint32_t unique_touch_event_id) |
| 1312 : LocatedEvent(details.type(), | 1413 : LocatedEvent(details.type(), |
| 1313 gfx::PointF(x, y), | 1414 gfx::PointF(x, y), |
| 1314 gfx::PointF(x, y), | 1415 gfx::PointF(x, y), |
| 1315 time_stamp, | 1416 time_stamp, |
| 1316 flags | EF_FROM_TOUCH), | 1417 flags | EF_FROM_TOUCH), |
| 1317 details_(details), | 1418 details_(details), |
| 1318 unique_touch_event_id_(unique_touch_event_id) {} | 1419 unique_touch_event_id_(unique_touch_event_id) { |
| 1420 if ((flags | EF_FROM_TOUCH) || | |
|
brucedawson
2016/09/19 17:40:21
This line of code appears to be incorrect. This wa
sahel
2016/09/20 19:10:32
Acknowledged.
| |
| 1421 (details.device_type() == ui::GestureDeviceType::DEVICE_TOUCHSCREEN)) { | |
| 1422 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | |
| 1423 } else if (details.device_type() == ui::GestureDeviceType::DEVICE_TOUCHPAD) { | |
| 1424 latency()->set_source_event_type(ui::SourceEventType::WHEEL); | |
| 1425 } | |
| 1426 } | |
| 1319 | 1427 |
| 1320 GestureEvent::~GestureEvent() { | 1428 GestureEvent::~GestureEvent() { |
| 1321 } | 1429 } |
| 1322 | 1430 |
| 1323 } // namespace ui | 1431 } // namespace ui |
| OLD | NEW |