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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 case ET_GESTURE_PINCH_UPDATE: | 142 case ET_GESTURE_PINCH_UPDATE: |
| 143 case ET_GESTURE_LONG_PRESS: | 143 case ET_GESTURE_LONG_PRESS: |
| 144 case ET_GESTURE_LONG_TAP: | 144 case ET_GESTURE_LONG_TAP: |
| 145 case ET_GESTURE_SWIPE: | 145 case ET_GESTURE_SWIPE: |
| 146 case ET_GESTURE_SHOW_PRESS: | 146 case ET_GESTURE_SHOW_PRESS: |
| 147 // Flings can be GestureEvents too. | 147 // Flings can be GestureEvents too. |
| 148 case ET_SCROLL_FLING_START: | 148 case ET_SCROLL_FLING_START: |
| 149 case ET_SCROLL_FLING_CANCEL: | 149 case ET_SCROLL_FLING_CANCEL: |
| 150 return SourceEventType::UNKNOWN; | 150 return SourceEventType::UNKNOWN; |
| 151 | 151 |
| 152 case ui::ET_KEY_PRESSED: | |
| 153 return ui::SourceEventType::KEY; | |
| 154 | |
| 152 case ET_MOUSE_PRESSED: | 155 case ET_MOUSE_PRESSED: |
| 153 case ET_MOUSE_DRAGGED: | 156 case ET_MOUSE_DRAGGED: |
| 154 case ET_MOUSE_RELEASED: | 157 case ET_MOUSE_RELEASED: |
| 155 case ET_MOUSE_MOVED: | 158 case ET_MOUSE_MOVED: |
| 156 case ET_MOUSE_ENTERED: | 159 case ET_MOUSE_ENTERED: |
| 157 case ET_MOUSE_EXITED: | 160 case ET_MOUSE_EXITED: |
| 158 case ET_KEY_PRESSED: | 161 // We measure latency for key presses, not key releases. Most behavior is |
|
mfomitchev
2017/04/04 14:59:06
Nit: Perhaps this comment should be in the SourceE
tdresser
2017/05/01 15:49:21
Added a comment in SourceEventType enum.
| |
| 162 // keyed off of presses, and release latency is higher than press latency as | |
| 163 // it's impacted by event handling of the press event. | |
| 159 case ET_KEY_RELEASED: | 164 case ET_KEY_RELEASED: |
| 160 case ET_MOUSE_CAPTURE_CHANGED: | 165 case ET_MOUSE_CAPTURE_CHANGED: |
| 161 case ET_DROP_TARGET_EVENT: | 166 case ET_DROP_TARGET_EVENT: |
| 162 case ET_CANCEL_MODE: | 167 case ET_CANCEL_MODE: |
| 163 case ET_UMA_DATA: | 168 case ET_UMA_DATA: |
| 164 return SourceEventType::OTHER; | 169 return SourceEventType::OTHER; |
| 165 | 170 |
| 166 case ET_TOUCH_RELEASED: | 171 case ET_TOUCH_RELEASED: |
| 167 case ET_TOUCH_PRESSED: | 172 case ET_TOUCH_PRESSED: |
| 168 case ET_TOUCH_MOVED: | 173 case ET_TOUCH_MOVED: |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1133 } | 1138 } |
| 1134 | 1139 |
| 1135 KeyEvent::KeyEvent(const base::NativeEvent& native_event) | 1140 KeyEvent::KeyEvent(const base::NativeEvent& native_event) |
| 1136 : KeyEvent(native_event, EventFlagsFromNative(native_event)) {} | 1141 : KeyEvent(native_event, EventFlagsFromNative(native_event)) {} |
| 1137 | 1142 |
| 1138 KeyEvent::KeyEvent(const base::NativeEvent& native_event, int event_flags) | 1143 KeyEvent::KeyEvent(const base::NativeEvent& native_event, int event_flags) |
| 1139 : Event(native_event, EventTypeFromNative(native_event), event_flags), | 1144 : Event(native_event, EventTypeFromNative(native_event), event_flags), |
| 1140 key_code_(KeyboardCodeFromNative(native_event)), | 1145 key_code_(KeyboardCodeFromNative(native_event)), |
| 1141 code_(CodeFromNative(native_event)), | 1146 code_(CodeFromNative(native_event)), |
| 1142 is_char_(IsCharFromNative(native_event)) { | 1147 is_char_(IsCharFromNative(native_event)) { |
| 1148 latency()->AddLatencyNumberWithTimestamp( | |
| 1149 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, | |
| 1150 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); | |
| 1151 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | |
| 1152 | |
| 1143 if (IsRepeated(*this)) | 1153 if (IsRepeated(*this)) |
| 1144 set_flags(flags() | ui::EF_IS_REPEAT); | 1154 set_flags(flags() | ui::EF_IS_REPEAT); |
| 1145 | 1155 |
| 1146 #if defined(USE_X11) | 1156 #if defined(USE_X11) |
| 1147 NormalizeFlags(); | 1157 NormalizeFlags(); |
| 1148 #endif | 1158 #endif |
| 1149 #if defined(OS_WIN) | 1159 #if defined(OS_WIN) |
| 1150 // Only Windows has native character events. | 1160 // Only Windows has native character events. |
| 1151 if (is_char_) | 1161 if (is_char_) |
| 1152 key_ = DomKey::FromCharacter(native_event.wParam); | 1162 key_ = DomKey::FromCharacter(native_event.wParam); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1445 flags | EF_FROM_TOUCH), | 1455 flags | EF_FROM_TOUCH), |
| 1446 details_(details), | 1456 details_(details), |
| 1447 unique_touch_event_id_(unique_touch_event_id) { | 1457 unique_touch_event_id_(unique_touch_event_id) { |
| 1448 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | 1458 latency()->set_source_event_type(ui::SourceEventType::TOUCH); |
| 1449 } | 1459 } |
| 1450 | 1460 |
| 1451 GestureEvent::~GestureEvent() { | 1461 GestureEvent::~GestureEvent() { |
| 1452 } | 1462 } |
| 1453 | 1463 |
| 1454 } // namespace ui | 1464 } // namespace ui |
| OLD | NEW |