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

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: fix macro case KeyX -> KEY_X Created 6 years, 2 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 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..ed9411f60ebb47eacd90482bc39b27e7cb88f026 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,8 +31,8 @@ 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
- const char* code;
+ // http://www.w3.org/TR/DOM-Level-3-Events-code/
+ DomCode code;
} KeycodeMapEntry;
// A class to convert between the current platform's native keycode (scancode)
@@ -44,6 +47,18 @@ class KeycodeConverter {
// The returned pointer references a static global string.
static const char* InvalidKeyboardEventCode();
+ // Convert a DomCode enum value to its corresponding UI Event |code| string.
+ static const char* DomCodeToCodeString(DomCode code);
+
+ // Convert a UI Event |code| string to its corresponding ui::DomCode.
+ static DomCode CodeStringToDomCode(const char *code);
+
+ // Convert a native (Mac/Win/Linux) keycode into the DomCode enum value.
+ static DomCode NativeKeycodeToDomCode(uint16_t native_keycode);
+
+ // Convert a DomCode enum value to a native keycode.
+ static uint16_t DomCodeToNativeKeycode(DomCode code);
+
// Convert a native (Mac/Win/Linux) keycode into the |code| string.
// The returned pointer references a static global string.
static const char* NativeKeycodeToCode(uint16_t native_keycode);
@@ -71,9 +86,19 @@ class KeycodeConverter {
// Convert a DOM3 Event |code| string into a USB keycode value.
static uint32_t CodeToUsbKeycode(const char* code);
+ // Convert a ui::DomKey to its corresponding UI Event |key| string.
+ static const char* DomKeyToKeyString(DomKey key);
+
+ // Convert a UI Event |key| string to its corresponding ui::DomKey.
+ static DomKey KeyStringToDomKey(const char *key);
+
// Static methods to support testing.
static size_t NumKeycodeMapEntriesForTest();
static const KeycodeMapEntry* GetKeycodeMapForTest();
+ static size_t NumDomCodeStringEntriesForTest();
+ static const char* const* DomCodeStringTableForTest();
+ static size_t NumDomKeyStringEntriesForTest();
+ static const char* const* DomKeyStringTableForTest();
private:
DISALLOW_COPY_AND_ASSIGN(KeycodeConverter);

Powered by Google App Engine
This is Rietveld 408576698