Bug 912858 part.1 WidgetKeyboardEvent should be able to store .key value as string if the key name isn't one of pre-defined key names r=smaug

This commit is contained in:
Masayuki Nakano 2013-12-11 01:14:53 +09:00
Родитель 47e89f5bad
Коммит 377b8b8c96
2 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -107,6 +107,8 @@ public:
bool mIsRepeat;
// DOM KeyboardEvent.key
KeyNameIndex mKeyNameIndex;
// DOM KeyboardEvent.key only when mKeyNameIndex is KEY_NAME_INDEX_USE_STRING.
nsString mKeyValue;
// OS-specific native event can optionally be preserved
void* mNativeKeyEvent;
// Unique id associated with a keydown / keypress event. Used in identifing
@ -117,6 +119,10 @@ public:
void GetDOMKeyName(nsAString& aKeyName)
{
if (mKeyNameIndex == KEY_NAME_INDEX_USE_STRING) {
aKeyName = mKeyValue;
return;
}
GetDOMKeyName(mKeyNameIndex, aKeyName);
}
@ -147,6 +153,7 @@ public:
isChar = aEvent.isChar;
mIsRepeat = aEvent.mIsRepeat;
mKeyNameIndex = aEvent.mKeyNameIndex;
mKeyValue = aEvent.mKeyValue;
// Don't copy mNativeKeyEvent because it may be referred after its instance
// is destroyed.
mNativeKeyEvent = nullptr;

Просмотреть файл

@ -297,6 +297,7 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent>
{
WriteParam(aMsg, static_cast<mozilla::WidgetInputEvent>(aParam));
WriteParam(aMsg, static_cast<uint32_t>(aParam.mKeyNameIndex));
WriteParam(aMsg, aParam.mKeyValue);
WriteParam(aMsg, aParam.keyCode);
WriteParam(aMsg, aParam.charCode);
WriteParam(aMsg, aParam.isChar);
@ -313,6 +314,7 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent>
if (ReadParam(aMsg, aIter,
static_cast<mozilla::WidgetInputEvent*>(aResult)) &&
ReadParam(aMsg, aIter, &keyNameIndex) &&
ReadParam(aMsg, aIter, &aResult->mKeyValue) &&
ReadParam(aMsg, aIter, &aResult->keyCode) &&
ReadParam(aMsg, aIter, &aResult->charCode) &&
ReadParam(aMsg, aIter, &aResult->isChar) &&