Bug 1260651 part.29 Rename mozilla::dom::SplitNodeTxn to mozilla::SplitNodeTransaction (and their files too) r?mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 07 Jul 2016 16:59:55 +0900
changeset 385719 728d69e58ecf4f2b69528554cd4ee36266de651c
parent 385718 5e88655303cc75082ba6f7a94813da7057fb1c60
child 385720 d9a89b4a75c6abb80b6e82e636aef3db79d74f39
push id22582
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 03:13:39 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.29 Rename mozilla::dom::SplitNodeTxn to mozilla::SplitNodeTransaction (and their files too) r?mccr8 MozReview-Commit-ID: 5guZsO9XGLY
editor/libeditor/SplitNodeTransaction.cpp
editor/libeditor/SplitNodeTransaction.h
editor/libeditor/SplitNodeTxn.cpp
editor/libeditor/SplitNodeTxn.h
editor/libeditor/moz.build
editor/libeditor/nsEditor.cpp
editor/libeditor/nsEditor.h
rename from editor/libeditor/SplitNodeTxn.cpp
rename to editor/libeditor/SplitNodeTransaction.cpp
--- a/editor/libeditor/SplitNodeTxn.cpp
+++ b/editor/libeditor/SplitNodeTransaction.cpp
@@ -1,52 +1,50 @@
 /* -*- 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 "SplitNodeTxn.h"
+#include "SplitNodeTransaction.h"
 
 #include "mozilla/dom/Selection.h"
 #include "nsAString.h"
 #include "nsDebug.h"                    // for NS_ASSERTION, etc
 #include "nsEditor.h"                   // for nsEditor
 #include "nsError.h"                    // for NS_ERROR_NOT_INITIALIZED, etc
 #include "nsIContent.h"                 // for nsIContent
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
-// note that aEditor is not refcounted
-SplitNodeTxn::SplitNodeTxn(nsEditor& aEditor, nsIContent& aNode,
-                           int32_t aOffset)
-  : EditTxn()
-  , mEditor(aEditor)
+SplitNodeTransaction::SplitNodeTransaction(nsEditor& aEditor,
+                                           nsIContent& aNode,
+                                           int32_t aOffset)
+  : mEditor(aEditor)
   , mExistingRightNode(&aNode)
   , mOffset(aOffset)
-  , mNewLeftNode(nullptr)
-  , mParent(nullptr)
 {
 }
 
-SplitNodeTxn::~SplitNodeTxn()
+SplitNodeTransaction::~SplitNodeTransaction()
 {
 }
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED(SplitNodeTxn, EditTxn,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(SplitNodeTransaction, EditTxn,
                                    mParent,
                                    mNewLeftNode)
 
-NS_IMPL_ADDREF_INHERITED(SplitNodeTxn, EditTxn)
-NS_IMPL_RELEASE_INHERITED(SplitNodeTxn, EditTxn)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SplitNodeTxn)
+NS_IMPL_ADDREF_INHERITED(SplitNodeTransaction, EditTxn)
+NS_IMPL_RELEASE_INHERITED(SplitNodeTransaction, EditTxn)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SplitNodeTransaction)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
 NS_IMETHODIMP
-SplitNodeTxn::DoTransaction()
+SplitNodeTransaction::DoTransaction()
 {
   // Create a new node
   ErrorResult rv;
   // Don't use .downcast directly because AsContent has an assertion we want
   nsCOMPtr<nsINode> clone = mExistingRightNode->CloneNode(false, rv);
   NS_ASSERTION(!rv.Failed() && clone, "Could not create clone");
   NS_ENSURE_TRUE(!rv.Failed() && clone, rv.StealNSResult());
   mNewLeftNode = dont_AddRef(clone.forget().take()->AsContent());
@@ -62,30 +60,30 @@ SplitNodeTxn::DoTransaction()
     RefPtr<Selection> selection = mEditor.GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
     rv = selection->Collapse(mNewLeftNode, mOffset);
   }
   return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
-SplitNodeTxn::UndoTransaction()
+SplitNodeTransaction::UndoTransaction()
 {
   MOZ_ASSERT(mNewLeftNode && mParent);
 
   // This assumes Do inserted the new node in front of the prior existing node
   return mEditor.JoinNodesImpl(mExistingRightNode, mNewLeftNode, mParent);
 }
 
 /* Redo cannot simply resplit the right node, because subsequent transactions
  * on the redo stack may depend on the left node existing in its previous
  * state.
  */
 NS_IMETHODIMP
-SplitNodeTxn::RedoTransaction()
+SplitNodeTransaction::RedoTransaction()
 {
   MOZ_ASSERT(mNewLeftNode && mParent);
 
   ErrorResult rv;
   // First, massage the existing node so it is in its post-split state
   if (mExistingRightNode->GetAsText()) {
     rv = mExistingRightNode->GetAsText()->DeleteData(0, mOffset);
     NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
@@ -109,19 +107,21 @@ SplitNodeTxn::RedoTransaction()
   }
   // Second, re-insert the left node into the tree
   mParent->InsertBefore(*mNewLeftNode, mExistingRightNode, rv);
   return rv.StealNSResult();
 }
 
 
 NS_IMETHODIMP
-SplitNodeTxn::GetTxnDescription(nsAString& aString)
+SplitNodeTransaction::GetTxnDescription(nsAString& aString)
 {
-  aString.AssignLiteral("SplitNodeTxn");
+  aString.AssignLiteral("SplitNodeTransaction");
   return NS_OK;
 }
 
 nsIContent*
-SplitNodeTxn::GetNewNode()
+SplitNodeTransaction::GetNewNode()
 {
   return mNewLeftNode;
 }
+
+} // namespace mozilla
rename from editor/libeditor/SplitNodeTxn.h
rename to editor/libeditor/SplitNodeTransaction.h
--- a/editor/libeditor/SplitNodeTxn.h
+++ b/editor/libeditor/SplitNodeTransaction.h
@@ -1,70 +1,68 @@
 /* -*- 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 SplitNodeTxn_h__
-#define SplitNodeTxn_h__
+#ifndef SplitNodeTransaction_h
+#define SplitNodeTransaction_h
 
 #include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
 #include "nsCOMPtr.h"                   // for nsCOMPtr
 #include "nsCycleCollectionParticipant.h"
 #include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED
 #include "nscore.h"                     // for NS_IMETHOD
 
 class nsEditor;
 class nsIContent;
 class nsINode;
 
 namespace mozilla {
-namespace dom {
 
 /**
  * A transaction that splits a node into two identical nodes, with the children
  * divided between the new nodes.
  */
-class SplitNodeTxn : public EditTxn
+class SplitNodeTransaction final : public EditTxn
 {
 public:
-  /** @param aEditor  The provider of core editing operations
-    * @param aNode    The node to split
-    * @param aOffset  The location within aNode to do the split.
-    *                 aOffset may refer to children of aNode, or content of aNode.
-    *                 The left node will have child|content 0..aOffset-1.
-    */
-  SplitNodeTxn(nsEditor& aEditor, nsIContent& aNode, int32_t aOffset);
+  /**
+   * @param aEditor  The provider of core editing operations
+   * @param aNode    The node to split
+   * @param aOffset  The location within aNode to do the split.  aOffset may
+   *                 refer to children of aNode, or content of aNode.  The left
+   *                 node will have child|content 0..aOffset-1.
+   */
+  SplitNodeTransaction(nsEditor& aEditor, nsIContent& aNode, int32_t aOffset);
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SplitNodeTxn, EditTxn)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SplitNodeTransaction, EditTxn)
 
   NS_DECL_EDITTXN
 
   NS_IMETHOD RedoTransaction() override;
 
   nsIContent* GetNewNode();
 
 protected:
-  virtual ~SplitNodeTxn();
+  virtual ~SplitNodeTransaction();
 
   nsEditor& mEditor;
 
-  /** The node to operate upon */
+  // The node to operate upon.
   nsCOMPtr<nsIContent> mExistingRightNode;
 
-  /** The offset into mExistingRightNode where its children are split.  mOffset
-    * is the index of the first child in the right node.  -1 means the new node
-    * gets no children.
-    */
+  // The offset into mExistingRightNode where its children are split.  mOffset
+  // is the index of the first child in the right node.  -1 means the new node
+  // gets no children.
   int32_t mOffset;
 
-  /** The node we create when splitting mExistingRightNode */
+  // The node we create when splitting mExistingRightNode.
   nsCOMPtr<nsIContent> mNewLeftNode;
 
-  /** The parent shared by mExistingRightNode and mNewLeftNode */
+  // The parent shared by mExistingRightNode and mNewLeftNode.
   nsCOMPtr<nsINode> mParent;
 };
 
-} // namespace dom
 } // namespace mozilla
 
-#endif
+#endif // #ifndef SplitNodeTransaction_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -49,17 +49,17 @@ UNIFIED_SOURCES += [
     'nsSelectionState.cpp',
     'nsStyleSheetTxns.cpp',
     'nsTableEditor.cpp',
     'nsTextEditRules.cpp',
     'nsTextEditRulesBidi.cpp',
     'nsWSRunObject.cpp',
     'PlaceholderTransaction.cpp',
     'SetDocumentTitleTransaction.cpp',
-    'SplitNodeTxn.cpp',
+    'SplitNodeTransaction.cpp',
     'TextEditorTest.cpp',
     'TextEditUtils.cpp',
     'TypeInState.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',
     '/editor/txmgr',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -18,17 +18,17 @@
 #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 "JoinNodeTransaction.h"        // for JoinNodeTransaction
 #include "PlaceholderTransaction.h"     // for PlaceholderTransaction
-#include "SplitNodeTxn.h"               // for SplitNodeTxn
+#include "SplitNodeTransaction.h"       // for SplitNodeTransaction
 #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
 #include "mozilla/dom/Selection.h"      // for Selection, etc
 #include "mozilla/Services.h"           // for GetObserverService
@@ -1427,21 +1427,22 @@ nsIContent*
 nsEditor::SplitNode(nsIContent& aNode, int32_t aOffset, ErrorResult& aResult)
 {
   AutoRules beginRulesSniffing(this, EditAction::splitNode, nsIEditor::eNext);
 
   for (auto& listener : mActionListeners) {
     listener->WillSplitNode(aNode.AsDOMNode(), aOffset);
   }
 
-  RefPtr<SplitNodeTxn> txn = CreateTxnForSplitNode(aNode, aOffset);
-  aResult = DoTransaction(txn);
+  RefPtr<SplitNodeTransaction> transaction =
+    CreateTxnForSplitNode(aNode, aOffset);
+  aResult = DoTransaction(transaction);
 
   nsCOMPtr<nsIContent> newNode = aResult.Failed() ? nullptr
-                                                  : txn->GetNewNode();
+                                                  : transaction->GetNewNode();
 
   mRangeUpdater.SelAdjSplitNode(aNode, aOffset, newNode);
 
   nsresult result = aResult.StealNSResult();
   for (auto& listener : mActionListeners) {
     listener->DidSplitNode(aNode.AsDOMNode(), aOffset, GetAsDOMNode(newNode),
                            result);
   }
@@ -2627,21 +2628,22 @@ nsEditor::CreateTxnForDeleteText(nsGener
     new DeleteTextTransaction(*this, aCharData, aOffset, aLength,
                               &mRangeUpdater);
   nsresult rv = transaction->Init();
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   return transaction.forget();
 }
 
-already_AddRefed<SplitNodeTxn>
+already_AddRefed<SplitNodeTransaction>
 nsEditor::CreateTxnForSplitNode(nsIContent& aNode, uint32_t aOffset)
 {
-  RefPtr<SplitNodeTxn> txn = new SplitNodeTxn(*this, aNode, aOffset);
-  return txn.forget();
+  RefPtr<SplitNodeTransaction> transaction =
+    new SplitNodeTransaction(*this, aNode, aOffset);
+  return transaction.forget();
 }
 
 already_AddRefed<JoinNodeTransaction>
 nsEditor::CreateTxnForJoinNode(nsINode& aLeftNode, nsINode& aRightNode)
 {
   RefPtr<JoinNodeTransaction> transaction =
     new JoinNodeTransaction(*this, aLeftNode, aRightNode);
 
--- a/editor/libeditor/nsEditor.h
+++ b/editor/libeditor/nsEditor.h
@@ -60,25 +60,25 @@ class ChangeAttributeTransaction;
 class CompositionTransaction;
 class CreateElementTransaction;
 class DeleteNodeTransaction;
 class DeleteTextTransaction;
 class ErrorResult;
 class InsertNodeTransaction;
 class InsertTextTransaction;
 class JoinNodeTransaction;
+class SplitNodeTransaction;
 class TextComposition;
 struct EditorDOMPoint;
 
 namespace dom {
 class DataTransfer;
 class Element;
 class EventTarget;
 class Selection;
-class SplitNodeTxn;
 class Text;
 } // namespace dom
 } // namespace mozilla
 
 namespace mozilla {
 namespace widget {
 struct IMEState;
 } // namespace widget
@@ -330,17 +330,17 @@ protected:
   already_AddRefed<mozilla::DeleteTextTransaction>
   CreateTxnForDeleteText(nsGenericDOMDataNode& aElement,
                          uint32_t aOffset, uint32_t aLength);
 
   already_AddRefed<mozilla::DeleteTextTransaction>
   CreateTxnForDeleteCharacter(nsGenericDOMDataNode& aData, uint32_t aOffset,
                               EDirection aDirection);
 
-  already_AddRefed<mozilla::dom::SplitNodeTxn>
+  already_AddRefed<mozilla::SplitNodeTransaction>
   CreateTxnForSplitNode(nsIContent& aNode, uint32_t aOffset);
 
   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