Bug 600117 part.1 Implement KeyboardEvent.repeat r=smaug, sr=jst
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 07 Nov 2013 20:17:32 +0900
changeset 169539 27c3093d65396edfd8408885bc3ee629b6bd4a8b
parent 169538 6e7f8b1e531994b46a26c980665e1b395f025a21
child 169540 4d0708417745d3c198d7662df0df64b98a2fdd1f
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, jst
bugs600117
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 600117 part.1 Implement KeyboardEvent.repeat r=smaug, sr=jst
content/events/src/nsDOMKeyboardEvent.cpp
content/events/src/nsDOMKeyboardEvent.h
dom/interfaces/events/nsIDOMKeyEvent.idl
dom/webidl/KeyboardEvent.webidl
widget/TextEvents.h
widget/nsGUIEventIPC.h
--- a/content/events/src/nsDOMKeyboardEvent.cpp
+++ b/content/events/src/nsDOMKeyboardEvent.cpp
@@ -85,16 +85,30 @@ nsDOMKeyboardEvent::MetaKey()
 NS_IMETHODIMP
 nsDOMKeyboardEvent::GetMetaKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = MetaKey();
   return NS_OK;
 }
 
+bool
+nsDOMKeyboardEvent::Repeat()
+{
+  return mEvent->AsKeyboardEvent()->mIsRepeat;
+}
+
+NS_IMETHODIMP
+nsDOMKeyboardEvent::GetRepeat(bool* aIsRepeat)
+{
+  NS_ENSURE_ARG_POINTER(aIsRepeat);
+  *aIsRepeat = Repeat();
+  return NS_OK;
+}
+
 NS_IMETHODIMP
 nsDOMKeyboardEvent::GetModifierState(const nsAString& aKey,
                                      bool* aState)
 {
   NS_ENSURE_ARG_POINTER(aState);
 
   *aState = GetModifierState(aKey);
   return NS_OK;
--- a/content/events/src/nsDOMKeyboardEvent.h
+++ b/content/events/src/nsDOMKeyboardEvent.h
@@ -38,16 +38,17 @@ public:
   bool ShiftKey();
   bool MetaKey();
 
   bool GetModifierState(const nsAString& aKey)
   {
     return GetModifierStateInternal(aKey);
   }
 
+  bool Repeat();
   uint32_t CharCode();
   uint32_t KeyCode();
   virtual uint32_t Which() MOZ_OVERRIDE;
   uint32_t Location();
 
   void InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
                     nsIDOMWindow* aView, bool aCtrlKey, bool aAltKey,
                     bool aShiftKey, bool aMetaKey,
--- a/dom/interfaces/events/nsIDOMKeyEvent.idl
+++ b/dom/interfaces/events/nsIDOMKeyEvent.idl
@@ -1,16 +1,16 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsIDOMUIEvent.idl"
 
-[scriptable, builtinclass, uuid(91a3d7f2-223b-4e09-a566-634e7ee0a31d)]
+[scriptable, builtinclass, uuid(2bbf1087-e404-45a5-880a-4f3702aebd4e)]
 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;
@@ -247,11 +247,12 @@ interface nsIDOMKeyEvent : nsIDOMUIEvent
   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;
+  readonly attribute boolean       repeat;
 
   readonly attribute DOMString key;
 };
--- a/dom/webidl/KeyboardEvent.webidl
+++ b/dom/webidl/KeyboardEvent.webidl
@@ -21,14 +21,15 @@ interface KeyboardEvent : UIEvent
   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;
+  readonly attribute boolean       repeat;
 
   readonly attribute DOMString key;
 };
 
 // Mozilla extensions
 KeyboardEvent implements KeyEvent;
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -74,17 +74,18 @@ private:
   }
 
 public:
   virtual WidgetKeyboardEvent* AsKeyboardEvent() MOZ_OVERRIDE { return this; }
 
   WidgetKeyboardEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
     WidgetInputEvent(aIsTrusted, aMessage, aWidget, NS_KEY_EVENT),
     keyCode(0), charCode(0),
-    location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD), isChar(0),
+    location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD),
+    isChar(false), mIsRepeat(false),
     mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified),
     mNativeKeyEvent(nullptr),
     mUniqueId(0)
   {
   }
 
   // A DOM keyCode value or 0.  If a keypress event whose charCode is 0, this
   // should be 0.
@@ -96,16 +97,19 @@ public:
   uint32_t charCode;
   // One of nsIDOMKeyEvent::DOM_KEY_LOCATION_*
   uint32_t location;
   // OS translated Unicode chars which are used for accesskey and accelkey
   // handling. The handlers will try from first character to last character.
   nsTArray<AlternativeCharCode> alternativeCharCodes;
   // Indicates whether the event signifies a printable character
   bool isChar;
+  // Indicates whether the event is generated by auto repeat or not.
+  // if this is keyup event, always false.
+  bool mIsRepeat;
   // DOM KeyboardEvent.key
   KeyNameIndex mKeyNameIndex;
   // OS-specific native event can optionally be preserved
   void* mNativeKeyEvent;
   // Unique id associated with a keydown / keypress event. Used in identifing
   // keypress events for removal from async event dispatch queue in metrofx
   // after preventDefault is called on keydown events. It's ok if this wraps
   // over long periods.
@@ -136,16 +140,17 @@ public:
   {
     AssignInputEventData(aEvent, aCopyTargets);
 
     keyCode = aEvent.keyCode;
     charCode = aEvent.charCode;
     location = aEvent.location;
     alternativeCharCodes = aEvent.alternativeCharCodes;
     isChar = aEvent.isChar;
+    mIsRepeat = aEvent.mIsRepeat;
     mKeyNameIndex = aEvent.mKeyNameIndex;
     // Don't copy mNativeKeyEvent because it may be referred after its instance
     // is destroyed.
     mNativeKeyEvent = nullptr;
     mUniqueId = aEvent.mUniqueId;
   }
 };
 
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -265,31 +265,33 @@ struct ParamTraits<mozilla::WidgetKeyboa
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<mozilla::WidgetInputEvent>(aParam));
     WriteParam(aMsg, static_cast<uint32_t>(aParam.mKeyNameIndex));
     WriteParam(aMsg, aParam.keyCode);
     WriteParam(aMsg, aParam.charCode);
     WriteParam(aMsg, aParam.isChar);
+    WriteParam(aMsg, aParam.mIsRepeat);
     WriteParam(aMsg, aParam.location);
     WriteParam(aMsg, aParam.mUniqueId);
     // An OS-specific native event might be attached in |mNativeKeyEvent|,  but
     // that cannot be copied across process boundaries.
   }
 
   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   {
     uint32_t keyNameIndex = 0;
     if (ReadParam(aMsg, aIter,
                   static_cast<mozilla::WidgetInputEvent*>(aResult)) &&
         ReadParam(aMsg, aIter, &keyNameIndex) &&
         ReadParam(aMsg, aIter, &aResult->keyCode) &&
         ReadParam(aMsg, aIter, &aResult->charCode) &&
         ReadParam(aMsg, aIter, &aResult->isChar) &&
+        ReadParam(aMsg, aIter, &aResult->mIsRepeat) &&
         ReadParam(aMsg, aIter, &aResult->location) &&
         ReadParam(aMsg, aIter, &aResult->mUniqueId))
     {
       aResult->mKeyNameIndex = static_cast<mozilla::KeyNameIndex>(keyNameIndex);
       aResult->mNativeKeyEvent = nullptr;
       return true;
     }
     return false;