Bug 1260651 part.21 Rename DeleteRangeTxn to mozilla::DeleteRangeTransaction (and their files too) r=mccr8
MozReview-Commit-ID: IYFkzr95E6U
rename from editor/libeditor/DeleteRangeTxn.cpp
rename to editor/libeditor/DeleteRangeTransaction.cpp
--- a/editor/libeditor/DeleteRangeTxn.cpp
+++ b/editor/libeditor/DeleteRangeTransaction.cpp
@@ -1,52 +1,51 @@
/* -*- 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 "DeleteRangeTransaction.h"
#include "DeleteNodeTransaction.h"
#include "DeleteTextTxn.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/mozalloc.h"
#include "nsCOMPtr.h"
#include "nsDebug.h"
#include "nsEditor.h"
#include "nsError.h"
#include "nsIContent.h"
#include "nsIContentIterator.h"
#include "nsIDOMCharacterData.h"
#include "nsINode.h"
#include "nsAString.h"
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
// note that aEditor is not refcounted
-DeleteRangeTxn::DeleteRangeTxn()
- : EditAggregateTxn(),
- mRange(),
- mEditor(nullptr),
- mRangeUpdater(nullptr)
+DeleteRangeTransaction::DeleteRangeTransaction()
+ : mEditor(nullptr)
+ , mRangeUpdater(nullptr)
{
}
-NS_IMPL_CYCLE_COLLECTION_INHERITED(DeleteRangeTxn, EditAggregateTxn,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(DeleteRangeTransaction, EditAggregateTxn,
mRange)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DeleteRangeTxn)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DeleteRangeTransaction)
NS_INTERFACE_MAP_END_INHERITING(EditAggregateTxn)
nsresult
-DeleteRangeTxn::Init(nsEditor* aEditor,
- nsRange* aRange,
- nsRangeUpdater* aRangeUpdater)
+DeleteRangeTransaction::Init(nsEditor* aEditor,
+ nsRange* aRange,
+ nsRangeUpdater* aRangeUpdater)
{
MOZ_ASSERT(aEditor && aRange);
mEditor = aEditor;
mRange = aRange->CloneRange();
mRangeUpdater = aRangeUpdater;
NS_ENSURE_TRUE(mEditor->IsModifiableNode(mRange->GetStartParent()),
@@ -55,17 +54,17 @@ DeleteRangeTxn::Init(nsEditor* aEditor,
NS_ERROR_FAILURE);
NS_ENSURE_TRUE(mEditor->IsModifiableNode(mRange->GetCommonAncestor()),
NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP
-DeleteRangeTxn::DoTransaction()
+DeleteRangeTransaction::DoTransaction()
{
MOZ_ASSERT(mRange && mEditor);
nsresult res;
// build the child transactions
nsCOMPtr<nsINode> startParent = mRange->GetStartParent();
int32_t startOffset = mRange->StartOffset();
nsCOMPtr<nsINode> endParent = mRange->GetEndParent();
@@ -103,42 +102,42 @@ DeleteRangeTxn::DoTransaction()
NS_ENSURE_SUCCESS(res, res);
}
// else do nothing - dom range gravity will adjust selection
return NS_OK;
}
NS_IMETHODIMP
-DeleteRangeTxn::UndoTransaction()
+DeleteRangeTransaction::UndoTransaction()
{
MOZ_ASSERT(mRange && mEditor);
return EditAggregateTxn::UndoTransaction();
}
NS_IMETHODIMP
-DeleteRangeTxn::RedoTransaction()
+DeleteRangeTransaction::RedoTransaction()
{
MOZ_ASSERT(mRange && mEditor);
return EditAggregateTxn::RedoTransaction();
}
NS_IMETHODIMP
-DeleteRangeTxn::GetTxnDescription(nsAString& aString)
+DeleteRangeTransaction::GetTxnDescription(nsAString& aString)
{
- aString.AssignLiteral("DeleteRangeTxn");
+ aString.AssignLiteral("DeleteRangeTransaction");
return NS_OK;
}
nsresult
-DeleteRangeTxn::CreateTxnsToDeleteBetween(nsINode* aNode,
- int32_t aStartOffset,
- int32_t aEndOffset)
+DeleteRangeTransaction::CreateTxnsToDeleteBetween(nsINode* aNode,
+ int32_t aStartOffset,
+ int32_t aEndOffset)
{
// see what kind of node we have
if (aNode->IsNodeOfType(nsINode::eDATA_NODE)) {
// if the node is a chardata node, then delete chardata content
int32_t numToDel;
if (aStartOffset == aEndOffset) {
numToDel = 1;
} else {
@@ -173,19 +172,19 @@ DeleteRangeTxn::CreateTxnsToDeleteBetwee
child = child->GetNextSibling();
}
NS_ENSURE_SUCCESS(res, res);
return NS_OK;
}
nsresult
-DeleteRangeTxn::CreateTxnsToDeleteContent(nsINode* aNode,
- int32_t aOffset,
- nsIEditor::EDirection aAction)
+DeleteRangeTransaction::CreateTxnsToDeleteContent(nsINode* aNode,
+ int32_t aOffset,
+ nsIEditor::EDirection aAction)
{
// see what kind of node we have
if (aNode->IsNodeOfType(nsINode::eDATA_NODE)) {
// if the node is a chardata node, then delete chardata content
uint32_t start, numToDelete;
if (nsIEditor::eNext == aAction) {
start = aOffset;
numToDelete = aNode->Length() - aOffset;
@@ -206,17 +205,17 @@ DeleteRangeTxn::CreateTxnsToDeleteConten
AppendChild(txn);
}
}
return NS_OK;
}
nsresult
-DeleteRangeTxn::CreateTxnsToDeleteNodesBetween()
+DeleteRangeTransaction::CreateTxnsToDeleteNodesBetween()
{
nsCOMPtr<nsIContentIterator> iter = NS_NewContentSubtreeIterator();
nsresult res = iter->Init(mRange);
NS_ENSURE_SUCCESS(res, res);
while (!iter->IsDone()) {
nsCOMPtr<nsINode> node = iter->GetCurrentNode();
@@ -226,8 +225,10 @@ DeleteRangeTxn::CreateTxnsToDeleteNodesB
res = transaction->Init(mEditor, node, mRangeUpdater);
NS_ENSURE_SUCCESS(res, res);
AppendChild(transaction);
iter->Next();
}
return NS_OK;
}
+
+} // namespace mozilla
rename from editor/libeditor/DeleteRangeTxn.h
rename to editor/libeditor/DeleteRangeTransaction.h
--- a/editor/libeditor/DeleteRangeTxn.h
+++ b/editor/libeditor/DeleteRangeTransaction.h
@@ -1,74 +1,78 @@
/* -*- 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 DeleteRangeTxn_h__
-#define DeleteRangeTxn_h__
+#ifndef DeleteRangeTransaction_h
+#define DeleteRangeTransaction_h
#include "EditAggregateTxn.h"
#include "EditTxn.h"
#include "nsCycleCollectionParticipant.h"
#include "nsID.h"
#include "nsIEditor.h"
#include "nsISupportsImpl.h"
#include "nsRange.h"
#include "nscore.h"
class nsEditor;
class nsINode;
class nsRangeUpdater;
+namespace mozilla {
+
/**
* A transaction that deletes an entire range in the content tree
*/
-class DeleteRangeTxn : public EditAggregateTxn
+class DeleteRangeTransaction final : public EditAggregateTxn
{
public:
- /** initialize the transaction.
- * @param aEditor the object providing basic editing operations
- * @param aRange the range to delete
- */
+ /**
+ * Initialize the transaction.
+ * @param aEditor The object providing basic editing operations.
+ * @param aRange The range to delete.
+ */
nsresult Init(nsEditor* aEditor,
nsRange* aRange,
nsRangeUpdater* aRangeUpdater);
- DeleteRangeTxn();
+ DeleteRangeTransaction();
- NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteRangeTxn, EditAggregateTxn)
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteRangeTransaction,
+ EditAggregateTxn)
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
NS_DECL_EDITTXN
NS_IMETHOD RedoTransaction() override;
virtual void LastRelease() override
{
mRange = nullptr;
EditAggregateTxn::LastRelease();
}
+
protected:
-
nsresult CreateTxnsToDeleteBetween(nsINode* aNode,
int32_t aStartOffset,
int32_t aEndOffset);
nsresult CreateTxnsToDeleteNodesBetween();
nsresult CreateTxnsToDeleteContent(nsINode* aParent,
int32_t aOffset,
nsIEditor::EDirection aAction);
-protected:
-
- /** p1 in the range */
+ // P1 in the range.
RefPtr<nsRange> mRange;
- /** the editor for this transaction */
+ // The editor for this transaction.
nsEditor* mEditor;
- /** range updater object */
+ // Range updater object.
nsRangeUpdater* mRangeUpdater;
};
-#endif
+} // namespace mozilla
+
+#endif // #ifndef DeleteRangeTransaction_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -13,17 +13,17 @@ MOCHITEST_CHROME_MANIFESTS += ['tests/ch
BROWSER_CHROME_MANIFESTS += ['tests/browser.ini']
UNIFIED_SOURCES += [
'ChangeAttributeTransaction.cpp',
'ChangeStyleTransaction.cpp',
'CreateElementTransaction.cpp',
'DeleteNodeTransaction.cpp',
- 'DeleteRangeTxn.cpp',
+ 'DeleteRangeTransaction.cpp',
'DeleteTextTxn.cpp',
'EditAggregateTxn.cpp',
'EditorUtils.cpp',
'EditTxn.cpp',
'HTMLEditUtils.cpp',
'IMETextTxn.cpp',
'InsertNodeTxn.cpp',
'InsertTextTxn.cpp',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -8,17 +8,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 "DeleteNodeTransaction.h" // for DeleteNodeTransaction
-#include "DeleteRangeTxn.h" // for DeleteRangeTxn
+#include "DeleteRangeTransaction.h" // for DeleteRangeTransaction
#include "DeleteTextTxn.h" // for DeleteTextTxn
#include "EditAggregateTxn.h" // for EditAggregateTxn
#include "EditorUtils.h" // for AutoRules, etc
#include "EditTxn.h" // for EditTxn
#include "IMETextTxn.h" // for IMETextTxn
#include "InsertNodeTxn.h" // for InsertNodeTxn
#include "InsertTextTxn.h" // for InsertTextTxn
#include "JoinNodeTxn.h" // for JoinNodeTxn
@@ -4297,19 +4297,19 @@ nsEditor::CreateTxnForDeleteSelection(ED
for (uint32_t rangeIdx = 0; rangeIdx < selection->RangeCount(); ++rangeIdx) {
RefPtr<nsRange> range = selection->GetRangeAt(rangeIdx);
NS_ENSURE_STATE(range);
// Same with range as with selection; if it is collapsed and action
// is eNone, do nothing.
if (!range->Collapsed()) {
- RefPtr<DeleteRangeTxn> txn = new DeleteRangeTxn();
- txn->Init(this, range, &mRangeUpdater);
- aggTxn->AppendChild(txn);
+ RefPtr<DeleteRangeTransaction> transaction = new DeleteRangeTransaction();
+ transaction->Init(this, range, &mRangeUpdater);
+ aggTxn->AppendChild(transaction);
} else if (aAction != eNone) {
// we have an insertion point. delete the thing in front of it or
// behind it, depending on aAction
nsresult res = CreateTxnForDeleteInsertionPoint(range, aAction, aggTxn,
aNode, aOffset, aLength);
NS_ENSURE_SUCCESS(res, res);
}
}