Bug 960871 part.9 Rename methods and classes which handled WidgetTextEvent r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 07 Oct 2014 19:01:49 +0900
changeset 232359 4f5abfd3505c4c51bc662749fbc16de521080547
parent 232358 93374aaa8f6e92919f39c6684261123adc45ce54
child 232360 52273860a2cda1e83b127d8f8ba53673db03f5f0
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs960871
milestone35.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 960871 part.9 Rename methods and classes which handled WidgetTextEvent r=smaug
dom/events/TextComposition.cpp
dom/events/TextComposition.h
editor/libeditor/nsPlaintextEditor.cpp
widget/cocoa/TextInputHandler.h
widget/cocoa/TextInputHandler.mm
widget/gtk/nsGtkIMModule.cpp
widget/gtk/nsGtkIMModule.h
widget/windows/nsIMM32Handler.cpp
widget/windows/nsIMM32Handler.h
widget/windows/nsTextStore.cpp
widget/windows/nsTextStore.h
--- a/dom/events/TextComposition.cpp
+++ b/dom/events/TextComposition.cpp
@@ -175,18 +175,18 @@ TextComposition::DispatchEvent(WidgetGUI
 
   if (NS_WARN_IF(Destroyed())) {
     return;
   }
 
   // Emulate editor behavior of compositionchange event (DOM text event) handler
   // if no editor handles composition events.
   if (aEvent->message == NS_COMPOSITION_CHANGE && !HasEditor()) {
-    EditorWillHandleTextEvent(aEvent->AsCompositionEvent());
-    EditorDidHandleTextEvent();
+    EditorWillHandleCompositionChangeEvent(aEvent->AsCompositionEvent());
+    EditorDidHandleCompositionChangeEvent();
   }
 
 #ifdef DEBUG
   else if (aEvent->message == NS_COMPOSITION_END) {
     MOZ_ASSERT(!mIsComposing, "Why is the editor still composing?");
     MOZ_ASSERT(!HasEditor(), "Why does the editor still keep to hold this?");
   }
 #endif // #ifdef DEBUG
@@ -259,19 +259,18 @@ TextComposition::RequestToCommit(nsIWidg
     if (aDiscard) {
       mIsRequestingCancel = true;
       mIsRequestingCommit = false;
     } else {
       mIsRequestingCancel = false;
       mIsRequestingCommit = true;
     }
     if (!mIsSynthesizedForTests) {
-      // FYI: CompositionEvent and TextEvent caused by a call of NotifyIME()
-      //      may be discarded by PresShell if it's not safe to dispatch the
-      //      event.
+      // FYI: CompositionEvents caused by a call of NotifyIME() may be
+      //      discarded by PresShell if it's not safe to dispatch the event.
       nsresult rv =
         aWidget->NotifyIME(IMENotification(aDiscard ?
                                              REQUEST_TO_CANCEL_COMPOSITION :
                                              REQUEST_TO_COMMIT_COMPOSITION));
       if (rv == NS_ERROR_NOT_IMPLEMENTED) {
         return rv;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -334,30 +333,30 @@ TextComposition::RequestToCommit(nsIWidg
 nsresult
 TextComposition::NotifyIME(IMEMessage aMessage)
 {
   NS_ENSURE_TRUE(mPresContext, NS_ERROR_NOT_AVAILABLE);
   return IMEStateManager::NotifyIME(aMessage, mPresContext);
 }
 
 void
-TextComposition::EditorWillHandleTextEvent(
+TextComposition::EditorWillHandleCompositionChangeEvent(
                    const WidgetCompositionEvent* aCompositionChangeEvent)
 {
   mIsComposing = aCompositionChangeEvent->IsComposing();
   mRanges = aCompositionChangeEvent->mRanges;
   mIsEditorHandlingEvent = true;
 
   MOZ_ASSERT(mLastData == aCompositionChangeEvent->mData,
     "The text of a compositionchange event must be same as previous data "
     "attribute value of the latest compositionupdate event");
 }
 
 void
-TextComposition::EditorDidHandleTextEvent()
+TextComposition::EditorDidHandleCompositionChangeEvent()
 {
   mString = mLastData;
   mIsEditorHandlingEvent = false;
 }
 
 void
 TextComposition::StartHandlingComposition(nsIEditor* aEditor)
 {
--- a/dom/events/TextComposition.h
+++ b/dom/events/TextComposition.h
@@ -45,22 +45,23 @@ public:
   bool Destroyed() const { return !mPresContext; }
   nsPresContext* GetPresContext() const { return mPresContext; }
   nsINode* GetEventTargetNode() const { return mNode; }
   // The latest CompositionEvent.data value except compositionstart event.
   // This value is modified at dispatching compositionupdate.
   const nsString& LastData() const { return mLastData; }
   // The composition string which is already handled by the focused editor.
   // I.e., this value must be same as the composition string on the focused
-  // editor.  This value is modified at a call of EditorDidHandleTextEvent().
+  // editor.  This value is modified at a call of
+  // EditorDidHandleCompositionChangeEvent().
   // Note that mString and mLastData are different between dispatcing
   // compositionupdate and compositionchange event handled by focused editor.
   const nsString& String() const { return mString; }
   // Returns the clauses and/or caret range of the composition string.
-  // This is modified at a call of EditorWillHandleTextEvent().
+  // This is modified at a call of EditorWillHandleCompositionChangeEvent().
   // This may return null if there is no clauses and caret.
   // XXX We should return |const TextRangeArray*| here, but it causes compile
   //     error due to inaccessible Release() method.
   TextRangeArray* GetRanges() const { return mRanges; }
   // Returns the widget which is proper to call NotifyIME().
   nsIWidget* GetWidget() const
   {
     return mPresContext ? mPresContext->GetRootWidget() : nullptr;
@@ -119,40 +120,43 @@ public:
   /**
    * StartHandlingComposition() and EndHandlingComposition() are called by
    * editor when it holds a TextComposition instance and release it.
    */
   void StartHandlingComposition(nsIEditor* aEditor);
   void EndHandlingComposition(nsIEditor* aEditor);
 
   /**
-   * TextEventHandlingMarker class should be created at starting to handle text
-   * event in focused editor.  This calls EditorWillHandleTextEvent() and
-   * EditorDidHandleTextEvent() automatically.
+   * CompositionChangeEventHandlingMarker class should be created at starting
+   * to handle text event in focused editor.  This calls
+   * EditorWillHandleCompositionChangeEvent() and
+   * EditorDidHandleCompositionChangeEvent() automatically.
    */
-  class MOZ_STACK_CLASS TextEventHandlingMarker
+  class MOZ_STACK_CLASS CompositionChangeEventHandlingMarker
   {
   public:
-    TextEventHandlingMarker(
+    CompositionChangeEventHandlingMarker(
       TextComposition* aComposition,
       const WidgetCompositionEvent* aCompositionChangeEvent)
       : mComposition(aComposition)
     {
-      mComposition->EditorWillHandleTextEvent(aCompositionChangeEvent);
+      mComposition->EditorWillHandleCompositionChangeEvent(
+                      aCompositionChangeEvent);
     }
 
-    ~TextEventHandlingMarker()
+    ~CompositionChangeEventHandlingMarker()
     {
-      mComposition->EditorDidHandleTextEvent();
+      mComposition->EditorDidHandleCompositionChangeEvent();
     }
 
   private:
     nsRefPtr<TextComposition> mComposition;
-    TextEventHandlingMarker();
-    TextEventHandlingMarker(const TextEventHandlingMarker& aOther);
+    CompositionChangeEventHandlingMarker();
+    CompositionChangeEventHandlingMarker(
+      const CompositionChangeEventHandlingMarker& aOther);
   };
 
 private:
   // Private destructor, to discourage deletion outside of Release():
   ~TextComposition()
   {
     // WARNING: mPresContext may be destroying, so, be careful if you touch it.
   }
@@ -228,27 +232,27 @@ private:
 
   /**
    * HasEditor() returns true if mEditorWeak holds nsIEditor instance which is
    * alive.  Otherwise, false.
    */
   bool HasEditor() const;
 
   /**
-   * EditorWillHandleTextEvent() must be called before the focused editor
-   * handles the compositionchange event.
+   * EditorWillHandleCompositionChangeEvent() must be called before the focused
+   * editor handles the compositionchange event.
    */
-  void EditorWillHandleTextEvent(
+  void EditorWillHandleCompositionChangeEvent(
          const WidgetCompositionEvent* aCompositionChangeEvent);
 
   /**
-   * EditorDidHandleTextEvent() must be called after the focused editor handles
-   * a compositionchange event.
+   * EditorDidHandleCompositionChangeEvent() must be called after the focused
+   * editor handles a compositionchange event.
    */
-  void EditorDidHandleTextEvent();
+  void EditorDidHandleCompositionChangeEvent();
 
   /**
    * DispatchEvent() dispatches the aEvent to the mContent synchronously.
    * The caller must ensure that it's safe to dispatch the event.
    */
   void DispatchEvent(WidgetGUIEvent* aEvent,
                      nsEventStatus* aStatus,
                      EventDispatchingCallback* aCallBack,
--- a/editor/libeditor/nsPlaintextEditor.cpp
+++ b/editor/libeditor/nsPlaintextEditor.cpp
@@ -857,27 +857,27 @@ nsPlaintextEditor::UpdateIMEComposition(
   nsCOMPtr<nsIPresShell> ps = GetPresShell();
   NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
 
   nsCOMPtr<nsISelection> selection;
   nsresult rv = GetSelection(getter_AddRefs(selection));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // NOTE: TextComposition should receive selection change notification before
-  //       TextEventHandlingMarker notifies TextComposition of the end of
-  //       handling compositionchange event because TextComposition may need to
-  //       ignore selection changes caused by composition.  Therefore,
-  //       TextEventHandlingMarker must be destroyed after a call of
-  //       NotifiyEditorObservers(eNotifyEditorObserversOfEnd) or
+  //       CompositionChangeEventHandlingMarker notifies TextComposition of the
+  //       end of handling compositionchange event because TextComposition may
+  //       need to ignore selection changes caused by composition.  Therefore,
+  //       CompositionChangeEventHandlingMarker must be destroyed after a call
+  //       of NotifiyEditorObservers(eNotifyEditorObserversOfEnd) or
   //       NotifiyEditorObservers(eNotifyEditorObserversOfCancel) which notifies
   //       TextComposition of a selection change.
   MOZ_ASSERT(!mPlaceHolderBatch,
     "UpdateIMEComposition() must be called without place holder batch");
-  TextComposition::TextEventHandlingMarker
-    textEventHandlingMarker(mComposition, compositionChangeEvent);
+  TextComposition::CompositionChangeEventHandlingMarker
+    compositionChangeEventHandlingMarker(mComposition, compositionChangeEvent);
 
   NotifyEditorObservers(eNotifyEditorObserversOfBefore);
 
   nsRefPtr<nsCaret> caretP = ps->GetCaret();
 
   {
     nsAutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName);
 
--- a/widget/cocoa/TextInputHandler.h
+++ b/widget/cocoa/TextInputHandler.h
@@ -841,29 +841,30 @@ class IMEInputHandler : public PluginTex
 public:
   virtual bool OnDestroyWidget(nsChildView* aDestroyingWidget);
 
   virtual void OnFocusChangeInGecko(bool aFocus);
 
   void OnSelectionChange() { mSelectedRange.location = NSNotFound; }
 
   /**
-   * DispatchTextEvent() dispatches a compositionchange event on mWidget.
+   * DispatchCompositionChangeEvent() dispatches a compositionchange event on
+   * mWidget.
    *
    * @param aText                 User text input.
    * @param aAttrString           An NSAttributedString instance which indicates
    *                              current composition string.
    * @param aSelectedRange        Current selected range (or caret position).
    * @param aDoCommit             TRUE if the composition string should be
    *                              committed.  Otherwise, FALSE.
    */
-  bool DispatchTextEvent(const nsString& aText,
-                           NSAttributedString* aAttrString,
-                           NSRange& aSelectedRange,
-                           bool aDoCommit);
+  bool DispatchCompositionChangeEvent(const nsString& aText,
+                                      NSAttributedString* aAttrString,
+                                      NSRange& aSelectedRange,
+                                      bool aDoCommit);
 
   /**
    * SetMarkedText() is a handler of setMarkedText of NSTextInput.
    *
    * @param aAttrString           This mut be an instance of NSAttributedString.
    *                              If the aString parameter to
    *                              [ChildView setMarkedText:setSelectedRange:]
    *                              isn't an instance of NSAttributedString,
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -2692,23 +2692,23 @@ IMEInputHandler::CreateTextRangeArray(NS
      GetRangeTypeName(range.mRangeType)));
 
   return textRangeArray.forget();
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSNULL;
 }
 
 bool
-IMEInputHandler::DispatchTextEvent(const nsString& aText,
-                                   NSAttributedString* aAttrString,
-                                   NSRange& aSelectedRange,
-                                   bool aDoCommit)
+IMEInputHandler::DispatchCompositionChangeEvent(const nsString& aText,
+                                                NSAttributedString* aAttrString,
+                                                NSRange& aSelectedRange,
+                                                bool aDoCommit)
 {
   PR_LOG(gLog, PR_LOG_ALWAYS,
-    ("%p IMEInputHandler::DispatchTextEvent, "
+    ("%p IMEInputHandler::DispatchCompositionChangeEvent, "
      "aText=\"%s\", aAttrString=\"%s\", "
      "aSelectedRange={ location=%llu, length=%llu }, "
      "aDoCommit=%s, Destroyed()=%s",
      this, NS_ConvertUTF16toUTF8(aText).get(),
      GetCharacters([aAttrString string]),
      aSelectedRange.location, aSelectedRange.length,
      TrueOrFalse(aDoCommit), TrueOrFalse(Destroyed())));
 
@@ -2805,17 +2805,17 @@ IMEInputHandler::InsertTextAsCommittingC
          "destroyed by compositionstart event", this));
       return;
     }
 
     OnStartIMEComposition();
   }
 
   NSRange range = NSMakeRange(0, str.Length());
-  DispatchTextEvent(str, aAttrString, range, true);
+  DispatchCompositionChangeEvent(str, aAttrString, range, true);
   if (Destroyed()) {
     PR_LOG(gLog, PR_LOG_ALWAYS,
       ("%p IMEInputHandler::InsertTextAsCommittingComposition, "
        "destroyed by compositionchange event", this));
     return;
   }
 
   OnUpdateIMEComposition([aAttrString string]);
@@ -2915,17 +2915,17 @@ IMEInputHandler::SetMarkedText(NSAttribu
 
     OnStartIMEComposition();
   }
 
   if (IsIMEComposing()) {
     OnUpdateIMEComposition([aAttrString string]);
 
     bool doCommit = str.IsEmpty();
-    DispatchTextEvent(str, aAttrString, aSelectedRange, doCommit);
+    DispatchCompositionChangeEvent(str, aAttrString, aSelectedRange, doCommit);
     if (Destroyed()) {
       PR_LOG(gLog, PR_LOG_ALWAYS,
         ("%p IMEInputHandler::SetMarkedText, "
          "destroyed by compositionchange event", this));
       return;
     }
 
     if (doCommit) {
--- a/widget/gtk/nsGtkIMModule.cpp
+++ b/widget/gtk/nsGtkIMModule.cpp
@@ -770,17 +770,17 @@ nsGtkIMModule::OnChangeCompositionNative
     nsAutoString compositionString;
     GetCompositionString(compositionString);
     if (!IsComposing() && compositionString.IsEmpty()) {
         mDispatchedCompositionString.Truncate();
         return; // Don't start the composition with empty string.
     }
 
     // Be aware, widget can be gone
-    DispatchTextEvent(compositionString, false);
+    DispatchCompositionChangeEvent(compositionString, false);
 }
 
 /* static */
 gboolean
 nsGtkIMModule::OnRetrieveSurroundingCallback(GtkIMContext  *aContext,
                                              nsGtkIMModule *aModule)
 {
     return aModule->OnRetrieveSurroundingNative(aContext);
@@ -916,17 +916,17 @@ bool
 nsGtkIMModule::CommitCompositionBy(const nsAString& aString)
 {
     PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
         ("GtkIMModule(%p): CommitCompositionBy, aString=\"%s\", "
          "mDispatchedCompositionString=\"%s\"",
          this, NS_ConvertUTF16toUTF8(aString).get(),
          NS_ConvertUTF16toUTF8(mDispatchedCompositionString).get()));
 
-    if (!DispatchTextEvent(aString, true)) {
+    if (!DispatchCompositionChangeEvent(aString, true)) {
         return false;
     }
     // We should dispatch the compositionend event here because some IMEs
     // might not fire "preedit_end" native event.
     return DispatchCompositionEnd(); // Be aware, widget can be gone
 }
 
 void
@@ -1062,21 +1062,22 @@ nsGtkIMModule::DispatchCompositionEnd()
             ("    NOTE, the focused widget was destroyed/changed by compositionend event"));
         return false;
     }
 
     return true;
 }
 
 bool
-nsGtkIMModule::DispatchTextEvent(const nsAString &aCompositionString,
-                                 bool aIsCommit)
+nsGtkIMModule::DispatchCompositionChangeEvent(
+                   const nsAString &aCompositionString,
+                   bool aIsCommit)
 {
     PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
-        ("GtkIMModule(%p): DispatchTextEvent, aIsCommit=%s",
+        ("GtkIMModule(%p): DispatchCompositionChangeEvent, aIsCommit=%s",
          this, aIsCommit ? "TRUE" : "FALSE"));
 
     if (!mLastFocusedWindow) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    FAILED, there are no focused window in this module"));
         return false;
     }
 
@@ -1119,18 +1120,18 @@ nsGtkIMModule::DispatchTextEvent(const n
     if (!aIsCommit) {
         // NOTE: SetTextRangeList() assumes that mDispatchedCompositionString
         //       has been updated already.
         compositionChangeEvent.mRanges = CreateTextRangeArray();
         targetOffset += compositionChangeEvent.mRanges->TargetClauseOffset();
     }
 
     mCompositionState = aIsCommit ?
-        eCompositionState_CommitTextEventDispatched :
-        eCompositionState_TextEventDispatched;
+        eCompositionState_CommitCompositionChangeEventDispatched :
+        eCompositionState_CompositionChangeEventDispatched;
 
     mLastFocusedWindow->DispatchEvent(&compositionChangeEvent, status);
     if (lastFocusedWindow->IsDestroyed() ||
         lastFocusedWindow != mLastFocusedWindow) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    NOTE, the focused widget was destroyed/changed by "
              "compositionchange event"));
         return false;
@@ -1443,17 +1444,17 @@ nsGtkIMModule::DeleteText(const int32_t 
     // First, we should cancel current composition because editor cannot
     // handle changing selection and deleting text.
     uint32_t selOffset;
     bool wasComposing = IsComposing();
     bool editorHadCompositionString = EditorHasCompositionString();
     if (wasComposing) {
         selOffset = mCompositionStart;
         if (editorHadCompositionString &&
-            !DispatchTextEvent(mSelectedString, false)) {
+            !DispatchCompositionChangeEvent(mSelectedString, false)) {
             PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
                 ("    FAILED, quitting from DeletText"));
             return NS_ERROR_FAILURE;
         }
         if (!DispatchCompositionEnd()) {
             PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
                 ("    FAILED, quitting from DeletText"));
             return NS_ERROR_FAILURE;
@@ -1570,17 +1571,17 @@ nsGtkIMModule::DeleteText(const int32_t 
     }
 
     if (!editorHadCompositionString) {
         return NS_OK;
     }
 
     nsAutoString compositionString;
     GetCompositionString(compositionString);
-    if (!DispatchTextEvent(compositionString, true)) {
+    if (!DispatchCompositionChangeEvent(compositionString, true)) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    FAILED, restoring composition string"));
         return NS_ERROR_FAILURE;
     }
 
     return NS_OK;
 }
 
--- a/widget/gtk/nsGtkIMModule.h
+++ b/widget/gtk/nsGtkIMModule.h
@@ -143,43 +143,44 @@ protected:
 
     // current target offset of IME composition
     uint32_t mCompositionTargetOffset;
 
     // mCompositionState indicates current status of composition.
     enum eCompositionState {
         eCompositionState_NotComposing,
         eCompositionState_CompositionStartDispatched,
-        eCompositionState_TextEventDispatched,
-        eCompositionState_CommitTextEventDispatched
+        eCompositionState_CompositionChangeEventDispatched,
+        eCompositionState_CommitCompositionChangeEventDispatched
     };
     eCompositionState mCompositionState;
 
     bool IsComposing()
     {
         return (mCompositionState != eCompositionState_NotComposing);
     }
 
     bool EditorHasCompositionString()
     {
-        return (mCompositionState == eCompositionState_TextEventDispatched);
+        return (mCompositionState ==
+                    eCompositionState_CompositionChangeEventDispatched);
     }
 
 #ifdef PR_LOGGING
     const char* GetCompositionStateName()
     {
         switch (mCompositionState) {
             case eCompositionState_NotComposing:
                 return "NotComposing";
             case eCompositionState_CompositionStartDispatched:
                 return "CompositionStartDispatched";
-            case eCompositionState_TextEventDispatched:
-                return "TextEventDispatched";
-            case eCompositionState_CommitTextEventDispatched:
-                return "CommitTextEventDispatched";
+            case eCompositionState_CompositionChangeEventDispatched:
+                return "CompositionChangeEventDispatched";
+            case eCompositionState_CommitCompositionChangeEventDispatched:
+                return "CommitCompositionChangeEventDispatched";
             default:
                 return "InvaildState";
         }
     }
 #endif // PR_LOGGING
 
 
     // mIsIMFocused is set to TRUE when we call gtk_im_context_focus_in(). And
@@ -289,27 +290,27 @@ protected:
     /**
      *  WARNING:
      *    Following methods dispatch gecko events.  Then, the focused widget
      *    can be destroyed, and also it can be stolen focus.  If they returns
      *    FALSE, callers cannot continue the composition.
      *      - CommitCompositionBy
      *      - DispatchCompositionStart
      *      - DispatchCompositionEnd
-     *      - DispatchTextEvent
+     *      - DispatchCompositionChangeEvent
      */
 
     // Commits the current composition by the aString.
     bool CommitCompositionBy(const nsAString& aString);
 
     // Dispatches a composition start event or a composition end event.
     bool DispatchCompositionStart();
     bool DispatchCompositionEnd();
 
     // Dispatches a compositionchange event.  If aIsCommit is TRUE, dispatches
     // a committed compositionchange event.  Otherwise, dispatches a composing
     // compositionchange event.
-    bool DispatchTextEvent(const nsAString& aCompositionString,
-                           bool aIsCommit);
+    bool DispatchCompositionChangeEvent(const nsAString& aCompositionString,
+                                        bool aIsCommit);
 
 };
 
 #endif // __nsGtkIMModule_h__
--- a/widget/windows/nsIMM32Handler.cpp
+++ b/widget/windows/nsIMM32Handler.cpp
@@ -490,17 +490,17 @@ nsIMM32Handler::OnIMEEndComposition(nsWi
   PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
     ("IMM32: OnIMEEndComposition, mCompositionString=\"%s\"%s",
      NS_ConvertUTF16toUTF8(mCompositionString).get(),
      mCompositionString.IsEmpty() ? "" : ", but canceling it..."));
 
   mCompositionString.Truncate();
 
   nsIMEContext IMEContext(aWindow->GetWindowHandle());
-  DispatchTextEvent(aWindow, IMEContext, false);
+  DispatchCompositionChangeEvent(aWindow, IMEContext, false);
 
   HandleEndComposition(aWindow);
 
   return true;
 }
 
 /* static */ bool
 nsIMM32Handler::OnIMEChar(nsWindow* aWindow,
@@ -1015,17 +1015,17 @@ nsIMM32Handler::HandleComposition(nsWind
       HandleStartComposition(aWindow, aIMEContext);
     }
 
     GetCompositionString(aIMEContext, GCS_RESULTSTR);
 
     PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
       ("IMM32: HandleComposition, GCS_RESULTSTR\n"));
 
-    DispatchTextEvent(aWindow, aIMEContext, false);
+    DispatchCompositionChangeEvent(aWindow, aIMEContext, false);
     HandleEndComposition(aWindow);
 
     if (!IS_COMPOSING_LPARAM(lParam)) {
       return ShouldDrawCompositionStringOurselves();
     }
   }
 
 
@@ -1057,17 +1057,17 @@ nsIMM32Handler::HandleComposition(nsWind
       return ShouldDrawCompositionStringOurselves();
     }
 
     // IME may send WM_IME_COMPOSITION without composing lParam values
     // when composition string becomes empty (e.g., using Backspace key).
     // If composition string is empty, we should dispatch a compositionchange
     // event with empty string.
     if (mCompositionString.IsEmpty()) {
-      DispatchTextEvent(aWindow, aIMEContext, false);
+      DispatchCompositionChangeEvent(aWindow, aIMEContext, false);
       return ShouldDrawCompositionStringOurselves();
     }
 
     // Otherwise, we cannot trust the lParam value.  We might need to
     // dispatch compositionchange event with the latest composition string
     // information.
   }
 
@@ -1197,17 +1197,17 @@ nsIMM32Handler::HandleComposition(nsWind
 
   PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
     ("IMM32: HandleComposition, GCS_CURSORPOS, mCursorPosition=%d\n",
      mCursorPosition));
 
   //--------------------------------------------------------
   // 5. Send the compositionchange event
   //--------------------------------------------------------
-  DispatchTextEvent(aWindow, aIMEContext);
+  DispatchCompositionChangeEvent(aWindow, aIMEContext);
 
   return ShouldDrawCompositionStringOurselves();
 }
 
 void
 nsIMM32Handler::HandleEndComposition(nsWindow* aWindow)
 {
   NS_PRECONDITION(mIsComposing,
@@ -1511,17 +1511,17 @@ nsIMM32Handler::CommitCompositionOnPrevi
     ("IMM32: CommitCompositionOnPreviousWindow, mIsComposing=%s, mIsComposingOnPlugin=%s\n",
      mIsComposing ? "TRUE" : "FALSE", mIsComposingOnPlugin ? "TRUE" : "FALSE"));
 
   // If we have composition, we should dispatch composition events internally.
   if (mIsComposing) {
     nsIMEContext IMEContext(mComposingWindow->GetWindowHandle());
     NS_ASSERTION(IMEContext.IsValid(), "IME context must be valid");
 
-    DispatchTextEvent(mComposingWindow, IMEContext, false);
+    DispatchCompositionChangeEvent(mComposingWindow, IMEContext, false);
     HandleEndComposition(mComposingWindow);
     return true;
   }
 
   // XXX When plug-in has composition, we should commit composition on the
   // plug-in.  However, we need some more work for that.
   return mIsComposingOnPlugin;
 }
@@ -1564,23 +1564,23 @@ GetRangeTypeName(uint32_t aRangeType)
       return "NS_TEXTRANGE_CARETPOSITION";
     default:
       return "UNKNOWN SELECTION TYPE!!";
   }
 }
 #endif
 
 void
-nsIMM32Handler::DispatchTextEvent(nsWindow* aWindow,
-                                  const nsIMEContext &aIMEContext,
-                                  bool aCheckAttr)
+nsIMM32Handler::DispatchCompositionChangeEvent(nsWindow* aWindow,
+                                               const nsIMEContext &aIMEContext,
+                                               bool aCheckAttr)
 {
   NS_ASSERTION(mIsComposing, "conflict state");
   PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
-    ("IMM32: DispatchTextEvent, aCheckAttr=%s\n",
+    ("IMM32: DispatchCompositionChangeEvent, aCheckAttr=%s\n",
      aCheckAttr ? "TRUE": "FALSE"));
 
   // If we don't need to draw composition string ourselves and this is not
   // commit event (i.e., under composing), we don't need to fire
   // compositionchange event during composing.
   if (aCheckAttr && !ShouldDrawCompositionStringOurselves()) {
     // But we need to adjust composition window pos and native caret pos, here.
     SetIMERelatedWindowsPos(aWindow, aIMEContext);
--- a/widget/windows/nsIMM32Handler.h
+++ b/widget/windows/nsIMM32Handler.h
@@ -285,18 +285,19 @@ protected:
    *  the composition string range because the all is the current target.
    *
    *  aLength can be null (default), but aOffset must not be null.
    *
    *  The aOffset value is offset in the contents.  So, when you need offset
    *  in the composition string, you need to subtract mCompositionStart from it.
    */
   bool GetTargetClauseRange(uint32_t *aOffset, uint32_t *aLength = nullptr);
-  void DispatchTextEvent(nsWindow* aWindow, const nsIMEContext &aIMEContext,
-                         bool aCheckAttr = true);
+  void DispatchCompositionChangeEvent(nsWindow* aWindow,
+                                      const nsIMEContext &aIMEContext,
+                                      bool aCheckAttr = true);
   already_AddRefed<mozilla::TextRangeArray> CreateTextRangeArray();
 
   nsresult EnsureClauseArray(int32_t aCount);
   nsresult EnsureAttributeArray(int32_t aCount);
 
   /**
    * When WM_IME_CHAR is received and passed to DefWindowProc, we need to
    * record the messages.  In other words, we should record the messages
--- a/widget/windows/nsTextStore.cpp
+++ b/widget/windows/nsTextStore.cpp
@@ -2436,40 +2436,40 @@ nsTextStore::RecordCompositionUpdateActi
          ("TSF: 0x%p   nsTextStore::RecordCompositionUpdateAction() "
           "succeeded", this));
 
   return S_OK;
 }
 
 HRESULT
 nsTextStore::SetSelectionInternal(const TS_SELECTION_ACP* pSelection,
-                                  bool aDispatchTextEvent)
+                                  bool aDispatchCompositionChangeEvent)
 {
   PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
          ("TSF: 0x%p   nsTextStore::SetSelectionInternal(pSelection={ "
           "acpStart=%ld, acpEnd=%ld, style={ ase=%s, fInterimChar=%s} }, "
-          "aDispatchTextEvent=%s), mComposition.IsComposing()=%s",
+          "aDispatchCompositionChangeEvent=%s), mComposition.IsComposing()=%s",
           this, pSelection->acpStart, pSelection->acpEnd,
           GetActiveSelEndName(pSelection->style.ase),
           GetBoolName(pSelection->style.fInterimChar),
-          GetBoolName(aDispatchTextEvent),
+          GetBoolName(aDispatchCompositionChangeEvent),
           GetBoolName(mComposition.IsComposing())));
 
   MOZ_ASSERT(IsReadWriteLocked());
 
   Selection& currentSel = CurrentSelection();
   if (currentSel.IsDirty()) {
     PR_LOG(sTextStoreLog, PR_LOG_ERROR,
        ("TSF: 0x%p   nsTextStore::SetSelectionInternal() FAILED due to "
         "CurrentSelection() failure", this));
     return E_FAIL;
   }
 
   if (mComposition.IsComposing()) {
-    if (aDispatchTextEvent) {
+    if (aDispatchCompositionChangeEvent) {
       HRESULT hr = RestartCompositionIfNecessary();
       if (FAILED(hr)) {
         PR_LOG(sTextStoreLog, PR_LOG_ERROR,
            ("TSF: 0x%p   nsTextStore::SetSelectionInternal() FAILED due to "
             "RestartCompositionIfNecessary() failure", this));
         return hr;
       }
     }
@@ -2477,17 +2477,17 @@ nsTextStore::SetSelectionInternal(const 
         pSelection->acpEnd > mComposition.EndOffset()) {
       PR_LOG(sTextStoreLog, PR_LOG_ERROR,
          ("TSF: 0x%p   nsTextStore::SetSelectionInternal() FAILED due to "
           "the selection being out of the composition string", this));
       return TS_E_INVALIDPOS;
     }
     // Emulate selection during compositions
     currentSel.SetSelection(*pSelection);
-    if (aDispatchTextEvent) {
+    if (aDispatchCompositionChangeEvent) {
       HRESULT hr = RecordCompositionUpdateAction();
       if (FAILED(hr)) {
         PR_LOG(sTextStoreLog, PR_LOG_ERROR,
            ("TSF: 0x%p   nsTextStore::SetSelectionInternal() FAILED due to "
             "RecordCompositionUpdateAction() failure", this));
         return hr;
       }
     }
--- a/widget/windows/nsTextStore.h
+++ b/widget/windows/nsTextStore.h
@@ -246,22 +246,23 @@ protected:
   bool     IsReadLocked() const { return IsReadLock(mLock); }
   bool     IsReadWriteLocked() const { return IsReadWriteLock(mLock); }
 
   // This is called immediately after a call of OnLockGranted() of mSink.
   // Note that mLock isn't cleared yet when this is called.
   void     DidLockGranted();
 
   bool     GetScreenExtInternal(RECT &aScreenExt);
-  // If aDispatchTextEvent is true, this method will dispatch compositionchange
-  // event if this is called during IME composing.  aDispatchTextEvent should
-  // be true only when this is called from SetSelection.  Because otherwise,
-  // the compositionchange event should not be sent from here.
+  // If aDispatchCompositionChangeEvent is true, this method will dispatch
+  // compositionchange event if this is called during IME composing.
+  // aDispatchCompositionChangeEvent should be true only when this is called
+  // from SetSelection.  Because otherwise, the compositionchange event should
+  // not be sent from here.
   HRESULT  SetSelectionInternal(const TS_SELECTION_ACP*,
-                                bool aDispatchTextEvent = false);
+                                bool aDispatchCompositionChangeEvent = false);
   bool     InsertTextAtSelectionInternal(const nsAString &aInsertStr,
                                          TS_TEXTCHANGE* aTextChange);
   void     CommitCompositionInternal(bool);
   nsresult OnTextChangeInternal(const IMENotification& aIMENotification);
   nsresult OnSelectionChangeInternal(void);
   nsresult OnMouseButtonEventInternal(const IMENotification& aIMENotification);
   HRESULT  GetDisplayAttribute(ITfProperty* aProperty,
                                ITfRange* aRange,