Bug 1260651 part.11 Rename DeleteNodeTxn to mozilla::DeleteNodeTransaction r?ehsan draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 16 Apr 2016 00:29:29 +0900
changeset 354810 22eadb92145cc6ae7e89664044081871e19936e4
parent 354809 b6765e0045d3b05b6043ecbad9d8db76720e109a
child 354811 580d4709b9c38bc3132a05bfc35ac2db23e94d75
push id16162
push usermasayuki@d-toybox.com
push dateThu, 21 Apr 2016 15:03:04 +0000
reviewersehsan
bugs1260651
milestone48.0a1
Bug 1260651 part.11 Rename DeleteNodeTxn to mozilla::DeleteNodeTransaction r?ehsan MozReview-Commit-ID: GyQCASKVL77
editor/libeditor/DeleteNodeTransaction.cpp
editor/libeditor/DeleteNodeTransaction.h
editor/libeditor/DeleteNodeTxn.cpp
editor/libeditor/DeleteNodeTxn.h
editor/libeditor/DeleteRangeTxn.cpp
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorBase.h
editor/libeditor/moz.build
rename from editor/libeditor/DeleteNodeTxn.cpp
rename to editor/libeditor/DeleteNodeTransaction.cpp
--- a/editor/libeditor/DeleteNodeTxn.cpp
+++ b/editor/libeditor/DeleteNodeTransaction.cpp
@@ -1,61 +1,66 @@
 /* -*- 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 "DeleteNodeTxn.h"
+#include "DeleteNodeTransaction.h"
 #include "EditorBase.h"
 #include "nsDebug.h"
 #include "nsError.h"
 #include "nsSelectionState.h" // nsRangeUpdater
 #include "nsAString.h"
 
-using namespace mozilla;
+namespace mozilla {
 
-DeleteNodeTxn::DeleteNodeTxn()
-  : EditTxn(), mNode(), mParent(), mRefNode(), mRangeUpdater(nullptr)
+DeleteNodeTransaction::DeleteNodeTransaction()
+  : EditTxn()
+  , mNode()
+  , mParent()
+  , mRefNode()
+  , mRangeUpdater(nullptr)
 {
 }
 
-DeleteNodeTxn::~DeleteNodeTxn()
+DeleteNodeTransaction::~DeleteNodeTransaction()
 {
 }
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED(DeleteNodeTxn, EditTxn,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(DeleteNodeTransaction, EditTxn,
                                    mNode,
                                    mParent,
                                    mRefNode)
 
-NS_IMPL_ADDREF_INHERITED(DeleteNodeTxn, EditTxn)
-NS_IMPL_RELEASE_INHERITED(DeleteNodeTxn, EditTxn)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DeleteNodeTxn)
+NS_IMPL_ADDREF_INHERITED(DeleteNodeTransaction, EditTxn)
+NS_IMPL_RELEASE_INHERITED(DeleteNodeTransaction, EditTxn)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DeleteNodeTransaction)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
 nsresult
-DeleteNodeTxn::Init(EditorBase* aEditorBase, nsINode* aNode,
-                    nsRangeUpdater* aRangeUpdater)
+DeleteNodeTransaction::Init(EditorBase* aEditorBase,
+                            nsINode* aNode,
+                            nsRangeUpdater* aRangeUpdater)
 {
   NS_ENSURE_TRUE(aEditorBase && aNode, NS_ERROR_NULL_POINTER);
   mEditorBase = aEditorBase;
   mNode = aNode;
   mParent = aNode->GetParentNode();
 
   // do nothing if the node has a parent and it's read-only
   NS_ENSURE_TRUE(!mParent || mEditorBase->IsModifiableNode(mParent),
                  NS_ERROR_FAILURE);
 
   mRangeUpdater = aRangeUpdater;
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-DeleteNodeTxn::DoTransaction()
+DeleteNodeTransaction::DoTransaction()
 {
   NS_ENSURE_TRUE(mNode, NS_ERROR_NOT_INITIALIZED);
 
   if (!mParent) {
     // this is a no-op, there's no parent to delete mNode from
     return NS_OK;
   }
 
@@ -71,33 +76,33 @@ DeleteNodeTxn::DoTransaction()
   }
 
   ErrorResult error;
   mParent->RemoveChild(*mNode, error);
   return error.StealNSResult();
 }
 
 NS_IMETHODIMP
-DeleteNodeTxn::UndoTransaction()
+DeleteNodeTransaction::UndoTransaction()
 {
   if (!mParent) {
     // this is a legal state, the txn is a no-op
     return NS_OK;
   }
   if (!mNode) {
     return NS_ERROR_NULL_POINTER;
   }
 
   ErrorResult error;
   mParent->InsertBefore(*mNode, mRefNode, error);
   return error.StealNSResult();
 }
 
 NS_IMETHODIMP
-DeleteNodeTxn::RedoTransaction()
+DeleteNodeTransaction::RedoTransaction()
 {
   if (!mParent) {
     // this is a legal state, the txn is a no-op
     return NS_OK;
   }
   if (!mNode) {
     return NS_ERROR_NULL_POINTER;
   }
@@ -107,13 +112,15 @@ DeleteNodeTxn::RedoTransaction()
   }
 
   ErrorResult error;
   mParent->RemoveChild(*mNode, error);
   return error.StealNSResult();
 }
 
 NS_IMETHODIMP
-DeleteNodeTxn::GetTxnDescription(nsAString& aString)
+DeleteNodeTransaction::GetTxnDescription(nsAString& aString)
 {
-  aString.AssignLiteral("DeleteNodeTxn");
+  aString.AssignLiteral("DeleteNodeTransaction");
   return NS_OK;
 }
+
+} // namespace mozilla
rename from editor/libeditor/DeleteNodeTxn.h
rename to editor/libeditor/DeleteNodeTransaction.h
--- a/editor/libeditor/DeleteNodeTxn.h
+++ b/editor/libeditor/DeleteNodeTransaction.h
@@ -1,63 +1,67 @@
 /* -*- 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 DeleteNodeTxn_h__
-#define DeleteNodeTxn_h__
+#ifndef DeleteNodeTransaction_h_
+#define DeleteNodeTransaction_h_
 
 #include "EditTxn.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIContent.h"
 #include "nsINode.h"
 #include "nsISupportsImpl.h"
 #include "nscore.h"
 
 class nsRangeUpdater;
 
 namespace mozilla {
+
 class EditorBase;
-}
 
 /**
  * A transaction that deletes a single element
  */
-class DeleteNodeTxn : public EditTxn
+class DeleteNodeTransaction final : public EditTxn
 {
 public:
-  /** initialize the transaction.
-    * @param aElement the node to delete
-    */
-  nsresult Init(mozilla::EditorBase* aEditorBase, nsINode* aNode,
+  /**
+   * initialize the transaction.
+   * @param aElement        the node to delete
+   */
+  nsresult Init(EditorBase* aEditorBase,
+                nsINode* aNode,
                 nsRangeUpdater* aRangeUpdater);
 
-  DeleteNodeTxn();
+  DeleteNodeTransaction();
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteNodeTxn, EditTxn)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteNodeTransaction, EditTxn)
 
   NS_DECL_EDITTXN
 
   NS_IMETHOD RedoTransaction() override;
 
 protected:
-  virtual ~DeleteNodeTxn();
+  virtual ~DeleteNodeTransaction();
 
   /** the element to delete */
   nsCOMPtr<nsINode> mNode;
 
   /** parent of node to delete */
   nsCOMPtr<nsINode> mParent;
 
   /** next sibling to remember for undo/redo purposes */
   nsCOMPtr<nsIContent> mRefNode;
 
   /** the editor for this transaction */
-  mozilla::EditorBase* mEditorBase;
+  EditorBase* mEditorBase;
 
   /** range updater object */
   nsRangeUpdater* mRangeUpdater;
 };
 
-#endif
+} // namespace mozilla
+
+#endif // #ifndef DeleteNodeTransaction_h_
--- a/editor/libeditor/DeleteRangeTxn.cpp
+++ b/editor/libeditor/DeleteRangeTxn.cpp
@@ -1,16 +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 "DeleteRangeTxn.h"
 
-#include "DeleteNodeTxn.h"
+#include "DeleteNodeTransaction.h"
 #include "DeleteTextTxn.h"
 #include "EditorBase.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/mozalloc.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsError.h"
@@ -159,20 +159,20 @@ DeleteRangeTxn::CreateTxnsToDeleteBetwee
     return NS_OK;
   }
 
   nsCOMPtr<nsIContent> child = aNode->GetChildAt(aStartOffset);
   NS_ENSURE_STATE(child);
 
   nsresult res = NS_OK;
   for (int32_t i = aStartOffset; i < aEndOffset; ++i) {
-    RefPtr<DeleteNodeTxn> txn = new DeleteNodeTxn();
-    res = txn->Init(mEditorBase, child, mRangeUpdater);
+    RefPtr<DeleteNodeTransaction> transaction = new DeleteNodeTransaction();
+    res = transaction->Init(mEditorBase, child, mRangeUpdater);
     if (NS_SUCCEEDED(res)) {
-      AppendChild(txn);
+      AppendChild(transaction);
     }
 
     child = child->GetNextSibling();
   }
 
   NS_ENSURE_SUCCESS(res, res);
   return NS_OK;
 }
@@ -218,18 +218,17 @@ DeleteRangeTxn::CreateTxnsToDeleteNodesB
 
   nsresult res = iter->Init(mRange);
   NS_ENSURE_SUCCESS(res, res);
 
   while (!iter->IsDone()) {
     nsCOMPtr<nsINode> node = iter->GetCurrentNode();
     NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
 
-    RefPtr<DeleteNodeTxn> txn = new DeleteNodeTxn();
-
-    res = txn->Init(mEditorBase, node, mRangeUpdater);
+    RefPtr<DeleteNodeTransaction> transaction = new DeleteNodeTransaction();
+    res = transaction->Init(mEditorBase, node, mRangeUpdater);
     NS_ENSURE_SUCCESS(res, res);
-    AppendChild(txn);
+    AppendChild(transaction);
 
     iter->Next();
   }
   return NS_OK;
 }
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -7,17 +7,17 @@
 
 #include "mozilla/DebugOnly.h"          // for DebugOnly
 
 #include <stdio.h>                      // for nullptr, stdout
 #include <string.h>                     // for strcmp
 
 #include "ChangeAttributeTransaction.h" // for ChangeAttributeTransaction
 #include "CreateElementTransaction.h"   // for CreateElementTransaction
-#include "DeleteNodeTxn.h"              // for DeleteNodeTxn
+#include "DeleteNodeTransaction.h"      // for DeleteNodeTransaction
 #include "DeleteRangeTxn.h"             // for DeleteRangeTxn
 #include "DeleteTextTxn.h"              // for DeleteTextTxn
 #include "EditAggregateTxn.h"           // for EditAggregateTxn
 #include "EditorCommonEventListener.h"  // for EditorCommonEventListener
 #include "EditTxn.h"                    // for EditTxn
 #include "IMETextTxn.h"                 // for IMETextTxn
 #include "InsertNodeTxn.h"              // for InsertNodeTxn
 #include "InsertTextTxn.h"              // for InsertTextTxn
@@ -1542,20 +1542,20 @@ EditorBase::DeleteNode(nsINode* aNode)
 {
   nsAutoRules beginRulesSniffing(this, EditAction::createNode, nsIEditor::ePrevious);
 
   // save node location for selection updating code.
   for (auto& listener : mActionListeners) {
     listener->WillDeleteNode(aNode->AsDOMNode());
   }
 
-  RefPtr<DeleteNodeTxn> txn;
-  nsresult res = CreateTxnForDeleteNode(aNode, getter_AddRefs(txn));
+  RefPtr<DeleteNodeTransaction> transaction;
+  nsresult res = CreateTxnForDeleteNode(aNode, getter_AddRefs(transaction));
   if (NS_SUCCEEDED(res))  {
-    res = DoTransaction(txn);
+    res = DoTransaction(transaction);
   }
 
   for (auto& listener : mActionListeners) {
     listener->DidDeleteNode(aNode->AsDOMNode(), res);
   }
 
   NS_ENSURE_SUCCESS(res, res);
   return NS_OK;
@@ -4282,26 +4282,25 @@ EditorBase::CreateTxnForInsertNode(nsICo
 {
   RefPtr<InsertNodeTxn> txn = new InsertNodeTxn(aNode, aParent, aPosition,
                                                   *this);
   return txn.forget();
 }
 
 nsresult
 EditorBase::CreateTxnForDeleteNode(nsINode* aNode,
-                                   DeleteNodeTxn** aTxn)
+                                   DeleteNodeTransaction** aTransaction)
 {
   NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
 
-  RefPtr<DeleteNodeTxn> txn = new DeleteNodeTxn();
-
-  nsresult res = txn->Init(this, aNode, &mRangeUpdater);
+  RefPtr<DeleteNodeTransaction> transaction = new DeleteNodeTransaction();
+  nsresult res = transaction->Init(this, aNode, &mRangeUpdater);
   NS_ENSURE_SUCCESS(res, res);
 
-  txn.forget(aTxn);
+  transaction.forget(aTransaction);
   return NS_OK;
 }
 
 already_AddRefed<IMETextTxn>
 EditorBase::CreateTxnForIMEText(const nsAString& aStringToInsert)
 {
   MOZ_ASSERT(mIMETextNode);
   // During handling IME composition, mComposition must have been initialized.
@@ -4477,21 +4476,21 @@ EditorBase::CreateTxnForDeleteInsertionP
         CreateTxnForDeleteCharacter(*priorNodeAsCharData, length, ePrevious);
       NS_ENSURE_STATE(txn);
 
       *aOffset = txn->GetOffset();
       *aLength = txn->GetNumCharsToDelete();
       aTxn->AppendChild(txn);
     } else {
       // priorNode is not chardata, so tell its parent to delete it
-      RefPtr<DeleteNodeTxn> txn;
-      res = CreateTxnForDeleteNode(priorNode, getter_AddRefs(txn));
+      RefPtr<DeleteNodeTransaction> transaction;
+      res = CreateTxnForDeleteNode(priorNode, getter_AddRefs(transaction));
       NS_ENSURE_SUCCESS(res, res);
 
-      aTxn->AppendChild(txn);
+      aTxn->AppendChild(transaction);
     }
 
     NS_ADDREF(*aNode = priorNode);
 
     return NS_OK;
   }
 
   if (aAction == eNext && isLast) {
@@ -4512,20 +4511,20 @@ EditorBase::CreateTxnForDeleteInsertionP
         CreateTxnForDeleteCharacter(*nextNodeAsCharData, 0, eNext);
       NS_ENSURE_STATE(txn);
 
       *aOffset = txn->GetOffset();
       *aLength = txn->GetNumCharsToDelete();
       aTxn->AppendChild(txn);
     } else {
       // nextNode is not chardata, so tell its parent to delete it
-      RefPtr<DeleteNodeTxn> txn;
-      res = CreateTxnForDeleteNode(nextNode, getter_AddRefs(txn));
+      RefPtr<DeleteNodeTransaction> transaction;
+      res = CreateTxnForDeleteNode(nextNode, getter_AddRefs(transaction));
       NS_ENSURE_SUCCESS(res, res);
-      aTxn->AppendChild(txn);
+      aTxn->AppendChild(transaction);
     }
 
     NS_ADDREF(*aNode = nextNode);
 
     return NS_OK;
   }
 
   if (node->IsNodeOfType(nsINode::eDATA_NODE)) {
@@ -4574,22 +4573,23 @@ EditorBase::CreateTxnForDeleteInsertionP
         CreateTxnForDeleteCharacter(*selectedNodeAsCharData, position,
                                     aAction);
       NS_ENSURE_TRUE(delTextTxn, NS_ERROR_NULL_POINTER);
 
       aTxn->AppendChild(delTextTxn);
       *aOffset = delTextTxn->GetOffset();
       *aLength = delTextTxn->GetNumCharsToDelete();
     } else {
-      RefPtr<DeleteNodeTxn> delElementTxn;
-      res = CreateTxnForDeleteNode(selectedNode, getter_AddRefs(delElementTxn));
+      RefPtr<DeleteNodeTransaction> deleteNodeTransaction;
+      res = CreateTxnForDeleteNode(selectedNode,
+                                   getter_AddRefs(deleteNodeTransaction));
       NS_ENSURE_SUCCESS(res, res);
-      NS_ENSURE_TRUE(delElementTxn, NS_ERROR_NULL_POINTER);
-
-      aTxn->AppendChild(delElementTxn);
+      NS_ENSURE_TRUE(deleteNodeTransaction, NS_ERROR_NULL_POINTER);
+
+      aTxn->AppendChild(deleteNodeTransaction);
     }
 
     NS_ADDREF(*aNode = selectedNode);
   }
 
   return NS_OK;
 }
 
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -24,17 +24,16 @@
 #include "nsIWeakReferenceUtils.h"      // for nsWeakPtr
 #include "nsLiteralString.h"            // for NS_LITERAL_STRING
 #include "nsSelectionState.h"           // for nsRangeUpdater, etc
 #include "nsString.h"                   // for nsCString
 #include "nsWeakReference.h"            // for nsSupportsWeakReference
 #include "nscore.h"                     // for nsresult, nsAString, etc
 
 class AddStyleSheetTxn;
-class DeleteNodeTxn;
 class EditAggregateTxn;
 class RemoveStyleSheetTxn;
 class nsAutoRules;
 class nsAutoSelectionReset;
 class nsAutoTxnsConserveSelection;
 class nsRangeUpdater;
 class nsIAtom;
 class nsIContent;
@@ -57,16 +56,17 @@ class nsIWidget;
 class nsRange;
 class nsString;
 class nsTransactionManager;
 struct DOMPoint;
 
 namespace mozilla {
 class ChangeAttributeTransaction;
 class CreateElementTransaction;
+class DeleteNodeTransaction;
 class ErrorResult;
 class TextComposition;
 
 namespace dom {
 class DataTransfer;
 class DeleteTextTxn;
 class Element;
 class EventTarget;
@@ -278,18 +278,18 @@ protected:
 
   /** create a transaction for inserting aNode as a child of aParent.
     */
   already_AddRefed<dom::InsertNodeTxn>
   CreateTxnForInsertNode(nsIContent& aNode, nsINode& aParent, int32_t aOffset);
 
   /** create a transaction for removing aNode from its parent.
     */
-  nsresult CreateTxnForDeleteNode(nsINode* aNode, DeleteNodeTxn** aTxn);
-
+  nsresult CreateTxnForDeleteNode(nsINode* aNode,
+                                  DeleteNodeTransaction** aTransaction);
 
   nsresult CreateTxnForDeleteSelection(EDirection aAction,
                                        EditAggregateTxn** aTxn,
                                        nsINode** aNode,
                                        int32_t* aOffset,
                                        int32_t* aLength);
 
   nsresult CreateTxnForDeleteInsertionPoint(nsRange* aRange,
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -12,17 +12,17 @@ MOCHITEST_MANIFESTS += [
 MOCHITEST_CHROME_MANIFESTS += ['tests/chrome.ini']
 
 BROWSER_CHROME_MANIFESTS += ['tests/browser.ini']
 
 UNIFIED_SOURCES += [
     'ChangeAttributeTransaction.cpp',
     'ChangeStyleTransaction.cpp',
     'CreateElementTransaction.cpp',
-    'DeleteNodeTxn.cpp',
+    'DeleteNodeTransaction.cpp',
     'DeleteRangeTxn.cpp',
     'DeleteTextTxn.cpp',
     'EditAggregateTxn.cpp',
     'EditorBase.cpp',
     'EditorCommonEventListener.cpp',
     'EditTxn.cpp',
     'HTMLAbsPositionEditor.cpp',
     'HTMLAnonymousUtils.cpp',