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/event_utils.h" | 5 #include "ui/events/event_utils.h" |
6 | 6 |
7 #include <Cocoa/Cocoa.h> | 7 #include <Cocoa/Cocoa.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 NSUInteger modifiers = [event modifierFlags]; | 77 NSUInteger modifiers = [event modifierFlags]; |
78 return EventFlagsFromNSEventWithModifiers(event, modifiers); | 78 return EventFlagsFromNSEventWithModifiers(event, modifiers); |
79 } | 79 } |
80 | 80 |
81 base::TimeTicks EventTimeFromNative(const base::NativeEvent& native_event) { | 81 base::TimeTicks EventTimeFromNative(const base::NativeEvent& native_event) { |
82 NSTimeInterval since_system_startup = [native_event timestamp]; | 82 NSTimeInterval since_system_startup = [native_event timestamp]; |
83 // Truncate to extract seconds before doing floating point arithmetic. | 83 // Truncate to extract seconds before doing floating point arithmetic. |
84 int64_t seconds = since_system_startup; | 84 int64_t seconds = since_system_startup; |
85 since_system_startup -= seconds; | 85 since_system_startup -= seconds; |
86 int64_t microseconds = since_system_startup * 1000000; | 86 int64_t microseconds = since_system_startup * 1000000; |
87 return ui::EventTimeStampFromSeconds(seconds) + | 87 base::TimeTicks timestamp = ui::EventTimeStampFromSeconds(seconds) + |
88 base::TimeDelta::FromMicroseconds(microseconds); | 88 base::TimeDelta::FromMicroseconds(microseconds); |
| 89 ValidateEventTimeClock(×tamp); |
| 90 return timestamp; |
89 } | 91 } |
90 | 92 |
91 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { | 93 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { |
92 NSWindow* window = [native_event window]; | 94 NSWindow* window = [native_event window]; |
93 if (!window) { | 95 if (!window) { |
94 NOTIMPLEMENTED(); // Point will be in screen coordinates. | 96 NOTIMPLEMENTED(); // Point will be in screen coordinates. |
95 return gfx::Point(); | 97 return gfx::Point(); |
96 } | 98 } |
97 NSPoint location = [native_event locationInWindow]; | 99 NSPoint location = [native_event locationInWindow]; |
98 NSRect content_rect = [window contentRectForFrameRect:[window frame]]; | 100 NSRect content_rect = [window contentRectForFrameRect:[window frame]]; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 uint16_t return_value; | 261 uint16_t return_value; |
260 [text getCharacters:&return_value]; | 262 [text getCharacters:&return_value]; |
261 return return_value; | 263 return return_value; |
262 } | 264 } |
263 | 265 |
264 bool IsCharFromNative(const base::NativeEvent& native_event) { | 266 bool IsCharFromNative(const base::NativeEvent& native_event) { |
265 return false; | 267 return false; |
266 } | 268 } |
267 | 269 |
268 } // namespace ui | 270 } // namespace ui |
OLD | NEW |