Bug 1260651 part.26 Rename mozilla::dom::JoinNodeTxn to mozilla::JoinNodeTransaction (and their files too) r=mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 07 Jul 2016 16:16:12 +0900
changeset 385858 4a724f410bed80aabcf0c00e041d474b1716e223
parent 385857 fe49f71ed5ae5c1dc65be3ea6328f128288a6453
child 385859 71d54193934d8fd80c67168a9aa6329dd817db02
push id22587
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 06:59:31 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.26 Rename mozilla::dom::JoinNodeTxn to mozilla::JoinNodeTransaction (and their files too) r=mccr8 MozReview-Commit-ID: ChcoinM0sfU
editor/libeditor/JoinNodeTransaction.cpp
editor/libeditor/JoinNodeTransaction.h
editor/libeditor/JoinNodeTxn.cpp
editor/libeditor/JoinNodeTxn.h
editor/libeditor/moz.build
editor/libeditor/nsEditor.cpp
editor/libeditor/nsEditor.h
rename from editor/libeditor/JoinNodeTxn.cpp
rename to editor/libeditor/JoinNodeTransaction.cpp
--- a/editor/libeditor/JoinNodeTxn.cpp
+++ b/editor/libeditor/JoinNodeTransaction.cpp
@@ -1,58 +1,58 @@
 /* -*- 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 "JoinNodeTxn.h"
+#include "JoinNodeTransaction.h"
 #include "nsAString.h"
 #include "nsDebug.h"                    // for NS_ASSERTION, etc
 #include "nsEditor.h"                   // for nsEditor
 #include "nsError.h"                    // for NS_ERROR_NULL_POINTER, etc
 #include "nsIContent.h"                 // for nsIContent
 #include "nsIDOMCharacterData.h"        // for nsIDOMCharacterData
 #include "nsIEditor.h"                  // for nsEditor::IsModifiableNode
 #include "nsISupportsImpl.h"            // for EditTxn::QueryInterface, etc
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
-JoinNodeTxn::JoinNodeTxn(nsEditor& aEditor, nsINode& aLeftNode,
-                         nsINode& aRightNode)
-  : EditTxn()
-  , mEditor(aEditor)
+JoinNodeTransaction::JoinNodeTransaction(nsEditor& aEditor,
+                                         nsINode& aLeftNode,
+                                         nsINode& aRightNode)
+  : mEditor(aEditor)
   , mLeftNode(&aLeftNode)
   , mRightNode(&aRightNode)
   , mOffset(0)
-  , mParent(nullptr)
 {
 }
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED(JoinNodeTxn, EditTxn,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(JoinNodeTransaction, EditTxn,
                                    mLeftNode,
                                    mRightNode,
                                    mParent)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(JoinNodeTxn)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(JoinNodeTransaction)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
 nsresult
-JoinNodeTxn::CheckValidity()
+JoinNodeTransaction::CheckValidity()
 {
   if (!mEditor.IsModifiableNode(mLeftNode->GetParentNode())) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 // After DoTransaction() and RedoTransaction(), the left node is removed from
 // the content tree and right node remains.
 NS_IMETHODIMP
-JoinNodeTxn::DoTransaction()
+JoinNodeTransaction::DoTransaction()
 {
   // Get the parent node
   nsCOMPtr<nsINode> leftParent = mLeftNode->GetParentNode();
   NS_ENSURE_TRUE(leftParent, NS_ERROR_NULL_POINTER);
 
   // Verify that mLeftNode and mRightNode have the same parent
   if (leftParent != mRightNode->GetParentNode()) {
     NS_ASSERTION(false, "Nodes do not have same parent");
@@ -65,17 +65,17 @@ JoinNodeTxn::DoTransaction()
   mOffset = mLeftNode->Length();
 
   return mEditor.JoinNodesImpl(mRightNode, mLeftNode, mParent);
 }
 
 //XXX: What if instead of split, we just deleted the unneeded children of
 //     mRight and re-inserted mLeft?
 NS_IMETHODIMP
-JoinNodeTxn::UndoTransaction()
+JoinNodeTransaction::UndoTransaction()
 {
   MOZ_ASSERT(mParent);
 
   // First, massage the existing node so it is in its post-split state
   ErrorResult rv;
   if (mRightNode->GetAsText()) {
     rv = mRightNode->GetAsText()->DeleteData(0, mOffset);
   } else {
@@ -93,13 +93,15 @@ JoinNodeTxn::UndoTransaction()
     }
   }
   // Second, re-insert the left node into the tree
   mParent->InsertBefore(*mLeftNode, mRightNode, rv);
   return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
-JoinNodeTxn::GetTxnDescription(nsAString& aString)
+JoinNodeTransaction::GetTxnDescription(nsAString& aString)
 {
-  aString.AssignLiteral("JoinNodeTxn");
+  aString.AssignLiteral("JoinNodeTransaction");
   return NS_OK;
 }
+
+} // namespace mozilla
rename from editor/libeditor/JoinNodeTxn.h
rename to editor/libeditor/JoinNodeTransaction.h
--- a/editor/libeditor/JoinNodeTxn.h
+++ b/editor/libeditor/JoinNodeTransaction.h
@@ -1,66 +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/. */
 
-#ifndef JoinNodeTxn_h__
-#define JoinNodeTxn_h__
+#ifndef JoinNodeTransaction_h
+#define JoinNodeTransaction_h
 
 #include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
 #include "nsCOMPtr.h"                   // for nsCOMPtr
 #include "nsCycleCollectionParticipant.h"
 #include "nsID.h"                       // for REFNSIID
 #include "nscore.h"                     // for NS_IMETHOD
 
 class nsEditor;
 class nsINode;
 
 namespace mozilla {
-namespace dom {
 
 /**
  * A transaction that joins two nodes E1 (left node) and E2 (right node) into a
  * single node E.  The children of E are the children of E1 followed by the
  * children of E2.  After DoTransaction() and RedoTransaction(), E1 is removed
  * from the content tree and E2 remains.
  */
-class JoinNodeTxn : public EditTxn
+class JoinNodeTransaction final : public EditTxn
 {
 public:
-  /** @param aEditor    the provider of core editing operations
-    * @param aLeftNode  the first of two nodes to join
-    * @param aRightNode the second of two nodes to join
-    */
-  JoinNodeTxn(nsEditor& aEditor, nsINode& aLeftNode, nsINode& aRightNode);
+  /**
+   * @param aEditor         The provider of core editing operations.
+   * @param aLeftNode       The first of two nodes to join.
+   * @param aRightNode      The second of two nodes to join.
+   */
+  JoinNodeTransaction(nsEditor& aEditor,
+                      nsINode& aLeftNode, nsINode& aRightNode);
 
-  /* Call this after constructing to ensure the inputs are correct */
+  /**
+   * Call this after constructing to ensure the inputs are correct.
+   */
   nsresult CheckValidity();
 
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinNodeTxn, EditTxn)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinNodeTransaction, EditTxn)
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
 
   NS_DECL_EDITTXN
 
 protected:
   nsEditor&  mEditor;
 
-  /** The nodes to operate upon.  After the merge, mRightNode remains and
-   * mLeftNode is removed from the content tree.
-    */
+  // The nodes to operate upon.  After the merge, mRightNode remains and
+  // mLeftNode is removed from the content tree.
   nsCOMPtr<nsINode> mLeftNode;
   nsCOMPtr<nsINode> mRightNode;
 
-  /** The offset into mNode where the children of mElement are split (for
-    * undo). mOffset is the index of the first child in the right node.  -1
-    * means the left node had no children.
-    */
+  // The offset into mNode where the children of mElement are split (for
+  // undo). mOffset is the index of the first child in the right node.  -1
+  // means the left node had no children.
   uint32_t  mOffset;
 
-  /** The parent node containing mLeftNode and mRightNode */
+  // The parent node containing mLeftNode and mRightNode.
   nsCOMPtr<nsINode> mParent;
 };
 
-} // namespace dom
 } // namespace mozilla
 
-#endif
+#endif // #ifndef JoinNodeTransaction_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -22,17 +22,17 @@ UNIFIED_SOURCES += [
     'DeleteRangeTransaction.cpp',
     'DeleteTextTransaction.cpp',
     'EditAggregateTxn.cpp',
     'EditorUtils.cpp',
     'EditTxn.cpp',
     'HTMLEditUtils.cpp',
     'InsertNodeTransaction.cpp',
     'InsertTextTransaction.cpp',
-    'JoinNodeTxn.cpp',
+    'JoinNodeTransaction.cpp',
     'nsEditor.cpp',
     'nsEditorCommands.cpp',
     'nsEditorController.cpp',
     'nsEditorEventListener.cpp',
     'nsHTMLAbsPosition.cpp',
     'nsHTMLAnonymousUtils.cpp',
     'nsHTMLCSSUtils.cpp',
     'nsHTMLDataTransfer.cpp',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -16,17 +16,17 @@
 #include "DeleteNodeTransaction.h"      // for DeleteNodeTransaction
 #include "DeleteRangeTransaction.h"     // for DeleteRangeTransaction
 #include "DeleteTextTransaction.h"      // for DeleteTextTransaction
 #include "EditAggregateTxn.h"           // for EditAggregateTxn
 #include "EditorUtils.h"                // for AutoRules, etc
 #include "EditTxn.h"                    // for EditTxn
 #include "InsertNodeTransaction.h"      // for InsertNodeTransaction
 #include "InsertTextTransaction.h"      // for InsertTextTransaction
-#include "JoinNodeTxn.h"                // for JoinNodeTxn
+#include "JoinNodeTransaction.h"        // for JoinNodeTransaction
 #include "PlaceholderTxn.h"             // for PlaceholderTxn
 #include "SplitNodeTxn.h"               // for SplitNodeTxn
 #include "TextEditUtils.h"              // for TextEditUtils
 #include "mozFlushType.h"               // for mozFlushType::Flush_Frames
 #include "mozInlineSpellChecker.h"      // for mozInlineSpellChecker
 #include "mozilla/CheckedInt.h"         // for CheckedInt
 #include "mozilla/IMEStateManager.h"    // for IMEStateManager
 #include "mozilla/Preferences.h"        // for Preferences
@@ -1478,19 +1478,20 @@ nsEditor::JoinNodes(nsINode& aLeftNode, 
   uint32_t oldLeftNodeLen = aLeftNode.Length();
 
   for (auto& listener : mActionListeners) {
     listener->WillJoinNodes(aLeftNode.AsDOMNode(), aRightNode.AsDOMNode(),
                             parent->AsDOMNode());
   }
 
   nsresult result = NS_OK;
-  RefPtr<JoinNodeTxn> txn = CreateTxnForJoinNode(aLeftNode, aRightNode);
-  if (txn)  {
-    result = DoTransaction(txn);
+  RefPtr<JoinNodeTransaction> transaction =
+    CreateTxnForJoinNode(aLeftNode, aRightNode);
+  if (transaction)  {
+    result = DoTransaction(transaction);
   }
 
   mRangeUpdater.SelAdjJoinNodes(aLeftNode, aRightNode, *parent, offset,
                                 (int32_t)oldLeftNodeLen);
 
   for (auto& listener : mActionListeners) {
     listener->DidJoinNodes(aLeftNode.AsDOMNode(), aRightNode.AsDOMNode(),
                            parent->AsDOMNode(), result);
@@ -2631,26 +2632,26 @@ nsEditor::CreateTxnForDeleteText(nsGener
 
 already_AddRefed<SplitNodeTxn>
 nsEditor::CreateTxnForSplitNode(nsIContent& aNode, uint32_t aOffset)
 {
   RefPtr<SplitNodeTxn> txn = new SplitNodeTxn(*this, aNode, aOffset);
   return txn.forget();
 }
 
-already_AddRefed<JoinNodeTxn>
+already_AddRefed<JoinNodeTransaction>
 nsEditor::CreateTxnForJoinNode(nsINode& aLeftNode, nsINode& aRightNode)
 {
-  RefPtr<JoinNodeTxn> txn = new JoinNodeTxn(*this, aLeftNode, aRightNode);
-
-  NS_ENSURE_SUCCESS(txn->CheckValidity(), nullptr);
-
-  return txn.forget();
-}
-
+  RefPtr<JoinNodeTransaction> transaction =
+    new JoinNodeTransaction(*this, aLeftNode, aRightNode);
+
+  NS_ENSURE_SUCCESS(transaction->CheckValidity(), nullptr);
+
+  return transaction.forget();
+}
 
 // END nsEditor core implementation
 
 
 // BEGIN nsEditor public helper methods
 
 struct SavedRange {
   RefPtr<Selection> mSelection;
--- a/editor/libeditor/nsEditor.h
+++ b/editor/libeditor/nsEditor.h
@@ -59,24 +59,24 @@ class AutoTransactionsConserveSelection;
 class ChangeAttributeTransaction;
 class CompositionTransaction;
 class CreateElementTransaction;
 class DeleteNodeTransaction;
 class DeleteTextTransaction;
 class ErrorResult;
 class InsertNodeTransaction;
 class InsertTextTransaction;
+class JoinNodeTransaction;
 class TextComposition;
 struct EditorDOMPoint;
 
 namespace dom {
 class DataTransfer;
 class Element;
 class EventTarget;
-class JoinNodeTxn;
 class Selection;
 class SplitNodeTxn;
 class Text;
 } // namespace dom
 } // namespace mozilla
 
 namespace mozilla {
 namespace widget {
@@ -333,17 +333,17 @@ protected:
 
   already_AddRefed<mozilla::DeleteTextTransaction>
   CreateTxnForDeleteCharacter(nsGenericDOMDataNode& aData, uint32_t aOffset,
                               EDirection aDirection);
 
   already_AddRefed<mozilla::dom::SplitNodeTxn>
   CreateTxnForSplitNode(nsIContent& aNode, uint32_t aOffset);
 
-  already_AddRefed<mozilla::dom::JoinNodeTxn>
+  already_AddRefed<mozilla::JoinNodeTransaction>
   CreateTxnForJoinNode(nsINode& aLeftNode, nsINode& aRightNode);
 
   /**
    * This method first deletes the selection, if it's not collapsed.  Then if
    * the selection lies in a CharacterData node, it splits it.  If the
    * selection is at this point collapsed in a CharacterData node, it's
    * adjusted to be collapsed right before or after the node instead (which is
    * always possible, since the node was split).