Bug 1176954 part.4 Define IMENotification::TextChangeDataBase and whose member names should be same as IMEContentObserver::TextChangeData's r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 11 Jul 2015 10:53:55 +0900
changeset 252464 890bb7cdc21a8cfe3653a8176f73b1818936ea2e
parent 252463 9d0af72de7c0f193eb56ecd5cd5e61a24d5f7346
child 252465 10807ee6ca50a7d0d65e35fb604e5a9b9793913a
push id29035
push usercbook@mozilla.com
push dateMon, 13 Jul 2015 09:52:17 +0000
treeherdermozilla-central@38d03bf4616e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1176954
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 1176954 part.4 Define IMENotification::TextChangeDataBase and whose member names should be same as IMEContentObserver::TextChangeData's r=smaug
dom/events/IMEContentObserver.cpp
dom/ipc/PBrowser.ipdl
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
widget/PuppetWidget.cpp
widget/android/nsWindow.cpp
widget/android/nsWindow.h
widget/nsGUIEventIPC.h
widget/nsIWidget.h
widget/windows/nsTextStore.cpp
--- a/dom/events/IMEContentObserver.cpp
+++ b/dom/events/IMEContentObserver.cpp
@@ -1722,18 +1722,18 @@ IMEContentObserver::TextChangeEvent::Run
 
   if (!IsSafeToNotifyIME()) {
     mIMEContentObserver->PostTextChangeNotification(mData);
     return NS_OK;
   }
 
   IMENotification notification(NOTIFY_IME_OF_TEXT_CHANGE);
   notification.mTextChangeData.mStartOffset = mData.mStartOffset;
-  notification.mTextChangeData.mOldEndOffset = mData.mRemovedEndOffset;
-  notification.mTextChangeData.mNewEndOffset = mData.mAddedEndOffset;
+  notification.mTextChangeData.mRemovedEndOffset = mData.mRemovedEndOffset;
+  notification.mTextChangeData.mAddedEndOffset = mData.mAddedEndOffset;
   notification.mTextChangeData.mCausedByComposition =
     mData.mCausedOnlyByComposition;
   IMEStateManager::NotifyIME(notification, mIMEContentObserver->mWidget);
   return NS_OK;
 }
 
 /******************************************************************************
  * mozilla::IMEContentObserver::PositionChangeEvent
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -192,26 +192,26 @@ parent:
 
     /**
      * 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
-     *  end          Ending offset of the range deleted
-     *  newEnd       New ending offset after insertion
+     *  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
      */
     prio(urgent) async NotifyIMETextChange(ContentCache contentCache,
-                                           uint32_t offset, uint32_t end,
-                                           uint32_t newEnd,
+                                           uint32_t offset, uint32_t removedEnd,
+                                           uint32_t addedEnd,
                                            bool causedByComposition);
 
     /**
      * Notifies chrome that there is a IME compostion rect updated
      *
      *  contentCache Cache of content
      */
     prio(urgent) async NotifyIMESelectedCompositionRect(ContentCache contentCache);
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1967,18 +1967,18 @@ TabParent::RecvNotifyIMEFocus(const bool
     *aPreference = widget->GetIMEUpdatePreference();
   }
   return true;
 }
 
 bool
 TabParent::RecvNotifyIMETextChange(const ContentCache& aContentCache,
                                    const uint32_t& aStart,
-                                   const uint32_t& aEnd,
-                                   const uint32_t& aNewEnd,
+                                   const uint32_t& aRemovedEnd,
+                                   const uint32_t& aAddedEnd,
                                    const bool& aCausedByComposition)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget)
     return true;
 
 #ifdef DEBUG
   nsIMEUpdatePreference updatePreference = widget->GetIMEUpdatePreference();
@@ -1986,18 +1986,18 @@ TabParent::RecvNotifyIMETextChange(const
                "Don't call Send/RecvNotifyIMETextChange without NOTIFY_TEXT_CHANGE");
   MOZ_ASSERT(!aCausedByComposition ||
                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.mOldEndOffset = aEnd;
-  notification.mTextChangeData.mNewEndOffset = aNewEnd;
+  notification.mTextChangeData.mRemovedEndOffset = aRemovedEnd;
+  notification.mTextChangeData.mAddedEndOffset = aAddedEnd;
   notification.mTextChangeData.mCausedByComposition = aCausedByComposition;
 
   mContentCache.AssignContent(aContentCache, &notification);
   mContentCache.MaybeNotifyIME(widget, notification);
   return true;
 }
 
 bool
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -162,18 +162,18 @@ public:
                                   InfallibleTArray<CpowEntry>&& aCpows,
                                   const IPC::Principal& aPrincipal) override;
     virtual bool RecvNotifyIMEFocus(const bool& aFocus,
                                     const ContentCache& aContentCache,
                                     nsIMEUpdatePreference* aPreference)
                                       override;
     virtual bool RecvNotifyIMETextChange(const ContentCache& aContentCache,
                                          const uint32_t& aStart,
-                                         const uint32_t& aEnd,
-                                         const uint32_t& aNewEnd,
+                                         const uint32_t& aRemovedEnd,
+                                         const uint32_t& aAddedEnd,
                                          const bool& aCausedByComposition) override;
     virtual bool RecvNotifyIMESelectedCompositionRect(const ContentCache& aContentCache) override;
     virtual bool RecvNotifyIMESelection(const ContentCache& aContentCache,
                                         const bool& aCausedByComposition) 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;
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -757,18 +757,18 @@ PuppetWidget::NotifyIMEOfTextChange(cons
   // 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.mOldEndOffset,
-      aIMENotification.mTextChangeData.mNewEndOffset,
+      aIMENotification.mTextChangeData.mRemovedEndOffset,
+      aIMENotification.mTextChangeData.mAddedEndOffset,
       aIMENotification.mTextChangeData.mCausedByComposition);
   } else {
     mTabChild->SendUpdateContentCache(mContentCache);
   }
   return NS_OK;
 }
 
 nsresult
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1732,18 +1732,18 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
             // on Gecko. Now we can notify Java of the newly focused content
             mIMETextChanges.Clear();
             mIMESelectionChanged = false;
             // NotifyIMEOfTextChange also notifies selection
             // Use 'INT32_MAX / 2' here because subsequent text changes might
             // combine with this text change, and overflow might occur if
             // we just use INT32_MAX
             IMENotification notification(NOTIFY_IME_OF_TEXT_CHANGE);
-            notification.mTextChangeData.mOldEndOffset =
-                notification.mTextChangeData.mNewEndOffset = INT32_MAX / 2;
+            notification.mTextChangeData.mRemovedEndOffset =
+                notification.mTextChangeData.mAddedEndOffset = INT32_MAX / 2;
             NotifyIMEOfTextChange(notification);
             FlushIMEChanges();
         }
         GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
         return;
 
     } else if (ae->Action() == AndroidGeckoEvent::IME_UPDATE_CONTEXT) {
         GeckoAppShell::NotifyIMEContext(mInputContext.mIMEState.mEnabled,
@@ -2241,18 +2241,18 @@ nsWindow::FlushIMEChanges()
 nsresult
 nsWindow::NotifyIMEOfTextChange(const IMENotification& aIMENotification)
 {
     MOZ_ASSERT(aIMENotification.mMessage == NOTIFY_IME_OF_TEXT_CHANGE,
                "NotifyIMEOfTextChange() is called with invaild notification");
 
     ALOGIME("IME: NotifyIMEOfTextChange: s=%d, oe=%d, ne=%d",
             aIMENotification.mTextChangeData.mStartOffset,
-            aIMENotification.mTextChangeData.mOldEndOffset,
-            aIMENotification.mTextChangeData.mNewEndOffset);
+            aIMENotification.mTextChangeData.mRemovedEndOffset,
+            aIMENotification.mTextChangeData.mAddedEndOffset);
 
     /* Make sure Java's selection is up-to-date */
     mIMESelectionChanged = false;
     NotifyIME(NOTIFY_IME_OF_SELECTION_CHANGE);
 
     PostFlushIMEChanges();
     AddIMETextChange(IMEChange(aIMENotification));
     return NS_OK;
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -178,18 +178,18 @@ protected:
         int32_t mStart, mOldEnd, mNewEnd;
 
         IMEChange() :
             mStart(-1), mOldEnd(-1), mNewEnd(-1)
         {
         }
         IMEChange(const IMENotification& aIMENotification)
             : mStart(aIMENotification.mTextChangeData.mStartOffset)
-            , mOldEnd(aIMENotification.mTextChangeData.mOldEndOffset)
-            , mNewEnd(aIMENotification.mTextChangeData.mNewEndOffset)
+            , mOldEnd(aIMENotification.mTextChangeData.mRemovedEndOffset)
+            , mNewEnd(aIMENotification.mTextChangeData.mAddedEndOffset)
         {
             MOZ_ASSERT(aIMENotification.mMessage ==
                            mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE,
                        "IMEChange initialized with wrong notification");
             MOZ_ASSERT(aIMENotification.mTextChangeData.IsInInt32Range(),
                        "The text change notification is out of range");
         }
         bool IsEmpty() const
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -674,18 +674,18 @@ struct ParamTraits<mozilla::widget::IMEN
         WriteParam(aMsg, aParam.mSelectionChangeData.mOffset);
         WriteParam(aMsg, aParam.mSelectionChangeData.mLength);
         WriteParam(aMsg, aParam.mSelectionChangeData.mWritingMode);
         WriteParam(aMsg, aParam.mSelectionChangeData.mReversed);
         WriteParam(aMsg, aParam.mSelectionChangeData.mCausedByComposition);
         return;
       case mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE:
         WriteParam(aMsg, aParam.mTextChangeData.mStartOffset);
-        WriteParam(aMsg, aParam.mTextChangeData.mOldEndOffset);
-        WriteParam(aMsg, aParam.mTextChangeData.mNewEndOffset);
+        WriteParam(aMsg, aParam.mTextChangeData.mRemovedEndOffset);
+        WriteParam(aMsg, aParam.mTextChangeData.mAddedEndOffset);
         WriteParam(aMsg, aParam.mTextChangeData.mCausedByComposition);
         return;
       case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
         WriteParam(aMsg, aParam.mMouseButtonEventData.mEventMessage);
         WriteParam(aMsg, aParam.mMouseButtonEventData.mOffset);
         WriteParam(aMsg, aParam.mMouseButtonEventData.mCursorPos.mX);
         WriteParam(aMsg, aParam.mMouseButtonEventData.mCursorPos.mY);
         WriteParam(aMsg, aParam.mMouseButtonEventData.mCharRect.mX);
@@ -719,19 +719,19 @@ struct ParamTraits<mozilla::widget::IMEN
                ReadParam(aMsg, aIter,
                          &aResult->mSelectionChangeData.mReversed) &&
                ReadParam(aMsg, aIter,
                          &aResult->mSelectionChangeData.mCausedByComposition);
       case mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE:
         return ReadParam(aMsg, aIter,
                          &aResult->mTextChangeData.mStartOffset) &&
                ReadParam(aMsg, aIter,
-                         &aResult->mTextChangeData.mOldEndOffset) &&
+                         &aResult->mTextChangeData.mRemovedEndOffset) &&
                ReadParam(aMsg, aIter,
-                         &aResult->mTextChangeData.mNewEndOffset) &&
+                         &aResult->mTextChangeData.mAddedEndOffset) &&
                ReadParam(aMsg, aIter,
                          &aResult->mTextChangeData.mCausedByComposition);
       case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
         return ReadParam(aMsg, aIter,
                          &aResult->mMouseButtonEventData.mEventMessage) &&
                ReadParam(aMsg, aIter,
                          &aResult->mMouseButtonEventData.mOffset) &&
                ReadParam(aMsg, aIter,
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -612,18 +612,18 @@ struct IMENotification
         mSelectionChangeData.mOffset = UINT32_MAX;
         mSelectionChangeData.mLength = 0;
         mSelectionChangeData.mWritingMode = 0;
         mSelectionChangeData.mReversed = false;
         mSelectionChangeData.mCausedByComposition = false;
         break;
       case NOTIFY_IME_OF_TEXT_CHANGE:
         mTextChangeData.mStartOffset = 0;
-        mTextChangeData.mOldEndOffset = 0;
-        mTextChangeData.mNewEndOffset = 0;
+        mTextChangeData.mRemovedEndOffset = 0;
+        mTextChangeData.mAddedEndOffset = 0;
         mTextChangeData.mCausedByComposition = false;
         break;
       case NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
         mMouseButtonEventData.mEventMessage = 0;
         mMouseButtonEventData.mOffset = UINT32_MAX;
         mMouseButtonEventData.mCursorPos.Set(nsIntPoint(0, 0));
         mMouseButtonEventData.mCharRect.Set(nsIntRect(0, 0, 0, 0));
         mMouseButtonEventData.mButton = -1;
@@ -665,20 +665,20 @@ struct IMENotification
           mSelectionChangeData.mCausedByComposition &&
             aNotification.mSelectionChangeData.mCausedByComposition;
         break;
       case NOTIFY_IME_OF_TEXT_CHANGE:
         MOZ_ASSERT(aNotification.mMessage == NOTIFY_IME_OF_TEXT_CHANGE);
         // TODO: Needs to merge the ranges rather than overwriting.
         mTextChangeData.mStartOffset =
           aNotification.mTextChangeData.mStartOffset;
-        mTextChangeData.mOldEndOffset =
-          aNotification.mTextChangeData.mOldEndOffset;
-        mTextChangeData.mNewEndOffset =
-          aNotification.mTextChangeData.mNewEndOffset;
+        mTextChangeData.mRemovedEndOffset =
+          aNotification.mTextChangeData.mRemovedEndOffset;
+        mTextChangeData.mAddedEndOffset =
+          aNotification.mTextChangeData.mAddedEndOffset;
         mTextChangeData.mCausedByComposition =
           mTextChangeData.mCausedByComposition &&
             aNotification.mTextChangeData.mCausedByComposition;
         break;
       case NOTIFY_IME_OF_COMPOSITION_UPDATE:
         MOZ_ASSERT(aNotification.mMessage == NOTIFY_IME_OF_COMPOSITION_UPDATE);
         break;
       default:
@@ -714,43 +714,49 @@ struct IMENotification
       return mOffset + (mReversed ? 0 : mLength);
     }
     bool IsInInt32Range() const
     {
       return mOffset + mLength <= INT32_MAX;
     }
   };
 
+  struct TextChangeDataBase
+  {
+    // mStartOffset is the start offset of modified or removed text in
+    // original content and inserted text in new content.
+    uint32_t mStartOffset;
+    // mRemovalEndOffset is the end offset of modified or removed text in
+    // original content.  If the value is same as mStartOffset, no text hasn't
+    // been removed yet.
+    uint32_t mRemovedEndOffset;
+    // mAddedEndOffset is the end offset of inserted text or same as
+    // mStartOffset if just removed.  The vlaue is offset in the new content.
+    uint32_t mAddedEndOffset;
+
+    bool mCausedByComposition;
+
+    uint32_t OldLength() const { return mRemovedEndOffset - mStartOffset; }
+    uint32_t NewLength() const { return mAddedEndOffset - mStartOffset; }
+
+    bool IsInInt32Range() const
+    {
+      return mStartOffset <= INT32_MAX &&
+             mRemovedEndOffset <= INT32_MAX &&
+             mAddedEndOffset <= INT32_MAX;
+    }
+  };
+
   union
   {
     // NOTIFY_IME_OF_SELECTION_CHANGE specific data
     SelectionChangeData mSelectionChangeData;
 
     // NOTIFY_IME_OF_TEXT_CHANGE specific data
-    struct
-    {
-      uint32_t mStartOffset;
-      uint32_t mOldEndOffset;
-      uint32_t mNewEndOffset;
-
-      bool mCausedByComposition;
-
-      uint32_t OldLength() const { return mOldEndOffset - mStartOffset; }
-      uint32_t NewLength() const { return mNewEndOffset - mStartOffset; }
-      int32_t AdditionalLength() const
-      {
-        return static_cast<int32_t>(mNewEndOffset - mOldEndOffset);
-      }
-      bool IsInInt32Range() const
-      {
-        return mStartOffset <= INT32_MAX &&
-               mOldEndOffset <= INT32_MAX &&
-               mNewEndOffset <= INT32_MAX;
-      }
-    } mTextChangeData;
+    TextChangeDataBase mTextChangeData;
 
     // NOTIFY_IME_OF_MOUSE_BUTTON_EVENT specific data
     struct
     {
       // The value of WidgetEvent::message
       uint32_t mEventMessage;
       // Character offset from the start of the focused editor under the cursor
       uint32_t mOffset;
--- a/widget/windows/nsTextStore.cpp
+++ b/widget/windows/nsTextStore.cpp
@@ -4310,22 +4310,22 @@ nsTextStore::GetIMEUpdatePreference()
 }
 
 nsresult
 nsTextStore::OnTextChangeInternal(const IMENotification& aIMENotification)
 {
   MOZ_LOG(sTextStoreLog, LogLevel::Debug,
          ("TSF: 0x%p   nsTextStore::OnTextChangeInternal(aIMENotification={ "
           "mMessage=0x%08X, mTextChangeData={ mStartOffset=%lu, "
-          "mOldEndOffset=%lu, mNewEndOffset=%lu}), mSink=0x%p, mSinkMask=%s, "
-          "mComposition.IsComposing()=%s",
+          "mRemovedEndOffset=%lu, mAddedEndOffset=%lu}), mSink=0x%p, "
+          "mSinkMask=%s, mComposition.IsComposing()=%s",
           this, aIMENotification.mMessage,
           aIMENotification.mTextChangeData.mStartOffset,
-          aIMENotification.mTextChangeData.mOldEndOffset,
-          aIMENotification.mTextChangeData.mNewEndOffset, mSink.get(),
+          aIMENotification.mTextChangeData.mRemovedEndOffset,
+          aIMENotification.mTextChangeData.mAddedEndOffset, mSink.get(),
           GetSinkMaskNameStr(mSinkMask).get(),
           GetBoolName(mComposition.IsComposing())));
 
   mDeferNotifyingTSF = false;
 
   if (IsReadLocked()) {
     // XXX If text change occurs during the document is locked, it must be
     //     modified by Javascript.  In such case, we should notify merged
@@ -4339,19 +4339,19 @@ nsTextStore::OnTextChangeInternal(const 
     return NS_OK;
   }
 
   if (aIMENotification.mTextChangeData.IsInInt32Range()) {
     TS_TEXTCHANGE textChange;
     textChange.acpStart =
       static_cast<LONG>(aIMENotification.mTextChangeData.mStartOffset);
     textChange.acpOldEnd =
-      static_cast<LONG>(aIMENotification.mTextChangeData.mOldEndOffset);
+      static_cast<LONG>(aIMENotification.mTextChangeData.mRemovedEndOffset);
     textChange.acpNewEnd =
-      static_cast<LONG>(aIMENotification.mTextChangeData.mNewEndOffset);
+      static_cast<LONG>(aIMENotification.mTextChangeData.mAddedEndOffset);
     NotifyTSFOfTextChange(textChange);
   } else {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
            ("TSF: 0x%p   nsTextStore::NotifyTSFOfTextChange() FAILED due to "
             "offset is too big for calling "
             "ITextStoreACPSink::OnTextChange()...",
             this));
   }