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 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "base/mac/mac_util.h" | 10 #import "base/mac/mac_util.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 226 |
227 uint32 WindowsKeycodeFromNative(const base::NativeEvent& native_event) { | 227 uint32 WindowsKeycodeFromNative(const base::NativeEvent& native_event) { |
228 return static_cast<uint32>(KeyboardCodeFromNSEvent(native_event)); | 228 return static_cast<uint32>(KeyboardCodeFromNSEvent(native_event)); |
229 } | 229 } |
230 | 230 |
231 uint16 TextFromNative(const base::NativeEvent& native_event) { | 231 uint16 TextFromNative(const base::NativeEvent& native_event) { |
232 NSString* text = @""; | 232 NSString* text = @""; |
233 if ([native_event type] != NSFlagsChanged) | 233 if ([native_event type] != NSFlagsChanged) |
234 text = [native_event characters]; | 234 text = [native_event characters]; |
235 | 235 |
236 // These exceptions are based on web_input_event_builders_mac.mm: | 236 // These exceptions are based on WebInputEventFactoryMac.mm: |
237 uint32 windows_keycode = WindowsKeycodeFromNative(native_event); | 237 uint32 windows_keycode = WindowsKeycodeFromNative(native_event); |
238 if (windows_keycode == '\r') | 238 if (windows_keycode == '\r') |
239 text = @"\r"; | 239 text = @"\r"; |
240 if ([text isEqualToString:@"\x7F"]) | 240 if ([text isEqualToString:@"\x7F"]) |
241 text = @"\x8"; | 241 text = @"\x8"; |
242 if (windows_keycode == 9) | 242 if (windows_keycode == 9) |
243 text = @"\x9"; | 243 text = @"\x9"; |
244 | 244 |
245 uint16 return_value; | 245 uint16 return_value; |
246 [text getCharacters:&return_value]; | 246 [text getCharacters:&return_value]; |
247 return return_value; | 247 return return_value; |
248 } | 248 } |
249 | 249 |
250 uint16 UnmodifiedTextFromNative(const base::NativeEvent& native_event) { | 250 uint16 UnmodifiedTextFromNative(const base::NativeEvent& native_event) { |
251 NSString* text = @""; | 251 NSString* text = @""; |
252 if ([native_event type] != NSFlagsChanged) | 252 if ([native_event type] != NSFlagsChanged) |
253 text = [native_event charactersIgnoringModifiers]; | 253 text = [native_event charactersIgnoringModifiers]; |
254 | 254 |
255 // These exceptions are based on web_input_event_builders_mac.mm: | 255 // These exceptions are based on WebInputEventFactoryMac.mm: |
256 uint32 windows_keycode = WindowsKeycodeFromNative(native_event); | 256 uint32 windows_keycode = WindowsKeycodeFromNative(native_event); |
257 if (windows_keycode == '\r') | 257 if (windows_keycode == '\r') |
258 text = @"\r"; | 258 text = @"\r"; |
259 if ([text isEqualToString:@"\x7F"]) | 259 if ([text isEqualToString:@"\x7F"]) |
260 text = @"\x8"; | 260 text = @"\x8"; |
261 if (windows_keycode == 9) | 261 if (windows_keycode == 9) |
262 text = @"\x9"; | 262 text = @"\x9"; |
263 | 263 |
264 uint16 return_value; | 264 uint16 return_value; |
265 [text getCharacters:&return_value]; | 265 [text getCharacters:&return_value]; |
266 return return_value; | 266 return return_value; |
267 } | 267 } |
268 | 268 |
269 bool IsCharFromNative(const base::NativeEvent& native_event) { | 269 bool IsCharFromNative(const base::NativeEvent& native_event) { |
270 return false; | 270 return false; |
271 } | 271 } |
272 | 272 |
273 } // namespace ui | 273 } // namespace ui |
OLD | NEW |