Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: ui/events/keycodes/dom_us_layout_data.h

Issue 1284433002: Revise ui::DomKey to unify character and non-character codes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IsDead Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 #ifndef UI_EVENTS_KEYCODES_DOM_US_LAYOUT_DATA_H_ 5 #ifndef UI_EVENTS_KEYCODES_DOM_US_LAYOUT_DATA_H_
6 #define UI_EVENTS_KEYCODES_DOM_US_LAYOUT_DATA_H_ 6 #define UI_EVENTS_KEYCODES_DOM_US_LAYOUT_DATA_H_
7 7
8 namespace ui { 8 namespace ui {
9 9
10 // This table maps a DomCode to a printable character, assuming US layout. 10 // This table maps a DomCode to a printable character, assuming US layout.
11 // It is used by DomCodeToUsLayoutMeaning(), which provides a fallback 11 // It is used by DomCodeToUsLayoutDomKey(), which provides a fallback
12 // interpretation when there is no other way to map a physical key. 12 // interpretation when there is no other way to map a physical key.
13 const struct PrintableCodeEntry { 13 const struct PrintableCodeEntry {
14 DomCode dom_code; 14 DomCode dom_code;
15 base::char16 character[2]; // normal, shift 15 base::char16 character[2]; // normal, shift
16 } kPrintableCodeMap[] = { 16 } kPrintableCodeMap[] = {
17 {DomCode::KEY_A, {'a', 'A'}}, 17 {DomCode::KEY_A, {'a', 'A'}},
18 {DomCode::KEY_B, {'b', 'B'}}, 18 {DomCode::KEY_B, {'b', 'B'}},
19 {DomCode::KEY_C, {'c', 'C'}}, 19 {DomCode::KEY_C, {'c', 'C'}},
20 {DomCode::KEY_D, {'d', 'D'}}, 20 {DomCode::KEY_D, {'d', 'D'}},
21 {DomCode::KEY_E, {'e', 'E'}}, 21 {DomCode::KEY_E, {'e', 'E'}},
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 {DomCode::NUMPAD0, {'0', '0'}}, 81 {DomCode::NUMPAD0, {'0', '0'}},
82 {DomCode::NUMPAD_DECIMAL, {'.', '.'}}, 82 {DomCode::NUMPAD_DECIMAL, {'.', '.'}},
83 {DomCode::NUMPAD_EQUAL, {'=', '='}}, 83 {DomCode::NUMPAD_EQUAL, {'=', '='}},
84 {DomCode::NUMPAD_COMMA, {',', ','}}, 84 {DomCode::NUMPAD_COMMA, {',', ','}},
85 {DomCode::NUMPAD_PAREN_LEFT, {'(', '('}}, 85 {DomCode::NUMPAD_PAREN_LEFT, {'(', '('}},
86 {DomCode::NUMPAD_PAREN_RIGHT, {')', ')'}}, 86 {DomCode::NUMPAD_PAREN_RIGHT, {')', ')'}},
87 {DomCode::NUMPAD_SIGN_CHANGE, {0x00B1, 0x00B1}}, 87 {DomCode::NUMPAD_SIGN_CHANGE, {0x00B1, 0x00B1}},
88 }; 88 };
89 89
90 // This table maps a DomCode to a DomKey, assuming US keyboard layout. 90 // This table maps a DomCode to a DomKey, assuming US keyboard layout.
91 // It is used by DomCodeToUsLayoutMeaning(), which provides a fallback 91 // It is used by DomCodeToUsLayoutDomKey(), which provides a fallback
92 // interpretation when there is no other way to map a physical key. 92 // interpretation when there is no other way to map a physical key.
93 const struct NonPrintableCodeEntry { 93 const struct NonPrintableCodeEntry {
94 DomCode dom_code; 94 DomCode dom_code;
95 DomKey dom_key; 95 DomKey::Base dom_key;
96 base::char16 character;
97 } kNonPrintableCodeMap[] = { 96 } kNonPrintableCodeMap[] = {
98 {DomCode::ABORT, DomKey::CANCEL}, 97 {DomCode::ABORT, DomKey::CANCEL},
99 {DomCode::AGAIN, DomKey::AGAIN}, 98 {DomCode::AGAIN, DomKey::AGAIN},
100 {DomCode::ALT_LEFT, DomKey::ALT}, 99 {DomCode::ALT_LEFT, DomKey::ALT},
101 {DomCode::ALT_RIGHT, DomKey::ALT}, 100 {DomCode::ALT_RIGHT, DomKey::ALT},
102 {DomCode::ARROW_DOWN, DomKey::ARROW_DOWN}, 101 {DomCode::ARROW_DOWN, DomKey::ARROW_DOWN},
103 {DomCode::ARROW_LEFT, DomKey::ARROW_LEFT}, 102 {DomCode::ARROW_LEFT, DomKey::ARROW_LEFT},
104 {DomCode::ARROW_RIGHT, DomKey::ARROW_RIGHT}, 103 {DomCode::ARROW_RIGHT, DomKey::ARROW_RIGHT},
105 {DomCode::ARROW_UP, DomKey::ARROW_UP}, 104 {DomCode::ARROW_UP, DomKey::ARROW_UP},
106 {DomCode::BACKSPACE, DomKey::BACKSPACE, 0x0008}, 105 {DomCode::BACKSPACE, DomKey::BACKSPACE},
107 {DomCode::BRIGHTNESS_DOWN, DomKey::BRIGHTNESS_DOWN}, 106 {DomCode::BRIGHTNESS_DOWN, DomKey::BRIGHTNESS_DOWN},
108 {DomCode::BRIGHTNESS_UP, DomKey::BRIGHTNESS_UP}, 107 {DomCode::BRIGHTNESS_UP, DomKey::BRIGHTNESS_UP},
109 // {DomCode::BRIGHTNESS_AUTO, DomKey::_} 108 // {DomCode::BRIGHTNESS_AUTO, DomKey::_}
110 // {DomCode::BRIGHTNESS_MAXIMUM, DomKey::_} 109 // {DomCode::BRIGHTNESS_MAXIMUM, DomKey::_}
111 // {DomCode::BRIGHTNESS_MINIMIUM, DomKey::_} 110 // {DomCode::BRIGHTNESS_MINIMIUM, DomKey::_}
112 // {DomCode::BRIGHTNESS_TOGGLE, DomKey::_} 111 // {DomCode::BRIGHTNESS_TOGGLE, DomKey::_}
113 {DomCode::BROWSER_BACK, DomKey::BROWSER_BACK}, 112 {DomCode::BROWSER_BACK, DomKey::BROWSER_BACK},
114 {DomCode::BROWSER_FAVORITES, DomKey::BROWSER_FAVORITES}, 113 {DomCode::BROWSER_FAVORITES, DomKey::BROWSER_FAVORITES},
115 {DomCode::BROWSER_FORWARD, DomKey::BROWSER_FORWARD}, 114 {DomCode::BROWSER_FORWARD, DomKey::BROWSER_FORWARD},
116 {DomCode::BROWSER_HOME, DomKey::BROWSER_HOME}, 115 {DomCode::BROWSER_HOME, DomKey::BROWSER_HOME},
117 {DomCode::BROWSER_REFRESH, DomKey::BROWSER_REFRESH}, 116 {DomCode::BROWSER_REFRESH, DomKey::BROWSER_REFRESH},
118 {DomCode::BROWSER_SEARCH, DomKey::BROWSER_SEARCH}, 117 {DomCode::BROWSER_SEARCH, DomKey::BROWSER_SEARCH},
119 {DomCode::BROWSER_STOP, DomKey::BROWSER_STOP}, 118 {DomCode::BROWSER_STOP, DomKey::BROWSER_STOP},
120 {DomCode::CAPS_LOCK, DomKey::CAPS_LOCK}, 119 {DomCode::CAPS_LOCK, DomKey::CAPS_LOCK},
121 {DomCode::CONTEXT_MENU, DomKey::CONTEXT_MENU}, 120 {DomCode::CONTEXT_MENU, DomKey::CONTEXT_MENU},
122 {DomCode::CONTROL_LEFT, DomKey::CONTROL}, 121 {DomCode::CONTROL_LEFT, DomKey::CONTROL},
123 {DomCode::CONTROL_RIGHT, DomKey::CONTROL}, 122 {DomCode::CONTROL_RIGHT, DomKey::CONTROL},
124 {DomCode::CONVERT, DomKey::CONVERT}, 123 {DomCode::CONVERT, DomKey::CONVERT},
125 {DomCode::COPY, DomKey::COPY}, 124 {DomCode::COPY, DomKey::COPY},
126 {DomCode::CUT, DomKey::CUT}, 125 {DomCode::CUT, DomKey::CUT},
127 {DomCode::DEL, DomKey::DEL, 0x007F}, 126 {DomCode::DEL, DomKey::DEL},
128 {DomCode::EJECT, DomKey::EJECT}, 127 {DomCode::EJECT, DomKey::EJECT},
129 {DomCode::END, DomKey::END}, 128 {DomCode::END, DomKey::END},
130 {DomCode::ENTER, DomKey::ENTER, 0x000D}, 129 {DomCode::ENTER, DomKey::ENTER},
131 {DomCode::ESCAPE, DomKey::ESCAPE, 0x001B}, 130 {DomCode::ESCAPE, DomKey::ESCAPE},
132 {DomCode::F1, DomKey::F1}, 131 {DomCode::F1, DomKey::F1},
133 {DomCode::F2, DomKey::F2}, 132 {DomCode::F2, DomKey::F2},
134 {DomCode::F3, DomKey::F3}, 133 {DomCode::F3, DomKey::F3},
135 {DomCode::F4, DomKey::F4}, 134 {DomCode::F4, DomKey::F4},
136 {DomCode::F5, DomKey::F5}, 135 {DomCode::F5, DomKey::F5},
137 {DomCode::F6, DomKey::F6}, 136 {DomCode::F6, DomKey::F6},
138 {DomCode::F7, DomKey::F7}, 137 {DomCode::F7, DomKey::F7},
139 {DomCode::F8, DomKey::F8}, 138 {DomCode::F8, DomKey::F8},
140 {DomCode::F9, DomKey::F9}, 139 {DomCode::F9, DomKey::F9},
141 {DomCode::F10, DomKey::F10}, 140 {DomCode::F10, DomKey::F10},
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 {DomCode::MAIL_REPLY, DomKey::MAIL_REPLY}, 178 {DomCode::MAIL_REPLY, DomKey::MAIL_REPLY},
180 {DomCode::MAIL_SEND, DomKey::MAIL_SEND}, 179 {DomCode::MAIL_SEND, DomKey::MAIL_SEND},
181 {DomCode::MEDIA_PLAY_PAUSE, DomKey::MEDIA_PLAY_PAUSE}, 180 {DomCode::MEDIA_PLAY_PAUSE, DomKey::MEDIA_PLAY_PAUSE},
182 {DomCode::MEDIA_SELECT, DomKey::MEDIA_SELECT}, 181 {DomCode::MEDIA_SELECT, DomKey::MEDIA_SELECT},
183 {DomCode::MEDIA_STOP, DomKey::MEDIA_STOP}, 182 {DomCode::MEDIA_STOP, DomKey::MEDIA_STOP},
184 {DomCode::MEDIA_TRACK_NEXT, DomKey::MEDIA_TRACK_NEXT}, 183 {DomCode::MEDIA_TRACK_NEXT, DomKey::MEDIA_TRACK_NEXT},
185 {DomCode::MEDIA_TRACK_PREVIOUS, DomKey::MEDIA_TRACK_PREVIOUS}, 184 {DomCode::MEDIA_TRACK_PREVIOUS, DomKey::MEDIA_TRACK_PREVIOUS},
186 // {DomCode::MENU, DomKey::_} 185 // {DomCode::MENU, DomKey::_}
187 {DomCode::NON_CONVERT, DomKey::NON_CONVERT}, 186 {DomCode::NON_CONVERT, DomKey::NON_CONVERT},
188 {DomCode::NUM_LOCK, DomKey::NUM_LOCK}, 187 {DomCode::NUM_LOCK, DomKey::NUM_LOCK},
189 {DomCode::NUMPAD_BACKSPACE, DomKey::BACKSPACE, 0x0008}, 188 {DomCode::NUMPAD_BACKSPACE, DomKey::BACKSPACE},
190 {DomCode::NUMPAD_CLEAR, DomKey::CLEAR}, 189 {DomCode::NUMPAD_CLEAR, DomKey::CLEAR},
191 {DomCode::NUMPAD_ENTER, DomKey::ENTER, 0x000D}, 190 {DomCode::NUMPAD_ENTER, DomKey::ENTER},
192 // {DomCode::NUMPAD_CLEAR_ENTRY, DomKey::_} 191 // {DomCode::NUMPAD_CLEAR_ENTRY, DomKey::_}
193 // {DomCode::NUMPAD_MEMORY_ADD, DomKey::_} 192 // {DomCode::NUMPAD_MEMORY_ADD, DomKey::_}
194 // {DomCode::NUMPAD_MEMORY_CLEAR, DomKey::_} 193 // {DomCode::NUMPAD_MEMORY_CLEAR, DomKey::_}
195 // {DomCode::NUMPAD_MEMORY_RECALL, DomKey::_} 194 // {DomCode::NUMPAD_MEMORY_RECALL, DomKey::_}
196 // {DomCode::NUMPAD_MEMORY_STORE, DomKey::_} 195 // {DomCode::NUMPAD_MEMORY_STORE, DomKey::_}
197 // {DomCode::NUMPAD_MEMORY_SUBTRACT, DomKey::_} 196 // {DomCode::NUMPAD_MEMORY_SUBTRACT, DomKey::_}
198 {DomCode::OPEN, DomKey::OPEN}, 197 {DomCode::OPEN, DomKey::OPEN},
199 {DomCode::OS_LEFT, DomKey::OS}, 198 {DomCode::OS_LEFT, DomKey::OS},
200 {DomCode::OS_RIGHT, DomKey::OS}, 199 {DomCode::OS_RIGHT, DomKey::OS},
201 {DomCode::PAGE_DOWN, DomKey::PAGE_DOWN}, 200 {DomCode::PAGE_DOWN, DomKey::PAGE_DOWN},
202 {DomCode::PAGE_UP, DomKey::PAGE_UP}, 201 {DomCode::PAGE_UP, DomKey::PAGE_UP},
203 {DomCode::PASTE, DomKey::PASTE}, 202 {DomCode::PASTE, DomKey::PASTE},
204 {DomCode::PAUSE, DomKey::PAUSE}, 203 {DomCode::PAUSE, DomKey::PAUSE},
205 {DomCode::POWER, DomKey::POWER}, 204 {DomCode::POWER, DomKey::POWER},
206 {DomCode::PRINT_SCREEN, DomKey::PRINT_SCREEN}, 205 {DomCode::PRINT_SCREEN, DomKey::PRINT_SCREEN},
207 {DomCode::PROPS, DomKey::PROPS}, 206 {DomCode::PROPS, DomKey::PROPS},
208 {DomCode::SCROLL_LOCK, DomKey::SCROLL_LOCK}, 207 {DomCode::SCROLL_LOCK, DomKey::SCROLL_LOCK},
209 {DomCode::SELECT, DomKey::SELECT}, 208 {DomCode::SELECT, DomKey::SELECT},
210 // {DomCode::SELECT_TASK, DomKey::_} 209 // {DomCode::SELECT_TASK, DomKey::_}
211 {DomCode::SHIFT_LEFT, DomKey::SHIFT}, 210 {DomCode::SHIFT_LEFT, DomKey::SHIFT},
212 {DomCode::SHIFT_RIGHT, DomKey::SHIFT}, 211 {DomCode::SHIFT_RIGHT, DomKey::SHIFT},
213 {DomCode::SUPER, DomKey::SUPER}, 212 {DomCode::SUPER, DomKey::SUPER},
214 {DomCode::TAB, DomKey::TAB, 0x0009}, 213 {DomCode::TAB, DomKey::TAB},
215 {DomCode::UNDO, DomKey::UNDO}, 214 {DomCode::UNDO, DomKey::UNDO},
216 // {DomCode::VOICE_COMMAND, DomKey::_} 215 // {DomCode::VOICE_COMMAND, DomKey::_}
217 {DomCode::VOLUME_DOWN, DomKey::VOLUME_DOWN}, 216 {DomCode::VOLUME_DOWN, DomKey::VOLUME_DOWN},
218 {DomCode::VOLUME_MUTE, DomKey::VOLUME_MUTE}, 217 {DomCode::VOLUME_MUTE, DomKey::VOLUME_MUTE},
219 {DomCode::VOLUME_UP, DomKey::VOLUME_UP}, 218 {DomCode::VOLUME_UP, DomKey::VOLUME_UP},
220 {DomCode::WAKE_UP, DomKey::WAKE_UP}, 219 {DomCode::WAKE_UP, DomKey::WAKE_UP},
221 {DomCode::ZOOM_TOGGLE, DomKey::ZOOM_TOGGLE}, 220 {DomCode::ZOOM_TOGGLE, DomKey::ZOOM_TOGGLE},
222 }; 221 };
223 222
224 // This table maps a DomKey to a non-located KeyboardCode. 223 // This table maps a DomKey to a non-located KeyboardCode.
225 const struct DomKeyToKeyboardCodeEntry { 224 const struct DomKeyToKeyboardCodeEntry {
226 DomKey dom_key; 225 DomKey::Base dom_key;
227 KeyboardCode key_code; 226 KeyboardCode key_code;
228 } kDomKeyToKeyboardCodeMap[] = { 227 } kDomKeyToKeyboardCodeMap[] = {
229 // No value. 228 // No value.
230 {DomKey::NONE, VKEY_UNKNOWN}, 229 {DomKey::NONE, VKEY_UNKNOWN},
231 // Special Key Values 230 // Special Key Values
232 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-special 231 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-special
233 {DomKey::UNIDENTIFIED, VKEY_UNKNOWN}, 232 {DomKey::UNIDENTIFIED, VKEY_UNKNOWN},
234 // Modifier Keys 233 // Modifier Keys
235 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-modifier 234 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-modifier
236 {DomKey::ALT, VKEY_MENU}, 235 {DomKey::ALT, VKEY_MENU},
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 // VKEY_MODECHANGE 621 // VKEY_MODECHANGE
623 // VKEY_NONAME 622 // VKEY_NONAME
624 // VKEY_PA1 623 // VKEY_PA1
625 // VKEY_PACKET 624 // VKEY_PACKET
626 // VKEY_PROCESSKEY 625 // VKEY_PROCESSKEY
627 }; 626 };
628 627
629 } // namespace ui 628 } // namespace ui
630 629
631 #endif // UI_EVENTS_KEYCODES_DOM_US_LAYOUT_DATA_H_ 630 #endif // UI_EVENTS_KEYCODES_DOM_US_LAYOUT_DATA_H_
OLDNEW
« no previous file with comments | « ui/events/keycodes/dom/keycode_converter_unittest.cc ('k') | ui/events/keycodes/keyboard_code_conversion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698