Bug 1260651 part.20 Rename mozilla::dom::SplitNodeTxn to mozilla::SplitNodeTransaction r?ehsan draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 20 Apr 2016 17:32:35 +0900
changeset 354819 83395e3df68777eb28e35675f54bfab1673a1b6d
parent 354818 76a851658895b8544d25ceb0255d9d43ff6d5e15
child 354820 c3c9f990b3b4b6b013f52c0fbfb408a42bdf7827
push id16162
push usermasayuki@d-toybox.com
push dateThu, 21 Apr 2016 15:03:04 +0000
reviewersehsan
bugs1260651
milestone48.0a1
Bug 1260651 part.20 Rename mozilla::dom::SplitNodeTxn to mozilla::SplitNodeTransaction r?ehsan MozReview-Commit-ID: 9iGuiDfIcD1
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorBase.h
editor/libeditor/SplitNodeTransaction.cpp
editor/libeditor/SplitNodeTransaction.h
editor/libeditor/SplitNodeTxn.cpp
editor/libeditor/SplitNodeTxn.h
editor/libeditor/moz.build
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -18,17 +18,17 @@
 #include "DeleteTextTransaction.h"      // for DeleteTextTransaction
 #include "EditAggregateTxn.h"           // for EditAggregateTxn
 #include "EditorCommonEventListener.h"  // for EditorCommonEventListener
 #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 "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
 #include "mozilla/TextComposition.h"    // for TextComposition
@@ -1453,21 +1453,22 @@ EditorBase::SplitNode(nsIContent& aNode,
 {
   nsAutoRules 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);
   }
@@ -2668,22 +2669,23 @@ EditorBase::CreateTxnForDeleteText(nsGen
     new DeleteTextTransaction(*this, aCharData, aOffset, aLength,
                               &mRangeUpdater);
   nsresult res = transaction->Init();
   NS_ENSURE_SUCCESS(res, nullptr);
 
   return transaction.forget();
 }
 
-already_AddRefed<SplitNodeTxn>
+already_AddRefed<SplitNodeTransaction>
 EditorBase::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>
 EditorBase::CreateTxnForJoinNode(nsINode& aLeftNode,
                                  nsINode& aRightNode)
 {
   RefPtr<JoinNodeTransaction> transaction =
     new JoinNodeTransaction(*this, aLeftNode, aRightNode);
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -63,24 +63,24 @@ class ChangeAttributeTransaction;
 class CompositionTransaction;
 class CreateElementTransaction;
 class DeleteNodeTransaction;
 class DeleteTextTransaction;
 class ErrorResult;
 class InsertNodeTransaction;
 class InsertTextTransaction;
 class JoinNodeTransaction;
+class SplitNodeTransaction;
 class TextComposition;
 
 namespace dom {
 class DataTransfer;
 class Element;
 class EventTarget;
 class Selection;
-class SplitNodeTxn;
 class Text;
 } // namespace dom
 
 namespace widget {
 struct IMEState;
 } // namespace widget
 } // namespace mozilla
 
@@ -329,17 +329,17 @@ protected:
   already_AddRefed<DeleteTextTransaction>
   CreateTxnForDeleteText(nsGenericDOMDataNode& aElement,
                          uint32_t aOffset, uint32_t aLength);
 
   already_AddRefed<DeleteTextTransaction>
   CreateTxnForDeleteCharacter(nsGenericDOMDataNode& aData, uint32_t aOffset,
                               EDirection aDirection);
 
-  already_AddRefed<dom::SplitNodeTxn>
+  already_AddRefed<SplitNodeTransaction>
   CreateTxnForSplitNode(nsIContent& aNode, uint32_t aOffset);
 
   already_AddRefed<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
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,54 @@
 /* -*- 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 "EditorBase.h"                 // for EditorBase
 #include "mozilla/dom/Selection.h"
 #include "nsAString.h"
 #include "nsDebug.h"                    // for NS_ASSERTION, etc
 #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 aEditorBase is not refcounted
-SplitNodeTxn::SplitNodeTxn(EditorBase& aEditorBase, nsIContent& aNode,
-                           int32_t aOffset)
+SplitNodeTransaction::SplitNodeTransaction(EditorBase& aEditorBase,
+                                           nsIContent& aNode,
+                                           int32_t aOffset)
   : EditTxn()
   , mEditorBase(aEditorBase)
   , 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 +64,30 @@ SplitNodeTxn::DoTransaction()
     RefPtr<Selection> selection = mEditorBase.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 mEditorBase.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 +111,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,57 +1,59 @@
 /* -*- 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 nsIContent;
 class nsINode;
 
 namespace mozilla {
 
 class EditorBase;
 
-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 aEditorBase  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(EditorBase& aEditorBase, nsIContent& aNode, int32_t aOffset);
+  /**
+   * @param aEditorBase     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 children or
+   *                        content from index 0 to index aOffset - 1.
+   */
+  SplitNodeTransaction(EditorBase& aEditorBase,
+                       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();
 
   EditorBase& mEditorBase;
 
   /** 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
@@ -61,12 +63,11 @@ protected:
 
   /** The node we create when splitting mExistingRightNode */
   nsCOMPtr<nsIContent> 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
@@ -48,17 +48,17 @@ UNIFIED_SOURCES += [
     'nsSelectionState.cpp',
     'nsStyleSheetTxns.cpp',
     'nsTextEditRules.cpp',
     'nsTextEditRulesBidi.cpp',
     'nsTextEditUtils.cpp',
     'nsWSRunObject.cpp',
     'PlaceholderTransaction.cpp',
     'SetDocumentTitleTransaction.cpp',
-    'SplitNodeTxn.cpp',
+    'SplitNodeTransaction.cpp',
     'TextDataTransfer.cpp',
     'TextEditor.cpp',
     'TextEditorTest.cpp',
     'TypeInState.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',