diff --git a/dom/base/TextInputProcessor.cpp b/dom/base/TextInputProcessor.cpp index e6506839b7ce..4fc6f9f4171a 100644 --- a/dom/base/TextInputProcessor.cpp +++ b/dom/base/TextInputProcessor.cpp @@ -766,6 +766,8 @@ TextInputProcessor::PrepareKeyboardEventToDispatch( aKeyboardEvent.mKeyNameIndex); } + aKeyboardEvent.mIsSynthesizedByTIP = (mForTests)? false : true; + return NS_OK; } diff --git a/widget/TextEvents.h b/widget/TextEvents.h index 69f47772bafd..dc803004c151 100644 --- a/widget/TextEvents.h +++ b/widget/TextEvents.h @@ -117,6 +117,8 @@ protected: , mNativeKeyCode(0) , mNativeModifierFlags(0) #endif + , mInputMethodAppState(eNotHandled) + , mIsSynthesizedByTIP(false) { } @@ -142,6 +144,8 @@ public: , mNativeKeyCode(0) , mNativeModifierFlags(0) #endif + , mInputMethodAppState(eNotHandled) + , mIsSynthesizedByTIP(false) { } @@ -211,6 +215,20 @@ public: nsString mPluginTextEventString; #endif + // Indicates that the event is being handled by input method app + typedef uint8_t InputMethodAppStateType; + enum InputMethodAppState : InputMethodAppStateType + { + eNotHandled, // not yet handled by intput method app + eHandling, // being handled by intput method app + eHandled // handled by input method app + }; + InputMethodAppState mInputMethodAppState; + + // Indicates whether the event is synthesized from Text Input Processor + // or an actual event from nsAppShell. + bool mIsSynthesizedByTIP; + // If the key should cause keypress events, this returns true. // Otherwise, false. bool ShouldCauseKeypressEvents() const; @@ -338,6 +356,8 @@ public: Assign(aEvent.mNativeCharactersIgnoringModifiers); mPluginTextEventString.Assign(aEvent.mPluginTextEventString); #endif + mInputMethodAppState = aEvent.mInputMethodAppState; + mIsSynthesizedByTIP = aEvent.mIsSynthesizedByTIP; } private: diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index 8b1c2edec9ff..7aa124754caa 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -384,6 +384,10 @@ struct ParamTraits WriteParam(aMsg, aParam.mIsRepeat); WriteParam(aMsg, aParam.location); WriteParam(aMsg, aParam.mUniqueId); + WriteParam(aMsg, aParam.mIsSynthesizedByTIP); + WriteParam(aMsg, + static_cast + (aParam.mInputMethodAppState)); #ifdef XP_MACOSX WriteParam(aMsg, aParam.mNativeKeyCode); WriteParam(aMsg, aParam.mNativeModifierFlags); @@ -398,6 +402,8 @@ struct ParamTraits static bool Read(const Message* aMsg, void** aIter, paramType* aResult) { uint32_t keyNameIndex = 0, codeNameIndex = 0; + mozilla::WidgetKeyboardEvent::InputMethodAppStateType + inputMethodAppState = 0; if (ReadParam(aMsg, aIter, static_cast(aResult)) && ReadParam(aMsg, aIter, &keyNameIndex) && @@ -411,7 +417,9 @@ struct ParamTraits ReadParam(aMsg, aIter, &aResult->isChar) && ReadParam(aMsg, aIter, &aResult->mIsRepeat) && ReadParam(aMsg, aIter, &aResult->location) && - ReadParam(aMsg, aIter, &aResult->mUniqueId) + ReadParam(aMsg, aIter, &aResult->mUniqueId) && + ReadParam(aMsg, aIter, &aResult->mIsSynthesizedByTIP) && + ReadParam(aMsg, aIter, &inputMethodAppState) #ifdef XP_MACOSX && ReadParam(aMsg, aIter, &aResult->mNativeKeyCode) && ReadParam(aMsg, aIter, &aResult->mNativeModifierFlags) @@ -425,6 +433,9 @@ struct ParamTraits aResult->mCodeNameIndex = static_cast(codeNameIndex); aResult->mNativeKeyEvent = nullptr; + aResult->mInputMethodAppState = + static_cast + (inputMethodAppState); return true; } return false; @@ -975,4 +986,3 @@ struct ParamTraits } // namespace IPC #endif // nsGUIEventIPC_h__ -