Bug 166240 part.1 Add D3E KeyboardEvent.location r=smaug, sr=jst
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 03 May 2012 17:35:01 +0900
changeset 97021 03c2b4944d971619601929aa3f8308c6d79552e7
parent 97020 a6a335cd2c9436d713fe9fc21861f1009ba69cb2
child 97022 1b790392d57048a4bbed1967d4d67077864c76bc
push id1116
push userlsblakk@mozilla.com
push dateMon, 16 Jul 2012 19:38:18 +0000
treeherdermozilla-beta@95f959a8b4dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, jst
bugs166240
milestone15.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 166240 part.1 Add D3E KeyboardEvent.location r=smaug, sr=jst
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMKeyboardEvent.cpp
dom/interfaces/events/nsIDOMKeyEvent.idl
widget/nsGUIEvent.h
widget/nsGUIEventIPC.h
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -674,16 +674,17 @@ NS_METHOD nsDOMEvent::DuplicatePrivateDa
     case NS_KEY_EVENT:
     {
       nsKeyEvent* keyEvent = new nsKeyEvent(false, msg, nsnull);
       NS_ENSURE_TRUE(keyEvent, NS_ERROR_OUT_OF_MEMORY);
       nsKeyEvent* oldKeyEvent = static_cast<nsKeyEvent*>(mEvent);
       isInputEvent = true;
       keyEvent->keyCode = oldKeyEvent->keyCode;
       keyEvent->charCode = oldKeyEvent->charCode;
+      keyEvent->location = oldKeyEvent->location;
       keyEvent->isChar = oldKeyEvent->isChar;
       newEvent = keyEvent;
       break;
     }
     case NS_MOUSE_EVENT:
     {
       nsMouseEvent* oldMouseEvent = static_cast<nsMouseEvent*>(mEvent);
       nsMouseEvent* mouseEvent =
--- a/content/events/src/nsDOMKeyboardEvent.cpp
+++ b/content/events/src/nsDOMKeyboardEvent.cpp
@@ -180,16 +180,25 @@ nsDOMKeyboardEvent::Which(PRUint32* aWhi
       *aWhich = 0;
       break;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsDOMKeyboardEvent::GetLocation(PRUint32* aLocation)
+{
+  NS_ENSURE_ARG_POINTER(aLocation);
+
+  *aLocation = static_cast<nsKeyEvent*>(mEvent)->location;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsDOMKeyboardEvent::InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
                                  nsIDOMWindow* aView, bool aCtrlKey, bool aAltKey,
                                  bool aShiftKey, bool aMetaKey,
                                  PRUint32 aKeyCode, PRUint32 aCharCode)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/dom/interfaces/events/nsIDOMKeyEvent.idl
+++ b/dom/interfaces/events/nsIDOMKeyEvent.idl
@@ -34,17 +34,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIDOMUIEvent.idl"
 
-[scriptable, uuid(5d33fb45-dd4b-4342-bff8-ff33737b2b54)]
+[scriptable, uuid(229244a6-0515-43bc-8218-9a1b1774959f)]
 interface nsIDOMKeyEvent : nsIDOMUIEvent
 {
   const unsigned long DOM_VK_CANCEL         = 0x03;
   const unsigned long DOM_VK_HELP           = 0x06;
   const unsigned long DOM_VK_BACK_SPACE     = 0x08;
   const unsigned long DOM_VK_TAB            = 0x09;
   const unsigned long DOM_VK_CLEAR          = 0x0C;
   const unsigned long DOM_VK_RETURN         = 0x0D;
@@ -197,9 +197,18 @@ interface nsIDOMKeyEvent : nsIDOMUIEvent
                                          in boolean ctrlKeyArg,
                                          in boolean altKeyArg,
                                          in boolean shiftKeyArg,
                                          in boolean metaKeyArg,
                                          in unsigned long keyCodeArg,
                                          in unsigned long charCodeArg);
 
   bool getModifierState(in DOMString keyArg);
+
+  const unsigned long DOM_KEY_LOCATION_STANDARD = 0x00;
+  const unsigned long DOM_KEY_LOCATION_LEFT     = 0x01;
+  const unsigned long DOM_KEY_LOCATION_RIGHT    = 0x02;
+  const unsigned long DOM_KEY_LOCATION_NUMPAD   = 0x03;
+  const unsigned long DOM_KEY_LOCATION_MOBILE   = 0x04;
+  const unsigned long DOM_KEY_LOCATION_JOYSTICK = 0x05;
+
+  readonly attribute unsigned long location;
 };
--- a/widget/nsGUIEvent.h
+++ b/widget/nsGUIEvent.h
@@ -1108,24 +1108,27 @@ private:
 
 public:
   nsKeyEvent()
   {
   }
 
   nsKeyEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
     : nsInputEvent(isTrusted, msg, w, NS_KEY_EVENT),
-      keyCode(0), charCode(0), isChar(0)
+      keyCode(0), charCode(0),
+      location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD), isChar(0)
   {
   }
 
   /// see NS_VK codes
   PRUint32        keyCode;   
   /// OS translated Unicode char
   PRUint32        charCode;
+  // One of nsIDOMKeyEvent::DOM_KEY_LOCATION_*
+  PRUint32        location;
   // OS translated Unicode chars which are used for accesskey and accelkey
   // handling. The handlers will try from first character to last character.
   nsTArray<nsAlternativeCharCode> alternativeCharCodes;
   // indicates whether the event signifies a printable character
   bool            isChar;
 };
 
 /**
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -188,24 +188,26 @@ struct ParamTraits<nsKeyEvent>
   typedef nsKeyEvent paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<nsInputEvent>(aParam));
     WriteParam(aMsg, aParam.keyCode);
     WriteParam(aMsg, aParam.charCode);
     WriteParam(aMsg, aParam.isChar);
+    WriteParam(aMsg, aParam.location);
   }
 
   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   {
     return ReadParam(aMsg, aIter, static_cast<nsInputEvent*>(aResult)) &&
            ReadParam(aMsg, aIter, &aResult->keyCode) &&
            ReadParam(aMsg, aIter, &aResult->charCode) &&
-           ReadParam(aMsg, aIter, &aResult->isChar);
+           ReadParam(aMsg, aIter, &aResult->isChar) &&
+           ReadParam(aMsg, aIter, &aResult->location);
   }
 };
 
 template<>
 struct ParamTraits<nsTextRangeStyle>
 {
   typedef nsTextRangeStyle paramType;