Skip to content

Commit 0070ecb

Browse files
Bug 600117 part.1 Implement KeyboardEvent.repeat r=smaug, sr=jst
1 parent 7cb4f81 commit 0070ecb

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed

content/events/src/nsDOMKeyboardEvent.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@ nsDOMKeyboardEvent::GetMetaKey(bool* aIsDown)
9090
return NS_OK;
9191
}
9292

93+
bool
94+
nsDOMKeyboardEvent::Repeat()
95+
{
96+
return mEvent->AsKeyboardEvent()->mIsRepeat;
97+
}
98+
99+
NS_IMETHODIMP
100+
nsDOMKeyboardEvent::GetRepeat(bool* aIsRepeat)
101+
{
102+
NS_ENSURE_ARG_POINTER(aIsRepeat);
103+
*aIsRepeat = Repeat();
104+
return NS_OK;
105+
}
106+
93107
NS_IMETHODIMP
94108
nsDOMKeyboardEvent::GetModifierState(const nsAString& aKey,
95109
bool* aState)

content/events/src/nsDOMKeyboardEvent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class nsDOMKeyboardEvent : public nsDOMUIEvent,
4343
return GetModifierStateInternal(aKey);
4444
}
4545

46+
bool Repeat();
4647
uint32_t CharCode();
4748
uint32_t KeyCode();
4849
virtual uint32_t Which() MOZ_OVERRIDE;

dom/interfaces/events/nsIDOMKeyEvent.idl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "nsIDOMUIEvent.idl"
77

8-
[scriptable, builtinclass, uuid(91a3d7f2-223b-4e09-a566-634e7ee0a31d)]
8+
[scriptable, builtinclass, uuid(2bbf1087-e404-45a5-880a-4f3702aebd4e)]
99
interface nsIDOMKeyEvent : nsIDOMUIEvent
1010
{
1111
const unsigned long DOM_VK_CANCEL = 0x03;
@@ -252,6 +252,7 @@ interface nsIDOMKeyEvent : nsIDOMUIEvent
252252
const unsigned long DOM_KEY_LOCATION_JOYSTICK = 0x05;
253253

254254
readonly attribute unsigned long location;
255+
readonly attribute boolean repeat;
255256

256257
readonly attribute DOMString key;
257258
};

dom/webidl/KeyboardEvent.webidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface KeyboardEvent : UIEvent
2626
const unsigned long DOM_KEY_LOCATION_JOYSTICK = 0x05;
2727

2828
readonly attribute unsigned long location;
29+
readonly attribute boolean repeat;
2930

3031
readonly attribute DOMString key;
3132
};

widget/TextEvents.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class WidgetKeyboardEvent : public WidgetInputEvent
7979
WidgetKeyboardEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
8080
WidgetInputEvent(aIsTrusted, aMessage, aWidget, NS_KEY_EVENT),
8181
keyCode(0), charCode(0),
82-
location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD), isChar(0),
82+
location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD),
83+
isChar(false), mIsRepeat(false),
8384
mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified),
8485
mNativeKeyEvent(nullptr),
8586
mUniqueId(0)
@@ -101,6 +102,9 @@ class WidgetKeyboardEvent : public WidgetInputEvent
101102
nsTArray<AlternativeCharCode> alternativeCharCodes;
102103
// Indicates whether the event signifies a printable character
103104
bool isChar;
105+
// Indicates whether the event is generated by auto repeat or not.
106+
// if this is keyup event, always false.
107+
bool mIsRepeat;
104108
// DOM KeyboardEvent.key
105109
KeyNameIndex mKeyNameIndex;
106110
// OS-specific native event can optionally be preserved
@@ -141,6 +145,7 @@ class WidgetKeyboardEvent : public WidgetInputEvent
141145
location = aEvent.location;
142146
alternativeCharCodes = aEvent.alternativeCharCodes;
143147
isChar = aEvent.isChar;
148+
mIsRepeat = aEvent.mIsRepeat;
144149
mKeyNameIndex = aEvent.mKeyNameIndex;
145150
// Don't copy mNativeKeyEvent because it may be referred after its instance
146151
// is destroyed.

widget/nsGUIEventIPC.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent>
270270
WriteParam(aMsg, aParam.keyCode);
271271
WriteParam(aMsg, aParam.charCode);
272272
WriteParam(aMsg, aParam.isChar);
273+
WriteParam(aMsg, aParam.mIsRepeat);
273274
WriteParam(aMsg, aParam.location);
274275
WriteParam(aMsg, aParam.mUniqueId);
275276
// An OS-specific native event might be attached in |mNativeKeyEvent|, but
@@ -285,6 +286,7 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent>
285286
ReadParam(aMsg, aIter, &aResult->keyCode) &&
286287
ReadParam(aMsg, aIter, &aResult->charCode) &&
287288
ReadParam(aMsg, aIter, &aResult->isChar) &&
289+
ReadParam(aMsg, aIter, &aResult->mIsRepeat) &&
288290
ReadParam(aMsg, aIter, &aResult->location) &&
289291
ReadParam(aMsg, aIter, &aResult->mUniqueId))
290292
{

0 commit comments

Comments
 (0)