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

Unified Diff: ui/events/keycodes/dom4/keycode_converter.h

Issue 641753003: DOM Level 3 .code and .key value enumerations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add code for unicode keys Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/keycodes/dom4/keycode_converter.h
diff --git a/ui/events/keycodes/dom4/keycode_converter.h b/ui/events/keycodes/dom4/keycode_converter.h
index a52d086e8de53ce156eb78b21cec5b37b8fbdba7..5a9fbc722ac213b8705fecc8873d01a810990c45 100644
--- a/ui/events/keycodes/dom4/keycode_converter.h
+++ b/ui/events/keycodes/dom4/keycode_converter.h
@@ -13,6 +13,9 @@
namespace ui {
+enum class DomCode;
+enum class DomKey;
+
// This structure is used to define the keycode mapping table.
// It is defined here because the unittests need access to it.
typedef struct {
@@ -28,7 +31,7 @@ typedef struct {
uint16_t native_keycode;
// The UIEvents (aka: DOM4Events) |code| value as defined in:
- // https://dvcs.w3.org/hg/d4e/raw-file/tip/source_respec.htm
+ // http://www.w3.org/TR/DOM-Level-3-Events-code/
const char* code;
} KeycodeMapEntry;
@@ -48,9 +51,27 @@ class KeycodeConverter {
// The returned pointer references a static global string.
static const char* NativeKeycodeToCode(uint16_t native_keycode);
+ // Convert a native (Mac/Win/Linux) keycode into a DomCode.
+ static DomCode NativeKeycodeToDomCode(uint16_t native_keycode);
+
// Convert a UI Events |code| string value into a native keycode.
static uint16_t CodeToNativeKeycode(const char* code);
+ // Convert a DomCode into a native keycode.
+ static uint16_t DomCodeToNativeKeycode(DomCode code);
+
+ // Convert a UI Events |code| string value into a DomCode.
+ static DomCode CodeStringToDomCode(const char* code);
+
+ // Convert a DomCode into a UI Events |code| string value.
+ static const char* DomCodeToCodeString(DomCode dom_code);
+
+ // Convert a UI Events |key| string value into a DomKey.
+ static DomKey KeyStringToDomKey(const char* key);
+
+ // Convert a DomKey into a UI Events |key| string value.
+ static const char* DomKeyToKeyString(DomKey dom_key);
+
// The following methods relate to USB keycodes.
// Note that USB keycodes are not part of any web standard.
// Please don't use USB keycodes in new code.
@@ -74,6 +95,8 @@ class KeycodeConverter {
// Static methods to support testing.
static size_t NumKeycodeMapEntriesForTest();
static const KeycodeMapEntry* GetKeycodeMapForTest();
+ static const char* DomCodeStringForTest(size_t index);
+ static const char* DomKeyStringForTest(size_t index);
private:
DISALLOW_COPY_AND_ASSIGN(KeycodeConverter);

Powered by Google App Engine
This is Rietveld 408576698