From 377b8b8c968a365708c86a27533bffb89b76d5ad Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 11 Dec 2013 01:14:53 +0900 Subject: [PATCH] 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 --- widget/TextEvents.h | 7 +++++++ widget/nsGUIEventIPC.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/widget/TextEvents.h b/widget/TextEvents.h index aa0e40ed1a0c..a0bb6c85acc1 100644 --- a/widget/TextEvents.h +++ b/widget/TextEvents.h @@ -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; diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index e219d618705a..55980a74e046 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -297,6 +297,7 @@ struct ParamTraits { WriteParam(aMsg, static_cast(aParam)); WriteParam(aMsg, static_cast(aParam.mKeyNameIndex)); + WriteParam(aMsg, aParam.mKeyValue); WriteParam(aMsg, aParam.keyCode); WriteParam(aMsg, aParam.charCode); WriteParam(aMsg, aParam.isChar); @@ -313,6 +314,7 @@ struct ParamTraits if (ReadParam(aMsg, aIter, static_cast(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) &&