Bug 1500862 - part 3: Change all stack base helper classes which access protected members of EditorBase to nested classes of EditorBase r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 24 Oct 2018 09:42:06 +0000
changeset 501964 b7fdf387fa7b2ecd8f046524f72ed1abc76a02fc
parent 501963 d2112ced49ef79ddf69c041a8b01589869c39343
child 501965 9a97be306a98f430af645ddf735f49ab57e043b8
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1500862
milestone65.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 1500862 - part 3: Change all stack base helper classes which access protected members of EditorBase to nested classes of EditorBase r=m_kato AutoTransactionBatch, AutoPlaceholderBatch, AutoSelectionRestorer, AutoTopLevelEditSubActionNotifier, AutoTransactionsConserveSelection and AutoUpdateViewBatch access protected members of EditorBase. The access scope management assume that they are used only by EditorBase or its subclasses or TextEditRules or its inherited class (i.e., HTMLEditRules). For guaranteeing this at build-time, we should change them to nested classes of EditorBase. Then, EditorBase and its subclasses and friends can use them. Differential Revision: https://phabricator.services.mozilla.com/D9479
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorBase.h
editor/libeditor/EditorUtils.cpp
editor/libeditor/EditorUtils.h
editor/libeditor/HTMLAbsPositionEditor.cpp
editor/libeditor/HTMLEditRules.cpp
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditorDataTransfer.cpp
editor/libeditor/HTMLEditorObjectResizer.cpp
editor/libeditor/HTMLStyleEditor.cpp
editor/libeditor/HTMLTableEditor.cpp
editor/libeditor/PlaceholderTransaction.h
editor/libeditor/TextEditRules.h
editor/libeditor/TextEditor.cpp
editor/libeditor/TextEditorDataTransfer.cpp
editor/libeditor/WSRunObject.cpp
editor/libeditor/WSRunObject.h
editor/spellchecker/TextServicesDocument.cpp
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -2506,17 +2506,17 @@ EditorBase::CloneAttributes(Element* aDe
 
   return NS_OK;
 }
 
 void
 EditorBase::CloneAttributesWithTransaction(Element& aDestElement,
                                            Element& aSourceElement)
 {
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   // Use transaction system for undo only if destination is already in the
   // document
   Element* rootElement = GetRoot();
   if (NS_WARN_IF(!rootElement)) {
     return;
   }
 
@@ -5177,9 +5177,49 @@ EditorBase::HideCaret(bool aHide)
   mHidingCaret = aHide;
   if (aHide) {
     caret->AddForceHide();
   } else {
     caret->RemoveForceHide();
   }
 }
 
+/******************************************************************************
+ * EditorBase::AutoSelectionRestorer
+ *****************************************************************************/
+
+EditorBase::AutoSelectionRestorer::AutoSelectionRestorer(
+                                     Selection& aSelection,
+                                     EditorBase& aEditorBase
+                                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
+  : mEditorBase(nullptr)
+{
+  MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+  if (aEditorBase.ArePreservingSelection()) {
+    // We already have initialized mSavedSel, so this must be nested call.
+    return;
+  }
+  mSelection = &aSelection;
+  mEditorBase = &aEditorBase;
+  mEditorBase->PreserveSelectionAcrossActions(mSelection);
+}
+
+EditorBase::AutoSelectionRestorer::~AutoSelectionRestorer()
+{
+  NS_ASSERTION(!mSelection || mEditorBase,
+               "mEditorBase should be non-null when mSelection is");
+  // mSelection will be null if this was nested call.
+  if (mSelection && mEditorBase->ArePreservingSelection()) {
+    mEditorBase->RestorePreservedSelection(mSelection);
+  }
+}
+
+void
+EditorBase::AutoSelectionRestorer::Abort()
+{
+  NS_ASSERTION(!mSelection || mEditorBase,
+               "mEditorBase should be non-null when mSelection is");
+  if (mSelection) {
+    mEditorBase->StopPreservingSelection();
+  }
+}
+
 } // namespace mozilla
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -2,16 +2,17 @@
 /* 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 mozilla_EditorBase_h
 #define mozilla_EditorBase_h
 
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc.
+#include "mozilla/EditAction.h"         // for EditSubAction
 #include "mozilla/EditorDOMPoint.h"     // for EditorDOMPoint
 #include "mozilla/Maybe.h"              // for Maybe
 #include "mozilla/OwningNonNull.h"      // for OwningNonNull
 #include "mozilla/PresShell.h"          // for PresShell
 #include "mozilla/RangeBoundary.h"      // for RawRangeBoundary, RangeBoundary
 #include "mozilla/SelectionState.h"     // for RangeUpdater, etc.
 #include "mozilla/StyleSheet.h"         // for StyleSheet
 #include "mozilla/TransactionManager.h" // for TransactionManager
@@ -78,17 +79,16 @@ class SplitNodeResult;
 class SplitNodeTransaction;
 class TextComposition;
 class TextEditor;
 class TextEditRules;
 class TextInputListener;
 class TextServicesDocument;
 class TypeInState;
 class WSRunObject;
-enum class EditSubAction : int32_t;
 
 namespace dom {
 class DataTransfer;
 class DragEvent;
 class Element;
 class EventTarget;
 class Text;
 } // namespace dom
@@ -1905,16 +1905,200 @@ private:
 
 
   /**
    * SetTextDirectionTo() sets text-direction of the root element.
    * Should use SwitchTextDirectionTo() or ToggleTextDirection() instead.
    * This is a helper class of them.
    */
   nsresult SetTextDirectionTo(TextDirection aTextDirection);
+
+protected: // helper classes which may be used by friends
+  /**
+   * Stack based helper class for calling EditorBase::EndTransactionInternal().
+   */
+  class MOZ_RAII AutoTransactionBatch final
+  {
+  public:
+    explicit AutoTransactionBatch(EditorBase& aEditorBase
+                                  MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+      : mEditorBase(aEditorBase)
+    {
+      MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+      mEditorBase->BeginTransactionInternal();
+    }
+
+    ~AutoTransactionBatch()
+    {
+      mEditorBase->EndTransactionInternal();
+    }
+
+  protected:
+    OwningNonNull<EditorBase> mEditorBase;
+    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+  };
+
+  /**
+   * Stack based helper class for batching a collection of transactions inside
+   * a placeholder transaction.
+   */
+  class MOZ_RAII AutoPlaceholderBatch final
+  {
+  public:
+    explicit AutoPlaceholderBatch(EditorBase& aEditorBase
+                                  MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+      : mEditorBase(aEditorBase)
+    {
+      MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+      mEditorBase->BeginPlaceholderTransaction(nullptr);
+    }
+
+    AutoPlaceholderBatch(EditorBase& aEditorBase,
+                         nsAtom& aTransactionName
+                         MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+      : mEditorBase(aEditorBase)
+    {
+      MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+      mEditorBase->BeginPlaceholderTransaction(&aTransactionName);
+    }
+
+    ~AutoPlaceholderBatch()
+    {
+      mEditorBase->EndPlaceholderTransaction();
+    }
+
+  protected:
+    OwningNonNull<EditorBase> mEditorBase;
+    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+  };
+
+  /**
+   * Stack based helper class for saving/restoring selection.  Note that this
+   * assumes that the nodes involved are still around afterwords!
+   */
+  class MOZ_RAII AutoSelectionRestorer final
+  {
+  public:
+    /**
+     * Constructor responsible for remembering all state needed to restore
+     * aSelection.
+     */
+    AutoSelectionRestorer(Selection& aSelection,
+                          EditorBase& aEditorBase
+                          MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
+
+    /**
+     * Destructor restores mSelection to its former state
+     */
+    ~AutoSelectionRestorer();
+
+    /**
+     * Abort() cancels to restore the selection.
+     */
+    void Abort();
+
+  protected:
+    RefPtr<Selection> mSelection;
+    EditorBase* mEditorBase;
+    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+  };
+
+  /**
+   * AutoTopLevelEditSubActionNotifier notifies editor of start to handle
+   * top level edit sub-action and end handling top level edit sub-action.
+   */
+  class MOZ_RAII AutoTopLevelEditSubActionNotifier final
+  {
+  public:
+    AutoTopLevelEditSubActionNotifier(EditorBase& aEditorBase,
+                                      EditSubAction aEditSubAction,
+                                      nsIEditor::EDirection aDirection
+                                      MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+      : mEditorBase(aEditorBase)
+      , mDoNothing(false)
+    {
+      MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+      // mTopLevelEditSubAction will already be set if this is nested call
+      // XXX Looks like that this is not aware of unexpected nested edit action
+      //     handling via selectionchange event listener or mutation event
+      //     listener.
+      if (!mEditorBase.mTopLevelEditSubAction) {
+        mEditorBase.OnStartToHandleTopLevelEditSubAction(aEditSubAction,
+                                                         aDirection);
+      } else {
+        mDoNothing = true; // nested calls will end up here
+      }
+    }
+
+    ~AutoTopLevelEditSubActionNotifier()
+    {
+      if (!mDoNothing) {
+        mEditorBase.OnEndHandlingTopLevelEditSubAction();
+      }
+    }
+
+  protected:
+    EditorBase& mEditorBase;
+    bool mDoNothing;
+    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+  };
+
+  /**
+   * Stack based helper class for turning off active selection adjustment
+   * by low level transactions
+   */
+  class MOZ_RAII AutoTransactionsConserveSelection final
+  {
+  public:
+    explicit AutoTransactionsConserveSelection(EditorBase& aEditorBase
+                                               MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+      : mEditorBase(aEditorBase)
+      , mAllowedTransactionsToChangeSelection(
+          aEditorBase.AllowsTransactionsToChangeSelection())
+    {
+      MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+      mEditorBase.MakeThisAllowTransactionsToChangeSelection(false);
+    }
+
+    ~AutoTransactionsConserveSelection()
+    {
+      mEditorBase.MakeThisAllowTransactionsToChangeSelection(
+                    mAllowedTransactionsToChangeSelection);
+    }
+
+  protected:
+    EditorBase& mEditorBase;
+    bool mAllowedTransactionsToChangeSelection;
+    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+  };
+
+  /***************************************************************************
+   * stack based helper class for batching reflow and paint requests.
+   */
+  class MOZ_RAII AutoUpdateViewBatch final
+  {
+  public:
+    explicit AutoUpdateViewBatch(EditorBase& aEditorBase
+                                 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+      : mEditorBase(aEditorBase)
+    {
+      MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+      mEditorBase.BeginUpdateViewBatch();
+    }
+
+    ~AutoUpdateViewBatch()
+    {
+      mEditorBase.EndUpdateViewBatch();
+    }
+
+  protected:
+    EditorBase& mEditorBase;
+    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+  };
+
 protected:
   enum Tristate
   {
     eTriUnset,
     eTriFalse,
     eTriTrue
   };
 
@@ -1996,22 +2180,16 @@ protected:
   bool mIsInEditSubAction;
   // Whether caret is hidden forcibly.
   bool mHidingCaret;
   // Whether spellchecker dictionary is initialized after focused.
   bool mSpellCheckerDictionaryUpdated;
   // Whether we are an HTML editor class.
   bool mIsHTMLEditorClass;
 
-  friend class AutoPlaceholderBatch;
-  friend class AutoSelectionRestorer;
-  friend class AutoTopLevelEditSubActionNotifier;
-  friend class AutoTransactionBatch;
-  friend class AutoTransactionsConserveSelection;
-  friend class AutoUpdateViewBatch;
   friend class CompositionTransaction;
   friend class CreateElementTransaction;
   friend class CSSEditUtils;
   friend class DeleteNodeTransaction;
   friend class DeleteRangeTransaction;
   friend class DeleteTextTransaction;
   friend class HTMLEditRules;
   friend class HTMLEditUtils;
--- a/editor/libeditor/EditorUtils.cpp
+++ b/editor/libeditor/EditorUtils.cpp
@@ -20,59 +20,16 @@
 class nsISupports;
 class nsRange;
 
 namespace mozilla {
 
 using namespace dom;
 
 /******************************************************************************
- * AutoSelectionRestorer
- *****************************************************************************/
-
-AutoSelectionRestorer::AutoSelectionRestorer(
-                         Selection* aSelection,
-                         EditorBase* aEditorBase
-                         MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
-  : mEditorBase(nullptr)
-{
-  MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-  if (NS_WARN_IF(!aSelection) || NS_WARN_IF(!aEditorBase)) {
-    return;
-  }
-  if (aEditorBase->ArePreservingSelection()) {
-    // We already have initialized mSavedSel, so this must be nested call.
-    return;
-  }
-  mSelection = aSelection;
-  mEditorBase = aEditorBase;
-  mEditorBase->PreserveSelectionAcrossActions(mSelection);
-}
-
-AutoSelectionRestorer::~AutoSelectionRestorer()
-{
-  NS_ASSERTION(!mSelection || mEditorBase,
-               "mEditorBase should be non-null when mSelection is");
-  // mSelection will be null if this was nested call.
-  if (mSelection && mEditorBase->ArePreservingSelection()) {
-    mEditorBase->RestorePreservedSelection(mSelection);
-  }
-}
-
-void
-AutoSelectionRestorer::Abort()
-{
-  NS_ASSERTION(!mSelection || mEditorBase,
-               "mEditorBase should be non-null when mSelection is");
-  if (mSelection) {
-    mEditorBase->StopPreservingSelection();
-  }
-}
-
-/******************************************************************************
  * some helper classes for iterating the dom tree
  *****************************************************************************/
 
 DOMIterator::DOMIterator(nsINode& aNode MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
 {
   MOZ_GUARD_OBJECT_NOTIFIER_INIT;
   mIter = NS_NewContentIterator();
   DebugOnly<nsresult> rv = mIter->Init(&aNode);
--- a/editor/libeditor/EditorUtils.h
+++ b/editor/libeditor/EditorUtils.h
@@ -474,214 +474,16 @@ public:
   }
 
   ~AutoTransactionBatchExternal()
   {
     mEditorBase->EndTransaction();
   }
 };
 
-/***************************************************************************
- * stack based helper class for calling EditorBase::EndTransaction() after
- * EditorBase::BeginTransaction().
- ***************************************************************************/
-class MOZ_RAII AutoTransactionBatch final
-{
-private:
-  OwningNonNull<EditorBase> mEditorBase;
-  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-
-public:
-  explicit AutoTransactionBatch(EditorBase& aEditorBase
-                                MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-    : mEditorBase(aEditorBase)
-  {
-    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-    mEditorBase->BeginTransactionInternal();
-  }
-
-  ~AutoTransactionBatch()
-  {
-    mEditorBase->EndTransactionInternal();
-  }
-};
-
-/***************************************************************************
- * stack based helper class for batching a collection of transactions inside a
- * placeholder transaction.
- */
-class MOZ_RAII AutoPlaceholderBatch final
-{
-private:
-  RefPtr<EditorBase> mEditorBase;
-  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-
-public:
-  explicit AutoPlaceholderBatch(EditorBase* aEditorBase
-                                MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-    : mEditorBase(aEditorBase)
-  {
-    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-    BeginPlaceholderTransaction(nullptr);
-  }
-  AutoPlaceholderBatch(EditorBase* aEditorBase,
-                       nsAtom* aTransactionName
-                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-    : mEditorBase(aEditorBase)
-  {
-    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-    BeginPlaceholderTransaction(aTransactionName);
-  }
-  ~AutoPlaceholderBatch()
-  {
-    if (mEditorBase) {
-      mEditorBase->EndPlaceholderTransaction();
-    }
-  }
-
-private:
-  void BeginPlaceholderTransaction(nsAtom* aTransactionName)
-  {
-    if (mEditorBase) {
-      mEditorBase->BeginPlaceholderTransaction(aTransactionName);
-    }
-  }
-};
-
-/***************************************************************************
- * stack based helper class for saving/restoring selection.  Note that this
- * assumes that the nodes involved are still around afterwards!
- */
-class MOZ_RAII AutoSelectionRestorer final
-{
-private:
-  // Ref-counted reference to the selection that we are supposed to restore.
-  RefPtr<dom::Selection> mSelection;
-  EditorBase* mEditorBase;  // Non-owning ref to EditorBase.
-  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-
-public:
-  /**
-   * Constructor responsible for remembering all state needed to restore
-   * aSelection.
-   */
-  AutoSelectionRestorer(dom::Selection* aSelection,
-                        EditorBase* aEditorBase
-                        MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
-
-  /**
-   * Destructor restores mSelection to its former state
-   */
-  ~AutoSelectionRestorer();
-
-  /**
-   * Abort() cancels to restore the selection.
-   */
-  void Abort();
-};
-
-/***************************************************************************
- * AutoTopLevelEditSubActionNotifier notifies editor of start to handle
- * top level edit sub-action and end handling top level edit sub-action.
- */
-class MOZ_RAII AutoTopLevelEditSubActionNotifier final
-{
-public:
-  AutoTopLevelEditSubActionNotifier(EditorBase& aEditorBase,
-                                    EditSubAction aEditSubAction,
-                                    nsIEditor::EDirection aDirection
-                                    MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-    : mEditorBase(aEditorBase)
-    , mDoNothing(false)
-  {
-    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-    // mTopLevelEditSubAction will already be set if this is nested call
-    // XXX Looks like that this is not aware of unexpected nested edit action
-    //     handling via selectionchange event listener or mutation event
-    //     listener.
-    if (!mEditorBase.mTopLevelEditSubAction) {
-      mEditorBase.OnStartToHandleTopLevelEditSubAction(aEditSubAction,
-                                                       aDirection);
-    } else {
-      mDoNothing = true; // nested calls will end up here
-    }
-  }
-
-  ~AutoTopLevelEditSubActionNotifier()
-  {
-    if (!mDoNothing) {
-      mEditorBase.OnEndHandlingTopLevelEditSubAction();
-    }
-  }
-
-protected:
-  EditorBase& mEditorBase;
-  bool mDoNothing;
-  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-};
-
-/***************************************************************************
- * stack based helper class for turning off active selection adjustment
- * by low level transactions
- */
-class MOZ_RAII AutoTransactionsConserveSelection final
-{
-public:
-  explicit AutoTransactionsConserveSelection(EditorBase& aEditorBase
-                                             MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-    : mEditorBase(aEditorBase)
-    , mAllowedTransactionsToChangeSelection(
-        aEditorBase.AllowsTransactionsToChangeSelection())
-  {
-    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-    mEditorBase.MakeThisAllowTransactionsToChangeSelection(false);
-  }
-
-  ~AutoTransactionsConserveSelection()
-  {
-    mEditorBase.MakeThisAllowTransactionsToChangeSelection(
-                  mAllowedTransactionsToChangeSelection);
-  }
-
-protected:
-  EditorBase& mEditorBase;
-  bool mAllowedTransactionsToChangeSelection;
-  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-};
-
-/***************************************************************************
- * stack based helper class for batching reflow and paint requests.
- */
-class MOZ_RAII AutoUpdateViewBatch final
-{
-public:
-  explicit AutoUpdateViewBatch(EditorBase* aEditorBase
-                               MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-    : mEditorBase(aEditorBase)
-  {
-    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-    NS_ASSERTION(mEditorBase, "null mEditorBase pointer!");
-
-    if (mEditorBase) {
-      mEditorBase->BeginUpdateViewBatch();
-    }
-  }
-
-  ~AutoUpdateViewBatch()
-  {
-    if (mEditorBase) {
-      mEditorBase->EndUpdateViewBatch();
-    }
-  }
-
-protected:
-  EditorBase* mEditorBase;
-  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-};
-
 class MOZ_STACK_CLASS AutoRangeArray final
 {
 public:
   explicit AutoRangeArray(dom::Selection* aSelection)
   {
     if (!aSelection) {
       return;
     }
--- a/editor/libeditor/HTMLAbsPositionEditor.cpp
+++ b/editor/libeditor/HTMLAbsPositionEditor.cpp
@@ -6,17 +6,16 @@
 
 #include <math.h>
 
 #include "HTMLEditorObjectResizerUtils.h"
 #include "HTMLEditRules.h"
 #include "HTMLEditUtils.h"
 #include "TextEditUtils.h"
 #include "mozilla/EditAction.h"
-#include "mozilla/EditorUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/TextEditRules.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/EventTarget.h"
 #include "mozilla/mozalloc.h"
 #include "nsAString.h"
 #include "nsAlgorithm.h"
@@ -43,17 +42,17 @@
 
 namespace mozilla {
 
 using namespace dom;
 
 nsresult
 HTMLEditor::SetSelectionToAbsoluteOrStatic(bool aEnabled)
 {
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this,
                                       aEnabled ?
                                         EditSubAction::eSetPositionToAbsolute :
                                         EditSubAction::eSetPositionToStatic,
                                       nsIEditor::eNext);
 
   // the line below does not match the code; should it be removed?
@@ -144,17 +143,17 @@ HTMLEditor::SetZIndex(Element& aElement,
   zIndexStr.AppendInt(aZindex);
 
   mCSSEditUtils->SetCSSProperty(aElement, *nsGkAtoms::z_index, zIndexStr);
 }
 
 nsresult
 HTMLEditor::AddZIndex(int32_t aChange)
 {
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this,
                                       aChange < 0 ?
                                         EditSubAction::eDecreaseZIndex :
                                         EditSubAction::eIncreaseZIndex,
                                       nsIEditor::eNext);
 
   // brade: can we get rid of this comment?
@@ -475,17 +474,17 @@ HTMLEditor::SetFinalPosition(int32_t aX,
 
   SnapToGrid(newX, newY);
 
   nsAutoString x, y;
   x.AppendInt(newX);
   y.AppendInt(newY);
 
   // we want one transaction only from a user's point of view
-  AutoPlaceholderBatch batchIt(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   if (NS_WARN_IF(!mAbsolutelyPositionedObject)) {
     return NS_ERROR_FAILURE;
   }
   OwningNonNull<Element> absolutelyPositionedObject =
     *mAbsolutelyPositionedObject;
   mCSSEditUtils->SetCSSPropertyPixels(*absolutelyPositionedObject,
                                       *nsGkAtoms::top, newY);
@@ -533,17 +532,17 @@ HTMLEditor::SetPositionToAbsoluteOrStati
   }
 
   return SetPositionToStatic(aElement);
 }
 
 nsresult
 HTMLEditor::SetPositionToAbsolute(Element& aElement)
 {
-  AutoPlaceholderBatch batchIt(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   int32_t x, y;
   GetElementOrigin(aElement, x, y);
 
   mCSSEditUtils->SetCSSProperty(aElement, *nsGkAtoms::position,
                                 NS_LITERAL_STRING("absolute"));
 
   AddPositioningOffset(x, y);
@@ -566,17 +565,17 @@ HTMLEditor::SetPositionToAbsolute(Elemen
     }
   }
   return NS_OK;
 }
 
 nsresult
 HTMLEditor::SetPositionToStatic(Element& aElement)
 {
-  AutoPlaceholderBatch batchIt(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   mCSSEditUtils->RemoveCSSProperty(aElement, *nsGkAtoms::position,
                                    EmptyString());
   mCSSEditUtils->RemoveCSSProperty(aElement, *nsGkAtoms::top,
                                    EmptyString());
   mCSSEditUtils->RemoveCSSProperty(aElement, *nsGkAtoms::left,
                                    EmptyString());
   mCSSEditUtils->RemoveCSSProperty(aElement, *nsGkAtoms::z_index,
@@ -631,17 +630,17 @@ HTMLEditor::GetGridSize(uint32_t* aSize)
 }
 
 // self-explanatory
 void
 HTMLEditor::SetTopAndLeft(Element& aElement,
                           int32_t aX,
                           int32_t aY)
 {
-  AutoPlaceholderBatch batchIt(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   mCSSEditUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::left, aX);
   mCSSEditUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::top, aY);
 }
 
 nsresult
 HTMLEditor::GetTemporaryStyleForFocusedPositionedElement(Element& aElement,
                                                          nsAString& aReturn)
 {
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -4017,17 +4017,17 @@ HTMLEditRules::WillMakeList(const nsAStr
 
 nsresult
 HTMLEditRules::MakeList(nsAtom& aListType,
                         bool aEntireList,
                         const nsAString* aBulletType,
                         bool* aCancel,
                         nsAtom& aItemType)
 {
-  AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
+  AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
 
   nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
   nsresult rv =
     GetListActionNodes(arrayOfNodes,
                        aEntireList ? EntireList::yes : EntireList::no,
                        TouchContent::yes);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -4102,17 +4102,17 @@ HTMLEditRules::MakeList(nsAtom& aListTyp
     }
     if (NS_WARN_IF(!theListItem)) {
       return NS_ERROR_FAILURE;
     }
 
     // remember our new block for postprocessing
     mNewBlock = theListItem;
     // Put selection in new list item and don't restore the Selection.
-    selectionRestorer.Abort();
+    restoreSelectionLater.Abort();
     ErrorResult error;
     SelectionRef().Collapse(EditorRawDOMPoint(theListItem, 0), error);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       error.SuppressException();
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(!error.Failed())) {
       return error.StealNSResult();
@@ -4432,17 +4432,17 @@ HTMLEditRules::WillRemoveList(bool* aCan
   *aCancel = false;
   *aHandled = true;
 
   nsresult rv = NormalizeSelection();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
+  AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
 
   nsTArray<RefPtr<nsRange>> arrayOfRanges;
   GetPromotedRanges(arrayOfRanges, EditSubAction::eCreateOrChangeList);
 
   // use these ranges to contruct a list of nodes to act on.
   nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
   rv = GetListActionNodes(arrayOfNodes, EntireList::no, TouchContent::yes);
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -4536,17 +4536,17 @@ HTMLEditRules::MakeBasicBlock(nsAtom& bl
 {
   MOZ_ASSERT(IsEditorDataAvailable());
 
   nsresult rv = NormalizeSelection();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
+  AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
   AutoTransactionsConserveSelection dontChangeMySelection(HTMLEditorRef());
 
   // Contruct a list of nodes to act on.
   nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
   rv = GetNodesFromSelection(EditSubAction::eCreateOrRemoveBlock, arrayOfNodes,
                              TouchContent::yes);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -4607,17 +4607,17 @@ HTMLEditRules::MakeBasicBlock(nsAtom& bl
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(!brContent)) {
         return NS_ERROR_FAILURE;
       }
       // Put selection at the split point
       EditorRawDOMPoint atBrNode(brContent);
       // Don't restore the selection
-      selectionRestorer.Abort();
+      restoreSelectionLater.Abort();
       ErrorResult error;
       SelectionRef().Collapse(atBrNode, error);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         error.SuppressException();
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(error.Failed())) {
         return error.StealNSResult();
@@ -4666,17 +4666,17 @@ HTMLEditRules::MakeBasicBlock(nsAtom& bl
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       arrayOfNodes.RemoveElementAt(0);
     }
     // Don't restore the selection
-    selectionRestorer.Abort();
+    restoreSelectionLater.Abort();
     // Put selection in new block
     rv = SelectionRef().Collapse(block, 0);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
@@ -4788,17 +4788,17 @@ HTMLEditRules::WillCSSIndent(bool* aCanc
   return NS_OK;
 }
 
 nsresult
 HTMLEditRules::IndentAroundSelectionWithCSS()
 {
   MOZ_ASSERT(IsEditorDataAvailable());
 
-  AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
+  AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
   nsTArray<OwningNonNull<nsRange>> arrayOfRanges;
   nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
 
   // short circuit: detect case of collapsed selection inside an <li>.
   // just sublist that <li>.  This prevents bug 97797.
 
   nsCOMPtr<Element> liNode;
   if (SelectionRef().IsCollapsed()) {
@@ -4875,17 +4875,17 @@ HTMLEditRules::IndentAroundSelectionWith
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       arrayOfNodes.RemoveElementAt(0);
     }
     // put selection in new block
     EditorRawDOMPoint atStartOfTheBlock(theBlock, 0);
     // Don't restore the selection
-    selectionRestorer.Abort();
+    restoreSelectionLater.Abort();
     ErrorResult error;
     SelectionRef().Collapse(atStartOfTheBlock, error);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       error.SuppressException();
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(!error.Failed())) {
       return error.StealNSResult();
@@ -5092,17 +5092,17 @@ HTMLEditRules::WillHTMLIndent(bool* aCan
   return NS_OK;
 }
 
 nsresult
 HTMLEditRules::IndentAroundSelectionWithHTML()
 {
   MOZ_ASSERT(IsEditorDataAvailable());
 
-  AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
+  AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
 
   // convert the selection ranges into "promoted" selection ranges:
   // this basically just expands the range to include the immediate
   // block parent, and then further expands to include any ancestors
   // whose children are all in the range
 
   nsTArray<RefPtr<nsRange>> arrayOfRanges;
   GetPromotedRanges(arrayOfRanges, EditSubAction::eIndent);
@@ -5155,17 +5155,17 @@ HTMLEditRules::IndentAroundSelectionWith
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       arrayOfNodes.RemoveElementAt(0);
     }
     EditorRawDOMPoint atStartOfTheBlock(theBlock, 0);
     // Don't restore the selection
-    selectionRestorer.Abort();
+    restoreSelectionLater.Abort();
     ErrorResult error;
     SelectionRef().Collapse(atStartOfTheBlock, error);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       error.SuppressException();
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(!error.Failed())) {
       return error.StealNSResult();
@@ -5472,17 +5472,17 @@ HTMLEditRules::WillOutdent(bool* aCancel
   return NS_OK;
 }
 
 SplitRangeOffFromNodeResult
 HTMLEditRules::OutdentAroundSelection()
 {
   MOZ_ASSERT(IsEditorDataAvailable());
 
-  AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
+  AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
 
   bool useCSS = HTMLEditorRef().IsCSSEnabled();
 
   // Convert the selection ranges into "promoted" selection ranges: this
   // basically just expands the range to include the immediate block parent,
   // and then further expands to include any ancestors whose children are all
   // in the range
   nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
@@ -6112,17 +6112,17 @@ HTMLEditRules::WillAlign(const nsAString
     return rv;
   }
   return NS_OK;
 }
 
 nsresult
 HTMLEditRules::AlignContentsAtSelection(const nsAString& aAlignType)
 {
-  AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
+  AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
 
   // Convert the selection ranges into "promoted" selection ranges: This
   // basically just expands the range to include the immediate block parent,
   // and then further expands to include any ancestors whose children are all
   // in the range
   nsTArray<OwningNonNull<nsINode>> nodeArray;
   nsresult rv =
     GetNodesFromSelection(EditSubAction::eSetOrClearAlignment, nodeArray,
@@ -6240,17 +6240,17 @@ HTMLEditRules::AlignContentsAtSelection(
     // Put in a moz-br so that it won't get deleted
     CreateElementResult createMozBrResult =
       CreateMozBR(EditorRawDOMPoint(div, 0));
     if (NS_WARN_IF(createMozBrResult.Failed())) {
       return createMozBrResult.Rv();
     }
     EditorRawDOMPoint atStartOfDiv(div, 0);
     // Don't restore the selection
-    selectionRestorer.Abort();
+    restoreSelectionLater.Abort();
     ErrorResult error;
     SelectionRef().Collapse(atStartOfDiv, error);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       error.SuppressException();
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(error.Failed())) {
       return error.StealNSResult();
@@ -10993,17 +10993,17 @@ HTMLEditRules::PrepareToMakeElementAbsol
                  bool* aHandled,
                  RefPtr<Element>* aTargetElement)
 {
   MOZ_ASSERT(IsEditorDataAvailable());
 
   MOZ_ASSERT(aHandled);
   MOZ_ASSERT(aTargetElement);
 
-  AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
+  AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
 
   // Convert the selection ranges into "promoted" selection ranges: this
   // basically just expands the range to include the immediate block parent,
   // and then further expands to include any ancestors whose children are all
   // in the range.
 
   nsTArray<RefPtr<nsRange>> arrayOfRanges;
   GetPromotedRanges(arrayOfRanges, EditSubAction::eSetPositionToAbsolute);
@@ -11057,17 +11057,17 @@ HTMLEditRules::PrepareToMakeElementAbsol
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       arrayOfNodes.RemoveElementAt(0);
     }
     // Put selection in new block
     *aHandled = true;
     // Don't restore the selection
-    selectionRestorer.Abort();
+    restoreSelectionLater.Abort();
     ErrorResult error;
     SelectionRef().Collapse(RawRangeBoundary(positionedDiv, 0), error);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       error.SuppressException();
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(error.Failed())) {
       return error.StealNSResult();
@@ -11298,17 +11298,17 @@ HTMLEditRules::WillRemoveAbsolutePositio
 
   RefPtr<Element> element =
     HTMLEditorRef().GetAbsolutelyPositionedSelectionContainer();
   if (NS_WARN_IF(!element)) {
     return NS_ERROR_FAILURE;
   }
 
   {
-    AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
+    AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
 
     nsresult rv = HTMLEditorRef().SetPositionToAbsoluteOrStatic(*element, false);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
@@ -11344,17 +11344,17 @@ HTMLEditRules::WillRelativeChangeZIndex(
 
   RefPtr<Element> element =
     HTMLEditorRef().GetAbsolutelyPositionedSelectionContainer();
   if (NS_WARN_IF(!element)) {
     return NS_ERROR_FAILURE;
   }
 
   {
-    AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
+    AutoSelectionRestorer restoreSelectionLater(SelectionRef(), HTMLEditorRef());
 
     int32_t zIndex;
     nsresult rv = HTMLEditorRef().RelativeChangeElementZIndex(*element, aChange,
                                                               &zIndex);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -1105,17 +1105,17 @@ HTMLEditor::UpdateBaseURL()
     doc->SetBaseURI(doc->GetDocumentURI());
   }
   return NS_OK;
 }
 
 nsresult
 HTMLEditor::OnInputLineBreak()
 {
-  AutoPlaceholderBatch batch(this, nsGkAtoms::TypingTxnName);
+  AutoPlaceholderBatch treatAsOneTransaction(*this, *nsGkAtoms::TypingTxnName);
   nsresult rv = InsertBrElementAtSelectionWithTransaction();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 nsresult
@@ -1321,17 +1321,17 @@ HTMLEditor::ReplaceHeadContentsWithSourc
   // Windows linebreaks: Map CRLF to LF:
   inputString.ReplaceSubstring(NS_LITERAL_STRING("\r\n"),
                                NS_LITERAL_STRING("\n"));
 
   // Mac linebreaks: Map any remaining CR to LF:
   inputString.ReplaceSubstring(NS_LITERAL_STRING("\r"),
                                NS_LITERAL_STRING("\n"));
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   // Get the first range in the selection, for context:
   RefPtr<nsRange> range = selection->GetRangeAt(0);
   if (NS_WARN_IF(!range)) {
     return NS_ERROR_FAILURE;
   }
 
   ErrorResult err;
@@ -1417,17 +1417,17 @@ HTMLEditor::RebuildDocumentFromSource(co
     foundclosehead = false;
   }
   // a valid close head appears before a found body
   if (foundbody && beginclosehead.get() > beginbody.get()) {
     foundclosehead = false;
   }
 
   // Time to change the document
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   nsReadingIterator<char16_t> endtotal;
   aSourceString.EndReading(endtotal);
 
   if (foundhead) {
     if (foundclosehead) {
       nsresult rv =
         ReplaceHeadContentsWithSourceWithTransaction(
@@ -1627,17 +1627,17 @@ HTMLEditor::InsertElementAtSelection(Ele
                                      bool aDeleteSelection)
 {
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
   NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER);
 
   CommitComposition();
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eInsertElement,
                                       nsIEditor::eNext);
 
   RefPtr<Selection> selection = GetSelection();
   if (!selection) {
     return NS_ERROR_FAILURE;
   }
@@ -1819,17 +1819,17 @@ HTMLEditor::SelectContentInternal(Select
   }
 
   nsINode* parent = aContentToSelect.GetParentNode();
   if (NS_WARN_IF(!parent)) {
     return NS_ERROR_FAILURE;
   }
 
   // Don't notify selection change at collapse.
-  AutoUpdateViewBatch notifySelectionChangeOnce(this);
+  AutoUpdateViewBatch notifySelectionChangeOnce(*this);
 
   // XXX Perhaps, Selection should have SelectNode(nsIContent&).
   int32_t offsetInParent = parent->ComputeIndexOf(&aContentToSelect);
 
   // Collapse selection to just before desired element,
   nsresult rv = aSelection.Collapse(parent, offsetInParent);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -2126,17 +2126,17 @@ HTMLEditor::MakeOrChangeList(const nsASt
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
   bool cancel, handled;
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eCreateOrChangeList,
                                       nsIEditor::eNext);
 
   // pre-process
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
@@ -2221,17 +2221,17 @@ HTMLEditor::RemoveList(const nsAString&)
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
   bool cancel, handled;
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eRemoveList,
                                       nsIEditor::eNext);
 
   // pre-process
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
@@ -2257,17 +2257,17 @@ HTMLEditor::MakeDefinitionListItemWithTr
   MOZ_ASSERT(&aTagName == nsGkAtoms::dt ||
              &aTagName == nsGkAtoms::dd);
 
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
   bool cancel, handled;
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier
     maybeTopLevelEditSubAction(*this,
                                EditSubAction::eCreateOrChangeDefinitionList,
                                nsIEditor::eNext);
 
   // pre-process
   RefPtr<Selection> selection = GetSelection();
   if (NS_WARN_IF(!selection)) {
@@ -2299,17 +2299,17 @@ HTMLEditor::InsertBasicBlockWithTransact
   MOZ_ASSERT(&aTagName != nsGkAtoms::dd &&
              &aTagName != nsGkAtoms::dt);
 
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
   bool cancel, handled;
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this,
                                       EditSubAction::eCreateOrRemoveBlock,
                                       nsIEditor::eNext);
 
   // pre-process
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
@@ -2403,32 +2403,32 @@ HTMLEditor::Indent(const nsAString& aInd
 
 nsresult
 HTMLEditor::IndentAsAction()
 {
   if (!mRules) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   nsresult rv = IndentOrOutdentAsSubAction(EditSubAction::eIndent);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 nsresult
 HTMLEditor::OutdentAsAction()
 {
   if (!mRules) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   nsresult rv = IndentOrOutdentAsSubAction(EditSubAction::eOutdent);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 nsresult
@@ -2540,17 +2540,17 @@ HTMLEditor::IndentOrOutdentAsSubAction(E
 //TODO: IMPLEMENT ALIGNMENT!
 
 NS_IMETHODIMP
 HTMLEditor::Align(const nsAString& aAlignType)
 {
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this,
                                       EditSubAction::eSetOrClearAlignment,
                                       nsIEditor::eNext);
 
   bool cancel, handled;
 
   // Find out if the selection is collapsed:
@@ -2954,17 +2954,17 @@ HTMLEditor::InsertLinkAroundSelection(El
 
   nsAutoString href;
   anchor->GetHref(href);
   if (href.IsEmpty()) {
     return NS_OK;
   }
 
   nsresult rv;
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   // Set all attributes found on the supplied anchor element
   RefPtr<nsDOMAttributeMap> attrMap = anchor->Attributes();
   NS_ENSURE_TRUE(attrMap, NS_ERROR_FAILURE);
 
   uint32_t count = attrMap->Length();
   nsAutoString value;
 
@@ -4468,21 +4468,21 @@ HTMLEditor::SetCSSBackgroundColorWithTra
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_STATE(selection);
 
   bool isCollapsed = selection->IsCollapsed();
 
-  AutoPlaceholderBatch batchIt(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eInsertElement,
                                       nsIEditor::eNext);
-  AutoSelectionRestorer selectionRestorer(selection, this);
+  AutoSelectionRestorer restoreSelectionLater(*selection, *this);
   AutoTransactionsConserveSelection dontChangeMySelection(*this);
 
   // XXX Although, this method may set background color of ancestor block
   //     element, using EditSubAction::eSetTextProperty.
   bool cancel, handled;
   EditSubActionInfo subActionInfo(EditSubAction::eSetTextProperty);
   nsresult rv =
     rules->WillDoAction(selection, subActionInfo, &cancel, &handled);
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -91,17 +91,17 @@ static nsresult FindTargetNode(nsINode* 
 
 nsresult
 HTMLEditor::LoadHTML(const nsAString& aInputString)
 {
   NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
 
   // force IME commit; set up rules sniffing and batching
   CommitComposition();
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this,
                                       EditSubAction::eInsertHTMLSource,
                                       nsIEditor::eNext);
 
   // Get selection
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_STATE(selection);
@@ -195,17 +195,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
 {
   NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
 
   // Prevent the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
   // force IME commit; set up rules sniffing and batching
   CommitComposition();
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::ePasteHTMLContent,
                                       nsIEditor::eNext);
 
   // Get selection
   RefPtr<Selection> selection = GetSelection();
   if (NS_WARN_IF(!selection)) {
     return NS_ERROR_FAILURE;
@@ -319,17 +319,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
     }
   } else {
     // Delete whole cells: we will replace with new table content.
 
     // Braces for artificial block to scope AutoSelectionRestorer.
     // Save current selection since DeleteTableCellWithTransaction() perturbs
     // it.
     {
-      AutoSelectionRestorer selectionRestorer(selection, this);
+      AutoSelectionRestorer restoreSelectionLater(*selection, *this);
       rv = DeleteTableCellWithTransaction(1);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
     // collapse selection to beginning of deleted table content
     selection->CollapseToStart(IgnoreErrors());
   }
@@ -1004,17 +1004,17 @@ HTMLEditor::BlobReader::OnResult(const n
   nsString blobType;
   mBlob->GetType(blobType);
 
   NS_ConvertUTF16toUTF8 type(blobType);
   nsAutoString stuffToPaste;
   nsresult rv = ImgFromData(type, aResult, stuffToPaste);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  AutoPlaceholderBatch beginBatching(mHTMLEditor);
+  AutoPlaceholderBatch treatAsOneTransaction(*mHTMLEditor);
   rv = mHTMLEditor->DoInsertHTMLWithContext(stuffToPaste, EmptyString(),
                                             EmptyString(),
                                             NS_LITERAL_STRING(kFileMime),
                                             mSourceDoc,
                                             mDestinationNode, mDestOffset,
                                             mDoDeleteSelection,
                                             mIsSafe, false);
   return rv;
@@ -1190,17 +1190,17 @@ HTMLEditor::InsertObject(const nsACStrin
       rv = imageStream->Close();
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     nsAutoString stuffToPaste;
     rv = ImgFromData(type, imageData, stuffToPaste);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    AutoPlaceholderBatch beginBatching(this);
+    AutoPlaceholderBatch treatAsOneTransaction(*this);
     rv = DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
                                  NS_LITERAL_STRING(kFileMime),
                                  aSourceDoc,
                                  aDestinationNode, aDestOffset,
                                  aDoDeleteSelection,
                                  aIsSafe, false);
   }
 
@@ -1242,17 +1242,17 @@ HTMLEditor::InsertFromTransferable(nsITr
       if (textDataObj && len > 0) {
         nsAutoCString cfhtml;
         textDataObj->GetData(cfhtml);
         NS_ASSERTION(cfhtml.Length() <= (len), "Invalid length!");
         nsString cfcontext, cffragment, cfselection; // cfselection left emtpy for now
 
         rv = ParseCFHTML(cfhtml, getter_Copies(cffragment), getter_Copies(cfcontext));
         if (NS_SUCCEEDED(rv) && !cffragment.IsEmpty()) {
-          AutoPlaceholderBatch beginBatching(this);
+          AutoPlaceholderBatch treatAsOneTransaction(*this);
           // If we have our private HTML flavor, we will only use the fragment
           // from the CF_HTML. The rest comes from the clipboard.
           if (havePrivateHTMLFlavor) {
             rv = DoInsertHTMLWithContext(cffragment,
                                          aContextStr, aInfoStr, flavor,
                                          aSourceDoc,
                                          nullptr, 0,
                                          aDoDeleteSelection,
@@ -1292,17 +1292,17 @@ HTMLEditor::InsertFromTransferable(nsITr
           nsAutoCString text;
           textDataObj->GetData(text);
           NS_ASSERTION(text.Length() <= len, "Invalid length!");
           stuffToPaste.Assign(NS_ConvertUTF8toUTF16(Substring(text, 0, len)));
         }
       }
 
       if (!stuffToPaste.IsEmpty()) {
-        AutoPlaceholderBatch beginBatching(this);
+        AutoPlaceholderBatch treatAsOneTransaction(*this);
         if (bestFlavor.EqualsLiteral(kHTMLMime)) {
           rv = DoInsertHTMLWithContext(stuffToPaste,
                                        aContextStr, aInfoStr, flavor,
                                        aSourceDoc,
                                        nullptr, 0,
                                        aDoDeleteSelection,
                                        isSafe);
         } else {
@@ -1377,17 +1377,17 @@ HTMLEditor::InsertFromDataTransfer(DataT
         nsAutoString text;
         GetStringFromDataTransfer(aDataTransfer, type, aIndex, text);
         NS_ConvertUTF16toUTF8 cfhtml(text);
 
         nsString cfcontext, cffragment, cfselection; // cfselection left emtpy for now
 
         nsresult rv = ParseCFHTML(cfhtml, getter_Copies(cffragment), getter_Copies(cfcontext));
         if (NS_SUCCEEDED(rv) && !cffragment.IsEmpty()) {
-          AutoPlaceholderBatch beginBatching(this);
+          AutoPlaceholderBatch treatAsOneTransaction(*this);
 
           if (hasPrivateHTMLFlavor) {
             // If we have our private HTML flavor, we will only use the fragment
             // from the CF_HTML. The rest comes from the clipboard.
             nsAutoString contextString, infoString;
             GetStringFromDataTransfer(aDataTransfer, NS_LITERAL_STRING(kHTMLContext), aIndex, contextString);
             GetStringFromDataTransfer(aDataTransfer, NS_LITERAL_STRING(kHTMLInfo), aIndex, infoString);
             return DoInsertHTMLWithContext(cffragment,
@@ -1406,34 +1406,34 @@ HTMLEditor::InsertFromDataTransfer(DataT
           }
         }
       } else if (type.EqualsLiteral(kHTMLMime)) {
         nsAutoString text, contextString, infoString;
         GetStringFromDataTransfer(aDataTransfer, type, aIndex, text);
         GetStringFromDataTransfer(aDataTransfer, NS_LITERAL_STRING(kHTMLContext), aIndex, contextString);
         GetStringFromDataTransfer(aDataTransfer, NS_LITERAL_STRING(kHTMLInfo), aIndex, infoString);
 
-        AutoPlaceholderBatch beginBatching(this);
+        AutoPlaceholderBatch treatAsOneTransaction(*this);
         if (type.EqualsLiteral(kHTMLMime)) {
           return DoInsertHTMLWithContext(text,
                                          contextString, infoString, type,
                                          aSourceDoc,
                                          aDestinationNode, aDestOffset,
                                          aDoDeleteSelection,
                                          isSafe);
         }
       }
     }
 
     if (type.EqualsLiteral(kTextMime) ||
         type.EqualsLiteral(kMozTextInternal)) {
       nsAutoString text;
       GetStringFromDataTransfer(aDataTransfer, type, aIndex, text);
 
-      AutoPlaceholderBatch beginBatching(this);
+      AutoPlaceholderBatch treatAsOneTransaction(*this);
       return InsertTextAt(text, aDestinationNode, aDestOffset, aDoDeleteSelection);
     }
   }
 
   return NS_OK;
 }
 
 bool
@@ -1700,17 +1700,17 @@ HTMLEditor::PasteAsQuotationAsAction(int
   if (IsPlaintextEditor()) {
     // XXX In this case, we don't dispatch ePaste event.  Why?
     return PasteAsPlaintextQuotation(aClipboardType);
   }
 
   // If it's not in plain text edit mode, paste text into new
   // <blockquote type="cite"> element after removing selection.
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eInsertQuotation,
                                       nsIEditor::eNext);
 
   RefPtr<Selection> selection = GetSelection();
   if (NS_WARN_IF(!selection)) {
     return NS_ERROR_FAILURE;
   }
@@ -1794,31 +1794,31 @@ HTMLEditor::PasteAsPlaintextQuotation(in
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (flav.EqualsLiteral(kUnicodeMime)) {
     nsCOMPtr<nsISupportsString> textDataObj = do_QueryInterface(genericDataObj);
     if (textDataObj && len > 0) {
       nsAutoString stuffToPaste;
       textDataObj->GetData(stuffToPaste);
       NS_ASSERTION(stuffToPaste.Length() <= (len/2), "Invalid length!");
-      AutoPlaceholderBatch beginBatching(this);
+      AutoPlaceholderBatch treatAsOneTransaction(*this);
       rv = InsertAsPlaintextQuotation(stuffToPaste, true, 0);
     }
   }
 
   return rv;
 }
 
 nsresult
 HTMLEditor::InsertTextWithQuotations(const nsAString& aStringToInsert)
 {
   // The whole operation should be undoable in one transaction:
   // XXX Why isn't enough to use only AutoPlaceholderBatch here?
   AutoTransactionBatch bundleAllTransactions(*this);
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   nsresult rv = InsertTextWithQuotationsInternal(aStringToInsert);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
@@ -1911,17 +1911,17 @@ HTMLEditor::InsertTextWithQuotationsInte
 
   return rv;
 }
 
 nsresult
 HTMLEditor::InsertAsQuotation(const nsAString& aQuotedText,
                               nsINode** aNodeInserted)
 {
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   if (IsPlaintextEditor()) {
     return InsertAsPlaintextQuotation(aQuotedText, true, aNodeInserted);
   }
 
   nsAutoString citation;
   return InsertAsCitedQuotation(aQuotedText, citation, false,
                                 aNodeInserted);
 }
@@ -2058,31 +2058,31 @@ HTMLEditor::Rewrap(bool aRespectNewlines
     DebugOnly<nsresult> rv = SelectAllInternal();
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),  "Failed to select all text");
   }
 
   // The whole operation in InsertTextWithQuotationsInternal() should be
   // undoable in one transaction.
   // XXX Why isn't enough to use only AutoPlaceholderBatch here?
   AutoTransactionBatch bundleAllTransactions(*this);
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   rv = InsertTextWithQuotationsInternal(wrapped);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLEditor::InsertAsCitedQuotation(const nsAString& aQuotedText,
                                    const nsAString& aCitation,
                                    bool aInsertHTML,
                                    nsINode** aNodeInserted)
 {
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   // Don't let anyone insert HTML when we're in plaintext mode.
   if (IsPlaintextEditor()) {
     NS_ASSERTION(!aInsertHTML,
       "InsertAsCitedQuotation: trying to insert html into plaintext editor");
     return InsertAsPlaintextQuotation(aQuotedText, true, aNodeInserted);
   }
 
--- a/editor/libeditor/HTMLEditorObjectResizer.cpp
+++ b/editor/libeditor/HTMLEditorObjectResizer.cpp
@@ -3,17 +3,16 @@
  * 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 "mozilla/HTMLEditor.h"
 #include "HTMLEditorObjectResizerUtils.h"
 
 #include "HTMLEditUtils.h"
 #include "mozilla/DebugOnly.h"
-#include "mozilla/EditorUtils.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/mozalloc.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/MouseEvent.h"
 #include "mozilla/dom/EventTarget.h"
 #include "nsAString.h"
@@ -1073,17 +1072,17 @@ HTMLEditor::SetFinalSize(int32_t aX,
   bool setWidth  = !mResizedObjectIsAbsolutelyPositioned || (width != mResizedObjectWidth);
   bool setHeight = !mResizedObjectIsAbsolutelyPositioned || (height != mResizedObjectHeight);
 
   int32_t x, y;
   x = left - ((mResizedObjectIsAbsolutelyPositioned) ? mResizedObjectBorderLeft+mResizedObjectMarginLeft : 0);
   y = top - ((mResizedObjectIsAbsolutelyPositioned) ? mResizedObjectBorderTop+mResizedObjectMarginTop : 0);
 
   // we want one transaction only from a user's point of view
-  AutoPlaceholderBatch batchIt(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   if (mResizedObjectIsAbsolutelyPositioned) {
     if (setHeight) {
       mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::top, y);
     }
     if (setWidth) {
       mCSSEditUtils->SetCSSPropertyPixels(*mResizedObject, *nsGkAtoms::left, x);
     }
--- a/editor/libeditor/HTMLStyleEditor.cpp
+++ b/editor/libeditor/HTMLStyleEditor.cpp
@@ -113,21 +113,21 @@ HTMLEditor::SetInlinePropertyInternal(ns
 
   if (selection->IsCollapsed()) {
     // Manipulating text attributes on a collapsed selection only sets state
     // for the next text insertion
     mTypeInState->SetProp(&aProperty, aAttribute, aValue);
     return NS_OK;
   }
 
-  AutoPlaceholderBatch batchIt(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eInsertElement,
                                       nsIEditor::eNext);
-  AutoSelectionRestorer selectionRestorer(selection, this);
+  AutoSelectionRestorer restoreSelectionLater(*selection, *this);
   AutoTransactionsConserveSelection dontChangeMySelection(*this);
 
   bool cancel, handled;
   EditSubActionInfo subActionInfo(EditSubAction::eSetTextProperty);
   // Protect the edit rules object from dying
   nsresult rv =
     rules->WillDoAction(selection, subActionInfo, &cancel, &handled);
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -1238,17 +1238,17 @@ HTMLEditor::GetInlinePropertyWithAttrVal
   if (!aValue.IsEmpty())
     val = &aValue;
   return GetInlinePropertyBase(*aProperty, aAttribute, val, aFirst, aAny, aAll, &outValue);
 }
 
 NS_IMETHODIMP
 HTMLEditor::RemoveAllInlineProperties()
 {
-  AutoPlaceholderBatch batchIt(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this,
                                       EditSubAction::eRemoveAllTextProperties,
                                       nsIEditor::eNext);
 
   nsresult rv = RemoveInlinePropertyInternal(nullptr, nullptr);
   NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
@@ -1290,21 +1290,21 @@ HTMLEditor::RemoveInlinePropertyInternal
     if (aProperty) {
       mTypeInState->ClearProp(aProperty, aAttribute);
     } else {
       mTypeInState->ClearAllProps();
     }
     return NS_OK;
   }
 
-  AutoPlaceholderBatch batchIt(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eRemoveTextProperty,
                                       nsIEditor::eNext);
-  AutoSelectionRestorer selectionRestorer(selection, this);
+  AutoSelectionRestorer restoreSelectionLater(*selection, *this);
   AutoTransactionsConserveSelection dontChangeMySelection(*this);
 
   bool cancel, handled;
   EditSubActionInfo subActionInfo(EditSubAction::eRemoveTextProperty);
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
   nsresult rv =
     rules->WillDoAction(selection, subActionInfo, &cancel, &handled);
@@ -1460,21 +1460,21 @@ HTMLEditor::RelativeFontChange(FontSize 
 
     // Manipulating text attributes on a collapsed selection only sets state
     // for the next text insertion
     mTypeInState->SetProp(&atom, nullptr, EmptyString());
     return NS_OK;
   }
 
   // Wrap with txn batching, rules sniffing, and selection preservation code
-  AutoPlaceholderBatch batchIt(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eSetTextProperty,
                                       nsIEditor::eNext);
-  AutoSelectionRestorer selectionRestorer(selection, this);
+  AutoSelectionRestorer restoreSelectionLater(*selection, *this);
   AutoTransactionsConserveSelection dontChangeMySelection(*this);
 
   // Loop through the ranges in the selection
   AutoRangeArray arrayOfRanges(selection);
   for (auto& range : arrayOfRanges.mRanges) {
     // Adjust range to include any ancestors with entirely selected children
     nsresult rv = PromoteInlineRange(*range);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -446,17 +446,17 @@ HTMLEditor::InsertTableColumnsWithTransa
   ErrorResult error;
   TableSize tableSize(*this, *table, error);
   if (NS_WARN_IF(error.Failed())) {
     return error.StealNSResult();
   }
   // Should not be empty since we've already found a cell.
   MOZ_ASSERT(!tableSize.IsEmpty());
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treateAsOneTransaction(*this);
   // Prevent auto insertion of <br> element in new cell until we're done.
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eInsertNode,
                                       nsIEditor::eNext);
 
   switch (aInsertPosition) {
     case InsertPosition::eBeforeSelectedCell:
       break;
@@ -635,17 +635,17 @@ HTMLEditor::InsertTableRowsWithTransacti
   ErrorResult error;
   TableSize tableSize(*this, *table, error);
   if (NS_WARN_IF(error.Failed())) {
     return error.StealNSResult();
   }
   // Should not be empty since we've already found a cell.
   MOZ_ASSERT(!tableSize.IsEmpty());
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treateAsOneTransaction(*this);
   // Prevent auto insertion of BR in new cell until we're done
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eInsertNode,
                                       nsIEditor::eNext);
 
   switch (aInsertPosition) {
     case InsertPosition::eBeforeSelectedCell:
       break;
@@ -858,17 +858,17 @@ HTMLEditor::DeleteTable()
                                nullptr, nullptr, nullptr, nullptr, nullptr);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   if (NS_WARN_IF(!selection) || NS_WARN_IF(!table)) {
     return NS_ERROR_FAILURE;
   }
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treateAsOneTransaction(*this);
   rv = DeleteTableElementAndChildrenWithTransaction(*selection, *table);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -899,17 +899,17 @@ HTMLEditor::DeleteTableCellWithTransacti
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   if (NS_WARN_IF(!table) || NS_WARN_IF(!cell)) {
     // Don't fail if we didn't find a table or cell.
     return NS_OK;
   }
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treateAsOneTransaction(*this);
   // Prevent rules testing until we're done
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eDeleteNode,
                                       nsIEditor::eNext);
 
   ErrorResult error;
   RefPtr<Element> firstSelectedCellElement =
     GetFirstSelectedTableCellElement(*selection, error);
@@ -1174,17 +1174,17 @@ HTMLEditor::DeleteTableCellContentsWithT
     return rv;
   }
   if (NS_WARN_IF(!selection) || NS_WARN_IF(!cell)) {
     // Don't fail if no cell found.
     return NS_OK;
   }
 
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treateAsOneTransaction(*this);
   // Prevent rules testing until we're done
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eDeleteNode,
                                       nsIEditor::eNext);
   // Don't let Rules System change the selection
   AutoTransactionsConserveSelection dontChangeSelection(*this);
 
   ErrorResult error;
@@ -1260,17 +1260,17 @@ HTMLEditor::DeleteSelectedTableColumnsWi
   }
 
   ErrorResult error;
   TableSize tableSize(*this, *table, error);
   if (NS_WARN_IF(error.Failed())) {
     return error.StealNSResult();
   }
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treateAsOneTransaction(*this);
 
   // Prevent rules testing until we're done
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eDeleteNode,
                                       nsIEditor::eNext);
 
   // Shortcut the case of deleting all columns in table
   if (!startColIndex && aNumberOfColumnsToDelete >= tableSize.mColumnCount) {
@@ -1490,17 +1490,17 @@ HTMLEditor::DeleteSelectedTableRowsWithT
   }
 
   ErrorResult error;
   TableSize tableSize(*this, *table, error);
   if (NS_WARN_IF(error.Failed())) {
     return error.StealNSResult();
   }
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treateAsOneTransaction(*this);
 
   // Prevent rules testing until we're done
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eDeleteNode,
                                       nsIEditor::eNext);
 
   // Shortcut the case of deleting all rows in table
   if (!startRowIndex && aNumberOfRowsToDelete >= tableSize.mRowCount) {
@@ -2142,17 +2142,17 @@ HTMLEditor::SplitTableCell()
                       actualRowSpan, actualColSpan);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Must have some span to split
   if (actualRowSpan <= 1 && actualColSpan <= 1) {
     return NS_OK;
   }
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treateAsOneTransaction(*this);
   // Prevent auto insertion of BR in new cell until we're done
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eInsertNode,
                                       nsIEditor::eNext);
 
   // We reset selection
   AutoSelectionSetterAfterTableEdit setCaret(*this, table, startRowIndex,
                                              startColIndex, ePreviousColumn,
@@ -2396,32 +2396,32 @@ HTMLEditor::SplitCellIntoRows(Element* a
 NS_IMETHODIMP
 HTMLEditor::SwitchTableCellHeaderType(Element* aSourceCell,
                                       Element** aNewCell)
 {
   if (NS_WARN_IF(!aSourceCell)) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treateAsOneTransaction(*this);
   // Prevent auto insertion of BR in new cell created by
   // ReplaceContainerAndCloneAttributesWithTransaction().
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eInsertNode,
                                       nsIEditor::eNext);
 
   // Save current selection to restore when done.
   // This is needed so ReplaceContainerAndCloneAttributesWithTransaction()
   // can monitor selection when replacing nodes.
   RefPtr<Selection> selection = GetSelection();
   if (NS_WARN_IF(!selection)) {
     return NS_ERROR_FAILURE;
   }
 
-  AutoSelectionRestorer selectionRestorer(selection, this);
+  AutoSelectionRestorer restoreSelectionLater(*selection, *this);
 
   // Set to the opposite of current type
   nsAtom* newCellName =
     aSourceCell->IsHTMLElement(nsGkAtoms::td) ? nsGkAtoms::th : nsGkAtoms::td;
 
   // This creates new node, moves children, copies attributes (true)
   //   and manages the selection!
   RefPtr<Element> newCell =
@@ -2454,17 +2454,17 @@ HTMLEditor::JoinTableCells(bool aMergeNo
                                &startRowIndex, &startColIndex);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   if (!table || !targetCell) {
     return NS_OK;
   }
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treateAsOneTransaction(*this);
   //Don't let Rules System change the selection
   AutoTransactionsConserveSelection dontChangeSelection(*this);
 
   // Note: We dont' use AutoSelectionSetterAfterTableEdit here so the selection
   //  is retained after joining. This leaves the target cell selected
   //  as well as the "non-contiguous" cells, so user can see what happened.
 
   RefPtr<Selection> selection = GetSelection();
@@ -3084,19 +3084,19 @@ HTMLEditor::NormalizeTable(Selection& aS
 
   ErrorResult error;
   TableSize tableSize(*this, *tableElement, error);
   if (NS_WARN_IF(error.Failed())) {
     return error.StealNSResult();
   }
 
   // Save current selection
-  AutoSelectionRestorer selectionRestorer(&aSelection, this);
-
-  AutoPlaceholderBatch beginBatching(this);
+  AutoSelectionRestorer restoreSelectionLater(aSelection, *this);
+
+  AutoPlaceholderBatch treateAsOneTransaction(*this);
   // Prevent auto insertion of BR in new cell until we're done
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eInsertNode,
                                       nsIEditor::eNext);
 
   // XXX If there is a cell which has bigger or smaller "rowspan" or "colspan"
   //     values, FixBadRowSpan() will return error.  So, we can do nothing
   //     if the table needs normalization...
--- a/editor/libeditor/PlaceholderTransaction.h
+++ b/editor/libeditor/PlaceholderTransaction.h
@@ -2,17 +2,16 @@
 /* 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 PlaceholderTransaction_h
 #define PlaceholderTransaction_h
 
 #include "EditAggregateTransaction.h"
-#include "mozilla/EditorUtils.h"
 #include "mozilla/Maybe.h"
 #include "nsIAbsorbingTransaction.h"
 #include "nsCOMPtr.h"
 #include "nsWeakPtr.h"
 
 namespace mozilla {
 
 class CompositionTransaction;
--- a/editor/libeditor/TextEditRules.h
+++ b/editor/libeditor/TextEditRules.h
@@ -2,16 +2,17 @@
 /* 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 mozilla_TextEditRules_h
 #define mozilla_TextEditRules_h
 
 #include "mozilla/EditAction.h"
+#include "mozilla/EditorBase.h"
 #include "mozilla/EditorDOMPoint.h"
 #include "mozilla/EditorUtils.h"
 #include "mozilla/HTMLEditor.h" // for nsIEditor::AsHTMLEditor()
 #include "mozilla/TextEditor.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIEditor.h"
 #include "nsINamed.h"
@@ -52,16 +53,23 @@ class Selection;
  *    false, the method have to return NS_ERROR_EDITOR_DESTROYED.  In other
  *    words, any methods which may change Selection or the DOM tree have to
  *    return nsresult directly or with simple class like EditActionResult.
  *    And such methods should be marked as MOZ_MUST_USE.
  */
 class TextEditRules : public nsITimerCallback
                     , public nsINamed
 {
+protected:
+  typedef EditorBase::AutoSelectionRestorer
+            AutoSelectionRestorer;
+  typedef EditorBase::AutoTopLevelEditSubActionNotifier
+            AutoTopLevelEditSubActionNotifier;
+  typedef EditorBase::AutoTransactionsConserveSelection
+            AutoTransactionsConserveSelection;
 public:
   typedef dom::Element Element;
   typedef dom::Selection Selection;
   typedef dom::Text Text;
   template<typename T> using OwningNonNull = OwningNonNull<T>;
 
   NS_DECL_NSITIMERCALLBACK
   NS_DECL_NSINAMED
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -8,17 +8,16 @@
 #include "EditAggregateTransaction.h"
 #include "HTMLEditRules.h"
 #include "InternetCiter.h"
 #include "TextEditUtils.h"
 #include "gfxFontUtils.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/EditAction.h"
 #include "mozilla/EditorDOMPoint.h"
-#include "mozilla/EditorUtils.h"
 #include "mozilla/HTMLEditor.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/mozalloc.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/TextEditRules.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TextServicesDocument.h"
@@ -415,28 +414,28 @@ TextEditor::HandleKeyPressEvent(WidgetKe
   aKeyboardEvent->PreventDefault();
   nsAutoString str(aKeyboardEvent->mCharCode);
   return OnInputText(str);
 }
 
 nsresult
 TextEditor::OnInputText(const nsAString& aStringToInsert)
 {
-  AutoPlaceholderBatch batch(this, nsGkAtoms::TypingTxnName);
+  AutoPlaceholderBatch treatAsOneTransaction(*this, *nsGkAtoms::TypingTxnName);
   nsresult rv = InsertTextAsSubAction(aStringToInsert);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 nsresult
 TextEditor::OnInputParagraphSeparator()
 {
-  AutoPlaceholderBatch batch(this, nsGkAtoms::TypingTxnName);
+  AutoPlaceholderBatch treatAsOneTransaction(*this, *nsGkAtoms::TypingTxnName);
   nsresult rv = InsertParagraphSeparatorAsAction();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 template<typename PT, typename CT>
@@ -658,17 +657,17 @@ TextEditor::DeleteSelectionAsAction(EDir
   // Showing this assertion is fine if this method is called by outside via
   // mutation event listener or something.  Otherwise, this is called by
   // wrong method.
   NS_ASSERTION(!mPlaceholderBatch,
     "Should be called only when this is the only edit action of the operation "
     "unless mutation event listener nests some operations");
 
   // delete placeholder txns merge.
-  AutoPlaceholderBatch batch(this, nsGkAtoms::DeleteTxnName);
+  AutoPlaceholderBatch treatAsOneTransaction(*this, *nsGkAtoms::DeleteTxnName);
   nsresult rv = DeleteSelectionAsSubAction(aDirection, aStripWrappers);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 nsresult
@@ -963,17 +962,17 @@ TextEditor::InsertTextAsAction(const nsA
 {
   // Showing this assertion is fine if this method is called by outside via
   // mutation event listener or something.  Otherwise, this is called by
   // wrong method.
   NS_ASSERTION(!mPlaceholderBatch,
     "Should be called only when this is the only edit action of the operation "
     "unless mutation event listener nests some operations");
 
-  AutoPlaceholderBatch batch(this, nullptr);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   nsresult rv = InsertTextAsSubAction(aStringToInsert);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 nsresult
@@ -1040,17 +1039,17 @@ TextEditor::InsertParagraphSeparatorAsAc
 {
   if (!mRules) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this,
                                       EditSubAction::eInsertParagraphSeparator,
                                       nsIEditor::eNext);
 
   RefPtr<Selection> selection = GetSelection();
   if (NS_WARN_IF(!selection)) {
     return NS_ERROR_FAILURE;
@@ -1131,29 +1130,29 @@ TextEditor::InsertParagraphSeparatorAsAc
   return rv;
 }
 
 nsresult
 TextEditor::SetText(const nsAString& aString)
 {
   MOZ_ASSERT(aString.FindChar(static_cast<char16_t>('\r')) == kNotFound);
 
-  AutoPlaceholderBatch batch(this, nullptr);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
   nsresult rv = SetTextAsSubAction(aString);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 nsresult
 TextEditor::ReplaceTextAsAction(const nsAString& aString,
                                 nsRange* aReplaceRange /* = nullptr */)
 {
-  AutoPlaceholderBatch batch(this, nullptr);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   // This should emulates inserting text for better undo/redo behavior.
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, EditSubAction::eInsertText,
                                       nsIEditor::eNext);
 
   if (!aReplaceRange) {
     nsresult rv = SetTextAsSubAction(aString);
@@ -1165,17 +1164,17 @@ TextEditor::ReplaceTextAsAction(const ns
 
   if (NS_WARN_IF(aString.IsEmpty() && aReplaceRange->Collapsed())) {
     return NS_OK;
   }
 
   // Note that do not notify selectionchange caused by selecting all text
   // because it's preparation of our delete implementation so web apps
   // shouldn't receive such selectionchange before the first mutation.
-  AutoUpdateViewBatch preventSelectionChangeEvent(this);
+  AutoUpdateViewBatch preventSelectionChangeEvent(*this);
 
   RefPtr<Selection> selection = GetSelection();
   if (NS_WARN_IF(!selection)) {
     return NS_ERROR_FAILURE;
   }
 
   // Select the range but as far as possible, we should not create new range
   // even if it's part of special Selection.
@@ -1230,17 +1229,17 @@ TextEditor::SetTextAsSubAction(const nsA
   }
   if (cancel) {
     return NS_OK;
   }
   if (!handled) {
     // Note that do not notify selectionchange caused by selecting all text
     // because it's preparation of our delete implementation so web apps
     // shouldn't receive such selectionchange before the first mutation.
-    AutoUpdateViewBatch preventSelectionChangeEvent(this);
+    AutoUpdateViewBatch preventSelectionChangeEvent(*this);
 
     // We want to select trailing BR node to remove all nodes to replace all,
     // but TextEditor::SelectEntireDocument doesn't select that BR node.
     if (rules->DocumentIsEmpty()) {
       // if it's empty, don't select entire doc - that would select
       // the bogus node
       Element* rootElement = GetRoot();
       if (NS_WARN_IF(!rootElement)) {
@@ -1349,17 +1348,17 @@ TextEditor::OnCompositionChange(WidgetCo
     "UpdateIMEComposition() must be called without place holder batch");
   TextComposition::CompositionChangeEventHandlingMarker
     compositionChangeEventHandlingMarker(mComposition, &aCompsitionChangeEvent);
 
   RefPtr<nsCaret> caretP = presShell->GetCaret();
 
   nsresult rv;
   {
-    AutoPlaceholderBatch batch(this, nsGkAtoms::IMETxnName);
+    AutoPlaceholderBatch treatAsOneTransaction(*this, *nsGkAtoms::IMETxnName);
 
     MOZ_ASSERT(mIsInEditSubAction,
       "AutoPlaceholderBatch should've notified the observes of before-edit");
     rv = InsertTextAsSubAction(aCompsitionChangeEvent.mData);
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
       "Failed to insert new composition string");
 
     if (caretP) {
@@ -1622,17 +1621,17 @@ TextEditor::Undo(uint32_t aCount)
   // undoes the committing composition.
   if (GetComposition()) {
     return NS_OK;
   }
 
   // Protect the edit rules object from dying.
   RefPtr<TextEditRules> rules(mRules);
 
-  AutoUpdateViewBatch beginViewBatching(this);
+  AutoUpdateViewBatch preventSelectionChangeEvent(*this);
 
   NotifyEditorObservers(eNotifyEditorObserversOfBefore);
   if (NS_WARN_IF(!CanUndo()) || NS_WARN_IF(Destroyed())) {
     return NS_ERROR_FAILURE;
   }
 
   nsresult rv;
   {
@@ -1677,17 +1676,17 @@ TextEditor::Redo(uint32_t aCount)
   // the redo queue.  So, it becomes impossible to redo anything.
   if (GetComposition()) {
     return NS_OK;
   }
 
   // Protect the edit rules object from dying.
   RefPtr<TextEditRules> rules(mRules);
 
-  AutoUpdateViewBatch beginViewBatching(this);
+  AutoUpdateViewBatch preventSelectionChangeEvent(*this);
 
   NotifyEditorObservers(eNotifyEditorObserversOfBefore);
   if (NS_WARN_IF(!CanRedo()) || NS_WARN_IF(Destroyed())) {
     return NS_ERROR_FAILURE;
   }
 
   nsresult rv;
   {
@@ -1761,17 +1760,18 @@ TextEditor::FireClipboardEvent(EventMess
 
 NS_IMETHODIMP
 TextEditor::Cut()
 {
   bool actionTaken = false;
   if (FireClipboardEvent(eCut, nsIClipboard::kGlobalClipboard, &actionTaken)) {
     // XXX This transaction name is referred by PlaceholderTransaction::Merge()
     //     so that we need to keep using it here.
-    AutoPlaceholderBatch batch(this, nsGkAtoms::DeleteTxnName);
+    AutoPlaceholderBatch treatAsOneTransaction(*this,
+                                               *nsGkAtoms::DeleteTxnName);
     DeleteSelectionAsSubAction(eNone, eStrip);
   }
   return actionTaken ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 TextEditor::CanCut(bool* aCanCut)
 {
@@ -1981,17 +1981,17 @@ TextEditor::PasteAsQuotationAsAction(int
       !flav.EqualsLiteral(kMozTextInternal)) {
     return NS_OK;
   }
 
   nsCOMPtr<nsISupportsString> textDataObj = do_QueryInterface(genericDataObj);
   if (textDataObj && len > 0) {
     nsAutoString stuffToPaste;
     textDataObj->GetData ( stuffToPaste );
-    AutoPlaceholderBatch beginBatching(this);
+    AutoPlaceholderBatch treatAsOneTransaction(*this);
     rv = InsertWithQuotationsAsSubAction(stuffToPaste);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
   return NS_OK;
 }
 
--- a/editor/libeditor/TextEditorDataTransfer.cpp
+++ b/editor/libeditor/TextEditorDataTransfer.cpp
@@ -1,17 +1,16 @@
 /* -*- 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 "mozilla/TextEditor.h"
 
 #include "mozilla/ArrayUtils.h"
-#include "mozilla/EditorUtils.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/SelectionState.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "mozilla/dom/DragEvent.h"
 #include "mozilla/dom/Selection.h"
 #include "nsAString.h"
 #include "nsCOMPtr.h"
 #include "nsComponentManagerUtils.h"
@@ -120,17 +119,17 @@ TextEditor::InsertTextFromTransferable(n
     if (textDataObj && len > 0) {
       nsAutoString stuffToPaste;
       textDataObj->GetData(stuffToPaste);
       NS_ASSERTION(stuffToPaste.Length() <= (len/2), "Invalid length!");
 
       // Sanitize possible carriage returns in the string to be inserted
       nsContentUtils::PlatformToDOMLineBreaks(stuffToPaste);
 
-      AutoPlaceholderBatch beginBatching(this);
+      AutoPlaceholderBatch treatAsOneTransaction(*this);
       rv = InsertTextAt(stuffToPaste, nullptr, 0, true);
     }
   }
 
   // Try to scroll the selection into view if the paste/drop succeeded
 
   if (NS_SUCCEEDED(rv)) {
     ScrollSelectionIntoView(false);
@@ -150,17 +149,17 @@ TextEditor::InsertFromDataTransfer(DataT
   nsCOMPtr<nsIVariant> data;
   aDataTransfer->GetDataAtNoSecurityCheck(NS_LITERAL_STRING("text/plain"), aIndex,
                                           getter_AddRefs(data));
   if (data) {
     nsAutoString insertText;
     data->GetAsAString(insertText);
     nsContentUtils::PlatformToDOMLineBreaks(insertText);
 
-    AutoPlaceholderBatch beginBatching(this);
+    AutoPlaceholderBatch treatAsOneTransaction(*this);
     return InsertTextAt(insertText, aDestinationNode, aDestOffset, aDoDeleteSelection);
   }
 
   return NS_OK;
 }
 
 nsresult
 TextEditor::OnDrop(DragEvent* aDropEvent)
@@ -198,17 +197,17 @@ TextEditor::OnDrop(DragEvent* aDropEvent
   }
 
   uint32_t numItems = dataTransfer->MozItemCount();
   if (numItems < 1) {
     return NS_ERROR_FAILURE;  // Nothing to drop?
   }
 
   // Combine any deletion and drop insertion into one transaction
-  AutoPlaceholderBatch beginBatching(this);
+  AutoPlaceholderBatch treatAsOneTransaction(*this);
 
   bool deleteSelection = false;
 
   // We have to figure out whether to delete and relocate caret only once
   // Parent and offset are under the mouse cursor
   nsCOMPtr<nsINode> newSelectionParent = aDropEvent->GetRangeParent();
   NS_ENSURE_TRUE(newSelectionParent, NS_ERROR_FAILURE);
 
--- a/editor/libeditor/WSRunObject.cpp
+++ b/editor/libeditor/WSRunObject.cpp
@@ -5,17 +5,16 @@
 
 #include "WSRunObject.h"
 
 #include "TextEditUtils.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Casting.h"
 #include "mozilla/EditorDOMPoint.h"
-#include "mozilla/EditorUtils.h"
 #include "mozilla/HTMLEditor.h"
 #include "mozilla/mozalloc.h"
 #include "mozilla/OwningNonNull.h"
 #include "mozilla/SelectionState.h"
 
 #include "nsAString.h"
 #include "nsCRT.h"
 #include "nsContentUtils.h"
--- a/editor/libeditor/WSRunObject.h
+++ b/editor/libeditor/WSRunObject.h
@@ -1,22 +1,18 @@
 /* -*- 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 WSRunObject_h
 #define WSRunObject_h
 
-#include "nsCOMPtr.h"
-#include "nsIEditor.h" // for EDirection
-#include "nsINode.h"
-#include "nscore.h"
-#include "mozilla/Attributes.h"
 #include "mozilla/dom/Text.h"
+#include "mozilla/EditorBase.h"
 #include "mozilla/EditorDOMPoint.h" // for EditorDOMPoint
 
 namespace mozilla {
 
 class HTMLEditor;
 class HTMLEditRules;
 
 // class WSRunObject represents the entire whitespace situation
@@ -145,16 +141,20 @@ inline const WSType operator&(const WSTy
 inline const WSType operator|(const WSType::Enum& aLeft,
                               const WSType::Enum& aRight)
 {
   return WSType(aLeft) | WSType(aRight);
 }
 
 class MOZ_STACK_CLASS WSRunObject final
 {
+protected:
+  typedef EditorBase::AutoTransactionsConserveSelection
+            AutoTransactionsConserveSelection;
+
 public:
   enum BlockBoundary
   {
     kBeforeBlock,
     kBlockStart,
     kBlockEnd,
     kAfterBlock
   };
--- a/editor/spellchecker/TextServicesDocument.cpp
+++ b/editor/spellchecker/TextServicesDocument.cpp
@@ -1,17 +1,17 @@
 /* -*- 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 "TextServicesDocument.h"
 
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/EditorUtils.h"        // for AutoTransactionBatch
+#include "mozilla/EditorUtils.h"        // for AutoTransactionBatchExternal
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/mozalloc.h"           // for operator new, etc
 #include "mozilla/TextEditor.h"         // for TextEditor
 #include "nsAString.h"                  // for nsAString::Length, etc
 #include "nsContentUtils.h"             // for nsContentUtils
 #include "nsComposeTxtSrvFilter.h"
 #include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc