Bug 166240 part.1 Add D3E KeyboardEvent.location r=smaug, sr=jst

This commit is contained in:
Masayuki Nakano 2012-05-03 17:35:01 +09:00
parent 376873a657
commit 30ba20191d
5 changed files with 27 additions and 3 deletions

View File

@ -679,6 +679,7 @@ NS_METHOD nsDOMEvent::DuplicatePrivateData()
isInputEvent = true;
keyEvent->keyCode = oldKeyEvent->keyCode;
keyEvent->charCode = oldKeyEvent->charCode;
keyEvent->location = oldKeyEvent->location;
keyEvent->isChar = oldKeyEvent->isChar;
newEvent = keyEvent;
break;

View File

@ -184,6 +184,15 @@ nsDOMKeyboardEvent::Which(PRUint32* aWhich)
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,

View File

@ -39,7 +39,7 @@
#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;
@ -202,4 +202,13 @@ interface nsIDOMKeyEvent : nsIDOMUIEvent
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;
};

View File

@ -1113,7 +1113,8 @@ public:
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)
{
}
@ -1121,6 +1122,8 @@ public:
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;

View File

@ -193,6 +193,7 @@ struct ParamTraits<nsKeyEvent>
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)
@ -200,7 +201,8 @@ struct ParamTraits<nsKeyEvent>
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);
}
};