Bug 1453397 - use ContiguousEnumSerializer for serialization of enums in IPC for IMEs; r=masayuki
authorAlex Gaynor <agaynor@mozilla.com>
Wed, 11 Apr 2018 12:26:33 -0400
changeset 412980 775374240991a0bb94bea3e0a24d3750b92a5f13
parent 412979 2b5a2f284d0f9c51aa9c811d4bc7e3efdf8ba23f
child 412981 daed9174cdab67adb51b3923d143c3c905f14689
push id33828
push userarchaeopteryx@coole-files.de
push dateThu, 12 Apr 2018 19:19:41 +0000
treeherdermozilla-central@6e22c4a726c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1453397
milestone61.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 1453397 - use ContiguousEnumSerializer for serialization of enums in IPC for IMEs; r=masayuki MozReview-Commit-ID: Enfhhu2HnH5
dom/ipc/PBrowser.ipdl
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
widget/PuppetWidget.cpp
widget/nsGUIEventIPC.h
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -45,16 +45,20 @@ using mozilla::layers::MaybeZoomConstrai
 using mozilla::layers::GeckoContentController::TapType from "mozilla/layers/GeckoContentController.h";
 using FrameMetrics::ViewID from "FrameMetrics.h";
 using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
 using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
 using nscolor from "nsColor.h";
 using class mozilla::WidgetCompositionEvent from "ipc/nsGUIEventIPC.h";
 using struct mozilla::widget::IMENotification from "mozilla/widget/IMEData.h";
 using struct mozilla::widget::IMENotificationRequests from "mozilla/widget/IMEData.h";
+using mozilla::widget::IMEState::Enabled from "mozilla/widget/IMEData.h";
+using mozilla::widget::IMEState::Open from "mozilla/widget/IMEData.h";
+using mozilla::widget::InputContextAction::Cause from "mozilla/widget/IMEData.h";
+using mozilla::widget::InputContextAction::FocusChange from "mozilla/widget/IMEData.h";
 using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
 using mozilla::gfx::IntPoint from "mozilla/gfx/Point.h";
 using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
 using class mozilla::ContentCache from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetKeyboardEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetMouseEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetWheelEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetDragEvent from "ipc/nsGUIEventIPC.h";
@@ -340,27 +344,27 @@ parent:
     /**
      * Indicate, based on the current state, that some commands are enabled and
      * some are disabled.
      */
     async EnableDisableCommands(nsString action,
                                 nsCString[] enabledCommands,
                                 nsCString[] disabledCommands);
 
-    nested(inside_cpow) sync GetInputContext() returns (int32_t IMEEnabled,
-                                                        int32_t IMEOpen);
+    nested(inside_cpow) sync GetInputContext() returns (Enabled IMEEnabled,
+                                                        Open IMEOpen);
 
-    nested(inside_cpow) async SetInputContext(int32_t IMEEnabled,
-                                              int32_t IMEOpen,
+    nested(inside_cpow) async SetInputContext(Enabled IMEEnabled,
+                                              Open IMEOpen,
                                               nsString type,
                                               nsString inputmode,
                                               nsString actionHint,
                                               bool inPrivateBrowsing,
-                                              int32_t cause,
-                                              int32_t focusChange);
+                                              Cause cause,
+                                              FocusChange focusChange);
 
     sync IsParentWindowMainWidgetVisible() returns (bool visible);
 
     /**
      * Set the native cursor.
      * @param value
      *   The widget cursor to set.
      * @param force
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -2438,54 +2438,53 @@ TabParent::RecvDefaultProcOfPluginEvent(
     return IPC_OK();
   }
 
   widget->DefaultProcOfPluginEvent(aEvent);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
-TabParent::RecvGetInputContext(int32_t* aIMEEnabled,
-                               int32_t* aIMEOpen)
+TabParent::RecvGetInputContext(IMEState::Enabled* aIMEEnabled,
+                               IMEState::Open* aIMEOpen)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     *aIMEEnabled = IMEState::DISABLED;
     *aIMEOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
     return IPC_OK();
   }
 
   InputContext context = widget->GetInputContext();
-  *aIMEEnabled = static_cast<int32_t>(context.mIMEState.mEnabled);
-  *aIMEOpen = static_cast<int32_t>(context.mIMEState.mOpen);
+  *aIMEEnabled = context.mIMEState.mEnabled;
+  *aIMEOpen = context.mIMEState.mOpen;
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
-TabParent::RecvSetInputContext(const int32_t& aIMEEnabled,
-                               const int32_t& aIMEOpen,
-                               const nsString& aType,
-                               const nsString& aInputmode,
-                               const nsString& aActionHint,
-                               const bool& aInPrivateBrowsing,
-                               const int32_t& aCause,
-                               const int32_t& aFocusChange)
+TabParent::RecvSetInputContext(
+  const IMEState::Enabled& aIMEEnabled,
+  const IMEState::Open& aIMEOpen,
+  const nsString& aType,
+  const nsString& aInputmode,
+  const nsString& aActionHint,
+  const bool& aInPrivateBrowsing,
+  const InputContextAction::Cause& aCause,
+  const InputContextAction::FocusChange& aFocusChange)
 {
   InputContext context;
-  context.mIMEState.mEnabled = static_cast<IMEState::Enabled>(aIMEEnabled);
-  context.mIMEState.mOpen = static_cast<IMEState::Open>(aIMEOpen);
+  context.mIMEState.mEnabled = aIMEEnabled;
+  context.mIMEState.mOpen = aIMEOpen;
   context.mHTMLInputType.Assign(aType);
   context.mHTMLInputInputmode.Assign(aInputmode);
   context.mActionHint.Assign(aActionHint);
   context.mOrigin = InputContext::ORIGIN_CONTENT;
   context.mInPrivateBrowsing = aInPrivateBrowsing;
 
-  InputContextAction action(
-    static_cast<InputContextAction::Cause>(aCause),
-    static_cast<InputContextAction::FocusChange>(aFocusChange));
+  InputContextAction action(aCause, aFocusChange);
 
   IMEStateManager::SetInputContextForChildProcess(this, context, action);
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 TabParent::RecvIsParentWindowMainWidgetVisible(bool* aIsVisible)
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -233,28 +233,29 @@ public:
   virtual mozilla::ipc::IPCResult RecvSetPluginFocused(const bool& aFocused) override;
 
   virtual mozilla::ipc::IPCResult RecvSetCandidateWindowForPlugin(
     const widget::CandidateWindowPosition& aPosition) override;
 
   virtual mozilla::ipc::IPCResult
   RecvDefaultProcOfPluginEvent(const WidgetPluginEvent& aEvent) override;
 
-  virtual mozilla::ipc::IPCResult RecvGetInputContext(int32_t* aIMEEnabled,
-                                                      int32_t* aIMEOpen) override;
+  virtual mozilla::ipc::IPCResult RecvGetInputContext(
+    widget::IMEState::Enabled* aIMEEnabled,
+    widget::IMEState::Open* aIMEOpen) override;
 
-  virtual mozilla::ipc::IPCResult RecvSetInputContext(const int32_t& aIMEEnabled,
-                                                      const int32_t& aIMEOpen,
-                                                      const nsString& aType,
-                                                      const nsString& aInputmode,
-                                                      const nsString& aActionHint,
-                                                      const bool& aInPrivateBrowsing,
-                                                      const int32_t& aCause,
-                                                      const int32_t& aFocusChange) override;
-
+  virtual mozilla::ipc::IPCResult RecvSetInputContext(
+    const widget::IMEState::Enabled& aIMEEnabled,
+    const widget::IMEState::Open& aIMEOpen,
+    const nsString& aType,
+    const nsString& aInputmode,
+    const nsString& aActionHint,
+    const bool& aInPrivateBrowsing,
+    const widget::InputContextAction::Cause& aCause,
+    const widget::InputContextAction::FocusChange& aFocusChange) override;
 
   // See nsIKeyEventInPluginCallback
   virtual void HandledWindowedPluginKeyEvent(
                  const NativeEventData& aKeyEventData,
                  bool aIsConsumed) override;
 
   virtual mozilla::ipc::IPCResult RecvOnWindowedPluginKeyEvent(
     const NativeEventData& aKeyEventData) override;
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -758,25 +758,24 @@ PuppetWidget::SetInputContext(const Inpu
   mInputContext = aContext;
   // Any widget instances cannot cache IME open state because IME open state
   // can be changed by user but native IME may not notify us of changing the
   // open state on some platforms.
   mInputContext.mIMEState.mOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
   if (!mTabChild) {
     return;
   }
-  mTabChild->SendSetInputContext(
-    static_cast<int32_t>(aContext.mIMEState.mEnabled),
-    static_cast<int32_t>(aContext.mIMEState.mOpen),
-    aContext.mHTMLInputType,
-    aContext.mHTMLInputInputmode,
-    aContext.mActionHint,
-    aContext.mInPrivateBrowsing,
-    static_cast<int32_t>(aAction.mCause),
-    static_cast<int32_t>(aAction.mFocusChange));
+  mTabChild->SendSetInputContext(aContext.mIMEState.mEnabled,
+                                 aContext.mIMEState.mOpen,
+                                 aContext.mHTMLInputType,
+                                 aContext.mHTMLInputInputmode,
+                                 aContext.mActionHint,
+                                 aContext.mInPrivateBrowsing,
+                                 aAction.mCause,
+                                 aAction.mFocusChange);
 }
 
 InputContext
 PuppetWidget::GetInputContext()
 {
   // XXX Currently, we don't support retrieving IME open state from child
   //     process.
 
@@ -790,20 +789,21 @@ PuppetWidget::GetInputContext()
 
   NS_WARNING("PuppetWidget::GetInputContext() needs to retrieve it with IPC");
 
   // Don't cache InputContext here because this process isn't managing IME
   // state of the chrome widget.  So, we cannot modify mInputContext when
   // chrome widget is set to new context.
   InputContext context;
   if (mTabChild) {
-    int32_t enabled, open;
+    IMEState::Enabled enabled;
+    IMEState::Open open;
     mTabChild->SendGetInputContext(&enabled, &open);
-    context.mIMEState.mEnabled = static_cast<IMEState::Enabled>(enabled);
-    context.mIMEState.mOpen = static_cast<IMEState::Open>(open);
+    context.mIMEState.mEnabled = enabled;
+    context.mIMEState.mOpen = open;
   }
   return context;
 }
 
 NativeIMEContext
 PuppetWidget::GetNativeIMEContext()
 {
   return mNativeIMEContext;
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -944,16 +944,52 @@ struct ParamTraits<mozilla::widget::IMEN
         return ReadParam(aMsg, aIter, &aResult->mMouseButtonEventData);
       default:
         return true;
     }
   }
 };
 
 template<>
+struct ParamTraits<mozilla::widget::IMEState::Enabled>
+  : ContiguousEnumSerializer<mozilla::widget::IMEState::Enabled,
+                             mozilla::widget::IMEState::Enabled::DISABLED,
+                             mozilla::widget::IMEState::Enabled::UNKNOWN>
+{
+};
+
+template<>
+struct ParamTraits<mozilla::widget::IMEState::Open>
+  : ContiguousEnumSerializerInclusive<
+      mozilla::widget::IMEState::Open,
+      mozilla::widget::IMEState::Open::OPEN_STATE_NOT_SUPPORTED,
+      mozilla::widget::IMEState::Open::CLOSED>
+{
+};
+
+template<>
+struct ParamTraits<mozilla::widget::InputContextAction::Cause>
+  : ContiguousEnumSerializerInclusive<
+      mozilla::widget::InputContextAction::Cause,
+      mozilla::widget::InputContextAction::Cause::CAUSE_UNKNOWN,
+      mozilla::widget::InputContextAction::Cause::
+        CAUSE_UNKNOWN_DURING_KEYBOARD_INPUT>
+{
+};
+
+template<>
+struct ParamTraits<mozilla::widget::InputContextAction::FocusChange>
+  : ContiguousEnumSerializerInclusive<
+      mozilla::widget::InputContextAction::FocusChange,
+      mozilla::widget::InputContextAction::FocusChange::FOCUS_NOT_CHANGED,
+      mozilla::widget::InputContextAction::FocusChange::WIDGET_CREATED>
+{
+};
+
+template<>
 struct ParamTraits<mozilla::WidgetPluginEvent>
 {
   typedef mozilla::WidgetPluginEvent paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<const mozilla::WidgetGUIEvent&>(aParam));
     WriteParam(aMsg, aParam.mRetargetToFocusedDocument);