Bug 1260651 part.13 Rename nsAutoPlaceHolderBatch to mozilla::AutoPlaceHolderBatch r=mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 23 Jun 2016 18:51:19 +0900
changeset 385845 3e161dea4676419485984ea913afc12985fe2e1c
parent 385844 9d1015608c35f4b9791492e8cfe5602853ed9e45
child 385846 91af161004b9efb4169ec137c9234abec684ea12
push id22587
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 06:59:31 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.13 Rename nsAutoPlaceHolderBatch to mozilla::AutoPlaceHolderBatch r=mccr8 MozReview-Commit-ID: E8IlZjFSFRU
editor/libeditor/EditorUtils.h
editor/libeditor/nsHTMLEditor.cpp
editor/libeditor/nsPlaintextEditor.cpp
extensions/spellcheck/src/mozInlineSpellChecker.cpp
--- a/editor/libeditor/EditorUtils.h
+++ b/editor/libeditor/EditorUtils.h
@@ -17,65 +17,67 @@
 
 class nsIAtom;
 class nsIContentIterator;
 class nsIDOMDocument;
 class nsIDOMEvent;
 class nsISimpleEnumerator;
 class nsITransferable;
 class nsRange;
+
 namespace mozilla {
 template <class T> class OwningNonNull;
+
 namespace dom {
 class Selection;
 } // namespace dom
-} // namespace mozilla
 
 /***************************************************************************
  * stack based helper class for batching a collection of txns inside a
  * placeholder txn.
  */
-class MOZ_RAII nsAutoPlaceHolderBatch
+class MOZ_RAII AutoPlaceHolderBatch
 {
-  private:
-    nsCOMPtr<nsIEditor> mEd;
-    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-  public:
-    nsAutoPlaceHolderBatch(nsIEditor *aEd, nsIAtom *atom MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-      : mEd(do_QueryInterface(aEd))
-    {
-      MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-      if (mEd) {
-        mEd->BeginPlaceHolderTransaction(atom);
-      }
+private:
+  nsCOMPtr<nsIEditor> mEditor;
+  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+
+public:
+  AutoPlaceHolderBatch(nsIEditor* aEditor,
+                       nsIAtom* aAtom
+                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+    : mEditor(aEditor)
+  {
+    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+    if (mEditor) {
+      mEditor->BeginPlaceHolderTransaction(aAtom);
     }
-    ~nsAutoPlaceHolderBatch()
-    {
-      if (mEd) {
-        mEd->EndPlaceHolderTransaction();
-      }
+  }
+  ~AutoPlaceHolderBatch()
+  {
+    if (mEditor) {
+      mEditor->EndPlaceHolderTransaction();
     }
+  }
 };
 
-namespace mozilla {
-
 /***************************************************************************
  * stack based helper class for batching a collection of txns.
  * Note: I changed this to use placeholder batching so that we get
  * proper selection save/restore across undo/redo.
  */
-class MOZ_RAII AutoEditBatch final : public nsAutoPlaceHolderBatch
+class MOZ_RAII AutoEditBatch final : public AutoPlaceHolderBatch
 {
 private:
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
 public:
   explicit AutoEditBatch(nsIEditor* aEditor
                          MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-    : nsAutoPlaceHolderBatch(aEditor, nullptr)
+    : AutoPlaceHolderBatch(aEditor, nullptr)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
   }
   ~AutoEditBatch() {}
 };
 
 /***************************************************************************
  * stack based helper class for saving/restoring selection.  Note that this
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -1036,17 +1036,17 @@ nsHTMLEditor::UpdateBaseURL()
    purposes.  Can't use HandleKeyPress() (above) for that since it takes
    a nsIDOMKeyEvent* parameter.  So instead we pass enough info through
    to TypedText() to determine what action to take, but without passing
    an event.
    */
 NS_IMETHODIMP
 nsHTMLEditor::TypedText(const nsAString& aString, ETypingAction aAction)
 {
-  nsAutoPlaceHolderBatch batch(this, nsGkAtoms::TypingTxnName);
+  AutoPlaceHolderBatch batch(this, nsGkAtoms::TypingTxnName);
 
   if (aAction == eTypedBR) {
     // only inserts a br node
     nsCOMPtr<nsIDOMNode> brNode;
     return InsertBR(address_of(brNode));
   }
 
   return nsPlaintextEditor::TypedText(aString, aAction);
--- a/editor/libeditor/nsPlaintextEditor.cpp
+++ b/editor/libeditor/nsPlaintextEditor.cpp
@@ -417,17 +417,17 @@ nsPlaintextEditor::HandleKeyPressEvent(n
    purposes.  Can't use HandleKeyPress() (above) for that since it takes
    a nsIDOMKeyEvent* parameter.  So instead we pass enough info through
    to TypedText() to determine what action to take, but without passing
    an event.
    */
 NS_IMETHODIMP
 nsPlaintextEditor::TypedText(const nsAString& aString, ETypingAction aAction)
 {
-  nsAutoPlaceHolderBatch batch(this, nsGkAtoms::TypingTxnName);
+  AutoPlaceHolderBatch batch(this, nsGkAtoms::TypingTxnName);
 
   switch (aAction) {
     case eTypedText:
       return InsertText(aString);
     case eTypedBreak:
       return InsertLineBreak();
     default:
       // eTypedBR is only for HTML
@@ -654,17 +654,17 @@ nsPlaintextEditor::DeleteSelection(EDire
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   nsresult result;
 
   // delete placeholder txns merge.
-  nsAutoPlaceHolderBatch batch(this, nsGkAtoms::DeleteTxnName);
+  AutoPlaceHolderBatch batch(this, nsGkAtoms::DeleteTxnName);
   AutoRules beginRulesSniffing(this, EditAction::deleteSelection, aAction);
 
   // pre-process
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   // If there is an existing selection when an extended delete is requested,
   //  platforms that use "caret-style" caret positioning collapse the
@@ -711,17 +711,17 @@ NS_IMETHODIMP nsPlaintextEditor::InsertT
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   EditAction opID = EditAction::insertText;
   if (ShouldHandleIMEComposition()) {
     opID = EditAction::insertIMEText;
   }
-  nsAutoPlaceHolderBatch batch(this, nullptr);
+  AutoPlaceHolderBatch batch(this, nullptr);
   AutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
 
   // pre-process
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   nsAutoString resultString;
   // XXX can we trust instring to outlive ruleInfo,
   // XXX and ruleInfo not to refer to instring in its dtor?
@@ -873,17 +873,17 @@ nsPlaintextEditor::UpdateIMEComposition(
     compositionChangeEventHandlingMarker(mComposition, compositionChangeEvent);
 
   NotifyEditorObservers(eNotifyEditorObserversOfBefore);
 
   RefPtr<nsCaret> caretP = ps->GetCaret();
 
   nsresult rv;
   {
-    nsAutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName);
+    AutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName);
 
     rv = InsertText(compositionChangeEvent->mData);
 
     if (caretP) {
       caretP->SetSelection(selection);
     }
   }
 
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -956,17 +956,17 @@ mozInlineSpellChecker::ReplaceWord(nsIDO
   {
     // This range was retrieved from the spellchecker selection. As
     // ranges cannot be shared between selections, we must clone it
     // before adding it to the editor's selection.
     nsCOMPtr<nsIDOMRange> editorRange;
     res = range->CloneRange(getter_AddRefs(editorRange));
     NS_ENSURE_SUCCESS(res, res);
 
-    nsAutoPlaceHolderBatch phb(editor, nullptr);
+    AutoPlaceHolderBatch phb(editor, nullptr);
   
     nsCOMPtr<nsISelection> selection;
     res = editor->GetSelection(getter_AddRefs(selection));
     NS_ENSURE_SUCCESS(res, res);
     selection->RemoveAllRanges();
     selection->AddRange(editorRange);
     editor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);