| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 int64_t seconds = since_system_startup; | 83 int64_t seconds = since_system_startup; |
| 84 since_system_startup -= seconds; | 84 since_system_startup -= seconds; |
| 85 int64_t microseconds = since_system_startup * 1000000; | 85 int64_t microseconds = since_system_startup * 1000000; |
| 86 base::TimeTicks timestamp = ui::EventTimeStampFromSeconds(seconds) + | 86 base::TimeTicks timestamp = ui::EventTimeStampFromSeconds(seconds) + |
| 87 base::TimeDelta::FromMicroseconds(microseconds); | 87 base::TimeDelta::FromMicroseconds(microseconds); |
| 88 ValidateEventTimeClock(×tamp); | 88 ValidateEventTimeClock(×tamp); |
| 89 return timestamp; | 89 return timestamp; |
| 90 } | 90 } |
| 91 | 91 |
| 92 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { | 92 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { |
| 93 return gfx::ToFlooredPoint(EventLocationFromNativeF(native_event)); |
| 94 } |
| 95 |
| 96 gfx::PointF EventLocationFromNativeF(const base::NativeEvent& native_event) { |
| 93 NSWindow* window = [native_event window]; | 97 NSWindow* window = [native_event window]; |
| 94 if (!window) { | 98 if (!window) { |
| 95 NOTIMPLEMENTED(); // Point will be in screen coordinates. | 99 NOTIMPLEMENTED(); // Point will be in screen coordinates. |
| 96 return gfx::Point(); | 100 return gfx::PointF(); |
| 97 } | 101 } |
| 98 NSPoint location = [native_event locationInWindow]; | 102 NSPoint location = [native_event locationInWindow]; |
| 99 NSRect content_rect = [window contentRectForFrameRect:[window frame]]; | 103 NSRect content_rect = [window contentRectForFrameRect:[window frame]]; |
| 100 return gfx::Point(location.x, NSHeight(content_rect) - location.y); | 104 return gfx::PointF(location.x, NSHeight(content_rect) - location.y); |
| 101 } | 105 } |
| 102 | 106 |
| 103 gfx::Point EventSystemLocationFromNative( | 107 gfx::Point EventSystemLocationFromNative( |
| 104 const base::NativeEvent& native_event) { | 108 const base::NativeEvent& native_event) { |
| 105 NOTIMPLEMENTED(); | 109 NOTIMPLEMENTED(); |
| 106 return gfx::Point(); | 110 return gfx::Point(); |
| 107 } | 111 } |
| 108 | 112 |
| 109 int EventButtonFromNative(const base::NativeEvent& native_event) { | 113 int EventButtonFromNative(const base::NativeEvent& native_event) { |
| 110 NOTIMPLEMENTED(); | 114 NOTIMPLEMENTED(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 uint16_t return_value; | 303 uint16_t return_value; |
| 300 [text getCharacters:&return_value]; | 304 [text getCharacters:&return_value]; |
| 301 return return_value; | 305 return return_value; |
| 302 } | 306 } |
| 303 | 307 |
| 304 bool IsCharFromNative(const base::NativeEvent& native_event) { | 308 bool IsCharFromNative(const base::NativeEvent& native_event) { |
| 305 return false; | 309 return false; |
| 306 } | 310 } |
| 307 | 311 |
| 308 } // namespace ui | 312 } // namespace ui |
| OLD | NEW |