Bug 930900 part.1 Add new key name index which means KeyboardEvent.key should refer stored string (not implemented yet) r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 29 Oct 2013 13:14:42 +0900
changeset 167161 55ea77a28509f776da6f4d18e3d2cc5b8b4e8a68
parent 167160 340cb402065a747a86d6e7a04ce682dd6300bf52
child 167162 7f7c141390b20c7e569186a77850ccba6b43ac91
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs930900
milestone28.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 930900 part.1 Add new key name index which means KeyboardEvent.key should refer stored string (not implemented yet) r=smaug
content/events/src/nsDOMKeyboardEvent.cpp
widget/EventForwards.h
widget/TextEvents.h
widget/tests/test_assign_event_data.html
--- a/content/events/src/nsDOMKeyboardEvent.cpp
+++ b/content/events/src/nsDOMKeyboardEvent.cpp
@@ -18,16 +18,17 @@ nsDOMKeyboardEvent::nsDOMKeyboardEvent(m
   NS_ASSERTION(mEvent->eventStructType == NS_KEY_EVENT, "event type mismatch");
 
   if (aEvent) {
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
+    mEvent->AsKeyboardEvent()->mKeyNameIndex = KEY_NAME_INDEX_USE_STRING;
   }
 }
 
 NS_IMPL_ADDREF_INHERITED(nsDOMKeyboardEvent, nsDOMUIEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMKeyboardEvent, nsDOMUIEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMKeyboardEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMKeyEvent)
@@ -97,19 +98,17 @@ nsDOMKeyboardEvent::GetModifierState(con
 
   *aState = GetModifierState(aKey);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMKeyboardEvent::GetKey(nsAString& aKeyName)
 {
-  if (!mEventIsInternal) {
-    mEvent->AsKeyboardEvent()->GetDOMKeyName(aKeyName);
-  }
+  mEvent->AsKeyboardEvent()->GetDOMKeyName(aKeyName);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMKeyboardEvent::GetCharCode(uint32_t* aCharCode)
 {
   NS_ENSURE_ARG_POINTER(aCharCode);
   *aCharCode = CharCode();
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -31,19 +31,19 @@ namespace mozilla {
 typedef uint16_t Modifiers;
 
 #define NS_DEFINE_KEYNAME(aCPPName, aDOMKeyName) \
   KEY_NAME_INDEX_##aCPPName,
 
 enum KeyNameIndex
 {
 #include "nsDOMKeyNameList.h"
-  // There shouldn't be "," at the end of enum definition, this dummy item
-  // avoids bustage on some platforms.
-  NUMBER_OF_KEY_NAME_INDEX
+  // 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
 
 } // namespace mozilla
 
 /**
  * All header files should include this header instead of *Events.h.
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -119,16 +119,17 @@ public:
   static void GetDOMKeyName(mozilla::KeyNameIndex aKeyNameIndex,
                             nsAString& aKeyName)
   {
 #define NS_DEFINE_KEYNAME(aCPPName, aDOMKeyName) \
       case KEY_NAME_INDEX_##aCPPName: \
         aKeyName.Assign(NS_LITERAL_STRING(aDOMKeyName)); return;
     switch (aKeyNameIndex) {
 #include "nsDOMKeyNameList.h"
+      case KEY_NAME_INDEX_USE_STRING:
       default:
         aKeyName.Truncate();
         return;
     }
 #undef NS_DEFINE_KEYNAME
   }
 
   void AssignKeyEventData(const WidgetKeyboardEvent& aEvent, bool aCopyTargets)
--- a/widget/tests/test_assign_event_data.html
+++ b/widget/tests/test_assign_event_data.html
@@ -141,67 +141,67 @@ const kTests = [
         gUtils.sendNativeKeyEvent(WIN_KL_US, WIN_VK_A, 0, "a", "a");
       } else if (kIsMac) {
         gUtils.sendNativeKeyEvent(MAC_KL_US, MAC_VK_ANSI_A, 0, "a", "a");
       }
     },
     canRun: function () {
       return (kIsMac || kIsWin);
     },
-    todoMismatch: [ "key" ],
+    todoMismatch: [],
   },
   { description: "nsKeyEvent (keyup of 'a' key without modifiers)",
     targetID: "input-text", eventType: "keydown",
     dispatchEvent: function () {
       document.getElementById(this.targetID).value = "";
       document.getElementById(this.targetID).focus();
       if (kIsWin) {
         gUtils.sendNativeKeyEvent(WIN_KL_US, WIN_VK_A, 0, "a", "a");
       } else if (kIsMac) {
         gUtils.sendNativeKeyEvent(MAC_KL_US, MAC_VK_ANSI_A, 0, "a", "a");
       }
     },
     canRun: function () {
       return (kIsMac || kIsWin);
     },
-    todoMismatch: [ "key" ],
+    todoMismatch: [],
   },
   { description: "nsKeyEvent (keypress of 'b' key with Shift)",
     targetID: "input-text", eventType: "keypress",
     dispatchEvent: function () {
       document.getElementById(this.targetID).value = "";
       document.getElementById(this.targetID).focus();
       if (kIsWin) {
         gUtils.sendNativeKeyEvent(WIN_KL_US, WIN_VK_B, NATIVE_SHIFT_LEFT, "B", "B");
       } else if (kIsMac) {
         gUtils.sendNativeKeyEvent(MAC_KL_US, MAC_VK_ANSI_B, NATIVE_SHIFT_LEFT, "B", "B");
       }
     },
     canRun: function () {
       return (kIsMac || kIsWin);
     },
     // "defaultPrevented" becomes true because the editor consumes the keypress event.
-    todoMismatch: [ "key", "defaultPrevented" ],
+    todoMismatch: [ "defaultPrevented" ],
   },
   { description: "nsKeyEvent (keypress of 'c' key with Accel)",
     targetID: "input-text", eventType: "keypress",
     dispatchEvent: function () {
       document.getElementById(this.targetID).value = "";
       document.getElementById(this.targetID).focus();
       if (kIsWin) {
         gUtils.sendNativeKeyEvent(WIN_KL_US, WIN_VK_C, NATIVE_CONTROL_RIGHT, "\u0003", "c");
       } else if (kIsMac) {
         gUtils.sendNativeKeyEvent(MAC_KL_US, MAC_VK_ANSI_C, NATIVE_META_RIGHT, "c", "c");
       }
     },
     canRun: function () {
       return (kIsMac || kIsWin);
     },
     // "defaultPrevented" becomes true because the editor consumes the keypress event.
-    todoMismatch: [ "key", "defaultPrevented" ],
+    todoMismatch: [ "defaultPrevented" ],
   },
   { description: "nsMouseEvent (mousedown of left button without modifier)",
     targetID: "button", eventType: "mousedown",
     dispatchEvent: function () {
       synthesizeMouseAtCenter(document.getElementById(this.targetID),
                               { button: 0 });
     },
     canRun: function () {