Bug 1297013 part.2 Implement some helper methods to log constants related to event handling r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 15 Sep 2016 00:48:47 +0900
changeset 360042 de82c28636a102736d72f823a934030eda7c8fb5
parent 360041 b1f41988e7a53e33c68d0f2a4ff6324f7e355450
child 360043 ce34596c89a41440d6d70dedb04b11b86ba2d22d
push id1369
push userjlorenzo@mozilla.com
push dateMon, 27 Feb 2017 14:59:41 +0000
treeherdermozilla-release@d75a1dba431f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1297013
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1297013 part.2 Implement some helper methods to log constants related to event handling r=smaug This patch implements some helper methods to log constants related to event handling. ToString(KeyNameIndex) and ToString(CodeNameIndex) converts the enum itmes to human readable string. They use WidgetKeyboardEvent's helper class which returns Unicode text. Therefore, this need to convert from UTF16 to UTF8. That's the reason why these methods don't return |const char*|. GetDOMKeyCodeName(uint32_t) returns DOM keycode name if it's defined. Otherwise, returns hexadecimal value. For generating switch-case statement, VirtualKeyCodeList.h shouldn't include ",". Therefore, this patch removes "," from VirtualKeyCodeList.h and append it at defining NS_DEFINE_VK. Additionally, the last item of enum and array should not end with ",". Therefore, this adds dummy last item at each of them. Finally, some of the keyCode values are shared between 2 keys. Therefore, it needs to support NS_DISALLOW_SAME_KEYCODE for switch-case generator. See the comment in the file for more detail. GetModifiersName(Modifiers) returns all modifier names included in the given value. MozReview-Commit-ID: 9i2ftFOTpDn
dom/events/VirtualKeyCodeList.h
dom/xbl/nsXBLPrototypeHandler.cpp
widget/BasicEvents.h
widget/EventForwards.h
widget/TextEvents.h
widget/WidgetEventImpl.cpp
--- a/dom/events/VirtualKeyCodeList.h
+++ b/dom/events/VirtualKeyCodeList.h
@@ -7,221 +7,234 @@
 
 /**
  * This header file defines all DOM keys which are defined in nsIDOMKeyEvent.
  * You must define NS_DEFINE_VK macro before including this.
  *
  * It must have two arguments, (aDOMKeyName, aDOMKeyCode)
  * aDOMKeyName is a key name in DOM.
  * aDOMKeyCode is one of nsIDOMKeyEvent::DOM_VK_*.
+ *
+ * Optionally, you can define NS_DISALLOW_SAME_KEYCODE.
+ *
+ * If NS_DISALLOW_SAME_KEYCODE is defined, same keyCode won't listed up.
+ * This is useful when you create switch-case statement.
  */
 
 #define DEFINE_VK_INTERNAL(aKeyName) \
   NS_DEFINE_VK(VK##aKeyName, nsIDOMKeyEvent::DOM_VK##aKeyName)
 
 // Some keycode may have different name in nsIDOMKeyEvent from its key name.
 #define DEFINE_VK_INTERNAL2(aKeyName, aKeyCodeName) \
   NS_DEFINE_VK(VK##aKeyName, nsIDOMKeyEvent::DOM_VK##aKeyCodeName)
 
-DEFINE_VK_INTERNAL(_CANCEL),
-DEFINE_VK_INTERNAL(_HELP),
-DEFINE_VK_INTERNAL2(_BACK, _BACK_SPACE),
-DEFINE_VK_INTERNAL(_TAB),
-DEFINE_VK_INTERNAL(_CLEAR),
-DEFINE_VK_INTERNAL(_RETURN),
-DEFINE_VK_INTERNAL(_SHIFT),
-DEFINE_VK_INTERNAL(_CONTROL),
-DEFINE_VK_INTERNAL(_ALT),
-DEFINE_VK_INTERNAL(_PAUSE),
-DEFINE_VK_INTERNAL(_CAPS_LOCK),
-DEFINE_VK_INTERNAL(_KANA),
-DEFINE_VK_INTERNAL(_HANGUL),
-DEFINE_VK_INTERNAL(_EISU),
-DEFINE_VK_INTERNAL(_JUNJA),
-DEFINE_VK_INTERNAL(_FINAL),
-DEFINE_VK_INTERNAL(_HANJA),
-DEFINE_VK_INTERNAL(_KANJI),
-DEFINE_VK_INTERNAL(_ESCAPE),
-DEFINE_VK_INTERNAL(_CONVERT),
-DEFINE_VK_INTERNAL(_NONCONVERT),
-DEFINE_VK_INTERNAL(_ACCEPT),
-DEFINE_VK_INTERNAL(_MODECHANGE),
-DEFINE_VK_INTERNAL(_SPACE),
-DEFINE_VK_INTERNAL(_PAGE_UP),
-DEFINE_VK_INTERNAL(_PAGE_DOWN),
-DEFINE_VK_INTERNAL(_END),
-DEFINE_VK_INTERNAL(_HOME),
-DEFINE_VK_INTERNAL(_LEFT),
-DEFINE_VK_INTERNAL(_UP),
-DEFINE_VK_INTERNAL(_RIGHT),
-DEFINE_VK_INTERNAL(_DOWN),
-DEFINE_VK_INTERNAL(_SELECT),
-DEFINE_VK_INTERNAL(_PRINT),
-DEFINE_VK_INTERNAL(_EXECUTE),
-DEFINE_VK_INTERNAL(_PRINTSCREEN),
-DEFINE_VK_INTERNAL(_INSERT),
-DEFINE_VK_INTERNAL(_DELETE),
+DEFINE_VK_INTERNAL(_CANCEL)
+DEFINE_VK_INTERNAL(_HELP)
+DEFINE_VK_INTERNAL2(_BACK, _BACK_SPACE)
+DEFINE_VK_INTERNAL(_TAB)
+DEFINE_VK_INTERNAL(_CLEAR)
+DEFINE_VK_INTERNAL(_RETURN)
+DEFINE_VK_INTERNAL(_SHIFT)
+DEFINE_VK_INTERNAL(_CONTROL)
+DEFINE_VK_INTERNAL(_ALT)
+DEFINE_VK_INTERNAL(_PAUSE)
+DEFINE_VK_INTERNAL(_CAPS_LOCK)
+#ifdef NS_DISALLOW_SAME_KEYCODE
+DEFINE_VK_INTERNAL2(_KANA_OR_HANGUL, _KANA)
+#else // #ifdef NS_DISALLOW_SAME_KEYCODE
+DEFINE_VK_INTERNAL(_KANA)
+DEFINE_VK_INTERNAL(_HANGUL)
+#endif
+DEFINE_VK_INTERNAL(_EISU)
+DEFINE_VK_INTERNAL(_JUNJA)
+DEFINE_VK_INTERNAL(_FINAL)
+#ifdef NS_DISALLOW_SAME_KEYCODE
+DEFINE_VK_INTERNAL2(_HANJA_OR_KANJI, _HANJA)
+#else // #ifdef NS_DISALLOW_SAME_KEYCODE
+DEFINE_VK_INTERNAL(_HANJA)
+DEFINE_VK_INTERNAL(_KANJI)
+#endif
+DEFINE_VK_INTERNAL(_ESCAPE)
+DEFINE_VK_INTERNAL(_CONVERT)
+DEFINE_VK_INTERNAL(_NONCONVERT)
+DEFINE_VK_INTERNAL(_ACCEPT)
+DEFINE_VK_INTERNAL(_MODECHANGE)
+DEFINE_VK_INTERNAL(_SPACE)
+DEFINE_VK_INTERNAL(_PAGE_UP)
+DEFINE_VK_INTERNAL(_PAGE_DOWN)
+DEFINE_VK_INTERNAL(_END)
+DEFINE_VK_INTERNAL(_HOME)
+DEFINE_VK_INTERNAL(_LEFT)
+DEFINE_VK_INTERNAL(_UP)
+DEFINE_VK_INTERNAL(_RIGHT)
+DEFINE_VK_INTERNAL(_DOWN)
+DEFINE_VK_INTERNAL(_SELECT)
+DEFINE_VK_INTERNAL(_PRINT)
+DEFINE_VK_INTERNAL(_EXECUTE)
+DEFINE_VK_INTERNAL(_PRINTSCREEN)
+DEFINE_VK_INTERNAL(_INSERT)
+DEFINE_VK_INTERNAL(_DELETE)
 
-DEFINE_VK_INTERNAL(_0),
-DEFINE_VK_INTERNAL(_1),
-DEFINE_VK_INTERNAL(_2),
-DEFINE_VK_INTERNAL(_3),
-DEFINE_VK_INTERNAL(_4),
-DEFINE_VK_INTERNAL(_5),
-DEFINE_VK_INTERNAL(_6),
-DEFINE_VK_INTERNAL(_7),
-DEFINE_VK_INTERNAL(_8),
-DEFINE_VK_INTERNAL(_9),
+DEFINE_VK_INTERNAL(_0)
+DEFINE_VK_INTERNAL(_1)
+DEFINE_VK_INTERNAL(_2)
+DEFINE_VK_INTERNAL(_3)
+DEFINE_VK_INTERNAL(_4)
+DEFINE_VK_INTERNAL(_5)
+DEFINE_VK_INTERNAL(_6)
+DEFINE_VK_INTERNAL(_7)
+DEFINE_VK_INTERNAL(_8)
+DEFINE_VK_INTERNAL(_9)
 
-DEFINE_VK_INTERNAL(_COLON),
-DEFINE_VK_INTERNAL(_SEMICOLON),
-DEFINE_VK_INTERNAL(_LESS_THAN),
-DEFINE_VK_INTERNAL(_EQUALS),
-DEFINE_VK_INTERNAL(_GREATER_THAN),
-DEFINE_VK_INTERNAL(_QUESTION_MARK),
-DEFINE_VK_INTERNAL(_AT),
+DEFINE_VK_INTERNAL(_COLON)
+DEFINE_VK_INTERNAL(_SEMICOLON)
+DEFINE_VK_INTERNAL(_LESS_THAN)
+DEFINE_VK_INTERNAL(_EQUALS)
+DEFINE_VK_INTERNAL(_GREATER_THAN)
+DEFINE_VK_INTERNAL(_QUESTION_MARK)
+DEFINE_VK_INTERNAL(_AT)
 
-DEFINE_VK_INTERNAL(_A),
-DEFINE_VK_INTERNAL(_B),
-DEFINE_VK_INTERNAL(_C),
-DEFINE_VK_INTERNAL(_D),
-DEFINE_VK_INTERNAL(_E),
-DEFINE_VK_INTERNAL(_F),
-DEFINE_VK_INTERNAL(_G),
-DEFINE_VK_INTERNAL(_H),
-DEFINE_VK_INTERNAL(_I),
-DEFINE_VK_INTERNAL(_J),
-DEFINE_VK_INTERNAL(_K),
-DEFINE_VK_INTERNAL(_L),
-DEFINE_VK_INTERNAL(_M),
-DEFINE_VK_INTERNAL(_N),
-DEFINE_VK_INTERNAL(_O),
-DEFINE_VK_INTERNAL(_P),
-DEFINE_VK_INTERNAL(_Q),
-DEFINE_VK_INTERNAL(_R),
-DEFINE_VK_INTERNAL(_S),
-DEFINE_VK_INTERNAL(_T),
-DEFINE_VK_INTERNAL(_U),
-DEFINE_VK_INTERNAL(_V),
-DEFINE_VK_INTERNAL(_W),
-DEFINE_VK_INTERNAL(_X),
-DEFINE_VK_INTERNAL(_Y),
-DEFINE_VK_INTERNAL(_Z),
+DEFINE_VK_INTERNAL(_A)
+DEFINE_VK_INTERNAL(_B)
+DEFINE_VK_INTERNAL(_C)
+DEFINE_VK_INTERNAL(_D)
+DEFINE_VK_INTERNAL(_E)
+DEFINE_VK_INTERNAL(_F)
+DEFINE_VK_INTERNAL(_G)
+DEFINE_VK_INTERNAL(_H)
+DEFINE_VK_INTERNAL(_I)
+DEFINE_VK_INTERNAL(_J)
+DEFINE_VK_INTERNAL(_K)
+DEFINE_VK_INTERNAL(_L)
+DEFINE_VK_INTERNAL(_M)
+DEFINE_VK_INTERNAL(_N)
+DEFINE_VK_INTERNAL(_O)
+DEFINE_VK_INTERNAL(_P)
+DEFINE_VK_INTERNAL(_Q)
+DEFINE_VK_INTERNAL(_R)
+DEFINE_VK_INTERNAL(_S)
+DEFINE_VK_INTERNAL(_T)
+DEFINE_VK_INTERNAL(_U)
+DEFINE_VK_INTERNAL(_V)
+DEFINE_VK_INTERNAL(_W)
+DEFINE_VK_INTERNAL(_X)
+DEFINE_VK_INTERNAL(_Y)
+DEFINE_VK_INTERNAL(_Z)
 
-DEFINE_VK_INTERNAL(_WIN),
-DEFINE_VK_INTERNAL(_CONTEXT_MENU),
-DEFINE_VK_INTERNAL(_SLEEP),
+DEFINE_VK_INTERNAL(_WIN)
+DEFINE_VK_INTERNAL(_CONTEXT_MENU)
+DEFINE_VK_INTERNAL(_SLEEP)
 
-DEFINE_VK_INTERNAL(_NUMPAD0),
-DEFINE_VK_INTERNAL(_NUMPAD1),
-DEFINE_VK_INTERNAL(_NUMPAD2),
-DEFINE_VK_INTERNAL(_NUMPAD3),
-DEFINE_VK_INTERNAL(_NUMPAD4),
-DEFINE_VK_INTERNAL(_NUMPAD5),
-DEFINE_VK_INTERNAL(_NUMPAD6),
-DEFINE_VK_INTERNAL(_NUMPAD7),
-DEFINE_VK_INTERNAL(_NUMPAD8),
-DEFINE_VK_INTERNAL(_NUMPAD9),
-DEFINE_VK_INTERNAL(_MULTIPLY),
-DEFINE_VK_INTERNAL(_ADD),
-DEFINE_VK_INTERNAL(_SEPARATOR),
-DEFINE_VK_INTERNAL(_SUBTRACT),
-DEFINE_VK_INTERNAL(_DECIMAL),
-DEFINE_VK_INTERNAL(_DIVIDE),
+DEFINE_VK_INTERNAL(_NUMPAD0)
+DEFINE_VK_INTERNAL(_NUMPAD1)
+DEFINE_VK_INTERNAL(_NUMPAD2)
+DEFINE_VK_INTERNAL(_NUMPAD3)
+DEFINE_VK_INTERNAL(_NUMPAD4)
+DEFINE_VK_INTERNAL(_NUMPAD5)
+DEFINE_VK_INTERNAL(_NUMPAD6)
+DEFINE_VK_INTERNAL(_NUMPAD7)
+DEFINE_VK_INTERNAL(_NUMPAD8)
+DEFINE_VK_INTERNAL(_NUMPAD9)
+DEFINE_VK_INTERNAL(_MULTIPLY)
+DEFINE_VK_INTERNAL(_ADD)
+DEFINE_VK_INTERNAL(_SEPARATOR)
+DEFINE_VK_INTERNAL(_SUBTRACT)
+DEFINE_VK_INTERNAL(_DECIMAL)
+DEFINE_VK_INTERNAL(_DIVIDE)
 
-DEFINE_VK_INTERNAL(_F1),
-DEFINE_VK_INTERNAL(_F2),
-DEFINE_VK_INTERNAL(_F3),
-DEFINE_VK_INTERNAL(_F4),
-DEFINE_VK_INTERNAL(_F5),
-DEFINE_VK_INTERNAL(_F6),
-DEFINE_VK_INTERNAL(_F7),
-DEFINE_VK_INTERNAL(_F8),
-DEFINE_VK_INTERNAL(_F9),
-DEFINE_VK_INTERNAL(_F10),
-DEFINE_VK_INTERNAL(_F11),
-DEFINE_VK_INTERNAL(_F12),
-DEFINE_VK_INTERNAL(_F13),
-DEFINE_VK_INTERNAL(_F14),
-DEFINE_VK_INTERNAL(_F15),
-DEFINE_VK_INTERNAL(_F16),
-DEFINE_VK_INTERNAL(_F17),
-DEFINE_VK_INTERNAL(_F18),
-DEFINE_VK_INTERNAL(_F19),
-DEFINE_VK_INTERNAL(_F20),
-DEFINE_VK_INTERNAL(_F21),
-DEFINE_VK_INTERNAL(_F22),
-DEFINE_VK_INTERNAL(_F23),
-DEFINE_VK_INTERNAL(_F24),
+DEFINE_VK_INTERNAL(_F1)
+DEFINE_VK_INTERNAL(_F2)
+DEFINE_VK_INTERNAL(_F3)
+DEFINE_VK_INTERNAL(_F4)
+DEFINE_VK_INTERNAL(_F5)
+DEFINE_VK_INTERNAL(_F6)
+DEFINE_VK_INTERNAL(_F7)
+DEFINE_VK_INTERNAL(_F8)
+DEFINE_VK_INTERNAL(_F9)
+DEFINE_VK_INTERNAL(_F10)
+DEFINE_VK_INTERNAL(_F11)
+DEFINE_VK_INTERNAL(_F12)
+DEFINE_VK_INTERNAL(_F13)
+DEFINE_VK_INTERNAL(_F14)
+DEFINE_VK_INTERNAL(_F15)
+DEFINE_VK_INTERNAL(_F16)
+DEFINE_VK_INTERNAL(_F17)
+DEFINE_VK_INTERNAL(_F18)
+DEFINE_VK_INTERNAL(_F19)
+DEFINE_VK_INTERNAL(_F20)
+DEFINE_VK_INTERNAL(_F21)
+DEFINE_VK_INTERNAL(_F22)
+DEFINE_VK_INTERNAL(_F23)
+DEFINE_VK_INTERNAL(_F24)
 
-DEFINE_VK_INTERNAL(_NUM_LOCK),
-DEFINE_VK_INTERNAL(_SCROLL_LOCK),
+DEFINE_VK_INTERNAL(_NUM_LOCK)
+DEFINE_VK_INTERNAL(_SCROLL_LOCK)
 
-DEFINE_VK_INTERNAL(_WIN_OEM_FJ_JISHO),
-DEFINE_VK_INTERNAL(_WIN_OEM_FJ_MASSHOU),
-DEFINE_VK_INTERNAL(_WIN_OEM_FJ_TOUROKU),
-DEFINE_VK_INTERNAL(_WIN_OEM_FJ_LOYA),
-DEFINE_VK_INTERNAL(_WIN_OEM_FJ_ROYA),
+DEFINE_VK_INTERNAL(_WIN_OEM_FJ_JISHO)
+DEFINE_VK_INTERNAL(_WIN_OEM_FJ_MASSHOU)
+DEFINE_VK_INTERNAL(_WIN_OEM_FJ_TOUROKU)
+DEFINE_VK_INTERNAL(_WIN_OEM_FJ_LOYA)
+DEFINE_VK_INTERNAL(_WIN_OEM_FJ_ROYA)
 
-DEFINE_VK_INTERNAL(_CIRCUMFLEX),
-DEFINE_VK_INTERNAL(_EXCLAMATION),
-DEFINE_VK_INTERNAL(_DOUBLE_QUOTE),
-DEFINE_VK_INTERNAL(_HASH),
-DEFINE_VK_INTERNAL(_DOLLAR),
-DEFINE_VK_INTERNAL(_PERCENT),
-DEFINE_VK_INTERNAL(_AMPERSAND),
-DEFINE_VK_INTERNAL(_UNDERSCORE),
-DEFINE_VK_INTERNAL(_OPEN_PAREN),
-DEFINE_VK_INTERNAL(_CLOSE_PAREN),
-DEFINE_VK_INTERNAL(_ASTERISK),
-DEFINE_VK_INTERNAL(_PLUS),
-DEFINE_VK_INTERNAL(_PIPE),
-DEFINE_VK_INTERNAL(_HYPHEN_MINUS),
+DEFINE_VK_INTERNAL(_CIRCUMFLEX)
+DEFINE_VK_INTERNAL(_EXCLAMATION)
+DEFINE_VK_INTERNAL(_DOUBLE_QUOTE)
+DEFINE_VK_INTERNAL(_HASH)
+DEFINE_VK_INTERNAL(_DOLLAR)
+DEFINE_VK_INTERNAL(_PERCENT)
+DEFINE_VK_INTERNAL(_AMPERSAND)
+DEFINE_VK_INTERNAL(_UNDERSCORE)
+DEFINE_VK_INTERNAL(_OPEN_PAREN)
+DEFINE_VK_INTERNAL(_CLOSE_PAREN)
+DEFINE_VK_INTERNAL(_ASTERISK)
+DEFINE_VK_INTERNAL(_PLUS)
+DEFINE_VK_INTERNAL(_PIPE)
+DEFINE_VK_INTERNAL(_HYPHEN_MINUS)
 
-DEFINE_VK_INTERNAL(_OPEN_CURLY_BRACKET),
-DEFINE_VK_INTERNAL(_CLOSE_CURLY_BRACKET),
+DEFINE_VK_INTERNAL(_OPEN_CURLY_BRACKET)
+DEFINE_VK_INTERNAL(_CLOSE_CURLY_BRACKET)
 
-DEFINE_VK_INTERNAL(_TILDE),
+DEFINE_VK_INTERNAL(_TILDE)
 
-DEFINE_VK_INTERNAL(_VOLUME_MUTE),
-DEFINE_VK_INTERNAL(_VOLUME_DOWN),
-DEFINE_VK_INTERNAL(_VOLUME_UP),
+DEFINE_VK_INTERNAL(_VOLUME_MUTE)
+DEFINE_VK_INTERNAL(_VOLUME_DOWN)
+DEFINE_VK_INTERNAL(_VOLUME_UP)
 
-DEFINE_VK_INTERNAL(_COMMA),
-DEFINE_VK_INTERNAL(_PERIOD),
-DEFINE_VK_INTERNAL(_SLASH),
-DEFINE_VK_INTERNAL(_BACK_QUOTE),
-DEFINE_VK_INTERNAL(_OPEN_BRACKET),
-DEFINE_VK_INTERNAL(_BACK_SLASH),
-DEFINE_VK_INTERNAL(_CLOSE_BRACKET),
-DEFINE_VK_INTERNAL(_QUOTE),
+DEFINE_VK_INTERNAL(_COMMA)
+DEFINE_VK_INTERNAL(_PERIOD)
+DEFINE_VK_INTERNAL(_SLASH)
+DEFINE_VK_INTERNAL(_BACK_QUOTE)
+DEFINE_VK_INTERNAL(_OPEN_BRACKET)
+DEFINE_VK_INTERNAL(_BACK_SLASH)
+DEFINE_VK_INTERNAL(_CLOSE_BRACKET)
+DEFINE_VK_INTERNAL(_QUOTE)
 
-DEFINE_VK_INTERNAL(_META),
-DEFINE_VK_INTERNAL(_ALTGR),
+DEFINE_VK_INTERNAL(_META)
+DEFINE_VK_INTERNAL(_ALTGR)
 
-DEFINE_VK_INTERNAL(_WIN_ICO_HELP),
-DEFINE_VK_INTERNAL(_WIN_ICO_00),
-DEFINE_VK_INTERNAL(_WIN_ICO_CLEAR),
-DEFINE_VK_INTERNAL(_WIN_OEM_RESET),
-DEFINE_VK_INTERNAL(_WIN_OEM_JUMP),
-DEFINE_VK_INTERNAL(_WIN_OEM_PA1),
-DEFINE_VK_INTERNAL(_WIN_OEM_PA2),
-DEFINE_VK_INTERNAL(_WIN_OEM_PA3),
-DEFINE_VK_INTERNAL(_WIN_OEM_WSCTRL),
-DEFINE_VK_INTERNAL(_WIN_OEM_CUSEL),
-DEFINE_VK_INTERNAL(_WIN_OEM_ATTN),
-DEFINE_VK_INTERNAL(_WIN_OEM_FINISH),
-DEFINE_VK_INTERNAL(_WIN_OEM_COPY),
-DEFINE_VK_INTERNAL(_WIN_OEM_AUTO),
-DEFINE_VK_INTERNAL(_WIN_OEM_ENLW),
-DEFINE_VK_INTERNAL(_WIN_OEM_BACKTAB),
+DEFINE_VK_INTERNAL(_WIN_ICO_HELP)
+DEFINE_VK_INTERNAL(_WIN_ICO_00)
+DEFINE_VK_INTERNAL(_WIN_ICO_CLEAR)
+DEFINE_VK_INTERNAL(_WIN_OEM_RESET)
+DEFINE_VK_INTERNAL(_WIN_OEM_JUMP)
+DEFINE_VK_INTERNAL(_WIN_OEM_PA1)
+DEFINE_VK_INTERNAL(_WIN_OEM_PA2)
+DEFINE_VK_INTERNAL(_WIN_OEM_PA3)
+DEFINE_VK_INTERNAL(_WIN_OEM_WSCTRL)
+DEFINE_VK_INTERNAL(_WIN_OEM_CUSEL)
+DEFINE_VK_INTERNAL(_WIN_OEM_ATTN)
+DEFINE_VK_INTERNAL(_WIN_OEM_FINISH)
+DEFINE_VK_INTERNAL(_WIN_OEM_COPY)
+DEFINE_VK_INTERNAL(_WIN_OEM_AUTO)
+DEFINE_VK_INTERNAL(_WIN_OEM_ENLW)
+DEFINE_VK_INTERNAL(_WIN_OEM_BACKTAB)
 
-DEFINE_VK_INTERNAL(_ATTN),
-DEFINE_VK_INTERNAL(_CRSEL),
-DEFINE_VK_INTERNAL(_EXSEL),
-DEFINE_VK_INTERNAL(_EREOF),
-DEFINE_VK_INTERNAL(_PLAY),
-DEFINE_VK_INTERNAL(_ZOOM),
-DEFINE_VK_INTERNAL(_PA1),
+DEFINE_VK_INTERNAL(_ATTN)
+DEFINE_VK_INTERNAL(_CRSEL)
+DEFINE_VK_INTERNAL(_EXSEL)
+DEFINE_VK_INTERNAL(_EREOF)
+DEFINE_VK_INTERNAL(_PLAY)
+DEFINE_VK_INTERNAL(_ZOOM)
+DEFINE_VK_INTERNAL(_PA1)
 DEFINE_VK_INTERNAL(_WIN_OEM_CLEAR)
 
 #undef DEFINE_VK_INTERNAL
 #undef DEFINE_VK_INTERNAL2
--- a/dom/xbl/nsXBLPrototypeHandler.cpp
+++ b/dom/xbl/nsXBLPrototypeHandler.cpp
@@ -638,34 +638,38 @@ struct keyCodeData {
 };
 
 // All of these must be uppercase, since the function below does
 // case-insensitive comparison by converting to uppercase.
 // XXX: be sure to check this periodically for new symbol additions!
 static const keyCodeData gKeyCodes[] = {
 
 #define NS_DEFINE_VK(aDOMKeyName, aDOMKeyCode) \
-  { #aDOMKeyName, sizeof(#aDOMKeyName) - 1, aDOMKeyCode }
+  { #aDOMKeyName, sizeof(#aDOMKeyName) - 1, aDOMKeyCode },
 #include "mozilla/VirtualKeyCodeList.h"
 #undef NS_DEFINE_VK
+
+  { nullptr, 0, 0 }
 };
 
 int32_t nsXBLPrototypeHandler::GetMatchingKeyCode(const nsAString& aKeyName)
 {
   nsAutoCString keyName;
   keyName.AssignWithConversion(aKeyName);
   ToUpperCase(keyName); // We want case-insensitive comparison with data
                         // stored as uppercase.
 
   uint32_t keyNameLength = keyName.Length();
   const char* keyNameStr = keyName.get();
-  for (uint16_t i = 0; i < (sizeof(gKeyCodes) / sizeof(gKeyCodes[0])); ++i)
+  for (uint16_t i = 0; i < ArrayLength(gKeyCodes) - 1; ++i) {
     if (keyNameLength == gKeyCodes[i].strlength &&
-        !nsCRT::strcmp(gKeyCodes[i].str, keyNameStr))
+        !nsCRT::strcmp(gKeyCodes[i].str, keyNameStr)) {
       return gKeyCodes[i].keycode;
+    }
+  }
 
   return 0;
 }
 
 int32_t nsXBLPrototypeHandler::KeyToMask(int32_t key)
 {
   switch (key)
   {
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -707,16 +707,86 @@ enum Modifier
 #define NS_DOM_KEYNAME_OS         "OS"
 
 /******************************************************************************
  * mozilla::Modifiers
  ******************************************************************************/
 
 typedef uint16_t Modifiers;
 
+class MOZ_STACK_CLASS GetModifiersName final : public nsAutoCString
+{
+public:
+  explicit GetModifiersName(Modifiers aModifiers)
+  {
+    if (aModifiers & MODIFIER_ALT) {
+      AssignLiteral(NS_DOM_KEYNAME_ALT);
+    }
+    if (aModifiers & MODIFIER_ALTGRAPH) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_ALTGRAPH);
+    }
+    if (aModifiers & MODIFIER_CAPSLOCK) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_CAPSLOCK);
+    }
+    if (aModifiers & MODIFIER_CONTROL) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_CONTROL);
+    }
+    if (aModifiers & MODIFIER_FN) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_FN);
+    }
+    if (aModifiers & MODIFIER_FNLOCK) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_FNLOCK);
+    }
+    if (aModifiers & MODIFIER_META) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_META);
+    }
+    if (aModifiers & MODIFIER_NUMLOCK) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_NUMLOCK);
+    }
+    if (aModifiers & MODIFIER_SCROLLLOCK) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_SCROLLLOCK);
+    }
+    if (aModifiers & MODIFIER_SHIFT) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_SHIFT);
+    }
+    if (aModifiers & MODIFIER_SYMBOL) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_SYMBOL);
+    }
+    if (aModifiers & MODIFIER_SYMBOLLOCK) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_SYMBOLLOCK);
+    }
+    if (aModifiers & MODIFIER_OS) {
+      MaybeAppendSeparator();
+      AppendLiteral(NS_DOM_KEYNAME_OS);
+    }
+    if (IsEmpty()) {
+      AssignLiteral("none");
+    }
+  }
+
+private:
+  void MaybeAppendSeparator()
+  {
+    if (!IsEmpty()) {
+      AppendLiteral(" | ");
+    }
+  }
+};
+
 /******************************************************************************
  * mozilla::WidgetInputEvent
  ******************************************************************************/
 
 class WidgetInputEvent : public WidgetGUIEvent
 {
 protected:
   WidgetInputEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -5,16 +5,18 @@
 
 #ifndef mozilla_EventForwards_h__
 #define mozilla_EventForwards_h__
 
 #include <stdint.h>
 
 #include "nsTArray.h"
 
+class nsCString;
+
 /**
  * XXX Following enums should be in BasicEvents.h.  However, currently, it's
  *     impossible to use foward delearation for enum.
  */
 
 /**
  * Return status for event processors.
  */
@@ -89,30 +91,34 @@ enum KeyNameIndex : KeyNameIndexType
 #include "mozilla/KeyNameList.h"
   // If a DOM keyboard event is synthesized by script, this is used.  Then,
   // specified key name should be stored and use it as .key value.
   KEY_NAME_INDEX_USE_STRING
 };
 
 #undef NS_DEFINE_KEYNAME
 
+const nsCString ToString(KeyNameIndex aKeyNameIndex);
+
 #define NS_DEFINE_PHYSICAL_KEY_CODE_NAME(aCPPName, aDOMCodeName) \
   CODE_NAME_INDEX_##aCPPName,
 
 typedef uint8_t CodeNameIndexType;
 enum CodeNameIndex : CodeNameIndexType
 {
 #include "mozilla/PhysicalKeyCodeNameList.h"
   // If a DOM keyboard event is synthesized by script, this is used.  Then,
   // specified code name should be stored and use it as .code value.
   CODE_NAME_INDEX_USE_STRING
 };
 
 #undef NS_DEFINE_PHYSICAL_KEY_CODE_NAME
 
+const nsCString ToString(CodeNameIndex aCodeNameIndex);
+
 #define NS_DEFINE_COMMAND(aName, aCommandStr) , Command##aName
 
 typedef int8_t CommandInt;
 enum Command : CommandInt
 {
   CommandDoNothing
 
 #include "mozilla/CommandList.h"
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -26,26 +26,27 @@
 
 class nsStringHashKey;
 template<class, class> class nsDataHashtable;
 
 /******************************************************************************
  * virtual keycode values
  ******************************************************************************/
 
-#define NS_DEFINE_VK(aDOMKeyName, aDOMKeyCode) NS_##aDOMKeyName = aDOMKeyCode
-
 enum
 {
+#define NS_DEFINE_VK(aDOMKeyName, aDOMKeyCode) NS_##aDOMKeyName = aDOMKeyCode,
 #include "mozilla/VirtualKeyCodeList.h"
+#undef NS_DEFINE_VK
+  NS_VK_UNKNOWN = 0xFF
 };
 
-#undef NS_DEFINE_VK
+namespace mozilla {
 
-namespace mozilla {
+const nsCString GetDOMKeyCodeName(uint32_t aKeyCode);
 
 namespace dom {
   class PBrowserParent;
   class PBrowserChild;
 } // namespace dom
 namespace plugins {
   class PPluginInstanceChild;
 } // namespace plugins
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -7,16 +7,17 @@
 #include "mozilla/BasicEvents.h"
 #include "mozilla/ContentEvents.h"
 #include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
+#include "nsPrintfCString.h"
 
 namespace mozilla {
 
 /******************************************************************************
  * Global helper methods
  ******************************************************************************/
 
 const char*
@@ -53,16 +54,57 @@ ToChar(EventClassID aEventClassID)
 
 #undef NS_EVENT_CLASS
 #undef NS_ROOT_EVENT_CLASS
     default:
       return "illegal event class ID";
   }
 }
 
+const nsCString
+ToString(KeyNameIndex aKeyNameIndex)
+{
+  if (aKeyNameIndex == KEY_NAME_INDEX_USE_STRING) {
+    return NS_LITERAL_CSTRING("USE_STRING");
+  }
+  nsAutoString keyName;
+  WidgetKeyboardEvent::GetDOMKeyName(aKeyNameIndex, keyName);
+  return NS_ConvertUTF16toUTF8(keyName);
+}
+
+const nsCString
+ToString(CodeNameIndex aCodeNameIndex)
+{
+  if (aCodeNameIndex == CODE_NAME_INDEX_USE_STRING) {
+    return NS_LITERAL_CSTRING("USE_STRING");
+  }
+  nsAutoString codeName;
+  WidgetKeyboardEvent::GetDOMCodeName(aCodeNameIndex, codeName);
+  return NS_ConvertUTF16toUTF8(codeName);
+}
+
+const nsCString
+GetDOMKeyCodeName(uint32_t aKeyCode)
+{
+  switch (aKeyCode) {
+#define NS_DISALLOW_SAME_KEYCODE
+#define NS_DEFINE_VK(aDOMKeyName, aDOMKeyCode) \
+    case aDOMKeyCode: \
+      return NS_LITERAL_CSTRING(#aDOMKeyName);
+
+#include "mozilla/VirtualKeyCodeList.h"
+
+#undef NS_DEFINE_VK
+#undef NS_DISALLOW_SAME_KEYCODE
+
+    default:
+      return nsPrintfCString("Invalid DOM keyCode (0x%08X)", aKeyCode);
+  }
+}
+
 bool
 IsValidRawTextRangeValue(RawTextRangeType aRawTextRangeType)
 {
   switch (static_cast<TextRangeType>(aRawTextRangeType)) {
     case TextRangeType::eUninitialized:
     case TextRangeType::eCaret:
     case TextRangeType::eRawClause:
     case TextRangeType::eSelectedRawClause: