Bug 1260651 part.23 Rename mozilla::dom::IMETextTxn to mozilla::CompositionTransaction (and their files too) r=mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 07 Jul 2016 15:42:08 +0900
changeset 385855 fad7f6a86612804a9e328d33cfba30fccf58bd25
parent 385854 c6edbc7306c56bdc8b40e55c058aadbd2c70ea1b
child 385856 80b825e3a3ac0c3f1cbac6366c1f7dcdc0275d74
push id22587
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 06:59:31 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.23 Rename mozilla::dom::IMETextTxn to mozilla::CompositionTransaction (and their files too) r=mccr8 This patch renames IMETextTxn to CompositionTransaction. "Composition" is now used in some web standard specs, e.g., CompositionEvent defined by UI Events. This patch also renames nsEditor::CreateTxnForIMEText() to nsEditor::CreateTxnForComposition(). MozReview-Commit-ID: JN0GgGdpAWG
editor/libeditor/CompositionTransaction.cpp
editor/libeditor/CompositionTransaction.h
editor/libeditor/IMETextTxn.cpp
editor/libeditor/IMETextTxn.h
editor/libeditor/PlaceholderTxn.cpp
editor/libeditor/PlaceholderTxn.h
editor/libeditor/moz.build
editor/libeditor/nsEditor.cpp
editor/libeditor/nsEditor.h
rename from editor/libeditor/IMETextTxn.cpp
rename to editor/libeditor/CompositionTransaction.cpp
--- a/editor/libeditor/IMETextTxn.cpp
+++ b/editor/libeditor/CompositionTransaction.cpp
@@ -1,63 +1,65 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "IMETextTxn.h"
+#include "CompositionTransaction.h"
 
 #include "mozilla/dom/Selection.h"      // local var
 #include "mozilla/dom/Text.h"           // mTextNode
 #include "nsAString.h"                  // params
 #include "nsDebug.h"                    // for NS_ASSERTION, etc
 #include "nsEditor.h"                   // mEditor
 #include "nsError.h"                    // for NS_SUCCEEDED, NS_FAILED, etc
 #include "nsIPresShell.h"               // nsISelectionController constants
 #include "nsRange.h"                    // local var
 #include "nsQueryObject.h"              // for do_QueryObject
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
-IMETextTxn::IMETextTxn(Text& aTextNode, uint32_t aOffset,
-                       uint32_t aReplaceLength,
-                       TextRangeArray* aTextRangeArray,
-                       const nsAString& aStringToInsert,
-                       nsEditor& aEditor)
-  : EditTxn()
-  , mTextNode(&aTextNode)
+CompositionTransaction::CompositionTransaction(
+                          Text& aTextNode,
+                          uint32_t aOffset,
+                          uint32_t aReplaceLength,
+                          TextRangeArray* aTextRangeArray,
+                          const nsAString& aStringToInsert,
+                          nsEditor& aEditor)
+  : mTextNode(&aTextNode)
   , mOffset(aOffset)
   , mReplaceLength(aReplaceLength)
   , mRanges(aTextRangeArray)
   , mStringToInsert(aStringToInsert)
   , mEditor(aEditor)
   , mFixed(false)
 {
 }
 
-IMETextTxn::~IMETextTxn()
+CompositionTransaction::~CompositionTransaction()
 {
 }
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED(IMETextTxn, EditTxn,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(CompositionTransaction, EditTxn,
                                    mTextNode)
 // mRangeList can't lead to cycles
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IMETextTxn)
-  if (aIID.Equals(NS_GET_IID(IMETextTxn))) {
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CompositionTransaction)
+  if (aIID.Equals(NS_GET_IID(CompositionTransaction))) {
     foundInterface = static_cast<nsITransaction*>(this);
   } else
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
-NS_IMPL_ADDREF_INHERITED(IMETextTxn, EditTxn)
-NS_IMPL_RELEASE_INHERITED(IMETextTxn, EditTxn)
+NS_IMPL_ADDREF_INHERITED(CompositionTransaction, EditTxn)
+NS_IMPL_RELEASE_INHERITED(CompositionTransaction, EditTxn)
 
 NS_IMETHODIMP
-IMETextTxn::DoTransaction()
+CompositionTransaction::DoTransaction()
 {
   // Fail before making any changes if there's no selection controller
   nsCOMPtr<nsISelectionController> selCon;
   mEditor.GetSelectionController(getter_AddRefs(selCon));
   NS_ENSURE_TRUE(selCon, NS_ERROR_NOT_INITIALIZED);
 
   // Advance caret: This requires the presentation shell to get the selection.
   nsresult res;
@@ -70,17 +72,17 @@ IMETextTxn::DoTransaction()
 
   res = SetSelectionForRanges();
   NS_ENSURE_SUCCESS(res, res);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-IMETextTxn::UndoTransaction()
+CompositionTransaction::UndoTransaction()
 {
   // Get the selection first so we'll fail before making any changes if we
   // can't get it
   RefPtr<Selection> selection = mEditor.GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
 
   nsresult res = mTextNode->DeleteData(mOffset, mStringToInsert.Length());
   NS_ENSURE_SUCCESS(res, res);
@@ -90,70 +92,72 @@ IMETextTxn::UndoTransaction()
   NS_ASSERTION(NS_SUCCEEDED(res),
                "Selection could not be collapsed after undo of IME insert.");
   NS_ENSURE_SUCCESS(res, res);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-IMETextTxn::Merge(nsITransaction* aTransaction, bool* aDidMerge)
+CompositionTransaction::Merge(nsITransaction* aTransaction,
+                              bool* aDidMerge)
 {
   NS_ENSURE_ARG_POINTER(aTransaction && aDidMerge);
 
   // Check to make sure we aren't fixed, if we are then nothing gets absorbed
   if (mFixed) {
     *aDidMerge = false;
     return NS_OK;
   }
 
-  // If aTransaction is another IMETextTxn then absorb it
-  RefPtr<IMETextTxn> otherTxn = do_QueryObject(aTransaction);
-  if (otherTxn) {
+  // If aTransaction is another CompositionTransaction then absorb it
+  RefPtr<CompositionTransaction> otherTransaction =
+    do_QueryObject(aTransaction);
+  if (otherTransaction) {
     // We absorb the next IME transaction by adopting its insert string
-    mStringToInsert = otherTxn->mStringToInsert;
-    mRanges = otherTxn->mRanges;
+    mStringToInsert = otherTransaction->mStringToInsert;
+    mRanges = otherTransaction->mRanges;
     *aDidMerge = true;
     return NS_OK;
   }
 
   *aDidMerge = false;
   return NS_OK;
 }
 
 void
-IMETextTxn::MarkFixed()
+CompositionTransaction::MarkFixed()
 {
   mFixed = true;
 }
 
 NS_IMETHODIMP
-IMETextTxn::GetTxnDescription(nsAString& aString)
+CompositionTransaction::GetTxnDescription(nsAString& aString)
 {
-  aString.AssignLiteral("IMETextTxn: ");
+  aString.AssignLiteral("CompositionTransaction: ");
   aString += mStringToInsert;
   return NS_OK;
 }
 
 /* ============ private methods ================== */
 
 nsresult
-IMETextTxn::SetSelectionForRanges()
+CompositionTransaction::SetSelectionForRanges()
 {
   return SetIMESelection(mEditor, mTextNode, mOffset,
                          mStringToInsert.Length(), mRanges);
 }
 
 // static
 nsresult
-IMETextTxn::SetIMESelection(nsEditor& aEditor,
-                            Text* aTextNode,
-                            uint32_t aOffsetInNode,
-                            uint32_t aLengthOfCompositionString,
-                            const TextRangeArray* aRanges)
+CompositionTransaction::SetIMESelection(nsEditor& aEditor,
+                                        Text* aTextNode,
+                                        uint32_t aOffsetInNode,
+                                        uint32_t aLengthOfCompositionString,
+                                        const TextRangeArray* aRanges)
 {
   RefPtr<Selection> selection = aEditor.GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
 
   nsresult rv = selection->StartBatchChanges();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // First, remove all selections of IME composition.
@@ -286,8 +290,10 @@ IMETextTxn::SetIMESelection(nsEditor& aE
     aEditor.HideCaret(true);
   }
 
   rv = selection->EndBatchChangesInternal();
   NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to end batch changes");
 
   return rv;
 }
+
+} // namespace mozilla
rename from editor/libeditor/IMETextTxn.h
rename to editor/libeditor/CompositionTransaction.h
--- a/editor/libeditor/IMETextTxn.h
+++ b/editor/libeditor/CompositionTransaction.h
@@ -1,92 +1,99 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef IMETextTxn_h__
-#define IMETextTxn_h__
+#ifndef CompositionTransaction_h
+#define CompositionTransaction_h
 
 #include "EditTxn.h"                      // base class
 #include "nsCycleCollectionParticipant.h" // various macros
 #include "nsString.h"                     // mStringToInsert
 
 class nsEditor;
 
 #define NS_IMETEXTTXN_IID \
   { 0xb391355d, 0x346c, 0x43d1, \
     { 0x85, 0xed, 0x9e, 0x65, 0xbe, 0xe7, 0x7e, 0x48 } }
 
 namespace mozilla {
 
 class TextRangeArray;
 
 namespace dom {
-
 class Text;
+} // namespace dom
 
 /**
-  * A transaction that inserts text into a content node.
-  */
-class IMETextTxn : public EditTxn
+ * CompositionTransaction stores all edit for a composition, i.e.,
+ * from compositionstart event to compositionend event.  E.g., inserting a
+ * composition string, modifying the composition string or its IME selection
+ * ranges and commit or cancel the composition.
+ */
+class CompositionTransaction final : public EditTxn
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMETEXTTXN_IID)
 
-  /** @param aTextNode the text content node
-    * @param aOffset  the location in aTextNode to do the insertion
-    * @param aReplaceLength the length of text to replace (0 == no replacement)
-    * @param aTextRangeArray clauses and/or caret information. This may be null.
-    * @param aString the new text to insert
-    * @param aEditor used to get and set the selection
-    */
-  IMETextTxn(Text& aTextNode, uint32_t aOffset, uint32_t aReplaceLength,
-             TextRangeArray* aTextRangeArray, const nsAString& aString,
-             nsEditor& aEditor);
+  /**
+   * @param aTextNode           The text content node.
+   * @param aOffset             The location in aTextNode to do the insertion.
+   * @param aReplaceLength      The length of text to replace. 0 means not
+   *                            replacing existing text.
+   * @param aTextRangeArray     Clauses and/or caret information. This may be
+   *                            null.
+   * @param aString             The new text to insert.
+   * @param aEditor             Used to get and set the selection.
+   */
+  CompositionTransaction(dom::Text& aTextNode,
+                         uint32_t aOffset, uint32_t aReplaceLength,
+                         TextRangeArray* aTextRangeArray,
+                         const nsAString& aString,
+                         nsEditor& aEditor);
 
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IMETextTxn, EditTxn)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CompositionTransaction, EditTxn)
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_EDITTXN
 
   NS_IMETHOD Merge(nsITransaction* aTransaction, bool* aDidMerge) override;
 
   void MarkFixed();
 
   static nsresult SetIMESelection(nsEditor& aEditor,
-                                  Text* aTextNode,
+                                  dom::Text* aTextNode,
                                   uint32_t aOffsetInNode,
                                   uint32_t aLengthOfCompositionString,
                                   const TextRangeArray* aRanges);
 
 private:
-  ~IMETextTxn();
+  ~CompositionTransaction();
 
   nsresult SetSelectionForRanges();
 
-  /** The text element to operate upon */
-  RefPtr<Text> mTextNode;
+  // The text element to operate upon.
+  RefPtr<dom::Text> mTextNode;
 
-  /** The offsets into mTextNode where the insertion should be placed */
+  // The offsets into mTextNode where the insertion should be placed.
   uint32_t mOffset;
 
   uint32_t mReplaceLength;
 
-  /** The range list **/
+  // The range list.
   RefPtr<TextRangeArray> mRanges;
 
-  /** The text to insert into mTextNode at mOffset */
+  // The text to insert into mTextNode at mOffset.
   nsString mStringToInsert;
 
-  /** The editor, which is used to get the selection controller */
+  // The editor, which is used to get the selection controller.
   nsEditor& mEditor;
 
   bool mFixed;
 };
 
-NS_DEFINE_STATIC_IID_ACCESSOR(IMETextTxn, NS_IMETEXTTXN_IID)
+NS_DEFINE_STATIC_IID_ACCESSOR(CompositionTransaction, NS_IMETEXTTXN_IID)
 
-} // namespace dom
 } // namespace mozilla
 
-#endif
+#endif // #ifndef CompositionTransaction_h
--- a/editor/libeditor/PlaceholderTxn.cpp
+++ b/editor/libeditor/PlaceholderTxn.cpp
@@ -1,31 +1,30 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "PlaceholderTxn.h"
+
+#include "CompositionTransaction.h"
+#include "mozilla/dom/Selection.h"
 #include "nsEditor.h"
-#include "IMETextTxn.h"
 #include "nsGkAtoms.h"
-#include "mozilla/dom/Selection.h"
 #include "nsQueryObject.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
-PlaceholderTxn::PlaceholderTxn() :  EditAggregateTxn(),
-                                    mAbsorb(true),
-                                    mForwarding(nullptr),
-                                    mIMETextTxn(nullptr),
-                                    mCommitted(false),
-                                    mStartSel(nullptr),
-                                    mEndSel(),
-                                    mEditor(nullptr)
+PlaceholderTxn::PlaceholderTxn()
+  : mAbsorb(true)
+  , mForwarding(nullptr)
+  , mCompositionTransaction(nullptr)
+  , mCommitted(false)
+  , mEditor(nullptr)
 {
 }
 
 PlaceholderTxn::~PlaceholderTxn()
 {
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(PlaceholderTxn)
@@ -122,42 +121,39 @@ NS_IMETHODIMP PlaceholderTxn::Merge(nsIT
 
   EditTxn *editTxn = (EditTxn*)aTransaction;  //XXX: hack, not safe!  need nsIEditTransaction!
   // determine if this incoming txn is a placeholder txn
   nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryObject(editTxn);
 
   // we are absorbing all txn's if mAbsorb is lit.
   if (mAbsorb)
   {
-    RefPtr<IMETextTxn> otherTxn = do_QueryObject(aTransaction);
-    if (otherTxn) {
-      // special handling for IMETextTxn's: they need to merge with any previous
-      // IMETextTxn in this placeholder, if possible.
-      if (!mIMETextTxn)
-      {
+    RefPtr<CompositionTransaction> otherTransaction =
+      do_QueryObject(aTransaction);
+    if (otherTransaction) {
+      // special handling for CompositionTransaction's: they need to merge with
+      // any previous CompositionTransaction in this placeholder, if possible.
+      if (!mCompositionTransaction) {
         // this is the first IME txn in the placeholder
-        mIMETextTxn =otherTxn;
+        mCompositionTransaction = otherTransaction;
         AppendChild(editTxn);
-      }
-      else
-      {
+      } else {
         bool didMerge;
-        mIMETextTxn->Merge(otherTxn, &didMerge);
-        if (!didMerge)
-        {
+        mCompositionTransaction->Merge(otherTransaction, &didMerge);
+        if (!didMerge) {
           // it wouldn't merge.  Earlier IME txn is already committed and will
           // not absorb further IME txns.  So just stack this one after it
           // and remember it as a candidate for further merges.
-          mIMETextTxn =otherTxn;
+          mCompositionTransaction = otherTransaction;
           AppendChild(editTxn);
         }
       }
-    }
-    else if (!plcTxn)  // see bug 171243: just drop incoming placeholders on the floor.
-    {                  // their children will be swallowed by this preexisting one.
+    } else if (!plcTxn) {
+      // See bug 171243: just drop incoming placeholders on the floor.
+      // Their children will be swallowed by this preexisting one.
       AppendChild(editTxn);
     }
     *aDidMerge = true;
 //  RememberEndingSelection();
 //  efficiency hack: no need to remember selection here, as we haven't yet
 //  finished the initial batch and we know we will be told when the batch ends.
 //  we can remeber the selection then.
   }
--- a/editor/libeditor/PlaceholderTxn.h
+++ b/editor/libeditor/PlaceholderTxn.h
@@ -11,19 +11,17 @@
 #include "nsIAbsorbingTransaction.h"
 #include "nsIDOMNode.h"
 #include "nsCOMPtr.h"
 #include "nsWeakPtr.h"
 #include "nsWeakReference.h"
 #include "nsAutoPtr.h"
 
 namespace mozilla {
-namespace dom {
-class IMETextTxn;
-} // namespace dom
+class CompositionTransaction;
 } // namespace mozilla
 
 /**
  * An aggregate transaction that knows how to absorb all subsequent
  * transactions with the same name.  This transaction does not "Do" anything.
  * But it absorbs other transactions via merge, and can undo/redo the
  * transactions it has absorbed.
  */
@@ -63,17 +61,18 @@ public:
   nsresult RememberEndingSelection();
 
 protected:
   virtual ~PlaceholderTxn();
 
   /** the presentation shell, which we'll need to get the selection */
   bool        mAbsorb;          // do we auto absorb any and all transaction?
   nsWeakPtr   mForwarding;
-  mozilla::dom::IMETextTxn *mIMETextTxn;      // first IME txn in this placeholder - used for IME merging
+  // First IME txn in this placeholder - used for IME merging.
+  mozilla::CompositionTransaction* mCompositionTransaction;
                                 // non-owning for now - can't nsCOMPtr it due to broken transaction interfaces
   bool        mCommitted;       // do we stop auto absorbing any matching placeholder txns?
   // these next two members store the state of the selection in a safe way.
   // selection at the start of the txn is stored, as is the selection at the end.
   // This is so that UndoTransaction() and RedoTransaction() can restore the
   // selection properly.
   nsAutoPtr<nsSelectionState> mStartSel; // use a pointer because this is constructed before we exist
   nsSelectionState  mEndSel;
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -11,25 +11,25 @@ MOCHITEST_MANIFESTS += [
 
 MOCHITEST_CHROME_MANIFESTS += ['tests/chrome.ini']
 
 BROWSER_CHROME_MANIFESTS += ['tests/browser.ini']
 
 UNIFIED_SOURCES += [
     'ChangeAttributeTransaction.cpp',
     'ChangeStyleTransaction.cpp',
+    'CompositionTransaction.cpp',
     'CreateElementTransaction.cpp',
     'DeleteNodeTransaction.cpp',
     'DeleteRangeTransaction.cpp',
     'DeleteTextTransaction.cpp',
     'EditAggregateTxn.cpp',
     'EditorUtils.cpp',
     'EditTxn.cpp',
     'HTMLEditUtils.cpp',
-    'IMETextTxn.cpp',
     'InsertNodeTxn.cpp',
     'InsertTextTxn.cpp',
     'JoinNodeTxn.cpp',
     'nsEditor.cpp',
     'nsEditorCommands.cpp',
     'nsEditorController.cpp',
     'nsEditorEventListener.cpp',
     'nsHTMLAbsPosition.cpp',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -6,24 +6,24 @@
 #include "nsEditor.h"
 
 #include "mozilla/DebugOnly.h"          // for DebugOnly
 
 #include <stdio.h>                      // for nullptr, stdout
 #include <string.h>                     // for strcmp
 
 #include "ChangeAttributeTransaction.h" // for ChangeAttributeTransaction
+#include "CompositionTransaction.h"     // for CompositionTransaction
 #include "CreateElementTransaction.h"   // for CreateElementTransaction
 #include "DeleteNodeTransaction.h"      // for DeleteNodeTransaction
 #include "DeleteRangeTransaction.h"     // for DeleteRangeTransaction
 #include "DeleteTextTransaction.h"      // for DeleteTextTransaction
 #include "EditAggregateTxn.h"           // for EditAggregateTxn
 #include "EditorUtils.h"                // for AutoRules, etc
 #include "EditTxn.h"                    // for EditTxn
-#include "IMETextTxn.h"                 // for IMETextTxn
 #include "InsertNodeTxn.h"              // for InsertNodeTxn
 #include "InsertTextTxn.h"              // for InsertTextTxn
 #include "JoinNodeTxn.h"                // for JoinNodeTxn
 #include "PlaceholderTxn.h"             // for PlaceholderTxn
 #include "SplitNodeTxn.h"               // for SplitNodeTxn
 #include "TextEditUtils.h"              // for TextEditUtils
 #include "mozFlushType.h"               // for mozFlushType::Flush_Frames
 #include "mozInlineSpellChecker.h"      // for mozInlineSpellChecker
@@ -2428,17 +2428,17 @@ nsEditor::InsertTextIntoTextNodeImpl(con
       if (!mPhonetic) {
         mPhonetic = new nsString();
       }
       nsAutoString stringToInsert(aStringToInsert);
       stringToInsert.Mid(*mPhonetic,
                          textRange.mStartOffset, textRange.Length());
     }
 
-    txn = CreateTxnForIMEText(aStringToInsert);
+    txn = CreateTxnForComposition(aStringToInsert);
     isIMETransaction = true;
     // All characters of the composition string will be replaced with
     // aStringToInsert.  So, we need to emulate to remove the composition
     // string.
     replacedOffset = mIMETextOffset;
     replacedLength = mIMETextLength;
     mIMETextLength = aStringToInsert.Length();
   } else {
@@ -2482,17 +2482,17 @@ nsEditor::InsertTextIntoTextNodeImpl(con
   // already savvy to having multiple ime txns inside them.
 
   // Delete empty IME text node if there is one
   if (isIMETransaction && mIMETextNode) {
     uint32_t len = mIMETextNode->Length();
     if (!len) {
       DeleteNode(mIMETextNode);
       mIMETextNode = nullptr;
-      static_cast<IMETextTxn*>(txn.get())->MarkFixed();
+      static_cast<CompositionTransaction*>(txn.get())->MarkFixed();
     }
   }
 
   return res;
 }
 
 
 nsresult
@@ -4223,29 +4223,29 @@ nsEditor::CreateTxnForDeleteNode(nsINode
 
   nsresult rv = transaction->Init(this, aNode, &mRangeUpdater);
   NS_ENSURE_SUCCESS(rv, rv);
 
   transaction.forget(aTransaction);
   return NS_OK;
 }
 
-already_AddRefed<IMETextTxn>
-nsEditor::CreateTxnForIMEText(const nsAString& aStringToInsert)
+already_AddRefed<CompositionTransaction>
+nsEditor::CreateTxnForComposition(const nsAString& aStringToInsert)
 {
   MOZ_ASSERT(mIMETextNode);
   // During handling IME composition, mComposition must have been initialized.
-  // TODO: We can simplify IMETextTxn::Init() with TextComposition class.
-  RefPtr<IMETextTxn> txn = new IMETextTxn(*mIMETextNode, mIMETextOffset,
-                                            mIMETextLength,
-                                            mComposition->GetRanges(),
-                                            aStringToInsert, *this);
-  return txn.forget();
-}
-
+  // TODO: We can simplify CompositionTransaction::Init() with TextComposition
+  //       class.
+  RefPtr<CompositionTransaction> transaction =
+    new CompositionTransaction(*mIMETextNode, mIMETextOffset, mIMETextLength,
+                               mComposition->GetRanges(), aStringToInsert,
+                               *this);
+  return transaction.forget();
+}
 
 NS_IMETHODIMP
 nsEditor::CreateTxnForAddStyleSheet(StyleSheetHandle aSheet, AddStyleSheetTxn* *aTxn)
 {
   RefPtr<AddStyleSheetTxn> txn = new AddStyleSheetTxn();
 
   nsresult rv = txn->Init(this, aSheet);
   if (NS_SUCCEEDED(rv))
@@ -4748,18 +4748,19 @@ nsEditor::InitializeSelection(nsIDOMEven
     int32_t startOffset = firstRange->StartOffset();
     FindBetterInsertionPoint(startNode, startOffset);
     Text* textNode = startNode->GetAsText();
     MOZ_ASSERT(textNode,
                "There must be text node if mIMETextLength is larger than 0");
     if (textNode) {
       MOZ_ASSERT(textNode->Length() >= mIMETextOffset + mIMETextLength,
                  "The text node must be different from the old mIMETextNode");
-      IMETextTxn::SetIMESelection(*this, textNode, mIMETextOffset,
-                                  mIMETextLength, mComposition->GetRanges());
+      CompositionTransaction::SetIMESelection(*this, textNode, mIMETextOffset,
+                                              mIMETextLength,
+                                              mComposition->GetRanges());
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsEditor::FinalizeSelection()
--- a/editor/libeditor/nsEditor.h
+++ b/editor/libeditor/nsEditor.h
@@ -52,28 +52,28 @@ class nsRange;
 class nsString;
 class nsTransactionManager;
 
 namespace mozilla {
 class AutoRules;
 class AutoSelectionRestorer;
 class AutoTransactionsConserveSelection;
 class ChangeAttributeTransaction;
+class CompositionTransaction;
 class CreateElementTransaction;
 class DeleteNodeTransaction;
 class DeleteTextTransaction;
 class ErrorResult;
 class TextComposition;
 struct EditorDOMPoint;
 
 namespace dom {
 class DataTransfer;
 class Element;
 class EventTarget;
-class IMETextTxn;
 class InsertTextTxn;
 class InsertNodeTxn;
 class JoinNodeTxn;
 class Selection;
 class SplitNodeTxn;
 class Text;
 } // namespace dom
 } // namespace mozilla
@@ -304,18 +304,18 @@ protected:
   /** Create a transaction for inserting aStringToInsert into aTextNode.  Never
     * returns null.
     */
   already_AddRefed<mozilla::dom::InsertTextTxn>
   CreateTxnForInsertText(const nsAString& aStringToInsert, Text& aTextNode,
                          int32_t aOffset);
 
   // Never returns null.
-  already_AddRefed<mozilla::dom::IMETextTxn>
-  CreateTxnForIMEText(const nsAString & aStringToInsert);
+  already_AddRefed<mozilla::CompositionTransaction>
+  CreateTxnForComposition(const nsAString& aStringToInsert);
 
   /** create a transaction for adding a style sheet
     */
   NS_IMETHOD CreateTxnForAddStyleSheet(mozilla::StyleSheetHandle aSheet,
                                        AddStyleSheetTxn* *aTxn);
 
   /** create a transaction for removing a style sheet
     */