Bug 960871 part.8 Rename variable names of NS_COMPOSITION_CHANGE event r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 07 Oct 2014 19:01:49 +0900
changeset 209143 93374aaa8f6e92919f39c6684261123adc45ce54
parent 209142 bd15674419d1e1880670163fdd8fac6a4668408f
child 209144 4f5abfd3505c4c51bc662749fbc16de521080547
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerssmaug
bugs960871
milestone35.0a1
Bug 960871 part.8 Rename variable names of NS_COMPOSITION_CHANGE event r=smaug
dom/base/CompositionStringSynthesizer.cpp
dom/events/EventStateManager.cpp
dom/events/TextComposition.cpp
dom/events/TextComposition.h
editor/libeditor/nsPlaintextEditor.cpp
widget/android/nsWindow.cpp
widget/cocoa/TextInputHandler.mm
widget/gtk/nsGtkIMModule.cpp
widget/gtk/nsWindow.cpp
widget/windows/nsTextStore.cpp
widget/xpwidgets/PuppetWidget.cpp
--- a/dom/base/CompositionStringSynthesizer.cpp
+++ b/dom/base/CompositionStringSynthesizer.cpp
@@ -130,28 +130,28 @@ CompositionStringSynthesizer::DispatchEv
     if (mCaret.mEndOffset > mString.Length()) {
       NS_WARNING("Caret position is out of the composition string");
       ClearInternal();
       return NS_ERROR_ILLEGAL_VALUE;
     }
     mClauses->AppendElement(mCaret);
   }
 
-  WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, widget);
-  textEvent.time = PR_IntervalNow();
-  textEvent.mData = mString;
+  WidgetCompositionEvent compChangeEvent(true, NS_COMPOSITION_CHANGE, widget);
+  compChangeEvent.time = PR_IntervalNow();
+  compChangeEvent.mData = mString;
   if (!mClauses->IsEmpty()) {
-    textEvent.mRanges = mClauses;
+    compChangeEvent.mRanges = mClauses;
   }
 
   // XXX How should we set false for this on b2g?
-  textEvent.mFlags.mIsSynthesizedForTests = true;
+  compChangeEvent.mFlags.mIsSynthesizedForTests = true;
 
   nsEventStatus status = nsEventStatus_eIgnore;
-  nsresult rv = widget->DispatchEvent(&textEvent, status);
+  nsresult rv = widget->DispatchEvent(&compChangeEvent, status);
   *aDefaultPrevented = (status == nsEventStatus_eConsumeNoDefault);
 
   ClearInternal();
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -793,20 +793,20 @@ EventStateManager::PreHandleEvent(nsPres
     break;
   case NS_CONTENT_COMMAND_SCROLL:
     {
       DoContentCommandScrollEvent(aEvent->AsContentCommandEvent());
     }
     break;
   case NS_COMPOSITION_CHANGE:
     {
-      WidgetCompositionEvent* textEvent = aEvent->AsCompositionEvent();
-      if (IsTargetCrossProcess(textEvent)) {
+      WidgetCompositionEvent* compositionEvent = aEvent->AsCompositionEvent();
+      if (IsTargetCrossProcess(compositionEvent)) {
         // Will not be handled locally, remote the event
-        if (GetCrossProcessTarget()->SendTextEvent(*textEvent)) {
+        if (GetCrossProcessTarget()->SendTextEvent(*compositionEvent)) {
           // Cancel local dispatching
           aEvent->mFlags.mPropagationStopped = true;
         }
       }
     }
     break;
   case NS_COMPOSITION_START:
     if (aEvent->mFlags.mIsTrusted) {
--- a/dom/events/TextComposition.cpp
+++ b/dom/events/TextComposition.cpp
@@ -280,29 +280,29 @@ TextComposition::RequestToCommit(nsIWidg
     } else {
       // Emulates to commit or cancel the composition
       // FYI: These events may be discarded by PresShell if it's not safe to
       //      dispatch the event.
       nsCOMPtr<nsIWidget> widget(aWidget);
       nsAutoString commitData(aDiscard ? EmptyString() : lastData);
       bool changingData = lastData != commitData;
 
-      WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, widget);
-      textEvent.mData = commitData;
-      textEvent.mFlags.mIsSynthesizedForTests = true;
+      WidgetCompositionEvent changeEvent(true, NS_COMPOSITION_CHANGE, widget);
+      changeEvent.mData = commitData;
+      changeEvent.mFlags.mIsSynthesizedForTests = true;
 
-      MaybeDispatchCompositionUpdate(&textEvent);
+      MaybeDispatchCompositionUpdate(&changeEvent);
 
       // If changing the data or committing string isn't empty, we need to
       // dispatch compositionchange event for setting the composition string
       // without IME selection.
       if (!Destroyed() && !widget->Destroyed() &&
           (changingData || !commitData.IsEmpty())) {
         nsEventStatus status = nsEventStatus_eIgnore;
-        widget->DispatchEvent(&textEvent, status);
+        widget->DispatchEvent(&changeEvent, status);
       }
 
       if (!Destroyed() && !widget->Destroyed()) {
         nsEventStatus status = nsEventStatus_eIgnore;
         WidgetCompositionEvent endEvent(true, NS_COMPOSITION_END, widget);
         endEvent.mData = commitData;
         endEvent.mFlags.mIsSynthesizedForTests = true;
         widget->DispatchEvent(&endEvent, status);
@@ -335,23 +335,23 @@ nsresult
 TextComposition::NotifyIME(IMEMessage aMessage)
 {
   NS_ENSURE_TRUE(mPresContext, NS_ERROR_NOT_AVAILABLE);
   return IMEStateManager::NotifyIME(aMessage, mPresContext);
 }
 
 void
 TextComposition::EditorWillHandleTextEvent(
-                   const WidgetCompositionEvent* aTextEvent)
+                   const WidgetCompositionEvent* aCompositionChangeEvent)
 {
-  mIsComposing = aTextEvent->IsComposing();
-  mRanges = aTextEvent->mRanges;
+  mIsComposing = aCompositionChangeEvent->IsComposing();
+  mRanges = aCompositionChangeEvent->mRanges;
   mIsEditorHandlingEvent = true;
 
-  MOZ_ASSERT(mLastData == aTextEvent->mData,
+  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()
 {
   mString = mLastData;
@@ -438,36 +438,27 @@ TextComposition::CompositionEventDispatc
       compStart.mData = selectedText.mReply.mString;
       compStart.mFlags.mIsSynthesizedForTests =
         mTextComposition->IsSynthesizedForTests();
       IMEStateManager::DispatchCompositionEvent(mEventTarget, presContext,
                                                 &compStart, &status, nullptr,
                                                 mIsSynthesizedEvent);
       break;
     }
-    case NS_COMPOSITION_END: {
+    case NS_COMPOSITION_END:
+    case NS_COMPOSITION_CHANGE: {
       WidgetCompositionEvent compEvent(true, mEventMessage, widget);
       compEvent.mData = mData;
       compEvent.mFlags.mIsSynthesizedForTests =
         mTextComposition->IsSynthesizedForTests();
       IMEStateManager::DispatchCompositionEvent(mEventTarget, presContext,
                                                 &compEvent, &status, nullptr,
                                                 mIsSynthesizedEvent);
       break;
     }
-    case NS_COMPOSITION_CHANGE: {
-      WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, widget);
-      textEvent.mData = mData;
-      textEvent.mFlags.mIsSynthesizedForTests =
-        mTextComposition->IsSynthesizedForTests();
-      IMEStateManager::DispatchCompositionEvent(mEventTarget, presContext,
-                                                &textEvent, &status, nullptr,
-                                                mIsSynthesizedEvent);
-      break;
-    }
     default:
       MOZ_CRASH("Unsupported event");
   }
   return NS_OK;
 }
 
 /******************************************************************************
  * TextCompositionArray
--- a/dom/events/TextComposition.h
+++ b/dom/events/TextComposition.h
@@ -126,21 +126,22 @@ public:
   /**
    * TextEventHandlingMarker class should be created at starting to handle text
    * event in focused editor.  This calls EditorWillHandleTextEvent() and
    * EditorDidHandleTextEvent() automatically.
    */
   class MOZ_STACK_CLASS TextEventHandlingMarker
   {
   public:
-    TextEventHandlingMarker(TextComposition* aComposition,
-                            const WidgetCompositionEvent* aTextEvent)
+    TextEventHandlingMarker(
+      TextComposition* aComposition,
+      const WidgetCompositionEvent* aCompositionChangeEvent)
       : mComposition(aComposition)
     {
-      mComposition->EditorWillHandleTextEvent(aTextEvent);
+      mComposition->EditorWillHandleTextEvent(aCompositionChangeEvent);
     }
 
     ~TextEventHandlingMarker()
     {
       mComposition->EditorDidHandleTextEvent();
     }
 
   private:
@@ -230,17 +231,18 @@ private:
    * alive.  Otherwise, false.
    */
   bool HasEditor() const;
 
   /**
    * EditorWillHandleTextEvent() must be called before the focused editor
    * handles the compositionchange event.
    */
-  void EditorWillHandleTextEvent(const WidgetCompositionEvent* aTextEvent);
+  void EditorWillHandleTextEvent(
+         const WidgetCompositionEvent* aCompositionChangeEvent);
 
   /**
    * EditorDidHandleTextEvent() must be called after the focused editor handles
    * a compositionchange event.
    */
   void EditorDidHandleTextEvent();
 
   /**
--- a/editor/libeditor/nsPlaintextEditor.cpp
+++ b/editor/libeditor/nsPlaintextEditor.cpp
@@ -841,23 +841,23 @@ nsPlaintextEditor::BeginIMEComposition(W
   return nsEditor::BeginIMEComposition(aEvent);
 }
 
 nsresult
 nsPlaintextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent)
 {
   NS_ABORT_IF_FALSE(aDOMTextEvent, "aDOMTextEvent must not be nullptr");
 
-  WidgetCompositionEvent* widgetTextEvent =
+  WidgetCompositionEvent* compositionChangeEvent =
     aDOMTextEvent->GetInternalNSEvent()->AsCompositionEvent();
-  NS_ENSURE_TRUE(widgetTextEvent, NS_ERROR_INVALID_ARG);
-  MOZ_ASSERT(compChangeEvent->message == NS_COMPOSITION_CHANGE,
+  NS_ENSURE_TRUE(compositionChangeEvent, NS_ERROR_INVALID_ARG);
+  MOZ_ASSERT(compositionChangeEvent->message == NS_COMPOSITION_CHANGE,
              "The internal event should be NS_COMPOSITION_CHANGE");
 
-  EnsureComposition(widgetTextEvent);
+  EnsureComposition(compositionChangeEvent);
 
   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);
 
@@ -867,26 +867,26 @@ nsPlaintextEditor::UpdateIMEComposition(
   //       ignore selection changes caused by composition.  Therefore,
   //       TextEventHandlingMarker 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, widgetTextEvent);
+    textEventHandlingMarker(mComposition, compositionChangeEvent);
 
   NotifyEditorObservers(eNotifyEditorObserversOfBefore);
 
   nsRefPtr<nsCaret> caretP = ps->GetCaret();
 
   {
     nsAutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName);
 
-    rv = InsertText(widgetTextEvent->mData);
+    rv = InsertText(compositionChangeEvent->mData);
 
     if (caretP) {
       caretP->SetSelection(selection);
     }
   }
 
   // If still composing, we should fire input event via observer.
   // Note that if committed, we don't need to notify it since it will be
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1702,24 +1702,25 @@ nsWindow::RemoveIMEComposition()
     // Remove composition on Gecko side
     if (!mIMEComposing)
         return;
 
     nsRefPtr<nsWindow> kungFuDeathGrip(this);
     AutoIMEMask selMask(mIMEMaskSelectionUpdate);
     AutoIMEMask textMask(mIMEMaskTextUpdate);
 
-    WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, this);
-    InitEvent(textEvent, nullptr);
-    textEvent.mData = mIMEComposingText;
-    DispatchEvent(&textEvent);
+    WidgetCompositionEvent compositionChangeEvent(true, NS_COMPOSITION_CHANGE,
+                                                  this);
+    InitEvent(compositionChangeEvent, nullptr);
+    compositionChangeEvent.mData = mIMEComposingText;
+    DispatchEvent(&compositionChangeEvent);
 
-    WidgetCompositionEvent event(true, NS_COMPOSITION_END, this);
-    InitEvent(event, nullptr);
-    DispatchEvent(&event);
+    WidgetCompositionEvent compEndEvent(true, NS_COMPOSITION_END, this);
+    InitEvent(compEndEvent, nullptr);
+    DispatchEvent(&compEndEvent);
 }
 
 void
 nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
 {
     MOZ_ASSERT(!mIMEMaskTextUpdate);
     MOZ_ASSERT(!mIMEMaskSelectionUpdate);
     /*
@@ -2081,24 +2082,25 @@ nsWindow::NotifyIME(const IMENotificatio
             return NS_OK;
         case REQUEST_TO_CANCEL_COMPOSITION:
             ALOGIME("IME: REQUEST_TO_CANCEL_COMPOSITION");
 
             // Cancel composition on Gecko side
             if (mIMEComposing) {
                 nsRefPtr<nsWindow> kungFuDeathGrip(this);
 
-                WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, this);
-                InitEvent(textEvent, nullptr);
-                DispatchEvent(&textEvent);
+                WidgetCompositionEvent compositionChangeEvent(
+                                         true, NS_COMPOSITION_CHANGE, this);
+                InitEvent(compositionChangeEvent, nullptr);
+                DispatchEvent(&compositionChangeEvent);
 
-                WidgetCompositionEvent compEvent(true, NS_COMPOSITION_END,
-                                                 this);
-                InitEvent(compEvent, nullptr);
-                DispatchEvent(&compEvent);
+                WidgetCompositionEvent compositionEndEvent(
+                                         true, NS_COMPOSITION_END, this);
+                InitEvent(compositionEndEvent, nullptr);
+                DispatchEvent(&compositionEndEvent);
             }
 
             mozilla::widget::android::GeckoAppShell::NotifyIME(REQUEST_TO_CANCEL_COMPOSITION);
             return NS_OK;
         case NOTIFY_IME_OF_FOCUS:
             ALOGIME("IME: NOTIFY_IME_OF_FOCUS");
             mozilla::widget::android::GeckoAppShell::NotifyIME(NOTIFY_IME_OF_FOCUS);
             return NS_OK;
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -2135,17 +2135,17 @@ TextInputHandler::InsertText(NSAttribute
   // If the replacement range is specified, select the range.  Then, the
   // selection will be replaced by the later keypress event.
   if (isEditable &&
       aReplacementRange && aReplacementRange->location != NSNotFound &&
       !NSEqualRanges(selectedRange, *aReplacementRange)) {
     NS_ENSURE_TRUE_VOID(SetSelection(*aReplacementRange));
   }
 
-  // Dispatch keypress event with char instead of textEvent
+  // Dispatch keypress event with char instead of compositionchange event
   WidgetKeyboardEvent keypressEvent(true, NS_KEY_PRESS, mWidget);
   keypressEvent.isChar = IsPrintableChar(str.CharAt(0));
 
   // Don't set other modifiers from the current event, because here in
   // -insertText: they've already been taken into account in creating
   // the input string.
 
   if (currentKeyEvent) {
@@ -2711,24 +2711,26 @@ IMEInputHandler::DispatchTextEvent(const
      GetCharacters([aAttrString string]),
      aSelectedRange.location, aSelectedRange.length,
      TrueOrFalse(aDoCommit), TrueOrFalse(Destroyed())));
 
   NS_ENSURE_TRUE(!Destroyed(), false);
 
   nsRefPtr<IMEInputHandler> kungFuDeathGrip(this);
 
-  WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, mWidget);
-  textEvent.time = PR_IntervalNow();
-  textEvent.mData = aText;
+  WidgetCompositionEvent compositionChangeEvent(true, NS_COMPOSITION_CHANGE,
+                                                mWidget);
+  compositionChangeEvent.time = PR_IntervalNow();
+  compositionChangeEvent.mData = aText;
   if (!aDoCommit) {
-    textEvent.mRanges = CreateTextRangeArray(aAttrString, aSelectedRange);
+    compositionChangeEvent.mRanges =
+      CreateTextRangeArray(aAttrString, aSelectedRange);
   }
-  mLastDispatchedCompositionString = textEvent.mData;
-  return DispatchEvent(textEvent);
+  mLastDispatchedCompositionString = compositionChangeEvent.mData;
+  return DispatchEvent(compositionChangeEvent);
 }
 
 void
 IMEInputHandler::InitCompositionEvent(WidgetCompositionEvent& aCompositionEvent)
 {
   aCompositionEvent.time = PR_IntervalNow();
 }
 
--- a/widget/gtk/nsGtkIMModule.cpp
+++ b/widget/gtk/nsGtkIMModule.cpp
@@ -1102,36 +1102,37 @@ nsGtkIMModule::DispatchTextEvent(const n
                                                        mLastFocusedWindow);
         mLastFocusedWindow->DispatchEvent(&querySelectedTextEvent, status);
         if (querySelectedTextEvent.mSucceeded) {
             mSelectedString = querySelectedTextEvent.mReply.mString;
             mCompositionStart = querySelectedTextEvent.mReply.mOffset;
         }
     }
 
-    WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE,
-                                     mLastFocusedWindow);
-    InitEvent(textEvent);
+    WidgetCompositionEvent compositionChangeEvent(true, NS_COMPOSITION_CHANGE,
+                                                  mLastFocusedWindow);
+    InitEvent(compositionChangeEvent);
 
     uint32_t targetOffset = mCompositionStart;
 
-    textEvent.mData = mDispatchedCompositionString = aCompositionString;
+    compositionChangeEvent.mData =
+      mDispatchedCompositionString = aCompositionString;
 
     if (!aIsCommit) {
         // NOTE: SetTextRangeList() assumes that mDispatchedCompositionString
         //       has been updated already.
-        textEvent.mRanges = CreateTextRangeArray();
-        targetOffset += textEvent.mRanges->TargetClauseOffset();
+        compositionChangeEvent.mRanges = CreateTextRangeArray();
+        targetOffset += compositionChangeEvent.mRanges->TargetClauseOffset();
     }
 
     mCompositionState = aIsCommit ?
         eCompositionState_CommitTextEventDispatched :
         eCompositionState_TextEventDispatched;
 
-    mLastFocusedWindow->DispatchEvent(&textEvent, status);
+    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;
     }
 
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3041,24 +3041,25 @@ nsWindow::OnKeyPressEvent(GdkEventKey *a
     else {
         // If the character code is in the BMP, send the key press event.
         // Otherwise, send a compositionchange event with the equivalent UTF-16
         // string.
         if (IS_IN_BMP(event.charCode)) {
             DispatchEvent(&event, status);
         }
         else {
-            WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, this);
+            WidgetCompositionEvent compositionChangeEvent(
+                                     true, NS_COMPOSITION_CHANGE, this);
             char16_t textString[3];
             textString[0] = H_SURROGATE(event.charCode);
             textString[1] = L_SURROGATE(event.charCode);
             textString[2] = 0;
-            textEvent.mData = textString;
-            textEvent.time = event.time;
-            DispatchEvent(&textEvent, status);
+            compositionChangeEvent.mData = textString;
+            compositionChangeEvent.time = event.time;
+            DispatchEvent(&compositionChangeEvent, status);
         }
     }
 
     // If the event was consumed, return.
     if (status == nsEventStatus_eConsumeNoDefault) {
         return TRUE;
     }
 
--- a/widget/windows/nsTextStore.cpp
+++ b/widget/windows/nsTextStore.cpp
@@ -1645,57 +1645,59 @@ nsTextStore::FlushPendingActions()
         }
 
         action.mData.ReplaceSubstring(NS_LITERAL_STRING("\r\n"),
                                       NS_LITERAL_STRING("\n"));
 
         PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
                ("TSF: 0x%p   nsTextStore::FlushPendingActions(), "
                 "dispatching compositionchange event...", this));
-        WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, mWidget);
-        mWidget->InitEvent(textEvent);
-        textEvent.mData = action.mData;
+        WidgetCompositionEvent compositionChange(true, NS_COMPOSITION_CHANGE,
+                                                 mWidget);
+        mWidget->InitEvent(compositionChange);
+        compositionChange.mData = action.mData;
         if (action.mRanges->IsEmpty()) {
           TextRange wholeRange;
           wholeRange.mStartOffset = 0;
-          wholeRange.mEndOffset = textEvent.mData.Length();
+          wholeRange.mEndOffset = compositionChange.mData.Length();
           wholeRange.mRangeType = NS_TEXTRANGE_RAWINPUT;
           action.mRanges->AppendElement(wholeRange);
         }
-        textEvent.mRanges = action.mRanges;
-        mWidget->DispatchWindowEvent(&textEvent);
+        compositionChange.mRanges = action.mRanges;
+        mWidget->DispatchWindowEvent(&compositionChange);
         // Be aware, the mWidget might already have been destroyed.
         break;
       }
       case PendingAction::COMPOSITION_END: {
         PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
                ("TSF: 0x%p   nsTextStore::FlushPendingActions() "
                 "flushing COMPOSITION_END={ mData=\"%s\" }",
                 this, NS_ConvertUTF16toUTF8(action.mData).get()));
 
         action.mData.ReplaceSubstring(NS_LITERAL_STRING("\r\n"),
                                       NS_LITERAL_STRING("\n"));
 
         PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
                ("TSF: 0x%p   nsTextStore::FlushPendingActions(), "
                 "dispatching compositionchange event...", this));
-        WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, mWidget);
-        mWidget->InitEvent(textEvent);
-        textEvent.mData = action.mData;
-        mWidget->DispatchWindowEvent(&textEvent);
+        WidgetCompositionEvent compositionChange(true, NS_COMPOSITION_CHANGE,
+                                                 mWidget);
+        mWidget->InitEvent(compositionChange);
+        compositionChange.mData = action.mData;
+        mWidget->DispatchWindowEvent(&compositionChange);
         if (!mWidget || mWidget->Destroyed()) {
           break;
         }
 
         PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
                ("TSF: 0x%p   nsTextStore::FlushPendingActions(), "
                 "dispatching compositionend event...", this));
         WidgetCompositionEvent compositionEnd(true, NS_COMPOSITION_END,
                                               mWidget);
-        compositionEnd.mData = textEvent.mData;
+        compositionEnd.mData = compositionChange.mData;
         mWidget->InitEvent(compositionEnd);
         mWidget->DispatchWindowEvent(&compositionEnd);
         if (!mWidget || mWidget->Destroyed()) {
           break;
         }
         break;
       }
       case PendingAction::SELECTION_SET: {
--- a/widget/xpwidgets/PuppetWidget.cpp
+++ b/widget/xpwidgets/PuppetWidget.cpp
@@ -374,35 +374,37 @@ PuppetWidget::GetLayerManager(PLayerTran
 nsresult
 PuppetWidget::IMEEndComposition(bool aCancel)
 {
 #ifndef MOZ_CROSS_PROCESS_IME
   return NS_OK;
 #endif
 
   nsEventStatus status;
-  WidgetCompositionEvent textEvent(true, NS_COMPOSITION_CHANGE, this);
-  InitEvent(textEvent, nullptr);
-  textEvent.mSeqno = mIMELastReceivedSeqno;
+  WidgetCompositionEvent compositionChangeEvent(true, NS_COMPOSITION_CHANGE,
+                                                this);
+  InitEvent(compositionChangeEvent, nullptr);
+  compositionChangeEvent.mSeqno = mIMELastReceivedSeqno;
   // SendEndIMEComposition is always called since ResetInputState
   // should always be called even if we aren't composing something.
   if (!mTabChild ||
-      !mTabChild->SendEndIMEComposition(aCancel, &textEvent.mData)) {
+      !mTabChild->SendEndIMEComposition(aCancel,
+                                        &compositionChangeEvent.mData)) {
     return NS_ERROR_FAILURE;
   }
 
   if (!mIMEComposing)
     return NS_OK;
 
-  DispatchEvent(&textEvent, status);
+  DispatchEvent(&compositionChangeEvent, status);
 
-  WidgetCompositionEvent compEvent(true, NS_COMPOSITION_END, this);
-  InitEvent(compEvent, nullptr);
-  compEvent.mSeqno = mIMELastReceivedSeqno;
-  DispatchEvent(&compEvent, status);
+  WidgetCompositionEvent compositionEndEvent(true, NS_COMPOSITION_END, this);
+  InitEvent(compositionEndEvent, nullptr);
+  compositionEndEvent.mSeqno = mIMELastReceivedSeqno;
+  DispatchEvent(&compositionEndEvent, status);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PuppetWidget::NotifyIME(const IMENotification& aIMENotification)
 {
   switch (aIMENotification.mMessage) {
     case REQUEST_TO_COMMIT_COMPOSITION: