Bug 1110030 - part1 - add flags:IsSynthesizedByTIP and InputMethodAppState in WidgetKeyboardEvent. r=masayuki

This commit is contained in:
chunminchang 2016-03-15 13:50:16 +08:00
parent 923a48177b
commit 55f5e1cc1b
3 changed files with 34 additions and 2 deletions

View File

@ -766,6 +766,8 @@ TextInputProcessor::PrepareKeyboardEventToDispatch(
aKeyboardEvent.mKeyNameIndex);
}
aKeyboardEvent.mIsSynthesizedByTIP = (mForTests)? false : true;
return NS_OK;
}

View File

@ -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:

View File

@ -384,6 +384,10 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent>
WriteParam(aMsg, aParam.mIsRepeat);
WriteParam(aMsg, aParam.location);
WriteParam(aMsg, aParam.mUniqueId);
WriteParam(aMsg, aParam.mIsSynthesizedByTIP);
WriteParam(aMsg,
static_cast<mozilla::WidgetKeyboardEvent::InputMethodAppStateType>
(aParam.mInputMethodAppState));
#ifdef XP_MACOSX
WriteParam(aMsg, aParam.mNativeKeyCode);
WriteParam(aMsg, aParam.mNativeModifierFlags);
@ -398,6 +402,8 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent>
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<mozilla::WidgetInputEvent*>(aResult)) &&
ReadParam(aMsg, aIter, &keyNameIndex) &&
@ -411,7 +417,9 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent>
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<mozilla::WidgetKeyboardEvent>
aResult->mCodeNameIndex =
static_cast<mozilla::CodeNameIndex>(codeNameIndex);
aResult->mNativeKeyEvent = nullptr;
aResult->mInputMethodAppState =
static_cast<mozilla::WidgetKeyboardEvent::InputMethodAppState>
(inputMethodAppState);
return true;
}
return false;
@ -975,4 +986,3 @@ struct ParamTraits<mozilla::widget::CandidateWindowPosition>
} // namespace IPC
#endif // nsGUIEventIPC_h__