--- a/editor/libeditor/DeleteRangeTransaction.cpp
+++ b/editor/libeditor/DeleteRangeTransaction.cpp
@@ -26,21 +26,22 @@ using namespace dom;
// note that aEditor is not refcounted
DeleteRangeTransaction::DeleteRangeTransaction()
: mEditor(nullptr)
, mRangeUpdater(nullptr)
{
}
-NS_IMPL_CYCLE_COLLECTION_INHERITED(DeleteRangeTransaction, EditAggregateTxn,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(DeleteRangeTransaction,
+ EditAggregateTransaction,
mRange)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DeleteRangeTransaction)
-NS_INTERFACE_MAP_END_INHERITING(EditAggregateTxn)
+NS_INTERFACE_MAP_END_INHERITING(EditAggregateTransaction)
nsresult
DeleteRangeTransaction::Init(nsEditor* aEditor,
nsRange* aRange,
nsRangeUpdater* aRangeUpdater)
{
MOZ_ASSERT(aEditor && aRange);
@@ -84,17 +85,17 @@ DeleteRangeTransaction::DoTransaction()
res = CreateTxnsToDeleteNodesBetween();
NS_ENSURE_SUCCESS(res, res);
// delete the relevant content in the end node
res = CreateTxnsToDeleteContent(endParent, endOffset, nsIEditor::ePrevious);
NS_ENSURE_SUCCESS(res, res);
}
// if we've successfully built this aggregate transaction, then do it.
- res = EditAggregateTxn::DoTransaction();
+ res = EditAggregateTransaction::DoTransaction();
NS_ENSURE_SUCCESS(res, res);
// only set selection to deletion point if editor gives permission
bool bAdjustSelection;
mEditor->ShouldTxnSetSelection(&bAdjustSelection);
if (bAdjustSelection) {
RefPtr<Selection> selection = mEditor->GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
@@ -106,25 +107,25 @@ DeleteRangeTransaction::DoTransaction()
return NS_OK;
}
NS_IMETHODIMP
DeleteRangeTransaction::UndoTransaction()
{
MOZ_ASSERT(mRange && mEditor);
- return EditAggregateTxn::UndoTransaction();
+ return EditAggregateTransaction::UndoTransaction();
}
NS_IMETHODIMP
DeleteRangeTransaction::RedoTransaction()
{
MOZ_ASSERT(mRange && mEditor);
- return EditAggregateTxn::RedoTransaction();
+ return EditAggregateTransaction::RedoTransaction();
}
NS_IMETHODIMP
DeleteRangeTransaction::GetTxnDescription(nsAString& aString)
{
aString.AssignLiteral("DeleteRangeTransaction");
return NS_OK;
}
--- a/editor/libeditor/DeleteRangeTransaction.h
+++ b/editor/libeditor/DeleteRangeTransaction.h
@@ -1,17 +1,17 @@
/* -*- 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 DeleteRangeTransaction_h
#define DeleteRangeTransaction_h
-#include "EditAggregateTxn.h"
+#include "EditAggregateTransaction.h"
#include "EditTxn.h"
#include "nsCycleCollectionParticipant.h"
#include "nsID.h"
#include "nsIEditor.h"
#include "nsISupportsImpl.h"
#include "nsRange.h"
#include "nscore.h"
@@ -19,42 +19,42 @@ class nsEditor;
class nsINode;
class nsRangeUpdater;
namespace mozilla {
/**
* A transaction that deletes an entire range in the content tree
*/
-class DeleteRangeTransaction final : public EditAggregateTxn
+class DeleteRangeTransaction final : public EditAggregateTransaction
{
public:
/**
* 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);
DeleteRangeTransaction();
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteRangeTransaction,
- EditAggregateTxn)
+ EditAggregateTransaction)
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
NS_DECL_EDITTXN
NS_IMETHOD RedoTransaction() override;
virtual void LastRelease() override
{
mRange = nullptr;
- EditAggregateTxn::LastRelease();
+ EditAggregateTransaction::LastRelease();
}
protected:
nsresult CreateTxnsToDeleteBetween(nsINode* aNode,
int32_t aStartOffset,
int32_t aEndOffset);
nsresult CreateTxnsToDeleteNodesBetween();
rename from editor/libeditor/EditAggregateTxn.cpp
rename to editor/libeditor/EditAggregateTransaction.cpp
--- a/editor/libeditor/EditAggregateTxn.cpp
+++ b/editor/libeditor/EditAggregateTransaction.cpp
@@ -1,128 +1,139 @@
/* -*- 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 "EditAggregateTxn.h"
+#include "EditAggregateTransaction.h"
#include "nsAString.h"
#include "nsCOMPtr.h" // for nsCOMPtr
#include "nsError.h" // for NS_OK, etc
#include "nsISupportsUtils.h" // for NS_ADDREF
#include "nsITransaction.h" // for nsITransaction
#include "nsString.h" // for nsAutoString
-EditAggregateTxn::EditAggregateTxn()
- : EditTxn()
+namespace mozilla {
+
+EditAggregateTransaction::EditAggregateTransaction()
{
}
-EditAggregateTxn::~EditAggregateTxn()
+EditAggregateTransaction::~EditAggregateTransaction()
{
}
-NS_IMPL_CYCLE_COLLECTION_INHERITED(EditAggregateTxn, EditTxn,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(EditAggregateTransaction, EditTxn,
mChildren)
-NS_IMPL_ADDREF_INHERITED(EditAggregateTxn, EditTxn)
-NS_IMPL_RELEASE_INHERITED(EditAggregateTxn, EditTxn)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(EditAggregateTxn)
+NS_IMPL_ADDREF_INHERITED(EditAggregateTransaction, EditTxn)
+NS_IMPL_RELEASE_INHERITED(EditAggregateTransaction, EditTxn)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(EditAggregateTransaction)
NS_INTERFACE_MAP_END_INHERITING(EditTxn)
-NS_IMETHODIMP EditAggregateTxn::DoTransaction(void)
+NS_IMETHODIMP
+EditAggregateTransaction::DoTransaction()
{
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
for (uint32_t i = 0, length = mChildren.Length(); i < length; ++i)
{
nsITransaction *txn = mChildren[i];
if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->DoTransaction();
if (NS_FAILED(result))
break;
}
return result;
}
-NS_IMETHODIMP EditAggregateTxn::UndoTransaction(void)
+NS_IMETHODIMP
+EditAggregateTransaction::UndoTransaction()
{
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
// undo goes through children backwards
for (uint32_t i = mChildren.Length(); i-- != 0; )
{
nsITransaction *txn = mChildren[i];
if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->UndoTransaction();
if (NS_FAILED(result))
break;
}
return result;
}
-NS_IMETHODIMP EditAggregateTxn::RedoTransaction(void)
+NS_IMETHODIMP
+EditAggregateTransaction::RedoTransaction()
{
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
for (uint32_t i = 0, length = mChildren.Length(); i < length; ++i)
{
nsITransaction *txn = mChildren[i];
if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->RedoTransaction();
if (NS_FAILED(result))
break;
}
return result;
}
-NS_IMETHODIMP EditAggregateTxn::Merge(nsITransaction *aTransaction, bool *aDidMerge)
+NS_IMETHODIMP
+EditAggregateTransaction::Merge(nsITransaction* aTransaction,
+ bool* aDidMerge)
{
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
if (aDidMerge)
*aDidMerge = false;
// FIXME: Is this really intended not to loop? It looks like the code
// that used to be here sort of intended to loop, but didn't.
if (mChildren.Length() > 0)
{
nsITransaction *txn = mChildren[0];
if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->Merge(aTransaction, aDidMerge);
}
return result;
}
-NS_IMETHODIMP EditAggregateTxn::GetTxnDescription(nsAString& aString)
+NS_IMETHODIMP
+EditAggregateTransaction::GetTxnDescription(nsAString& aString)
{
- aString.AssignLiteral("EditAggregateTxn: ");
+ aString.AssignLiteral("EditAggregateTransaction: ");
if (mName)
{
nsAutoString name;
mName->ToString(name);
aString += name;
}
return NS_OK;
}
-NS_IMETHODIMP EditAggregateTxn::AppendChild(EditTxn *aTxn)
+NS_IMETHODIMP
+EditAggregateTransaction::AppendChild(EditTxn* aTransaction)
{
- if (!aTxn) {
+ if (!aTransaction) {
return NS_ERROR_NULL_POINTER;
}
RefPtr<EditTxn> *slot = mChildren.AppendElement();
if (!slot) {
return NS_ERROR_OUT_OF_MEMORY;
}
- *slot = aTxn;
+ *slot = aTransaction;
return NS_OK;
}
-NS_IMETHODIMP EditAggregateTxn::GetName(nsIAtom **aName)
+NS_IMETHODIMP
+EditAggregateTransaction::GetName(nsIAtom** aName)
{
if (aName && mName)
{
*aName = mName;
NS_ADDREF(*aName);
return NS_OK;
}
return NS_ERROR_NULL_POINTER;
}
+
+} // namespace mozilla
rename from editor/libeditor/EditAggregateTxn.h
rename to editor/libeditor/EditAggregateTransaction.h
--- a/editor/libeditor/EditAggregateTxn.h
+++ b/editor/libeditor/EditAggregateTransaction.h
@@ -1,49 +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 EditAggregateTxn_h__
-#define EditAggregateTxn_h__
+#ifndef EditAggregateTransaction_h
+#define EditAggregateTransaction_h
#include "EditTxn.h"
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIAtom.h"
#include "nsISupportsImpl.h"
#include "nsTArray.h"
#include "nscore.h"
class nsITransaction;
+namespace mozilla {
+
/**
* base class for all document editing transactions that require aggregation.
* provides a list of child transactions.
*/
-class EditAggregateTxn : public EditTxn
+class EditAggregateTransaction : public EditTxn
{
public:
- EditAggregateTxn();
+ EditAggregateTransaction();
NS_DECL_ISUPPORTS_INHERITED
- NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(EditAggregateTxn, EditTxn)
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(EditAggregateTransaction, EditTxn)
NS_DECL_EDITTXN
NS_IMETHOD RedoTransaction() override;
- NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge) override;
+ NS_IMETHOD Merge(nsITransaction* aTransaction, bool* aDidMerge) override;
- /** append a transaction to this aggregate */
- NS_IMETHOD AppendChild(EditTxn *aTxn);
+ /**
+ * Append a transaction to this aggregate.
+ */
+ NS_IMETHOD AppendChild(EditTxn* aTxn);
- /** get the name assigned to this txn */
- NS_IMETHOD GetName(nsIAtom **aName);
+ /**
+ * Get the name assigned to this transaction.
+ */
+ NS_IMETHOD GetName(nsIAtom** aName);
protected:
- virtual ~EditAggregateTxn();
+ virtual ~EditAggregateTransaction();
- nsTArray< RefPtr<EditTxn> > mChildren;
+ nsTArray<RefPtr<EditTxn>> mChildren;
nsCOMPtr<nsIAtom> mName;
};
-#endif
+} // namespace mozilla
+
+#endif // #ifndef EditAggregateTransaction_h
--- a/editor/libeditor/PlaceholderTransaction.cpp
+++ b/editor/libeditor/PlaceholderTransaction.cpp
@@ -26,38 +26,38 @@ PlaceholderTransaction::PlaceholderTrans
PlaceholderTransaction::~PlaceholderTransaction()
{
}
NS_IMPL_CYCLE_COLLECTION_CLASS(PlaceholderTransaction)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PlaceholderTransaction,
- EditAggregateTxn)
+ EditAggregateTransaction)
if (tmp->mStartSel) {
ImplCycleCollectionUnlink(*tmp->mStartSel);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEndSel);
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PlaceholderTransaction,
- EditAggregateTxn)
+ EditAggregateTransaction)
if (tmp->mStartSel) {
ImplCycleCollectionTraverse(cb, *tmp->mStartSel, "mStartSel", 0);
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEndSel);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PlaceholderTransaction)
NS_INTERFACE_MAP_ENTRY(nsIAbsorbingTransaction)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-NS_INTERFACE_MAP_END_INHERITING(EditAggregateTxn)
+NS_INTERFACE_MAP_END_INHERITING(EditAggregateTransaction)
-NS_IMPL_ADDREF_INHERITED(PlaceholderTransaction, EditAggregateTxn)
-NS_IMPL_RELEASE_INHERITED(PlaceholderTransaction, EditAggregateTxn)
+NS_IMPL_ADDREF_INHERITED(PlaceholderTransaction, EditAggregateTransaction)
+NS_IMPL_RELEASE_INHERITED(PlaceholderTransaction, EditAggregateTransaction)
NS_IMETHODIMP
PlaceholderTransaction::Init(nsIAtom* aName,
nsSelectionState* aSelState,
nsEditor* aEditor)
{
NS_ENSURE_TRUE(aEditor && aSelState, NS_ERROR_NULL_POINTER);
@@ -71,34 +71,34 @@ NS_IMETHODIMP
PlaceholderTransaction::DoTransaction()
{
return NS_OK;
}
NS_IMETHODIMP
PlaceholderTransaction::UndoTransaction()
{
- // undo txns
- nsresult res = EditAggregateTxn::UndoTransaction();
- NS_ENSURE_SUCCESS(res, res);
+ // Undo transactions.
+ nsresult rv = EditAggregateTransaction::UndoTransaction();
+ NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(mStartSel, NS_ERROR_NULL_POINTER);
// now restore selection
RefPtr<Selection> selection = mEditor->GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
return mStartSel->RestoreSelection(selection);
}
NS_IMETHODIMP
PlaceholderTransaction::RedoTransaction()
{
- // redo txns
- nsresult res = EditAggregateTxn::RedoTransaction();
- NS_ENSURE_SUCCESS(res, res);
+ // Redo transactions.
+ nsresult rv = EditAggregateTransaction::RedoTransaction();
+ NS_ENSURE_SUCCESS(rv, rv);
// now restore selection
RefPtr<Selection> selection = mEditor->GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
return mEndSel.RestoreSelection(selection);
}
--- a/editor/libeditor/PlaceholderTransaction.h
+++ b/editor/libeditor/PlaceholderTransaction.h
@@ -1,17 +1,17 @@
/* -*- 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 PlaceholderTransaction_h
#define PlaceholderTransaction_h
-#include "EditAggregateTxn.h"
+#include "EditAggregateTransaction.h"
#include "EditorUtils.h"
#include "nsIAbsorbingTransaction.h"
#include "nsIDOMNode.h"
#include "nsCOMPtr.h"
#include "nsWeakPtr.h"
#include "nsWeakReference.h"
#include "nsAutoPtr.h"
@@ -21,28 +21,28 @@ class CompositionTransaction;
/**
* An aggregate transaction that knows how to absorb all subsequent
* transactions with the same name. This transaction does not "Do" anything.
* But it absorbs other transactions via merge, and can undo/redo the
* transactions it has absorbed.
*/
-class PlaceholderTransaction final : public EditAggregateTxn,
+class PlaceholderTransaction final : public EditAggregateTransaction,
public nsIAbsorbingTransaction,
public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS_INHERITED
PlaceholderTransaction();
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PlaceholderTransaction,
- EditAggregateTxn)
-// ------------ EditAggregateTxn -----------------------
+ EditAggregateTransaction)
+// ------------ EditAggregateTransaction -----------------------
NS_DECL_EDITTXN
NS_IMETHOD RedoTransaction() override;
NS_IMETHOD Merge(nsITransaction* aTransaction, bool* aDidMerge) override;
// ------------ nsIAbsorbingTransaction -----------------------
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -16,17 +16,17 @@ BROWSER_CHROME_MANIFESTS += ['tests/brow
UNIFIED_SOURCES += [
'ChangeAttributeTransaction.cpp',
'ChangeStyleTransaction.cpp',
'CompositionTransaction.cpp',
'CreateElementTransaction.cpp',
'DeleteNodeTransaction.cpp',
'DeleteRangeTransaction.cpp',
'DeleteTextTransaction.cpp',
- 'EditAggregateTxn.cpp',
+ 'EditAggregateTransaction.cpp',
'EditorUtils.cpp',
'EditTxn.cpp',
'HTMLEditUtils.cpp',
'InsertNodeTransaction.cpp',
'InsertTextTransaction.cpp',
'JoinNodeTransaction.cpp',
'nsEditor.cpp',
'nsEditorCommands.cpp',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -11,17 +11,17 @@
#include <string.h> // for strcmp
#include "ChangeAttributeTransaction.h" // for ChangeAttributeTransaction
#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 "EditAggregateTransaction.h" // for EditAggregateTransaction
#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 "SplitNodeTransaction.h" // for SplitNodeTransaction
#include "TextEditUtils.h" // for TextEditUtils
@@ -3982,27 +3982,27 @@ nsEditor::GetShouldTxnSetSelection()
NS_IMETHODIMP
nsEditor::DeleteSelectionImpl(EDirection aAction,
EStripWrappers aStripWrappers)
{
MOZ_ASSERT(aStripWrappers == eStrip || aStripWrappers == eNoStrip);
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_STATE(selection);
- RefPtr<EditAggregateTxn> txn;
+ RefPtr<EditAggregateTransaction> transaction;
nsCOMPtr<nsINode> deleteNode;
int32_t deleteCharOffset = 0, deleteCharLength = 0;
- nsresult res = CreateTxnForDeleteSelection(aAction, getter_AddRefs(txn),
- getter_AddRefs(deleteNode),
- &deleteCharOffset,
- &deleteCharLength);
+ nsresult rv = CreateTxnForDeleteSelection(aAction,
+ getter_AddRefs(transaction),
+ getter_AddRefs(deleteNode),
+ &deleteCharOffset,
+ &deleteCharLength);
nsCOMPtr<nsIDOMCharacterData> deleteCharData(do_QueryInterface(deleteNode));
- if (NS_SUCCEEDED(res))
- {
+ if (NS_SUCCEEDED(rv)) {
AutoRules beginRulesSniffing(this, EditAction::deleteSelection, aAction);
// Notify nsIEditActionListener::WillDelete[Selection|Text|Node]
if (!deleteNode) {
for (auto& listener : mActionListeners) {
listener->WillDeleteSelection(selection);
}
} else if (deleteCharData) {
for (auto& listener : mActionListeners) {
@@ -4010,35 +4010,35 @@ nsEditor::DeleteSelectionImpl(EDirection
}
} else {
for (auto& listener : mActionListeners) {
listener->WillDeleteNode(deleteNode->AsDOMNode());
}
}
// Delete the specified amount
- res = DoTransaction(txn);
+ rv = DoTransaction(transaction);
// Notify nsIEditActionListener::DidDelete[Selection|Text|Node]
if (!deleteNode) {
for (auto& listener : mActionListeners) {
listener->DidDeleteSelection(selection);
}
} else if (deleteCharData) {
for (auto& listener : mActionListeners) {
- listener->DidDeleteText(deleteCharData, deleteCharOffset, 1, res);
+ listener->DidDeleteText(deleteCharData, deleteCharOffset, 1, rv);
}
} else {
for (auto& listener : mActionListeners) {
- listener->DidDeleteNode(deleteNode->AsDOMNode(), res);
+ listener->DidDeleteNode(deleteNode->AsDOMNode(), rv);
}
}
}
- return res;
+ return rv;
}
already_AddRefed<Element>
nsEditor::DeleteSelectionAndCreateElement(nsIAtom& aTag)
{
nsresult res = DeleteSelectionAndPrepareToCreateNode();
NS_ENSURE_SUCCESS(res, nullptr);
@@ -4273,55 +4273,57 @@ nsEditor::CreateTxnForRemoveStyleSheet(S
}
return rv;
}
nsresult
nsEditor::CreateTxnForDeleteSelection(EDirection aAction,
- EditAggregateTxn** aTxn,
+ EditAggregateTransaction** aTransaction,
nsINode** aNode,
int32_t* aOffset,
int32_t* aLength)
{
- MOZ_ASSERT(aTxn);
- *aTxn = nullptr;
+ MOZ_ASSERT(aTransaction);
+ *aTransaction = nullptr;
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_STATE(selection);
// Check whether the selection is collapsed and we should do nothing:
if (selection->Collapsed() && aAction == eNone) {
return NS_OK;
}
// allocate the out-param transaction
- RefPtr<EditAggregateTxn> aggTxn = new EditAggregateTxn();
+ RefPtr<EditAggregateTransaction> aggregateTransaction =
+ new EditAggregateTransaction();
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<DeleteRangeTransaction> transaction = new DeleteRangeTransaction();
transaction->Init(this, range, &mRangeUpdater);
- aggTxn->AppendChild(transaction);
+ aggregateTransaction->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);
+ nsresult rv = CreateTxnForDeleteInsertionPoint(range, aAction,
+ aggregateTransaction,
+ aNode, aOffset, aLength);
+ NS_ENSURE_SUCCESS(rv, rv);
}
}
- aggTxn.forget(aTxn);
+ aggregateTransaction.forget(aTransaction);
return NS_OK;
}
already_AddRefed<DeleteTextTransaction>
nsEditor::CreateTxnForDeleteCharacter(nsGenericDOMDataNode& aData,
uint32_t aOffset, EDirection aDirection)
{
@@ -4352,22 +4354,23 @@ nsEditor::CreateTxnForDeleteCharacter(ns
return nullptr;
}
return CreateTxnForDeleteText(aData, segOffset, segLength);
}
//XXX: currently, this doesn't handle edge conditions because GetNext/GetPrior
//are not implemented
nsresult
-nsEditor::CreateTxnForDeleteInsertionPoint(nsRange* aRange,
- EDirection aAction,
- EditAggregateTxn* aTxn,
- nsINode** aNode,
- int32_t* aOffset,
- int32_t* aLength)
+nsEditor::CreateTxnForDeleteInsertionPoint(
+ nsRange* aRange,
+ EDirection aAction,
+ EditAggregateTransaction* aTransaction,
+ nsINode** aNode,
+ int32_t* aOffset,
+ int32_t* aLength)
{
MOZ_ASSERT(aAction != eNone);
nsresult res;
// get the node and offset of the insertion point
nsCOMPtr<nsINode> node = aRange->GetStartParent();
NS_ENSURE_STATE(node);
@@ -4402,24 +4405,24 @@ nsEditor::CreateTxnForDeleteInsertionPoi
// Bail out for empty chardata XXX: Do we want to do something else?
NS_ENSURE_STATE(length);
RefPtr<DeleteTextTransaction> transaction =
CreateTxnForDeleteCharacter(*priorNodeAsCharData, length, ePrevious);
NS_ENSURE_STATE(transaction);
*aOffset = transaction->GetOffset();
*aLength = transaction->GetNumCharsToDelete();
- aTxn->AppendChild(transaction);
+ aTransaction->AppendChild(transaction);
} else {
// priorNode is not chardata, so tell its parent to delete it
RefPtr<DeleteNodeTransaction> transaction;
res = CreateTxnForDeleteNode(priorNode, getter_AddRefs(transaction));
NS_ENSURE_SUCCESS(res, res);
- aTxn->AppendChild(transaction);
+ aTransaction->AppendChild(transaction);
}
NS_ADDREF(*aNode = priorNode);
return NS_OK;
}
if (aAction == eNext && isLast) {
@@ -4437,39 +4440,39 @@ nsEditor::CreateTxnForDeleteInsertionPoi
// Bail out for empty chardata XXX: Do we want to do something else?
NS_ENSURE_STATE(length);
RefPtr<DeleteTextTransaction> transaction =
CreateTxnForDeleteCharacter(*nextNodeAsCharData, 0, eNext);
NS_ENSURE_STATE(transaction);
*aOffset = transaction->GetOffset();
*aLength = transaction->GetNumCharsToDelete();
- aTxn->AppendChild(transaction);
+ aTransaction->AppendChild(transaction);
} else {
// nextNode is not chardata, so tell its parent to delete it
RefPtr<DeleteNodeTransaction> transaction;
res = CreateTxnForDeleteNode(nextNode, getter_AddRefs(transaction));
NS_ENSURE_SUCCESS(res, res);
- aTxn->AppendChild(transaction);
+ aTransaction->AppendChild(transaction);
}
NS_ADDREF(*aNode = nextNode);
return NS_OK;
}
if (node->IsNodeOfType(nsINode::eDATA_NODE)) {
RefPtr<nsGenericDOMDataNode> nodeAsCharData =
static_cast<nsGenericDOMDataNode*>(node.get());
// we have chardata, so delete a char at the proper offset
RefPtr<DeleteTextTransaction> transaction =
CreateTxnForDeleteCharacter(*nodeAsCharData, offset, aAction);
NS_ENSURE_STATE(transaction);
- aTxn->AppendChild(transaction);
+ aTransaction->AppendChild(transaction);
NS_ADDREF(*aNode = node);
*aOffset = transaction->GetOffset();
*aLength = transaction->GetNumCharsToDelete();
} else {
// we're either deleting a node or chardata, need to dig into the next/prev
// node to find out
nsCOMPtr<nsINode> selectedNode;
if (aAction == ePrevious) {
@@ -4498,27 +4501,27 @@ nsEditor::CreateTxnForDeleteInsertionPoi
if (aAction == ePrevious) {
position = selectedNode->Length();
}
RefPtr<DeleteTextTransaction> deleteTextTransaction =
CreateTxnForDeleteCharacter(*selectedNodeAsCharData, position,
aAction);
NS_ENSURE_TRUE(deleteTextTransaction, NS_ERROR_NULL_POINTER);
- aTxn->AppendChild(deleteTextTransaction);
+ aTransaction->AppendChild(deleteTextTransaction);
*aOffset = deleteTextTransaction->GetOffset();
*aLength = deleteTextTransaction->GetNumCharsToDelete();
} else {
RefPtr<DeleteNodeTransaction> deleteNodeTransaction;
res = CreateTxnForDeleteNode(selectedNode,
getter_AddRefs(deleteNodeTransaction));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(deleteNodeTransaction, NS_ERROR_NULL_POINTER);
- aTxn->AppendChild(deleteNodeTransaction);
+ aTransaction->AppendChild(deleteNodeTransaction);
}
NS_ADDREF(*aNode = selectedNode);
}
return NS_OK;
}
--- a/editor/libeditor/nsEditor.h
+++ b/editor/libeditor/nsEditor.h
@@ -23,17 +23,16 @@
#include "nsIWeakReferenceUtils.h" // for nsWeakPtr
#include "nsLiteralString.h" // for NS_LITERAL_STRING
#include "nsSelectionState.h" // for nsRangeUpdater, etc
#include "nsString.h" // for nsCString
#include "nsWeakReference.h" // for nsSupportsWeakReference
#include "nscore.h" // for nsresult, nsAString, etc
class AddStyleSheetTxn;
-class EditAggregateTxn;
class RemoveStyleSheetTxn;
class nsIAtom;
class nsIContent;
class nsIDOMDocument;
class nsIDOMEvent;
class nsIDOMEventListener;
class nsIDOMEventTarget;
class nsIDOMKeyEvent;
@@ -56,16 +55,17 @@ namespace mozilla {
class AutoRules;
class AutoSelectionRestorer;
class AutoTransactionsConserveSelection;
class ChangeAttributeTransaction;
class CompositionTransaction;
class CreateElementTransaction;
class DeleteNodeTransaction;
class DeleteTextTransaction;
+class EditAggregateTransaction;
class ErrorResult;
class InsertNodeTransaction;
class InsertTextTransaction;
class JoinNodeTransaction;
class SplitNodeTransaction;
class TextComposition;
struct EditorDOMPoint;
@@ -282,28 +282,30 @@ protected:
CreateTxnForInsertNode(nsIContent& aNode, nsINode& aParent, int32_t aOffset);
/** create a transaction for removing aNode from its parent.
*/
nsresult CreateTxnForDeleteNode(
nsINode* aNode,
mozilla::DeleteNodeTransaction** aTransaction);
- nsresult CreateTxnForDeleteSelection(EDirection aAction,
- EditAggregateTxn** aTxn,
- nsINode** aNode,
- int32_t* aOffset,
- int32_t* aLength);
+ nsresult CreateTxnForDeleteSelection(
+ EDirection aAction,
+ mozilla::EditAggregateTransaction** aTransaction,
+ nsINode** aNode,
+ int32_t* aOffset,
+ int32_t* aLength);
- nsresult CreateTxnForDeleteInsertionPoint(nsRange* aRange,
- EDirection aAction,
- EditAggregateTxn* aTxn,
- nsINode** aNode,
- int32_t* aOffset,
- int32_t* aLength);
+ nsresult CreateTxnForDeleteInsertionPoint(
+ nsRange* aRange,
+ EDirection aAction,
+ mozilla::EditAggregateTransaction* aTransaction,
+ nsINode** aNode,
+ int32_t* aOffset,
+ int32_t* aLength);
/** Create a transaction for inserting aStringToInsert into aTextNode. Never
* returns null.
*/
already_AddRefed<mozilla::InsertTextTransaction>
CreateTxnForInsertText(const nsAString& aStringToInsert, Text& aTextNode,
int32_t aOffset);