OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/test/chromedriver/keycode_text_conversion.h" | 5 #include "chrome/test/chromedriver/keycode_text_conversion.h" |
6 | 6 |
7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
8 | 8 |
9 #include <cctype> | 9 #include <cctype> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 if (modifiers & kControlKeyModifierMask) | 37 if (modifiers & kControlKeyModifierMask) |
38 mac_modifiers |= controlKey; | 38 mac_modifiers |= controlKey; |
39 if (modifiers & kAltKeyModifierMask) | 39 if (modifiers & kAltKeyModifierMask) |
40 mac_modifiers |= optionKey; | 40 mac_modifiers |= optionKey; |
41 if (modifiers & kMetaKeyModifierMask) | 41 if (modifiers & kMetaKeyModifierMask) |
42 mac_modifiers |= cmdKey; | 42 mac_modifiers |= cmdKey; |
43 // Convert EventRecord modifiers to format UCKeyTranslate accepts. See docs | 43 // Convert EventRecord modifiers to format UCKeyTranslate accepts. See docs |
44 // on UCKeyTranslate for more info. | 44 // on UCKeyTranslate for more info. |
45 UInt32 modifier_key_state = (mac_modifiers >> 8) & 0xFF; | 45 UInt32 modifier_key_state = (mac_modifiers >> 8) & 0xFF; |
46 | 46 |
47 base::mac::ScopedCFTypeRef<TISInputSourceRef> input_source_copy( | 47 base::ScopedCFTypeRef<TISInputSourceRef> input_source_copy( |
48 TISCopyCurrentKeyboardLayoutInputSource()); | 48 TISCopyCurrentKeyboardLayoutInputSource()); |
49 CFDataRef layout_data = static_cast<CFDataRef>(TISGetInputSourceProperty( | 49 CFDataRef layout_data = static_cast<CFDataRef>(TISGetInputSourceProperty( |
50 input_source_copy, kTISPropertyUnicodeKeyLayoutData)); | 50 input_source_copy, kTISPropertyUnicodeKeyLayoutData)); |
51 | 51 |
52 UInt32 dead_key_state = 0; | 52 UInt32 dead_key_state = 0; |
53 UniCharCount char_count = 0; | 53 UniCharCount char_count = 0; |
54 UniChar character = 0; | 54 UniChar character = 0; |
55 OSStatus status = UCKeyTranslate( | 55 OSStatus status = UCKeyTranslate( |
56 reinterpret_cast<const UCKeyboardLayout*>(CFDataGetBytePtr(layout_data)), | 56 reinterpret_cast<const UCKeyboardLayout*>(CFDataGetBytePtr(layout_data)), |
57 static_cast<UInt16>(mac_key_code), | 57 static_cast<UInt16>(mac_key_code), |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 *necessary_modifiers = kShiftKeyModifierMask; | 103 *necessary_modifiers = kShiftKeyModifierMask; |
104 found_code = true; | 104 found_code = true; |
105 } | 105 } |
106 if (found_code) { | 106 if (found_code) { |
107 *key_code = code; | 107 *key_code = code; |
108 break; | 108 break; |
109 } | 109 } |
110 } | 110 } |
111 return found_code; | 111 return found_code; |
112 } | 112 } |
OLD | NEW |