Chromium Code Reviews| Index: ui/events/keycodes/platform_key_map_win.cc |
| diff --git a/ui/events/keycodes/platform_key_map_win.cc b/ui/events/keycodes/platform_key_map_win.cc |
| index 5c99275b905d71f72da67c6ca725fdc7960d8e13..31cf5b949b7f43eaedc4504a226b05be55bf33c3 100644 |
| --- a/ui/events/keycodes/platform_key_map_win.cc |
| +++ b/ui/events/keycodes/platform_key_map_win.cc |
| @@ -243,9 +243,6 @@ const struct NonPrintableKeyEntry { |
| {VKEY_ALTGR, DomKey::ALT_GRAPH}, |
| {VKEY_PROCESSKEY, DomKey::PROCESS}, |
| // VKEY_PACKET - Used to pass Unicode char, considered as printable key. |
| - |
| - // TODO(chongz): Handle Japanese keyboard layout keys 0xF0..0xF5. |
| - // https://crbug.com/612694 |
| {VKEY_ATTN, DomKey::ATTN}, |
| {VKEY_CRSEL, DomKey::CR_SEL}, |
| {VKEY_EXSEL, DomKey::EX_SEL}, |
| @@ -257,7 +254,27 @@ const struct NonPrintableKeyEntry { |
| {VKEY_OEM_CLEAR, DomKey::CLEAR}, |
| }; |
| -DomKey NonPrintableKeyboardCodeToDomKey(KeyboardCode key_code) { |
| +DomKey LangSpecificNonPrintableKeyboardCodeToDomKey(KeyboardCode key_code, |
| + HKL layout) { |
|
Wez
2016/06/10 22:55:09
nit: I'd suggest calling this LanguageSpecificOemK
chongz
2016/06/14 20:41:47
Done.
|
| + WORD langID = LOWORD(layout); |
|
Wez
2016/06/10 22:55:09
nit: langID->language_id, or just |language|
chongz
2016/06/14 20:41:47
Done.
|
| + WORD primaryLangID = PRIMARYLANGID(langID); |
|
Wez
2016/06/10 22:55:09
nit: primary_language_id or just |primary_language
chongz
2016/06/14 20:41:47
Done.
|
| + // TODO(chongz): Handle Japanese keyboard layout keys 0xF0..0xF5. |
| + // https://crbug.com/612694 |
|
Wez
2016/06/10 22:55:09
nit: I'd suggest putting this comment after the Ko
chongz
2016/06/14 20:41:47
Done.
|
| + if (primaryLangID == LANG_KOREAN) { |
| + switch (key_code) { |
| + case VKEY_HANGUL: // Same as VKEY_KANA. |
| + return DomKey::HANGUL_MODE; |
| + case VKEY_HANJA: // Same as VKEY_KANJI. |
|
Wez
2016/06/10 22:55:09
Do these comments make sense in the context of Kor
chongz
2016/06/14 20:41:47
Done.
|
| + return DomKey::HANJA_MODE; |
| + default: |
| + return DomKey::NONE; |
| + } |
| + } |
| + return DomKey::NONE; |
| +} |
| + |
| +DomKey NonPrintableKeyboardCodeToDomKey(KeyboardCode key_code, HKL layout) { |
| + // 1. Look up general key map. |
|
Wez
2016/06/10 22:55:09
nit: Suggest "Most |key_codes| have the same meani
chongz
2016/06/14 20:41:47
Done.
|
| const NonPrintableKeyEntry* result = std::lower_bound( |
| std::begin(kNonPrintableKeyMap), std::end(kNonPrintableKeyMap), key_code, |
| [](const NonPrintableKeyEntry& entry, KeyboardCode needle) { |
| @@ -265,7 +282,8 @@ DomKey NonPrintableKeyboardCodeToDomKey(KeyboardCode key_code) { |
| }); |
| if (result != std::end(kNonPrintableKeyMap) && result->key_code == key_code) |
| return result->dom_key; |
| - return DomKey::NONE; |
| + // 2. Look up language specific key map. |
| + return LangSpecificNonPrintableKeyboardCodeToDomKey(key_code, layout); |
| } |
| void CleanupKeyMapTls(void* data) { |
| @@ -299,14 +317,10 @@ PlatformKeyMap::~PlatformKeyMap() {} |
| DomKey PlatformKeyMap::DomKeyFromNativeImpl(DomCode code, |
| KeyboardCode key_code, |
| int flags) const { |
| - DomKey key = NonPrintableKeyboardCodeToDomKey(key_code); |
| + DomKey key = NonPrintableKeyboardCodeToDomKey(key_code, keyboard_layout_); |
| if (key != DomKey::NONE) |
| return key; |
| - // TODO(chongz): Handle VKEY_KANA/VKEY_HANGUL, VKEY_HANJA/VKEY_KANJI based on |
| - // layout. |
| - // https://crbug.com/612736 |
| - |
| if (KeycodeConverter::DomCodeToLocation(code) == DomKeyLocation::NUMPAD) { |
| // Derived the DOM Key value from |key_code| instead of |code|, to address |
| // Windows Numlock/Shift interaction - see crbug.com/594552. |