| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webdriver/keycode_text_conversion.h" | 5 #include "chrome/test/webdriver/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 23 matching lines...) Expand all Loading... |
| 34 if (modifiers & automation::kControlKeyMask) | 34 if (modifiers & automation::kControlKeyMask) |
| 35 mac_modifiers |= controlKey; | 35 mac_modifiers |= controlKey; |
| 36 if (modifiers & automation::kAltKeyMask) | 36 if (modifiers & automation::kAltKeyMask) |
| 37 mac_modifiers |= optionKey; | 37 mac_modifiers |= optionKey; |
| 38 if (modifiers & automation::kMetaKeyMask) | 38 if (modifiers & automation::kMetaKeyMask) |
| 39 mac_modifiers |= cmdKey; | 39 mac_modifiers |= cmdKey; |
| 40 // Convert EventRecord modifiers to format UCKeyTranslate accepts. See docs | 40 // Convert EventRecord modifiers to format UCKeyTranslate accepts. See docs |
| 41 // on UCKeyTranslate for more info. | 41 // on UCKeyTranslate for more info. |
| 42 UInt32 modifier_key_state = (mac_modifiers >> 8) & 0xFF; | 42 UInt32 modifier_key_state = (mac_modifiers >> 8) & 0xFF; |
| 43 | 43 |
| 44 base::mac::ScopedCFTypeRef<TISInputSourceRef> input_source_copy( | 44 base::ScopedCFTypeRef<TISInputSourceRef> input_source_copy( |
| 45 TISCopyCurrentKeyboardLayoutInputSource()); | 45 TISCopyCurrentKeyboardLayoutInputSource()); |
| 46 CFDataRef layout_data = static_cast<CFDataRef>(TISGetInputSourceProperty( | 46 CFDataRef layout_data = static_cast<CFDataRef>(TISGetInputSourceProperty( |
| 47 input_source_copy, kTISPropertyUnicodeKeyLayoutData)); | 47 input_source_copy, kTISPropertyUnicodeKeyLayoutData)); |
| 48 | 48 |
| 49 UInt32 dead_key_state = 0; | 49 UInt32 dead_key_state = 0; |
| 50 UniCharCount char_count = 0; | 50 UniCharCount char_count = 0; |
| 51 UniChar character = 0; | 51 UniChar character = 0; |
| 52 OSStatus status = UCKeyTranslate( | 52 OSStatus status = UCKeyTranslate( |
| 53 reinterpret_cast<const UCKeyboardLayout*>(CFDataGetBytePtr(layout_data)), | 53 reinterpret_cast<const UCKeyboardLayout*>(CFDataGetBytePtr(layout_data)), |
| 54 static_cast<UInt16>(mac_key_code), | 54 static_cast<UInt16>(mac_key_code), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 if (found_code) { | 94 if (found_code) { |
| 95 *key_code = code; | 95 *key_code = code; |
| 96 break; | 96 break; |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 return found_code; | 99 return found_code; |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace webdriver | 102 } // namespace webdriver |
| OLD | NEW |