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

Side by Side Diff: ui/events/keycodes/dom/keycode_converter.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
« no previous file with comments | « ui/events/keycodes/dom/dom_key_data.inc ('k') | ui/events/keycodes/dom/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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_DOM4_KEYCODE_CONVERTER_H_ 5 #ifndef UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_
6 #define UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_ 6 #define UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string>
10
9 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "ui/events/keycodes/dom/dom_key.h"
10 13
11 // For reference, the W3C UI Event spec is located at: 14 // For reference, the W3C UI Event spec is located at:
12 // http://www.w3.org/TR/uievents/ 15 // http://www.w3.org/TR/uievents/
13 16
14 namespace ui { 17 namespace ui {
15 18
16 enum class DomCode; 19 enum class DomCode;
17 enum class DomKey;
18 20
19 enum class DomKeyLocation { STANDARD, LEFT, RIGHT, NUMPAD }; 21 enum class DomKeyLocation { STANDARD, LEFT, RIGHT, NUMPAD };
20 22
21 // This structure is used to define the keycode mapping table. 23 // This structure is used to define the keycode mapping table.
22 // It is defined here because the unittests need access to it. 24 // It is defined here because the unittests need access to it.
23 typedef struct { 25 typedef struct {
24 // USB keycode: 26 // USB keycode:
25 // Upper 16-bits: USB Usage Page. 27 // Upper 16-bits: USB Usage Page.
26 // Lower 16-bits: USB Usage Id: Assigned ID within this usage page. 28 // Lower 16-bits: USB Usage Id: Assigned ID within this usage page.
27 uint32_t usb_keycode; 29 uint32_t usb_keycode;
(...skipping 29 matching lines...) Expand all
57 // Convert a DomCode into a UI Events |code| string value. 59 // Convert a DomCode into a UI Events |code| string value.
58 static const char* DomCodeToCodeString(DomCode dom_code); 60 static const char* DomCodeToCodeString(DomCode dom_code);
59 61
60 // Return the DomKeyLocation of a DomCode. The DomKeyLocation distinguishes 62 // Return the DomKeyLocation of a DomCode. The DomKeyLocation distinguishes
61 // keys with the same meaning, and therefore the same DomKey or non-located 63 // keys with the same meaning, and therefore the same DomKey or non-located
62 // KeyboardCode (VKEY), and corresponds to the DOM UI Events 64 // KeyboardCode (VKEY), and corresponds to the DOM UI Events
63 // |KeyboardEvent.location|. 65 // |KeyboardEvent.location|.
64 static DomKeyLocation DomCodeToLocation(DomCode dom_code); 66 static DomKeyLocation DomCodeToLocation(DomCode dom_code);
65 67
66 // Convert a UI Events |key| string value into a DomKey. 68 // Convert a UI Events |key| string value into a DomKey.
69 // Accepts a character string containing either
70 // - a key name from http://www.w3.org/TR/DOM-Level-3-Events-key/, or
71 // - a single Unicode character (represented in UTF-8).
72 // Returns DomKey::NONE for other inputs, including |nullptr|.
67 static DomKey KeyStringToDomKey(const char* key); 73 static DomKey KeyStringToDomKey(const char* key);
68 74
69 // Convert a DomKey into a UI Events |key| string value. 75 // Convert a DomKey into a UI Events |key| string value.
70 static const char* DomKeyToKeyString(DomKey dom_key); 76 // For an invalid DomKey, returns an empty string.
77 static std::string DomKeyToKeyString(DomKey dom_key);
71 78
72 // Returns true if the DomKey is a modifier. 79 // Returns true if the DomKey is a modifier.
73 static bool IsDomKeyForModifier(DomKey dom_key); 80 static bool IsDomKeyForModifier(DomKey dom_key);
74 81
75 // The following methods relate to USB keycodes. 82 // The following methods relate to USB keycodes.
76 // Note that USB keycodes are not part of any web standard. 83 // Note that USB keycodes are not part of any web standard.
77 // Please don't use USB keycodes in new code. 84 // Please don't use USB keycodes in new code.
78 85
79 // Return the value that identifies an invalid USB keycode. 86 // Return the value that identifies an invalid USB keycode.
80 static uint32_t InvalidUsbKeycode(); 87 static uint32_t InvalidUsbKeycode();
(...skipping 18 matching lines...) Expand all
99 static const KeycodeMapEntry* GetKeycodeMapForTest(); 106 static const KeycodeMapEntry* GetKeycodeMapForTest();
100 static const char* DomKeyStringForTest(size_t index); 107 static const char* DomKeyStringForTest(size_t index);
101 108
102 private: 109 private:
103 DISALLOW_COPY_AND_ASSIGN(KeycodeConverter); 110 DISALLOW_COPY_AND_ASSIGN(KeycodeConverter);
104 }; 111 };
105 112
106 } // namespace ui 113 } // namespace ui
107 114
108 #endif // UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_ 115 #endif // UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_
OLDNEW
« no previous file with comments | « ui/events/keycodes/dom/dom_key_data.inc ('k') | ui/events/keycodes/dom/keycode_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698