| Index: ui/events/keycodes/keyboard_code_conversion.cc
|
| diff --git a/ui/events/keycodes/keyboard_code_conversion.cc b/ui/events/keycodes/keyboard_code_conversion.cc
|
| index 6229ab361a22e4c4c214e1ec4beb49dddc3b4a5e..38432670d9ba436a542ef916bdc4c477c602d5cd 100644
|
| --- a/ui/events/keycodes/keyboard_code_conversion.cc
|
| +++ b/ui/events/keycodes/keyboard_code_conversion.cc
|
| @@ -15,130 +15,6 @@ namespace ui {
|
|
|
| namespace {
|
|
|
| -// This table maps a subset of |KeyboardCode| (VKEYs) to DomKey and character.
|
| -// Only values not otherwise handled by GetDomKeyFromKeyCode() are here.
|
| -const struct KeyboardCodeToDomKey {
|
| - KeyboardCode key_code;
|
| - DomKey::Base plain;
|
| - DomKey::Base shift;
|
| -} kKeyboardCodeToDomKey[] = {
|
| - {VKEY_BACK, DomKey::BACKSPACE},
|
| - {VKEY_TAB, DomKey::TAB},
|
| - {VKEY_RETURN, DomKey::ENTER},
|
| - {VKEY_ESCAPE, DomKey::ESCAPE},
|
| - {VKEY_SPACE, DomKey::Constant<' '>::Character},
|
| - {VKEY_MULTIPLY, DomKey::Constant<'*'>::Character},
|
| - {VKEY_ADD, DomKey::Constant<'+'>::Character},
|
| - {VKEY_SEPARATOR, DomKey::Constant<','>::Character},
|
| - {VKEY_SUBTRACT, DomKey::Constant<'-'>::Character},
|
| - {VKEY_DECIMAL, DomKey::Constant<'.'>::Character},
|
| - {VKEY_DIVIDE, DomKey::Constant<'/'>::Character},
|
| - {VKEY_OEM_1, DomKey::Constant<';'>::Character,
|
| - DomKey::Constant<':'>::Character},
|
| - {VKEY_OEM_PLUS, DomKey::Constant<'='>::Character,
|
| - DomKey::Constant<'+'>::Character},
|
| - {VKEY_OEM_COMMA, DomKey::Constant<','>::Character,
|
| - DomKey::Constant<'<'>::Character},
|
| - {VKEY_OEM_MINUS, DomKey::Constant<'-'>::Character,
|
| - DomKey::Constant<'_'>::Character},
|
| - {VKEY_OEM_PERIOD, DomKey::Constant<'.'>::Character,
|
| - DomKey::Constant<'>'>::Character},
|
| - {VKEY_OEM_2, DomKey::Constant<'/'>::Character,
|
| - DomKey::Constant<'?'>::Character},
|
| - {VKEY_OEM_3, DomKey::Constant<'`'>::Character,
|
| - DomKey::Constant<'~'>::Character},
|
| - {VKEY_OEM_4, DomKey::Constant<'['>::Character,
|
| - DomKey::Constant<'{'>::Character},
|
| - {VKEY_OEM_5, DomKey::Constant<'\\'>::Character,
|
| - DomKey::Constant<'|'>::Character},
|
| - {VKEY_OEM_6, DomKey::Constant<']'>::Character,
|
| - DomKey::Constant<'}'>::Character},
|
| - {VKEY_OEM_7, DomKey::Constant<'\''>::Character,
|
| - DomKey::Constant<'"'>::Character},
|
| - {VKEY_OEM_102, DomKey::Constant<'<'>::Character,
|
| - DomKey::Constant<'>'>::Character},
|
| - {VKEY_CLEAR, DomKey::CLEAR},
|
| - {VKEY_SHIFT, DomKey::SHIFT},
|
| - {VKEY_CONTROL, DomKey::CONTROL},
|
| - {VKEY_MENU, DomKey::ALT},
|
| - {VKEY_PAUSE, DomKey::PAUSE},
|
| - {VKEY_CAPITAL, DomKey::CAPS_LOCK},
|
| - // Windows conflates 'KanaMode' and 'HangulMode'.
|
| - {VKEY_KANA, DomKey::KANA_MODE},
|
| - {VKEY_JUNJA, DomKey::JUNJA_MODE},
|
| - {VKEY_FINAL, DomKey::FINAL_MODE},
|
| - // Windows conflates 'HanjaMode' and 'KanjiMode'.
|
| - {VKEY_HANJA, DomKey::HANJA_MODE},
|
| - {VKEY_CONVERT, DomKey::CONVERT},
|
| - {VKEY_NONCONVERT, DomKey::NON_CONVERT},
|
| - {VKEY_ACCEPT, DomKey::ACCEPT},
|
| - {VKEY_MODECHANGE, DomKey::MODE_CHANGE},
|
| - {VKEY_PRIOR, DomKey::PAGE_UP},
|
| - {VKEY_NEXT, DomKey::PAGE_DOWN},
|
| - {VKEY_END, DomKey::END},
|
| - {VKEY_HOME, DomKey::HOME},
|
| - {VKEY_LEFT, DomKey::ARROW_LEFT},
|
| - {VKEY_UP, DomKey::ARROW_UP},
|
| - {VKEY_RIGHT, DomKey::ARROW_RIGHT},
|
| - {VKEY_DOWN, DomKey::ARROW_DOWN},
|
| - {VKEY_SELECT, DomKey::SELECT},
|
| - {VKEY_PRINT, DomKey::PRINT},
|
| - {VKEY_EXECUTE, DomKey::EXECUTE},
|
| - {VKEY_SNAPSHOT, DomKey::PRINT_SCREEN},
|
| - {VKEY_INSERT, DomKey::INSERT},
|
| - {VKEY_DELETE, DomKey::DEL},
|
| - {VKEY_HELP, DomKey::HELP},
|
| - {VKEY_LWIN, DomKey::OS},
|
| - {VKEY_RWIN, DomKey::OS},
|
| - {VKEY_APPS, DomKey::MEDIA_APPS},
|
| - {VKEY_NUMLOCK, DomKey::NUM_LOCK},
|
| - {VKEY_SCROLL, DomKey::SCROLL_LOCK},
|
| - {VKEY_LSHIFT, DomKey::SHIFT},
|
| - {VKEY_RSHIFT, DomKey::SHIFT},
|
| - {VKEY_LCONTROL, DomKey::CONTROL},
|
| - {VKEY_RCONTROL, DomKey::CONTROL},
|
| - {VKEY_LMENU, DomKey::ALT},
|
| - {VKEY_RMENU, DomKey::ALT},
|
| - {VKEY_BROWSER_BACK, DomKey::BROWSER_BACK},
|
| - {VKEY_BROWSER_FORWARD, DomKey::BROWSER_FORWARD},
|
| - {VKEY_BROWSER_REFRESH, DomKey::BROWSER_REFRESH},
|
| - {VKEY_BROWSER_STOP, DomKey::BROWSER_STOP},
|
| - {VKEY_BROWSER_SEARCH, DomKey::BROWSER_SEARCH},
|
| - {VKEY_BROWSER_FAVORITES, DomKey::BROWSER_FAVORITES},
|
| - {VKEY_BROWSER_HOME, DomKey::BROWSER_HOME},
|
| - {VKEY_VOLUME_MUTE, DomKey::VOLUME_MUTE},
|
| - {VKEY_VOLUME_DOWN, DomKey::VOLUME_DOWN},
|
| - {VKEY_VOLUME_UP, DomKey::VOLUME_UP},
|
| - {VKEY_MEDIA_NEXT_TRACK, DomKey::MEDIA_TRACK_NEXT},
|
| - {VKEY_MEDIA_PREV_TRACK, DomKey::MEDIA_TRACK_PREVIOUS},
|
| - {VKEY_MEDIA_STOP, DomKey::MEDIA_STOP},
|
| - {VKEY_MEDIA_PLAY_PAUSE, DomKey::MEDIA_PLAY_PAUSE},
|
| - {VKEY_MEDIA_LAUNCH_MAIL, DomKey::LAUNCH_MAIL},
|
| - {VKEY_MEDIA_LAUNCH_MEDIA_SELECT, DomKey::LAUNCH_MEDIA_PLAYER},
|
| - {VKEY_MEDIA_LAUNCH_APP1, DomKey::LAUNCH_MY_COMPUTER},
|
| - {VKEY_MEDIA_LAUNCH_APP2, DomKey::LAUNCH_CALCULATOR},
|
| - {VKEY_OEM_8, DomKey::SUPER}, // ISO Level 5 Shift in ChromeOS
|
| - {VKEY_PROCESSKEY, DomKey::PROCESS},
|
| - {VKEY_DBE_SBCSCHAR, DomKey::HANKAKU},
|
| - {VKEY_DBE_DBCSCHAR, DomKey::ZENKAKU},
|
| - {VKEY_ATTN, DomKey::ATTN},
|
| - {VKEY_CRSEL, DomKey::CR_SEL},
|
| - {VKEY_EXSEL, DomKey::EX_SEL},
|
| - {VKEY_EREOF, DomKey::ERASE_EOF},
|
| - {VKEY_PLAY, DomKey::MEDIA_PLAY},
|
| - {VKEY_ZOOM, DomKey::ZOOM_TOGGLE},
|
| - {VKEY_OEM_CLEAR, DomKey::CLEAR},
|
| - {VKEY_ALTGR, DomKey::ALT_GRAPH},
|
| -#if defined(OS_POSIX)
|
| - {VKEY_POWER, DomKey::POWER},
|
| - {VKEY_BRIGHTNESS_DOWN, DomKey::BRIGHTNESS_DOWN},
|
| - {VKEY_BRIGHTNESS_UP, DomKey::BRIGHTNESS_UP},
|
| - {VKEY_COMPOSE, DomKey::COMPOSE},
|
| - {VKEY_OEM_103, DomKey::MEDIA_REWIND},
|
| - {VKEY_OEM_104, DomKey::MEDIA_FAST_FORWARD},
|
| -#endif
|
| -};
|
| -
|
| bool IsRightSideDomCode(DomCode code) {
|
| return (code == DomCode::SHIFT_RIGHT) || (code == DomCode::CONTROL_RIGHT) ||
|
| (code == DomCode::ALT_RIGHT) || (code == DomCode::OS_RIGHT);
|
| @@ -153,83 +29,14 @@ bool IsModifierDomCode(DomCode code) {
|
|
|
| } // anonymous namespace
|
|
|
| -base::char16 GetCharacterFromKeyCode(KeyboardCode key_code, int flags) {
|
| - DomKey key = GetDomKeyFromKeyCode(key_code, flags);
|
| - if (key.IsCharacter())
|
| - return key.ToCharacter();
|
| - return 0;
|
| -}
|
| -
|
| -DomKey GetDomKeyFromKeyCode(KeyboardCode key_code, int flags) {
|
| - const bool ctrl = (flags & EF_CONTROL_DOWN) != 0;
|
| - const bool shift = (flags & EF_SHIFT_DOWN) != 0;
|
| - const bool upper = shift ^ ((flags & EF_CAPS_LOCK_DOWN) != 0);
|
| -
|
| - // Control characters.
|
| - if (ctrl) {
|
| - // Following Windows behavior to map ctrl-a ~ ctrl-z to \x01 ~ \x1A.
|
| - if (key_code >= VKEY_A && key_code <= VKEY_Z)
|
| - return DomKey::FromCharacter(key_code - VKEY_A + 1);
|
| - // Other control characters.
|
| - if (shift) {
|
| - // The following graphics characters require the shift key to input.
|
| - switch (key_code) {
|
| - // ctrl-@ maps to \x00 (Null byte)
|
| - case VKEY_2:
|
| - return DomKey::FromCharacter(0);
|
| - // ctrl-^ maps to \x1E (Record separator, Information separator two)
|
| - case VKEY_6:
|
| - return DomKey::FromCharacter(0x1E);
|
| - // ctrl-_ maps to \x1F (Unit separator, Information separator one)
|
| - case VKEY_OEM_MINUS:
|
| - return DomKey::FromCharacter(0x1F);
|
| - // Returns UNIDENTIFIED for all other keys to avoid inputting
|
| - // unexpected chars.
|
| - default:
|
| - return DomKey::UNIDENTIFIED;
|
| - }
|
| - } else {
|
| - switch (key_code) {
|
| - // ctrl-[ maps to \x1B (Escape)
|
| - case VKEY_OEM_4:
|
| - return DomKey::ESCAPE;
|
| - // ctrl-\ maps to \x1C (File separator, Information separator four)
|
| - case VKEY_OEM_5:
|
| - return DomKey::FromCharacter(0x1C);
|
| - // ctrl-] maps to \x1D (Group separator, Information separator three)
|
| - case VKEY_OEM_6:
|
| - return DomKey::FromCharacter(0x1D);
|
| - // ctrl-Enter maps to \x0A (Line feed)
|
| - case VKEY_RETURN:
|
| - return DomKey::FromCharacter(0x0A);
|
| - // Returns UNIDENTIFIED for all other keys to avoid inputting
|
| - // unexpected chars.
|
| - default:
|
| - return DomKey::UNIDENTIFIED;
|
| - }
|
| - }
|
| - }
|
| -
|
| - // ASCII alphanumeric characters.
|
| - if (key_code >= VKEY_A && key_code <= VKEY_Z)
|
| - return DomKey::FromCharacter(key_code - VKEY_A + (upper ? 'A' : 'a'));
|
| - if (key_code >= VKEY_0 && key_code <= VKEY_9) {
|
| - return DomKey::FromCharacter(shift ? ")!@#$%^&*("[key_code - VKEY_0]
|
| - : '0' + key_code - VKEY_0);
|
| - }
|
| - if (key_code >= VKEY_NUMPAD0 && key_code <= VKEY_NUMPAD9)
|
| - return DomKey::FromCharacter(key_code - VKEY_NUMPAD0 + '0');
|
| -
|
| - // Function keys.
|
| - if (key_code >= VKEY_F1 && key_code <= VKEY_F24)
|
| - return DomKey::FromCharacter(key_code - VKEY_F1 + DomKey::F1);
|
| -
|
| - // Other keys.
|
| - for (const auto& k : kKeyboardCodeToDomKey) {
|
| - if (k.key_code == key_code)
|
| - return (shift && k.shift) ? k.shift : k.plain;
|
| +base::char16 DomCodeToUsLayoutCharacter(DomCode dom_code, int flags) {
|
| + DomKey dom_key;
|
| + KeyboardCode key_code;
|
| + if (DomCodeToUsLayoutDomKey(dom_code, flags, &dom_key, &key_code) &&
|
| + dom_key.IsCharacter()) {
|
| + return dom_key.ToCharacter();
|
| }
|
| - return DomKey::UNIDENTIFIED;
|
| + return 0;
|
| }
|
|
|
| bool DomCodeToUsLayoutDomKey(DomCode dom_code,
|
|
|