Bug 1110030 - part1 - add flags:IsSynthesizedByTIP and InputMethodAppState in WidgetKeyboardEvent. r=masayuki
authorchunminchang <cchang@mozilla.com>
Tue, 15 Mar 2016 13:50:16 +0800
changeset 328832 341c531db14221b3efe74518c8f7ff76bb99dc48
parent 328831 7f1ca2749ce7060fef60202c3125cad9e448436b
child 328833 5d9e6b3810fe593cbdbe42f1356139f7dfcf9a9a
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1110030
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1110030 - part1 - add flags:IsSynthesizedByTIP and InputMethodAppState in WidgetKeyboardEvent. r=masayuki
dom/base/TextInputProcessor.cpp
widget/TextEvents.h
widget/nsGUIEventIPC.h
--- a/dom/base/TextInputProcessor.cpp
+++ b/dom/base/TextInputProcessor.cpp
@@ -761,16 +761,18 @@ TextInputProcessor::PrepareKeyboardEvent
     // If KeyboardEvent.keyCode is 0, it may be uninitialized.  If so, we may
     // be able to decide a good .keyCode value if the .key value is a
     // non-printable key.
     aKeyboardEvent.keyCode =
       WidgetKeyboardEvent::ComputeKeyCodeFromKeyNameIndex(
         aKeyboardEvent.mKeyNameIndex);
   }
 
+  aKeyboardEvent.mIsSynthesizedByTIP = (mForTests)? false : true;
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TextInputProcessor::Keydown(nsIDOMKeyEvent* aDOMKeyEvent,
                             uint32_t aKeyFlags,
                             uint8_t aOptionalArgc,
                             uint32_t* aConsumedFlags)
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -112,16 +112,18 @@ protected:
     , mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified)
     , mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN)
     , mNativeKeyEvent(nullptr)
     , mUniqueId(0)
 #ifdef XP_MACOSX
     , mNativeKeyCode(0)
     , mNativeModifierFlags(0)
 #endif
+    , mInputMethodAppState(eNotHandled)
+    , mIsSynthesizedByTIP(false)
   {
   }
 
 public:
   virtual WidgetKeyboardEvent* AsKeyboardEvent() override { return this; }
 
   WidgetKeyboardEvent(bool aIsTrusted, EventMessage aMessage,
                       nsIWidget* aWidget,
@@ -137,16 +139,18 @@ public:
     , mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified)
     , mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN)
     , mNativeKeyEvent(nullptr)
     , mUniqueId(0)
 #ifdef XP_MACOSX
     , mNativeKeyCode(0)
     , mNativeModifierFlags(0)
 #endif
+    , mInputMethodAppState(eNotHandled)
+    , mIsSynthesizedByTIP(false)
   {
   }
 
   virtual WidgetEvent* Duplicate() const override
   {
     MOZ_ASSERT(mClass == eKeyboardEventClass,
                "Duplicate() must be overridden by sub class");
     // Not copying widget, it is a weak reference.
@@ -206,16 +210,30 @@ public:
   uint32_t mNativeModifierFlags;
   nsString mNativeCharacters;
   nsString mNativeCharactersIgnoringModifiers;
   // If this is non-empty, create a text event for plugins instead of a
   // keyboard event.
   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;
 
   // charCode value of non-eKeyPress events is always 0.  However, if
   // non-eKeyPress event has one or more alternative char code values,
   // its first item should be the charCode value of following eKeyPress event.
   // PseudoCharCode() returns charCode value for eKeyPress event,
@@ -333,16 +351,18 @@ public:
 #ifdef XP_MACOSX
     mNativeKeyCode = aEvent.mNativeKeyCode;
     mNativeModifierFlags = aEvent.mNativeModifierFlags;
     mNativeCharacters.Assign(aEvent.mNativeCharacters);
     mNativeCharactersIgnoringModifiers.
       Assign(aEvent.mNativeCharactersIgnoringModifiers);
     mPluginTextEventString.Assign(aEvent.mPluginTextEventString);
 #endif
+    mInputMethodAppState = aEvent.mInputMethodAppState;
+    mIsSynthesizedByTIP = aEvent.mIsSynthesizedByTIP;
   }
 
 private:
   static const char16_t* const kKeyNames[];
   static const char16_t* const kCodeNames[];
   typedef nsDataHashtable<nsStringHashKey,
                           KeyNameIndex> KeyNameIndexHashtable;
   typedef nsDataHashtable<nsStringHashKey,
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -379,57 +379,68 @@ struct ParamTraits<mozilla::WidgetKeyboa
     WriteParam(aMsg, aParam.keyCode);
     WriteParam(aMsg, aParam.charCode);
     WriteParam(aMsg, aParam.mPseudoCharCode);
     WriteParam(aMsg, aParam.alternativeCharCodes);
     WriteParam(aMsg, aParam.isChar);
     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);
     WriteParam(aMsg, aParam.mNativeCharacters);
     WriteParam(aMsg, aParam.mNativeCharactersIgnoringModifiers);
     WriteParam(aMsg, aParam.mPluginTextEventString);
 #endif
     // An OS-specific native event might be attached in |mNativeKeyEvent|,  but
     // that cannot be copied across process boundaries.
   }
 
   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) &&
         ReadParam(aMsg, aIter, &codeNameIndex) &&
         ReadParam(aMsg, aIter, &aResult->mKeyValue) &&
         ReadParam(aMsg, aIter, &aResult->mCodeValue) &&
         ReadParam(aMsg, aIter, &aResult->keyCode) &&
         ReadParam(aMsg, aIter, &aResult->charCode) &&
         ReadParam(aMsg, aIter, &aResult->mPseudoCharCode) &&
         ReadParam(aMsg, aIter, &aResult->alternativeCharCodes) &&
         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)
         && ReadParam(aMsg, aIter, &aResult->mNativeCharacters)
         && ReadParam(aMsg, aIter, &aResult->mNativeCharactersIgnoringModifiers)
         && ReadParam(aMsg, aIter, &aResult->mPluginTextEventString)
 #endif
         )
     {
       aResult->mKeyNameIndex = static_cast<mozilla::KeyNameIndex>(keyNameIndex);
       aResult->mCodeNameIndex =
         static_cast<mozilla::CodeNameIndex>(codeNameIndex);
       aResult->mNativeKeyEvent = nullptr;
+      aResult->mInputMethodAppState =
+        static_cast<mozilla::WidgetKeyboardEvent::InputMethodAppState>
+          (inputMethodAppState);
       return true;
     }
     return false;
   }
 };
 
 template<>
 struct ParamTraits<mozilla::InternalBeforeAfterKeyboardEvent>
@@ -970,9 +981,8 @@ struct ParamTraits<mozilla::widget::Cand
            ReadParam(aMsg, aIter, &aResult->mRect) &&
            ReadParam(aMsg, aIter, &aResult->mExcludeRect);
   }
 };
 
 } // namespace IPC
 
 #endif // nsGUIEventIPC_h__
-