| 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 756fabfca5dc72ec6627c38fa04467150b656c83..593e386936dd4167f21ca08105d0024186715185 100644
|
| --- a/ui/events/keycodes/platform_key_map_win.cc
|
| +++ b/ui/events/keycodes/platform_key_map_win.cc
|
| @@ -183,9 +183,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},
|
| @@ -197,7 +194,30 @@ const struct NonPrintableKeyEntry {
|
| {VKEY_OEM_CLEAR, DomKey::CLEAR},
|
| };
|
|
|
| -DomKey NonPrintableKeyboardCodeToDomKey(KeyboardCode key_code) {
|
| +// Disambiguates the meaning of certain non-printable keys which have different
|
| +// meanings under different languages, but use the same VKEY code.
|
| +DomKey LanguageSpecificOemKeyboardCodeToDomKey(KeyboardCode key_code,
|
| + HKL layout) {
|
| + WORD language = LOWORD(layout);
|
| + WORD primary_language = PRIMARYLANGID(language);
|
| + if (primary_language == LANG_KOREAN) {
|
| + switch (key_code) {
|
| + case VKEY_HANGUL:
|
| + return DomKey::HANGUL_MODE;
|
| + case VKEY_HANJA:
|
| + return DomKey::HANJA_MODE;
|
| + default:
|
| + return DomKey::NONE;
|
| + }
|
| + }
|
| + // TODO(chongz): Handle Japanese keyboard layout keys 0xF0..0xF5, VKEY_KANA,
|
| + // VKEY_KANJI.
|
| + // https://crbug.com/612694
|
| + return DomKey::NONE;
|
| +}
|
| +
|
| +DomKey NonPrintableKeyboardCodeToDomKey(KeyboardCode key_code, HKL layout) {
|
| + // 1. Most |key_codes| have the same meaning regardless of |layout|.
|
| const NonPrintableKeyEntry* result = std::lower_bound(
|
| std::begin(kNonPrintableKeyMap), std::end(kNonPrintableKeyMap), key_code,
|
| [](const NonPrintableKeyEntry& entry, KeyboardCode needle) {
|
| @@ -205,7 +225,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 a |layout|-specific meaning for |key_code|.
|
| + return LanguageSpecificOemKeyboardCodeToDomKey(key_code, layout);
|
| }
|
|
|
| void CleanupKeyMapTls(void* data) {
|
| @@ -238,14 +259,10 @@ PlatformKeyMap::~PlatformKeyMap() {}
|
|
|
| DomKey PlatformKeyMap::DomKeyFromKeyboardCodeImpl(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
|
| -
|
| const int flags_to_try[] = {
|
| // Trying to match Firefox's behavior and UIEvents DomKey guidelines.
|
| // If the combination doesn't produce a printable character, the key value
|
|
|