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

Side by Side Diff: ui/events/keycodes/dom4/keycode_converter.h

Issue 1136503003: Consolidate ui/events/keycodes/dom[34]/ into .../dom/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 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
« no previous file with comments | « ui/events/keycodes/dom4/DEPS ('k') | ui/events/keycodes/dom4/keycode_converter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_
6 #define UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_
7
8 #include <stdint.h>
9 #include "base/basictypes.h"
10
11 // For reference, the W3C UI Event spec is located at:
12 // http://www.w3.org/TR/uievents/
13
14 namespace ui {
15
16 enum class DomCode;
17 enum class DomKey;
18
19 enum class DomKeyLocation { STANDARD, LEFT, RIGHT, NUMPAD };
20
21 // This structure is used to define the keycode mapping table.
22 // It is defined here because the unittests need access to it.
23 typedef struct {
24 // USB keycode:
25 // Upper 16-bits: USB Usage Page.
26 // Lower 16-bits: USB Usage Id: Assigned ID within this usage page.
27 uint32_t usb_keycode;
28
29 // Contains one of the following:
30 // On Linux: XKB scancode
31 // On Windows: Windows OEM scancode
32 // On Mac: Mac keycode
33 int native_keycode;
34
35 // The UIEvents (aka: DOM4Events) |code| value as defined in:
36 // http://www.w3.org/TR/DOM-Level-3-Events-code/
37 const char* code;
38 } KeycodeMapEntry;
39
40 // A class to convert between the current platform's native keycode (scancode)
41 // and platform-neutral |code| values (as defined in the W3C UI Events
42 // spec (http://www.w3.org/TR/uievents/).
43 class KeycodeConverter {
44 public:
45 // Return the value that identifies an invalid native keycode.
46 static int InvalidNativeKeycode();
47
48 // Convert a native (Mac/Win/Linux) keycode into the |code| string.
49 // The returned pointer references a static global string.
50 static const char* NativeKeycodeToCode(int native_keycode);
51
52 // Convert a native (Mac/Win/Linux) keycode into a DomCode.
53 static DomCode NativeKeycodeToDomCode(int native_keycode);
54
55 // Convert a UI Events |code| string value into a native keycode.
56 static int CodeToNativeKeycode(const char* code);
57
58 // Convert a DomCode into a native keycode.
59 static int DomCodeToNativeKeycode(DomCode code);
60
61 // Convert a UI Events |code| string value into a DomCode.
62 static DomCode CodeStringToDomCode(const char* code);
63
64 // Convert a DomCode into a UI Events |code| string value.
65 static const char* DomCodeToCodeString(DomCode dom_code);
66
67 // Return the DomKeyLocation of a DomCode. The DomKeyLocation distinguishes
68 // keys with the same meaning, and therefore the same DomKey or KeyboardCode
69 // (VKEY), and corresponds to the DOM UI Events |KeyboardEvent.location|.
70 static DomKeyLocation DomCodeToLocation(DomCode dom_code);
71
72 // Convert a UI Events |key| string value into a DomKey.
73 static DomKey KeyStringToDomKey(const char* key);
74
75 // Convert a DomKey into a UI Events |key| string value.
76 static const char* DomKeyToKeyString(DomKey dom_key);
77
78 // The following methods relate to USB keycodes.
79 // Note that USB keycodes are not part of any web standard.
80 // Please don't use USB keycodes in new code.
81
82 // Return the value that identifies an invalid USB keycode.
83 static uint32_t InvalidUsbKeycode();
84
85 // Convert a USB keycode into an equivalent platform native keycode.
86 static int UsbKeycodeToNativeKeycode(uint32_t usb_keycode);
87
88 // Convert a platform native keycode into an equivalent USB keycode.
89 static uint32_t NativeKeycodeToUsbKeycode(int native_keycode);
90
91 // Convert a USB keycode into the string with the DOM3 |code| value.
92 // The returned pointer references a static global string.
93 static const char* UsbKeycodeToCode(uint32_t usb_keycode);
94
95 // Convert a USB keycode into a DomCode.
96 static DomCode UsbKeycodeToDomCode(uint32_t usb_keycode);
97
98 // Convert a DOM3 Event |code| string into a USB keycode value.
99 static uint32_t CodeToUsbKeycode(const char* code);
100
101 // Static methods to support testing.
102 static size_t NumKeycodeMapEntriesForTest();
103 static const KeycodeMapEntry* GetKeycodeMapForTest();
104 static const char* DomKeyStringForTest(size_t index);
105
106 private:
107 DISALLOW_COPY_AND_ASSIGN(KeycodeConverter);
108 };
109
110 } // namespace ui
111
112 #endif // UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_
OLDNEW
« no previous file with comments | « ui/events/keycodes/dom4/DEPS ('k') | ui/events/keycodes/dom4/keycode_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698