Bug 1260651 part.24 Rename mozilla::dom::InsertNodeTxn to mozilla::InsertNodeTransaction (and their files too) r=mccr8
MozReview-Commit-ID: 1eF1DsxwZL6
rename from editor/libeditor/InsertNodeTxn.cpp
rename to editor/libeditor/InsertNodeTransaction.cpp
--- a/editor/libeditor/InsertNodeTxn.cpp
+++ b/editor/libeditor/InsertNodeTransaction.cpp
@@ -1,54 +1,56 @@
/* -*- 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 "InsertNodeTxn.h"
+#include "InsertNodeTransaction.h"
#include "mozilla/dom/Selection.h" // for Selection
#include "nsAString.h"
#include "nsDebug.h" // for NS_ENSURE_TRUE, etc
#include "nsEditor.h" // for nsEditor
#include "nsError.h" // for NS_ERROR_NULL_POINTER, etc
#include "nsIContent.h" // for nsIContent
#include "nsMemory.h" // for nsMemory
#include "nsReadableUtils.h" // for ToNewCString
#include "nsString.h" // for nsString
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
-InsertNodeTxn::InsertNodeTxn(nsIContent& aNode, nsINode& aParent,
- int32_t aOffset, nsEditor& aEditor)
- : EditTxn()
- , mNode(&aNode)
+InsertNodeTransaction::InsertNodeTransaction(nsIContent& aNode,
+ nsINode& aParent,
+ int32_t aOffset,
+ nsEditor& aEditor)
+ : mNode(&aNode)
, mParent(&aParent)
, mOffset(aOffset)
, mEditor(aEditor)
{
}
-InsertNodeTxn::~InsertNodeTxn()
+InsertNodeTransaction::~InsertNodeTransaction()
{
}
-NS_IMPL_CYCLE_COLLECTION_INHERITED(InsertNodeTxn, EditTxn,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(InsertNodeTransaction, EditTxn,
mNode,
mParent)
-NS_IMPL_ADDREF_INHERITED(InsertNodeTxn, EditTxn)
-NS_IMPL_RELEASE_INHERITED(InsertNodeTxn, EditTxn)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InsertNodeTxn)
+NS_IMPL_ADDREF_INHERITED(InsertNodeTransaction, EditTxn)
+NS_IMPL_RELEASE_INHERITED(InsertNodeTransaction, EditTxn)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InsertNodeTransaction)
NS_INTERFACE_MAP_END_INHERITING(EditTxn)
NS_IMETHODIMP
-InsertNodeTxn::DoTransaction()
+InsertNodeTransaction::DoTransaction()
{
MOZ_ASSERT(mNode && mParent);
uint32_t count = mParent->GetChildCount();
if (mOffset > static_cast<int32_t>(count) || mOffset == -1) {
// -1 is sentinel value meaning "append at end"
mOffset = count;
}
@@ -70,23 +72,25 @@ InsertNodeTxn::DoTransaction()
selection->Collapse(mParent, mOffset + 1);
} else {
// Do nothing - DOM Range gravity will adjust selection
}
return NS_OK;
}
NS_IMETHODIMP
-InsertNodeTxn::UndoTransaction()
+InsertNodeTransaction::UndoTransaction()
{
MOZ_ASSERT(mNode && mParent);
ErrorResult rv;
mParent->RemoveChild(*mNode, rv);
return rv.StealNSResult();
}
NS_IMETHODIMP
-InsertNodeTxn::GetTxnDescription(nsAString& aString)
+InsertNodeTransaction::GetTxnDescription(nsAString& aString)
{
- aString.AssignLiteral("InsertNodeTxn");
+ aString.AssignLiteral("InsertNodeTransaction");
return NS_OK;
}
+
+} // namespace mozilla
rename from editor/libeditor/InsertNodeTxn.h
rename to editor/libeditor/InsertNodeTransaction.h
--- a/editor/libeditor/InsertNodeTxn.h
+++ b/editor/libeditor/InsertNodeTransaction.h
@@ -1,58 +1,57 @@
/* -*- 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 InsertNodeTxn_h__
-#define InsertNodeTxn_h__
+#ifndef InsertNodeTransaction_h
+#define InsertNodeTransaction_h
#include "EditTxn.h" // for EditTxn, NS_DECL_EDITTXN
#include "nsCOMPtr.h" // for nsCOMPtr
#include "nsCycleCollectionParticipant.h"
#include "nsIContent.h" // for nsIContent
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
class nsEditor;
namespace mozilla {
-namespace dom {
/**
* A transaction that inserts a single element
*/
-class InsertNodeTxn : public EditTxn
+class InsertNodeTransaction final : public EditTxn
{
public:
- /** initialize the transaction.
- * @param aNode the node to insert
- * @param aParent the node to insert into
- * @param aOffset the offset in aParent to insert aNode
- */
- InsertNodeTxn(nsIContent& aNode, nsINode& aParent, int32_t aOffset,
- nsEditor& aEditor);
+ /**
+ * Initialize the transaction.
+ * @param aNode The node to insert.
+ * @param aParent The node to insert into.
+ * @param aOffset The offset in aParent to insert aNode.
+ */
+ InsertNodeTransaction(nsIContent& aNode, nsINode& aParent, int32_t aOffset,
+ nsEditor& aEditor);
NS_DECL_ISUPPORTS_INHERITED
- NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertNodeTxn, EditTxn)
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertNodeTransaction, EditTxn)
NS_DECL_EDITTXN
protected:
- virtual ~InsertNodeTxn();
+ virtual ~InsertNodeTransaction();
- /** the element to insert */
+ // The element to insert.
nsCOMPtr<nsIContent> mNode;
- /** the node into which the new node will be inserted */
+ // The node into which the new node will be inserted.
nsCOMPtr<nsINode> mParent;
- /** the index in mParent for the new node */
+ // The index in mParent for the new node.
int32_t mOffset;
- /** the editor for this transaction */
+ // The editor for this transaction.
nsEditor& mEditor;
};
-} // namespace dom
} // namespace mozilla
-#endif
+#endif // #ifndef InsertNodeTransaction_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -20,17 +20,17 @@ UNIFIED_SOURCES += [
'CreateElementTransaction.cpp',
'DeleteNodeTransaction.cpp',
'DeleteRangeTransaction.cpp',
'DeleteTextTransaction.cpp',
'EditAggregateTxn.cpp',
'EditorUtils.cpp',
'EditTxn.cpp',
'HTMLEditUtils.cpp',
- 'InsertNodeTxn.cpp',
+ 'InsertNodeTransaction.cpp',
'InsertTextTxn.cpp',
'JoinNodeTxn.cpp',
'nsEditor.cpp',
'nsEditorCommands.cpp',
'nsEditorController.cpp',
'nsEditorEventListener.cpp',
'nsHTMLAbsPosition.cpp',
'nsHTMLAnonymousUtils.cpp',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -14,17 +14,17 @@
#include "CompositionTransaction.h" // for CompositionTransaction
#include "CreateElementTransaction.h" // for CreateElementTransaction
#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 "InsertNodeTxn.h" // for InsertNodeTxn
+#include "InsertNodeTransaction.h" // for InsertNodeTransaction
#include "InsertTextTxn.h" // for InsertTextTxn
#include "JoinNodeTxn.h" // for JoinNodeTxn
#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
@@ -1389,30 +1389,29 @@ nsEditor::InsertNode(nsIContent& aNode,
{
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
for (auto& listener : mActionListeners) {
listener->WillInsertNode(aNode.AsDOMNode(), aParent.AsDOMNode(),
aPosition);
}
- RefPtr<InsertNodeTxn> txn = CreateTxnForInsertNode(aNode, aParent,
- aPosition);
- nsresult res = DoTransaction(txn);
+ RefPtr<InsertNodeTransaction> transaction =
+ CreateTxnForInsertNode(aNode, aParent, aPosition);
+ nsresult rv = DoTransaction(transaction);
mRangeUpdater.SelAdjInsertNode(aParent.AsDOMNode(), aPosition);
for (auto& listener : mActionListeners) {
listener->DidInsertNode(aNode.AsDOMNode(), aParent.AsDOMNode(), aPosition,
- res);
- }
-
- return res;
-}
-
+ rv);
+ }
+
+ return rv;
+}
NS_IMETHODIMP
nsEditor::SplitNode(nsIDOMNode* aNode,
int32_t aOffset,
nsIDOMNode** aNewLeftNode)
{
nsCOMPtr<nsIContent> node = do_QueryInterface(aNode);
NS_ENSURE_STATE(node);
@@ -4198,24 +4197,24 @@ nsEditor::CreateTxnForCreateElement(nsIA
{
RefPtr<CreateElementTransaction> transaction =
new CreateElementTransaction(*this, aTag, aParent, aPosition);
return transaction.forget();
}
-already_AddRefed<InsertNodeTxn>
+already_AddRefed<InsertNodeTransaction>
nsEditor::CreateTxnForInsertNode(nsIContent& aNode,
nsINode& aParent,
int32_t aPosition)
{
- RefPtr<InsertNodeTxn> txn = new InsertNodeTxn(aNode, aParent, aPosition,
- *this);
- return txn.forget();
+ RefPtr<InsertNodeTransaction> transaction =
+ new InsertNodeTransaction(aNode, aParent, aPosition, *this);
+ return transaction.forget();
}
nsresult
nsEditor::CreateTxnForDeleteNode(nsINode* aNode,
DeleteNodeTransaction** aTransaction)
{
NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
--- a/editor/libeditor/nsEditor.h
+++ b/editor/libeditor/nsEditor.h
@@ -57,25 +57,25 @@ class AutoRules;
class AutoSelectionRestorer;
class AutoTransactionsConserveSelection;
class ChangeAttributeTransaction;
class CompositionTransaction;
class CreateElementTransaction;
class DeleteNodeTransaction;
class DeleteTextTransaction;
class ErrorResult;
+class InsertNodeTransaction;
class TextComposition;
struct EditorDOMPoint;
namespace dom {
class DataTransfer;
class Element;
class EventTarget;
class InsertTextTxn;
-class InsertNodeTxn;
class JoinNodeTxn;
class Selection;
class SplitNodeTxn;
class Text;
} // namespace dom
} // namespace mozilla
namespace mozilla {
@@ -273,17 +273,17 @@ protected:
nsINode& aParent,
int32_t aPosition);
already_AddRefed<Element> CreateNode(nsIAtom* aTag, nsINode* aParent,
int32_t aPosition);
/** create a transaction for inserting aNode as a child of aParent.
*/
- already_AddRefed<mozilla::dom::InsertNodeTxn>
+ already_AddRefed<mozilla::InsertNodeTransaction>
CreateTxnForInsertNode(nsIContent& aNode, nsINode& aParent, int32_t aOffset);
/** create a transaction for removing aNode from its parent.
*/
nsresult CreateTxnForDeleteNode(
nsINode* aNode,
mozilla::DeleteNodeTransaction** aTransaction);