Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: ui/events/cocoa/events_mac.mm

Issue 2007083002: Validate that ui::Event::time_stamp comes from the same clock as TimeTicks::Now (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@453559-use-timeticks-ui-event
Patch Set: Address feedback Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/base_event_utils.cc ('k') | ui/events/event_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(&timestamp);
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
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
OLDNEW
« no previous file with comments | « ui/events/base_event_utils.cc ('k') | ui/events/event_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698