Bug 1260651 part.14 Rename mozilla::dom::IMETextTxn to mozilla::CompositionTransaction r?ehsan draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 16 Apr 2016 01:38:56 +0900
changeset 354813 cb88ded009cf46bb15853051e0ba440641bfadbd
parent 354812 533532ec5c1c79763d1fb9fdfea7f5fb0e65f53f
child 354814 bf9ad88959579318161feeca11939381dfe73523
push id16162
push usermasayuki@d-toybox.com
push dateThu, 21 Apr 2016 15:03:04 +0000
reviewersehsan
bugs1260651
milestone48.0a1
Bug 1260651 part.14 Rename mozilla::dom::IMETextTxn to mozilla::CompositionTransaction r?ehsan 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 mozilla::EditorBase::CreateTxnForIMEText() to mozilla::EditorBase::CreateTxnForComposition(). MozReview-Commit-ID: FSj5mDkR3vR
editor/libeditor/CompositionTransaction.cpp
editor/libeditor/CompositionTransaction.h
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorBase.h
editor/libeditor/IMETextTxn.cpp
editor/libeditor/IMETextTxn.h
editor/libeditor/PlaceholderTxn.cpp
editor/libeditor/PlaceholderTxn.h
editor/libeditor/moz.build
rename from editor/libeditor/IMETextTxn.cpp
rename to editor/libeditor/CompositionTransaction.cpp
--- a/editor/libeditor/IMETextTxn.cpp
+++ b/editor/libeditor/CompositionTransaction.cpp
@@ -1,38 +1,38 @@
 /* -*- 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 "EditorBase.h"                 // mEditorBase
 #include "mozilla/dom/Selection.h"      // local var
 #include "mozilla/dom/Text.h"           // mTextNode
 #include "mozilla/Preferences.h"        // nsCaret Visibility
 #include "nsAString.h"                  // params
 #include "nsDebug.h"                    // for NS_ASSERTION, etc
 #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 {
 
-/*static*/ bool
-IMETextTxn::sCaretsExtendedVisibility = false;
+using namespace dom;
+
+bool CompositionTransaction::sCaretsExtendedVisibility = false;
 
-
-IMETextTxn::IMETextTxn(Text& aTextNode, uint32_t aOffset,
-                       uint32_t aReplaceLength,
-                       TextRangeArray* aTextRangeArray,
-                       const nsAString& aStringToInsert,
-                       EditorBase& aEditorBase)
+CompositionTransaction::CompositionTransaction(Text& aTextNode,
+                                               uint32_t aOffset,
+                                               uint32_t aReplaceLength,
+                                               TextRangeArray* aTextRangeArray,
+                                               const nsAString& aStringToInsert,
+                                               EditorBase& aEditorBase)
   : EditTxn()
   , mTextNode(&aTextNode)
   , mOffset(aOffset)
   , mReplaceLength(aReplaceLength)
   , mRanges(aTextRangeArray)
   , mStringToInsert(aStringToInsert)
   , mEditorBase(aEditorBase)
   , mFixed(false)
@@ -40,35 +40,35 @@ IMETextTxn::IMETextTxn(Text& aTextNode, 
   static bool addedPrefs = false;
   if (!addedPrefs) {
     mozilla::Preferences::AddBoolVarCache(&sCaretsExtendedVisibility,
                                           "layout.accessiblecaret.extendedvisibility");
     addedPrefs = true;
   }
 }
 
-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;
   mEditorBase.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;
@@ -81,17 +81,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 = mEditorBase.GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
 
   nsresult res = mTextNode->DeleteData(mOffset, mStringToInsert.Length());
   NS_ENSURE_SUCCESS(res, res);
@@ -101,50 +101,52 @@ 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> otherCompositionTransaction =
+                                   do_QueryObject(aTransaction);
+  if (otherCompositionTransaction) {
     // We absorb the next IME transaction by adopting its insert string
-    mStringToInsert = otherTxn->mStringToInsert;
-    mRanges = otherTxn->mRanges;
+    mStringToInsert = otherCompositionTransaction->mStringToInsert;
+    mRanges = otherCompositionTransaction->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 ================== */
 static SelectionType
 ToSelectionType(uint32_t aTextRangeType)
 {
@@ -159,29 +161,29 @@ ToSelectionType(uint32_t aTextRangeType)
       return nsISelectionController::SELECTION_IME_SELECTEDCONVERTEDTEXT;
     default:
       MOZ_CRASH("Selection type is invalid");
       return nsISelectionController::SELECTION_NORMAL;
   }
 }
 
 nsresult
-IMETextTxn::SetSelectionForRanges()
+CompositionTransaction::SetSelectionForRanges()
 {
   return SetIMESelection(mEditorBase, mTextNode, mOffset,
                          mStringToInsert.Length(), mRanges);
 }
 
 // static
 nsresult
-IMETextTxn::SetIMESelection(EditorBase& aEditorBase,
-                            Text* aTextNode,
-                            uint32_t aOffsetInNode,
-                            uint32_t aLengthOfCompositionString,
-                            const TextRangeArray* aRanges)
+CompositionTransaction::SetIMESelection(EditorBase& aEditorBase,
+                                        Text* aTextNode,
+                                        uint32_t aOffsetInNode,
+                                        uint32_t aLengthOfCompositionString,
+                                        const TextRangeArray* aRanges)
 {
   RefPtr<Selection> selection = aEditorBase.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.
@@ -318,8 +320,10 @@ IMETextTxn::SetIMESelection(EditorBase& 
     }
   }
 
   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,76 +1,83 @@
 /* -*- 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 "nsAutoPtr.h"                    // mTextNode, mRanges
 #include "nsCycleCollectionParticipant.h" // various macros
 #include "nsString.h"                     // mStringToInsert
 
-#define NS_IMETEXTTXN_IID \
+#define NS_COMPOSITION_TRANSACTION_IID \
   { 0xb391355d, 0x346c, 0x43d1, \
     { 0x85, 0xed, 0x9e, 0x65, 0xbe, 0xe7, 0x7e, 0x48 } }
 
 namespace mozilla {
 
 class EditorBase;
 class TextRangeArray;
 
 namespace dom {
-
 class Text;
+} // namespace dom
 
 /**
-  * A transaction that inserts text into a content node.
-  */
-class IMETextTxn : public EditTxn
+ * A transaction that inserts new composition string or updates existing
+ * composition string in a content node.
+ */
+class CompositionTransaction final : public EditTxn
 {
 public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMETEXTTXN_IID)
+  NS_DECLARE_STATIC_IID_ACCESSOR(NS_COMPOSITION_TRANSACTION_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 aEditorBase used to get and set the selection
-    */
-  IMETextTxn(Text& aTextNode, uint32_t aOffset, uint32_t aReplaceLength,
-             TextRangeArray* aTextRangeArray, const nsAString& aString,
-             EditorBase& aEditorBase);
+  /**
+   * @param aTextNode           The text content node,
+   * @param aOffset             The location in aTextNode to do the insertion.
+   * @param aReplaceLength      The length of text to replace.  If this is 0,
+   *                            not replacing any text.
+   * @param aTextRangeArray     Clauses and/or caret information of the
+   *                            composition string.  This may be null.
+   * @param aString             The new text to insert.
+   * @param aEditorBase         Used to get and set the selection.
+   */
+  CompositionTransaction(dom::Text& aTextNode,
+                         uint32_t aOffset,
+                         uint32_t aReplaceLength,
+                         TextRangeArray* aTextRangeArray,
+                         const nsAString& aString,
+                         EditorBase& aEditorBase);
 
-  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(EditorBase& aEditorBase,
-                                  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;
+  RefPtr<dom::Text> mTextNode;
 
   /** The offsets into mTextNode where the insertion should be placed */
   uint32_t mOffset;
 
   uint32_t mReplaceLength;
 
   /** The range list **/
   RefPtr<TextRangeArray> mRanges;
@@ -86,14 +93,14 @@ private:
   /*
    * AccessibleCaret visibility preference. Used to avoid hiding caret during
    * handle drag, caused by dynamic eCompositionCommit events generated by
    * the keyboard IME for autoSuggest/autoCorrect support.
    */
   static bool sCaretsExtendedVisibility;
 };
 
-NS_DEFINE_STATIC_IID_ACCESSOR(IMETextTxn, NS_IMETEXTTXN_IID)
+NS_DEFINE_STATIC_IID_ACCESSOR(CompositionTransaction,
+                              NS_COMPOSITION_TRANSACTION_IID)
 
-} // namespace dom
 } // namespace mozilla
 
-#endif
+#endif // #ifndef CompositionTransaction_h_
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -6,24 +6,24 @@
 #include "EditorBase.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 "EditorCommonEventListener.h"  // for EditorCommonEventListener
 #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 "mozFlushType.h"               // for mozFlushType::Flush_Frames
 #include "mozInlineSpellChecker.h"      // for mozInlineSpellChecker
 #include "mozilla/CheckedInt.h"         // for CheckedInt
@@ -2465,17 +2465,17 @@ EditorBase::InsertTextIntoTextNodeImpl(c
       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 {
@@ -2519,17 +2519,17 @@ EditorBase::InsertTextIntoTextNodeImpl(c
   // 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
@@ -4294,29 +4294,29 @@ EditorBase::CreateTxnForDeleteNode(nsINo
   RefPtr<DeleteNodeTransaction> transaction = new DeleteNodeTransaction();
   nsresult res = transaction->Init(this, aNode, &mRangeUpdater);
   NS_ENSURE_SUCCESS(res, res);
 
   transaction.forget(aTransaction);
   return NS_OK;
 }
 
-already_AddRefed<IMETextTxn>
-EditorBase::CreateTxnForIMEText(const nsAString& aStringToInsert)
+already_AddRefed<CompositionTransaction>
+EditorBase::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
 EditorBase::CreateTxnForAddStyleSheet(StyleSheetHandle aSheet,
                                       AddStyleSheetTxn** aTxn)
 {
   RefPtr<AddStyleSheetTxn> txn = new AddStyleSheetTxn();
 
   nsresult rv = txn->Init(this, aSheet);
@@ -4825,18 +4825,19 @@ EditorBase::InitializeSelection(nsIDOMEv
     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
 EditorBase::FinalizeSelection()
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -55,27 +55,27 @@ class nsITransaction;
 class nsIWidget;
 class nsRange;
 class nsString;
 class nsTransactionManager;
 struct DOMPoint;
 
 namespace mozilla {
 class ChangeAttributeTransaction;
+class CompositionTransaction;
 class CreateElementTransaction;
 class DeleteNodeTransaction;
 class DeleteTextTransaction;
 class ErrorResult;
 class TextComposition;
 
 namespace dom {
 class DataTransfer;
 class Element;
 class EventTarget;
-class IMETextTxn;
 class InsertTextTxn;
 class InsertNodeTxn;
 class JoinNodeTxn;
 class Selection;
 class SplitNodeTxn;
 class Text;
 } // namespace dom
 
@@ -303,18 +303,18 @@ protected:
   /** Create a transaction for inserting aStringToInsert into aTextNode.  Never
     * returns null.
     */
   already_AddRefed<dom::InsertTextTxn>
   CreateTxnForInsertText(const nsAString& aStringToInsert,
                          dom::Text& aTextNode, int32_t aOffset);
 
   // Never returns null.
-  already_AddRefed<dom::IMETextTxn>
-  CreateTxnForIMEText(const nsAString & aStringToInsert);
+  already_AddRefed<CompositionTransaction>
+  CreateTxnForComposition(const nsAString& aStringToInsert);
 
   /** create a transaction for adding a style sheet
     */
   NS_IMETHOD CreateTxnForAddStyleSheet(StyleSheetHandle aSheet,
                                        AddStyleSheetTxn* *aTxn);
 
   /** create a transaction for removing a style sheet
     */
--- a/editor/libeditor/PlaceholderTxn.cpp
+++ b/editor/libeditor/PlaceholderTxn.cpp
@@ -1,31 +1,31 @@
 /* -*- 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 "EditorBase.h"
-#include "IMETextTxn.h"
 
 #include "mozilla/dom/Selection.h"
 
 #include "nsGkAtoms.h"
 #include "nsQueryObject.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 PlaceholderTxn::PlaceholderTxn()
   : EditAggregateTxn()
   , mAbsorb(true)
   , mForwarding(nullptr)
-  , mIMETextTxn(nullptr)
+  , mCompositionTransaction(nullptr)
   , mCommitted(false)
   , mStartSel(nullptr)
   , mEndSel()
   , mEditorBase(nullptr)
 {
 }
 
 PlaceholderTxn::~PlaceholderTxn()
@@ -122,36 +122,34 @@ 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)
-      {
-        // this is the first IME txn in the placeholder
-        mIMETextTxn =otherTxn;
+    RefPtr<CompositionTransaction> otherCompositionTransaction =
+                                     do_QueryObject(aTransaction);
+    if (otherCompositionTransaction) {
+      // Special handling for CompositionTransaction's: they need to merge with
+      // any previous CompositionTransaction in this placeholder, if possible.
+      if (!mCompositionTransaction) {
+        // this is the first composition transaction in the placeholder
+        mCompositionTransaction = otherCompositionTransaction;
         AppendChild(editTxn);
-      }
-      else
-      {
+      } else {
         bool didMerge;
-        mIMETextTxn->Merge(otherTxn, &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->Merge(otherCompositionTransaction, &didMerge);
+        if (!didMerge) {
+          // it wouldn't merge.  Earlier composition transaction is already
+          // committed and will not absorb further composition transactions.
+          // So just stack this one after it and remember it as a candidate
+          // for further merges.
+          mCompositionTransaction = otherCompositionTransaction;
           AppendChild(editTxn);
         }
       }
     }
     else if (!plcTxn)  // see bug 171243: just drop incoming placeholders on the floor.
     {                  // their children will be swallowed by this preexisting one.
       AppendChild(editTxn);
     }
--- 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,19 @@ 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 composition transaction in this placeholder.  This is used for
+  // merging IME composition transactions.
+  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,16 +11,17 @@ 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',
     'EditorBase.cpp',
     'EditorCommonEventListener.cpp',
     'EditTxn.cpp',
@@ -28,17 +29,16 @@ UNIFIED_SOURCES += [
     'HTMLAnonymousUtils.cpp',
     'HTMLDataTransfer.cpp',
     'HTMLEditor.cpp',
     'HTMLEditorEventListener.cpp',
     'HTMLInlineTableEditor.cpp',
     'HTMLObjectResizer.cpp',
     'HTMLStyleEditor.cpp',
     'HTMLTableEditor.cpp',
-    'IMETextTxn.cpp',
     'InsertNodeTxn.cpp',
     'InsertTextTxn.cpp',
     'JoinNodeTxn.cpp',
     'nsEditorCommands.cpp',
     'nsEditorController.cpp',
     'nsEditorUtils.cpp',
     'nsHTMLCSSUtils.cpp',
     'nsHTMLEditRules.cpp',