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 #ifndef UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ | 5 #ifndef UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ |
6 #define UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ | 6 #define UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "ui/events/events_base_export.h" | 10 #include "ui/events/events_base_export.h" |
11 #include "ui/events/keycodes/keyboard_codes.h" | 11 #include "ui/events/keycodes/keyboard_codes.h" |
12 | 12 |
13 namespace ui { | 13 namespace ui { |
14 | 14 |
15 enum class DomCode; | 15 enum class DomCode; |
16 enum class DomKey; | 16 enum class DomKey; |
17 | 17 |
18 // Helper functions to get the meaning of a Windows key code in a | 18 // Helper functions to get the meaning of a DOM |code| in a |
19 // platform independent way. It supports control characters as well. | 19 // platform independent way. It supports control characters as well. |
20 // It assumes a US keyboard layout is used, so it may only be used when there | 20 // It assumes a US keyboard layout is used, so it may only be used when there |
21 // is no native event or no better way to get the character. | 21 // is no native event or no better way to get the character. |
22 // | 22 // |
23 // For example, if a virtual keyboard implementation can only generate key | 23 // For example, if a virtual keyboard implementation can only generate key |
24 // events with key_code and flags information, then there is no way for us to | 24 // events with key_code and flags information, then there is no way for us to |
25 // determine the actual character that should be generate by the key. Because | 25 // determine the actual character that should be generate by the key. Because |
26 // a key_code only represents a physical key on the keyboard, it has nothing | 26 // a key_code only represents a physical key on the keyboard, it has nothing |
27 // to do with the actual character printed on that key. In such case, the only | 27 // to do with the actual character printed on that key. In such case, the only |
28 // thing we can do is to assume that we are using a US keyboard and get the | 28 // thing we can do is to assume that we are using a US keyboard and get the |
29 // character according to US keyboard layout definition. Preferably, such | 29 // character according to US keyboard layout definition. Preferably, such |
30 // events should be created using a full KeyEvent constructor, explicitly | 30 // events should be created using a full KeyEvent constructor, explicitly |
31 // specifying the character and DOM 3 values as well as the legacy VKEY. | 31 // specifying the character and DOM 3 values as well as the legacy VKEY. |
32 // | 32 |
33 // TODO(kpschoedel): replace remaining uses of the ...FromKeyCode() functions | 33 // TODO(kpschoedel): replace remaining uses of the ...FromKeyCode() functions |
34 // and remove them, to avoid future creation of underspecified key events. | 34 // and remove them, to avoid future creation of underspecified key events. |
35 // crbug.com/444045 | 35 // crbug.com/444045 |
36 EVENTS_BASE_EXPORT base::char16 GetCharacterFromKeyCode(KeyboardCode key_code, | 36 EVENTS_BASE_EXPORT base::char16 GetCharacterFromKeyCode(KeyboardCode key_code, |
37 int flags); | 37 int flags); |
38 EVENTS_BASE_EXPORT bool GetMeaningFromKeyCode(KeyboardCode key_code, | 38 EVENTS_BASE_EXPORT bool GetMeaningFromKeyCode(KeyboardCode key_code, |
39 int flags, | 39 int flags, |
40 DomKey* dom_key, | 40 DomKey* dom_key, |
41 base::char16* character); | 41 base::char16* character); |
42 | 42 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 // Determine the located VKEY corresponding to a non-located VKEY. | 86 // Determine the located VKEY corresponding to a non-located VKEY. |
87 EVENTS_BASE_EXPORT KeyboardCode | 87 EVENTS_BASE_EXPORT KeyboardCode |
88 NonLocatedToLocatedKeyboardCode(KeyboardCode key_code, DomCode dom_code); | 88 NonLocatedToLocatedKeyboardCode(KeyboardCode key_code, DomCode dom_code); |
89 | 89 |
90 // Returns a DOM Level 3 |code| from a Windows-based VKEY value. | 90 // Returns a DOM Level 3 |code| from a Windows-based VKEY value. |
91 // This assumes a US layout and should only be used when |code| cannot be | 91 // This assumes a US layout and should only be used when |code| cannot be |
92 // determined from a physical scan code, for example when a key event was | 92 // determined from a physical scan code, for example when a key event was |
93 // generated synthetically by JavaScript with only a VKEY value supplied. | 93 // generated synthetically by JavaScript with only a VKEY value supplied. |
94 EVENTS_BASE_EXPORT DomCode UsLayoutKeyboardCodeToDomCode(KeyboardCode key_code); | 94 EVENTS_BASE_EXPORT DomCode UsLayoutKeyboardCodeToDomCode(KeyboardCode key_code); |
95 | |
96 } // namespace ui | 95 } // namespace ui |
97 | 96 |
98 #endif // UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ | 97 #endif // UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ |
OLD | NEW |