Bug 1184004 part.3 IPC methods to notify IME should use IMENotification for its argument r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 17 Jul 2015 13:30:01 +0900
changeset 285094 9a31fa80ee8c647940dd075d27181ab9d688cc52
parent 285093 314c6be265d0630c31fcc6459a89970e3616bbe6
child 285095 c7e2eb0b375c1551820193a63373a23620aa2d64
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1184004
milestone42.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 1184004 part.3 IPC methods to notify IME should use IMENotification for its argument r=smaug
dom/ipc/PBrowser.ipdl
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
widget/ContentCache.cpp
widget/ContentCache.h
widget/PuppetWidget.cpp
widget/PuppetWidget.h
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -177,61 +177,52 @@ parent:
     prio(high) sync RpcMessage(nsString aMessage, ClonedMessageData aData,
                                CpowEntry[] aCpows, Principal aPrincipal)
       returns (OwningSerializedStructuredCloneBuffer[] retval);
 
     /**
      * Notifies chrome that there is a focus change involving an editable
      * object (input, textarea, document, contentEditable. etc.)
      *
-     *  focus        PR_TRUE if editable object is receiving focus
-     *               PR_FALSE if losing focus
      *  contentCache Cache of content
+     *  notification Whole data of the notification
      *  preference   Native widget preference for IME updates
      */
-    prio(urgent) sync NotifyIMEFocus(bool focus, ContentCache contentCache)
+    prio(urgent) sync NotifyIMEFocus(ContentCache contentCache,
+                                     IMENotification notification)
       returns (nsIMEUpdatePreference preference);
 
     /**
      * Notifies chrome that there has been a change in text content
      * One call can encompass both a delete and an insert operation
      * Only called when NotifyIMEFocus returns PR_TRUE for mWantUpdates
      *
      *  contentCache Cache of content
-     *  offset       Starting offset of the change
-     *  removedEnd   Ending offset of the range deleted
-     *  addedEnd     New ending offset after insertion
-     *  causedByComposition true if the change is caused by composition
-     *
-     *  for insertion, offset == end
-     *  for deletion, offset == newEnd
+     *  notification Whole data of the notification
      */
     prio(urgent) async NotifyIMETextChange(ContentCache contentCache,
-                                           uint32_t offset, uint32_t removedEnd,
-                                           uint32_t addedEnd,
-                                           bool causedByComposition);
+                                           IMENotification notification);
 
     /**
      * Notifies chrome that there is a IME compostion rect updated
      *
      *  contentCache Cache of content
      */
-    prio(urgent) async NotifyIMESelectedCompositionRect(ContentCache contentCache);
+    prio(urgent) async NotifyIMECompositionUpdate(ContentCache contentCache,
+                                                  IMENotification notification);
 
     /**
      * Notifies chrome that there has been a change in selection
      * Only called when NotifyIMEFocus returns PR_TRUE for mWantUpdates
      *
      *  contentCache Cache of content
-     *  causedByComposition true if the change is caused by composition
-     *  causedBySelectionEvent true if the change is caused by selection event
+     *  notification Whole data of the notification
      */
     prio(urgent) async NotifyIMESelection(ContentCache contentCache,
-                                          bool causedByComposition,
-                                          bool causedBySelectionEvent);
+                                          IMENotification notification);
 
     /**
      * Notifies chrome of updating its content cache.
      * This is useful if content is modified but we don't need to notify IME.
      *
      *  contentCache Cache of content
      */
     prio(urgent) async UpdateContentCache(ContentCache contentCache);
@@ -244,17 +235,18 @@ parent:
     prio(urgent) sync NotifyIMEMouseButtonEvent(IMENotification notification)
       returns (bool consumedByIME);
 
     /**
      * Notifies chrome to position change
      *
      *  contentCache Cache of content
      */
-    prio(urgent) async NotifyIMEPositionChange(ContentCache contentCache);
+    prio(urgent) async NotifyIMEPositionChange(ContentCache contentCache,
+                                               IMENotification notification);
 
     /**
      * Instructs chrome to end any pending composition
      *
      *  cancel       true if composition should be cancelled
      *  noCompositionEvent   true if no composition event is fired by commit or
      *                       cancel
      *  composition  Text to commit before ending the composition
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1947,105 +1947,88 @@ TabParent::RecvHideTooltip()
     return true;
   }
 
   xulBrowserWindow->HideTooltip();
   return true;
 }
 
 bool
-TabParent::RecvNotifyIMEFocus(const bool& aFocus,
-                              const ContentCache& aContentCache,
+TabParent::RecvNotifyIMEFocus(const ContentCache& aContentCache,
+                              const IMENotification& aIMENotification,
                               nsIMEUpdatePreference* aPreference)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     *aPreference = nsIMEUpdatePreference();
     return true;
   }
 
-  IMENotification notification(aFocus ? NOTIFY_IME_OF_FOCUS :
-                                        NOTIFY_IME_OF_BLUR);
-  mContentCache.AssignContent(aContentCache, &notification);
-  IMEStateManager::NotifyIME(notification, widget, true);
-
-  if (aFocus) {
+  mContentCache.AssignContent(aContentCache, &aIMENotification);
+  IMEStateManager::NotifyIME(aIMENotification, widget, true);
+
+  if (aIMENotification.mMessage == NOTIFY_IME_OF_FOCUS) {
     *aPreference = widget->GetIMEUpdatePreference();
   }
   return true;
 }
 
 bool
 TabParent::RecvNotifyIMETextChange(const ContentCache& aContentCache,
-                                   const uint32_t& aStart,
-                                   const uint32_t& aRemovedEnd,
-                                   const uint32_t& aAddedEnd,
-                                   const bool& aCausedByComposition)
+                                   const IMENotification& aIMENotification)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget)
     return true;
 
 #ifdef DEBUG
   nsIMEUpdatePreference updatePreference = widget->GetIMEUpdatePreference();
   NS_ASSERTION(updatePreference.WantTextChange(),
                "Don't call Send/RecvNotifyIMETextChange without NOTIFY_TEXT_CHANGE");
-  MOZ_ASSERT(!aCausedByComposition ||
+  MOZ_ASSERT(!aIMENotification.mTextChangeData.mCausedByComposition ||
                updatePreference.WantChangesCausedByComposition(),
     "The widget doesn't want text change notification caused by composition");
 #endif
 
-  IMENotification notification(NOTIFY_IME_OF_TEXT_CHANGE);
-  notification.mTextChangeData.mStartOffset = aStart;
-  notification.mTextChangeData.mRemovedEndOffset = aRemovedEnd;
-  notification.mTextChangeData.mAddedEndOffset = aAddedEnd;
-  notification.mTextChangeData.mCausedByComposition = aCausedByComposition;
-
-  mContentCache.AssignContent(aContentCache, &notification);
-  mContentCache.MaybeNotifyIME(widget, notification);
+  mContentCache.AssignContent(aContentCache, &aIMENotification);
+  mContentCache.MaybeNotifyIME(widget, aIMENotification);
   return true;
 }
 
 bool
-TabParent::RecvNotifyIMESelectedCompositionRect(
-             const ContentCache& aContentCache)
+TabParent::RecvNotifyIMECompositionUpdate(
+             const ContentCache& aContentCache,
+             const IMENotification& aIMENotification)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return true;
   }
 
-  IMENotification notification(NOTIFY_IME_OF_COMPOSITION_UPDATE);
-  mContentCache.AssignContent(aContentCache, &notification);
-  mContentCache.MaybeNotifyIME(widget, notification);
+  mContentCache.AssignContent(aContentCache, &aIMENotification);
+  mContentCache.MaybeNotifyIME(widget, aIMENotification);
   return true;
 }
 
 bool
 TabParent::RecvNotifyIMESelection(const ContentCache& aContentCache,
-                                  const bool& aCausedByComposition,
-                                  const bool& aCausedBySelectionEvent)
+                                  const IMENotification& aIMENotification)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget)
     return true;
 
-  IMENotification notification(NOTIFY_IME_OF_SELECTION_CHANGE);
-  mContentCache.AssignContent(aContentCache, &notification);
+  mContentCache.AssignContent(aContentCache, &aIMENotification);
 
   const nsIMEUpdatePreference updatePreference =
     widget->GetIMEUpdatePreference();
   if (updatePreference.WantSelectionChange() &&
       (updatePreference.WantChangesCausedByComposition() ||
-       !aCausedByComposition)) {
-    notification.mSelectionChangeData.mCausedByComposition =
-      aCausedByComposition;
-    notification.mSelectionChangeData.mCausedBySelectionEvent =
-      aCausedBySelectionEvent;
-    mContentCache.MaybeNotifyIME(widget, notification);
+       !aIMENotification.mSelectionChangeData.mCausedByComposition)) {
+    mContentCache.MaybeNotifyIME(widget, aIMENotification);
   }
   return true;
 }
 
 bool
 TabParent::RecvUpdateContentCache(const ContentCache& aContentCache)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
@@ -2069,30 +2052,30 @@ TabParent::RecvNotifyIMEMouseButtonEvent
     return true;
   }
   nsresult rv = IMEStateManager::NotifyIME(aIMENotification, widget, true);
   *aConsumedByIME = rv == NS_SUCCESS_EVENT_CONSUMED;
   return true;
 }
 
 bool
-TabParent::RecvNotifyIMEPositionChange(const ContentCache& aContentCache)
+TabParent::RecvNotifyIMEPositionChange(const ContentCache& aContentCache,
+                                       const IMENotification& aIMENotification)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return true;
   }
 
-  IMENotification notification(NOTIFY_IME_OF_POSITION_CHANGE);
-  mContentCache.AssignContent(aContentCache, &notification);
+  mContentCache.AssignContent(aContentCache, &aIMENotification);
 
   const nsIMEUpdatePreference updatePreference =
     widget->GetIMEUpdatePreference();
   if (updatePreference.WantPositionChanged()) {
-    IMEStateManager::NotifyIME(notification, widget, true);
+    IMEStateManager::NotifyIME(aIMENotification, widget, true);
   }
   return true;
 }
 
 bool
 TabParent::RecvOnEventNeedingAckReceived(const uint32_t& aMessage)
 {
   // This is called when the child process receives WidgetCompositionEvent or
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -157,33 +157,31 @@ public:
                                 const ClonedMessageData& aData,
                                 InfallibleTArray<CpowEntry>&& aCpows,
                                 const IPC::Principal& aPrincipal,
                                 nsTArray<OwningSerializedStructuredCloneBuffer>* aRetVal) override;
     virtual bool RecvAsyncMessage(const nsString& aMessage,
                                   const ClonedMessageData& aData,
                                   InfallibleTArray<CpowEntry>&& aCpows,
                                   const IPC::Principal& aPrincipal) override;
-    virtual bool RecvNotifyIMEFocus(const bool& aFocus,
-                                    const ContentCache& aContentCache,
+    virtual bool RecvNotifyIMEFocus(const ContentCache& aContentCache,
+                                    const widget::IMENotification& aEventMessage,
                                     nsIMEUpdatePreference* aPreference)
                                       override;
     virtual bool RecvNotifyIMETextChange(const ContentCache& aContentCache,
-                                         const uint32_t& aStart,
-                                         const uint32_t& aRemovedEnd,
-                                         const uint32_t& aAddedEnd,
-                                         const bool& aCausedByComposition) override;
-    virtual bool RecvNotifyIMESelectedCompositionRect(const ContentCache& aContentCache) override;
+                                         const widget::IMENotification& aEventMessage) override;
+    virtual bool RecvNotifyIMECompositionUpdate(const ContentCache& aContentCache,
+                                                const widget::IMENotification& aEventMessage) override;
     virtual bool RecvNotifyIMESelection(const ContentCache& aContentCache,
-                                        const bool& aCausedByComposition,
-                                        const bool& aCausedBySelectionEvent) override;
+                                        const widget::IMENotification& aEventMessage) override;
     virtual bool RecvUpdateContentCache(const ContentCache& aContentCache) override;
     virtual bool RecvNotifyIMEMouseButtonEvent(const widget::IMENotification& aEventMessage,
                                                bool* aConsumedByIME) override;
-    virtual bool RecvNotifyIMEPositionChange(const ContentCache& aContentCache) override;
+    virtual bool RecvNotifyIMEPositionChange(const ContentCache& aContentCache,
+                                             const widget::IMENotification& aEventMessage) override;
     virtual bool RecvOnEventNeedingAckReceived(const uint32_t& aMessage) override;
     virtual bool RecvEndIMEComposition(const bool& aCancel,
                                        bool* aNoCompositionEvent,
                                        nsString* aComposition) override;
     virtual bool RecvStartPluginIME(const WidgetKeyboardEvent& aKeyboardEvent,
                                     const int32_t& aPanelX,
                                     const int32_t& aPanelY,
                                     nsString* aCommitted) override;
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -955,25 +955,18 @@ ContentCacheInParent::RequestToCommitCom
   mRequestedToCommitOrCancelComposition = false;
   aLastString = mCommitStringByRequest;
   mCommitStringByRequest.Truncate(0);
   return mCompositionEventsDuringRequest;
 }
 
 void
 ContentCacheInParent::MaybeNotifyIME(nsIWidget* aWidget,
-                                     IMENotification& aNotification)
+                                     const IMENotification& aNotification)
 {
-  if (aNotification.mMessage == NOTIFY_IME_OF_SELECTION_CHANGE) {
-    aNotification.mSelectionChangeData.mOffset = mSelection.StartOffset();
-    aNotification.mSelectionChangeData.mLength = mSelection.Length();
-    aNotification.mSelectionChangeData.mReversed = mSelection.Reversed();
-    aNotification.mSelectionChangeData.SetWritingMode(mSelection.mWritingMode);
-  }
-
   if (!mPendingEventsNeedingAck) {
     IMEStateManager::NotifyIME(aNotification, aWidget, true);
     return;
   }
 
   switch (aNotification.mMessage) {
     case NOTIFY_IME_OF_SELECTION_CHANGE:
       mPendingSelectionChange.MergeWith(aNotification);
--- a/widget/ContentCache.h
+++ b/widget/ContentCache.h
@@ -343,17 +343,17 @@ public:
                                       nsAString& aLastString);
 
   /**
    * MaybeNotifyIME() may notify IME of the notification.  If child process
    * hasn't been handled all sending events yet, this stores the notification
    * and flush it later.
    */
   void MaybeNotifyIME(nsIWidget* aWidget,
-                      IMENotification& aNotification);
+                      const IMENotification& aNotification);
 
 private:
   IMENotification mPendingSelectionChange;
   IMENotification mPendingTextChange;
   IMENotification mPendingCompositionUpdate;
 
   // This is commit string which is caused by our request.
   nsString mCommitStringByRequest;
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -133,18 +133,18 @@ PuppetWidget::Create(nsIWidget        *a
 }
 
 void
 PuppetWidget::InitIMEState()
 {
   MOZ_ASSERT(mTabChild);
   if (mNeedIMEStateInit) {
     mContentCache.Clear();
-    mTabChild->SendNotifyIMEFocus(false, mContentCache,
-                                  &mIMEPreferenceOfParent);
+    mTabChild->SendUpdateContentCache(mContentCache);
+    mIMEPreferenceOfParent = nsIMEUpdatePreference();
     mNeedIMEStateInit = false;
   }
 }
 
 already_AddRefed<nsIWidget>
 PuppetWidget::CreateChild(const nsIntRect  &aRect,
                           nsWidgetInitData *aInitData,
                           bool             aForceUseIWidgetParent)
@@ -595,17 +595,17 @@ PuppetWidget::NotifyIMEInternal(const IM
     case NOTIFY_IME_OF_FOCUS:
     case NOTIFY_IME_OF_BLUR:
       return NotifyIMEOfFocusChange(aIMENotification);
     case NOTIFY_IME_OF_SELECTION_CHANGE:
       return NotifyIMEOfSelectionChange(aIMENotification);
     case NOTIFY_IME_OF_TEXT_CHANGE:
       return NotifyIMEOfTextChange(aIMENotification);
     case NOTIFY_IME_OF_COMPOSITION_UPDATE:
-      return NotifyIMEOfUpdateComposition(aIMENotification);
+      return NotifyIMEOfCompositionUpdate(aIMENotification);
     case NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
       return NotifyIMEOfMouseButtonEvent(aIMENotification);
     case NOTIFY_IME_OF_POSITION_CHANGE:
       return NotifyIMEOfPositionChange(aIMENotification);
     default:
       return NS_ERROR_NOT_IMPLEMENTED;
   }
 }
@@ -689,37 +689,37 @@ PuppetWidget::NotifyIMEOfFocusChange(con
       return NS_ERROR_FAILURE;
     }
   } else {
     // When IME loses focus, we don't need to store anything.
     mContentCache.Clear();
   }
 
   mIMEPreferenceOfParent = nsIMEUpdatePreference();
-  if (!mTabChild->SendNotifyIMEFocus(gotFocus, mContentCache,
+  if (!mTabChild->SendNotifyIMEFocus(mContentCache, aIMENotification,
                                      &mIMEPreferenceOfParent)) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 nsresult
-PuppetWidget::NotifyIMEOfUpdateComposition(
+PuppetWidget::NotifyIMEOfCompositionUpdate(
                 const IMENotification& aIMENotification)
 {
 #ifndef MOZ_CROSS_PROCESS_IME
   return NS_OK;
 #endif
 
   NS_ENSURE_TRUE(mTabChild, NS_ERROR_FAILURE);
 
   if (NS_WARN_IF(!mContentCache.CacheSelection(this, &aIMENotification))) {
     return NS_ERROR_FAILURE;
   }
-  mTabChild->SendNotifyIMESelectedCompositionRect(mContentCache);
+  mTabChild->SendNotifyIMECompositionUpdate(mContentCache, aIMENotification);
   return NS_OK;
 }
 
 nsIMEUpdatePreference
 PuppetWidget::GetIMEUpdatePreference()
 {
 #ifdef MOZ_CROSS_PROCESS_IME
   // e10s requires IME information cache into TabParent
@@ -754,22 +754,17 @@ PuppetWidget::NotifyIMEOfTextChange(cons
     return NS_ERROR_FAILURE;
   }
 
   // TabParent doesn't this this to cache.  we don't send the notification
   // if parent process doesn't request NOTIFY_TEXT_CHANGE.
   if (mIMEPreferenceOfParent.WantTextChange() &&
       (mIMEPreferenceOfParent.WantChangesCausedByComposition() ||
        !aIMENotification.mTextChangeData.mCausedByComposition)) {
-    mTabChild->SendNotifyIMETextChange(
-      mContentCache,
-      aIMENotification.mTextChangeData.mStartOffset,
-      aIMENotification.mTextChangeData.mRemovedEndOffset,
-      aIMENotification.mTextChangeData.mAddedEndOffset,
-      aIMENotification.mTextChangeData.mCausedByComposition);
+    mTabChild->SendNotifyIMETextChange(mContentCache, aIMENotification);
   } else {
     mTabChild->SendUpdateContentCache(mContentCache);
   }
   return NS_OK;
 }
 
 nsresult
 PuppetWidget::NotifyIMEOfSelectionChange(
@@ -783,25 +778,23 @@ PuppetWidget::NotifyIMEOfSelectionChange
 #endif
 
   if (!mTabChild)
     return NS_ERROR_FAILURE;
 
   // Note that selection change must be notified after text change if it occurs.
   // Therefore, we don't need to query text content again here.
   mContentCache.SetSelection(
-    this,
+    this, 
     aIMENotification.mSelectionChangeData.mOffset,
     aIMENotification.mSelectionChangeData.mLength,
     aIMENotification.mSelectionChangeData.mReversed,
     aIMENotification.mSelectionChangeData.GetWritingMode());
 
-  mTabChild->SendNotifyIMESelection(
-    mContentCache, aIMENotification.mSelectionChangeData.mCausedByComposition,
-    aIMENotification.mSelectionChangeData.mCausedBySelectionEvent);
+  mTabChild->SendNotifyIMESelection(mContentCache, aIMENotification);
   return NS_OK;
 }
 
 nsresult
 PuppetWidget::NotifyIMEOfMouseButtonEvent(
                 const IMENotification& aIMENotification)
 {
   if (!mTabChild) {
@@ -826,17 +819,18 @@ PuppetWidget::NotifyIMEOfPositionChange(
   if (NS_WARN_IF(!mTabChild)) {
     return NS_ERROR_FAILURE;
   }
 
   if (NS_WARN_IF(!mContentCache.CacheEditorRect(this, &aIMENotification)) ||
       NS_WARN_IF(!mContentCache.CacheSelection(this, &aIMENotification))) {
     return NS_ERROR_FAILURE;
   }
-  if (!mTabChild->SendNotifyIMEPositionChange(mContentCache)) {
+  if (!mTabChild->SendNotifyIMEPositionChange(mContentCache,
+                                              aIMENotification)) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PuppetWidget::SetCursor(nsCursor aCursor)
 {
--- a/widget/PuppetWidget.h
+++ b/widget/PuppetWidget.h
@@ -257,17 +257,17 @@ protected:
 private:
   nsresult Paint();
 
   void SetChild(PuppetWidget* aChild);
 
   nsresult IMEEndComposition(bool aCancel);
   nsresult NotifyIMEOfFocusChange(const IMENotification& aIMENotification);
   nsresult NotifyIMEOfSelectionChange(const IMENotification& aIMENotification);
-  nsresult NotifyIMEOfUpdateComposition(const IMENotification& aIMENotification);
+  nsresult NotifyIMEOfCompositionUpdate(const IMENotification& aIMENotification);
   nsresult NotifyIMEOfTextChange(const IMENotification& aIMENotification);
   nsresult NotifyIMEOfMouseButtonEvent(const IMENotification& aIMENotification);
   nsresult NotifyIMEOfPositionChange(const IMENotification& aIMENotification);
 
   bool CacheEditorRect();
   bool CacheCompositionRects(uint32_t& aStartOffset,
                              nsTArray<mozilla::LayoutDeviceIntRect>& aRectArray,
                              uint32_t& aTargetCauseOffset);