Bug 1260651 part.25 Rename mozilla::dom::InsertTextTxn to mozilla::InsertTextTransaction (and their files too) r=mccr8
MozReview-Commit-ID: wEBkU65pCM
rename from editor/libeditor/InsertTextTxn.cpp
rename to editor/libeditor/InsertTextTransaction.cpp
--- a/editor/libeditor/InsertTextTxn.cpp
+++ b/editor/libeditor/InsertTextTransaction.cpp
@@ -1,57 +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 "InsertTextTxn.h"
+#include "InsertTextTransaction.h"
#include "mozilla/dom/Selection.h" // Selection local var
#include "mozilla/dom/Text.h" // mTextNode
#include "nsAString.h" // nsAString parameter
#include "nsDebug.h" // for NS_ASSERTION, etc
#include "nsEditor.h" // mEditor
#include "nsError.h" // for NS_OK, etc
#include "nsQueryObject.h" // for do_QueryObject
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
-class nsITransaction;
+using namespace dom;
-InsertTextTxn::InsertTextTxn(Text& aTextNode, uint32_t aOffset,
- const nsAString& aStringToInsert,
- nsEditor& aEditor)
- : EditTxn()
- , mTextNode(&aTextNode)
+InsertTextTransaction::InsertTextTransaction(Text& aTextNode,
+ uint32_t aOffset,
+ const nsAString& aStringToInsert,
+ nsEditor& aEditor)
+ : mTextNode(&aTextNode)
, mOffset(aOffset)
, mStringToInsert(aStringToInsert)
, mEditor(aEditor)
{
}
-InsertTextTxn::~InsertTextTxn()
+InsertTextTransaction::~InsertTextTransaction()
{
}
-NS_IMPL_CYCLE_COLLECTION_INHERITED(InsertTextTxn, EditTxn,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(InsertTextTransaction, EditTxn,
mTextNode)
-NS_IMPL_ADDREF_INHERITED(InsertTextTxn, EditTxn)
-NS_IMPL_RELEASE_INHERITED(InsertTextTxn, EditTxn)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InsertTextTxn)
- if (aIID.Equals(NS_GET_IID(InsertTextTxn))) {
+NS_IMPL_ADDREF_INHERITED(InsertTextTransaction, EditTxn)
+NS_IMPL_RELEASE_INHERITED(InsertTextTransaction, EditTxn)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InsertTextTransaction)
+ if (aIID.Equals(NS_GET_IID(InsertTextTransaction))) {
foundInterface = static_cast<nsITransaction*>(this);
} else
NS_INTERFACE_MAP_END_INHERITING(EditTxn)
NS_IMETHODIMP
-InsertTextTxn::DoTransaction()
+InsertTextTransaction::DoTransaction()
{
nsresult res = mTextNode->InsertData(mOffset, mStringToInsert);
NS_ENSURE_SUCCESS(res, res);
// Only set selection to insertion point if editor gives permission
if (mEditor.GetShouldTxnSetSelection()) {
RefPtr<Selection> selection = mEditor.GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
@@ -62,57 +61,61 @@ InsertTextTxn::DoTransaction()
} else {
// Do nothing - DOM Range gravity will adjust selection
}
return NS_OK;
}
NS_IMETHODIMP
-InsertTextTxn::UndoTransaction()
+InsertTextTransaction::UndoTransaction()
{
return mTextNode->DeleteData(mOffset, mStringToInsert.Length());
}
NS_IMETHODIMP
-InsertTextTxn::Merge(nsITransaction* aTransaction, bool* aDidMerge)
+InsertTextTransaction::Merge(nsITransaction* aTransaction,
+ bool* aDidMerge)
{
if (!aTransaction || !aDidMerge) {
return NS_OK;
}
// Set out param default value
*aDidMerge = false;
- // If aTransaction is a InsertTextTxn, and if the selection hasn't changed,
- // then absorb it
- RefPtr<InsertTextTxn> otherInsTxn = do_QueryObject(aTransaction);
- if (otherInsTxn && IsSequentialInsert(*otherInsTxn)) {
+ // If aTransaction is a InsertTextTransaction, and if the selection hasn't
+ // changed, then absorb it.
+ RefPtr<InsertTextTransaction> otherTransaction = do_QueryObject(aTransaction);
+ if (otherTransaction && IsSequentialInsert(*otherTransaction)) {
nsAutoString otherData;
- otherInsTxn->GetData(otherData);
+ otherTransaction->GetData(otherData);
mStringToInsert += otherData;
*aDidMerge = true;
}
return NS_OK;
}
NS_IMETHODIMP
-InsertTextTxn::GetTxnDescription(nsAString& aString)
+InsertTextTransaction::GetTxnDescription(nsAString& aString)
{
- aString.AssignLiteral("InsertTextTxn: ");
+ aString.AssignLiteral("InsertTextTransaction: ");
aString += mStringToInsert;
return NS_OK;
}
/* ============ private methods ================== */
void
-InsertTextTxn::GetData(nsString& aResult)
+InsertTextTransaction::GetData(nsString& aResult)
{
aResult = mStringToInsert;
}
bool
-InsertTextTxn::IsSequentialInsert(InsertTextTxn& aOtherTxn)
+InsertTextTransaction::IsSequentialInsert(
+ InsertTextTransaction& aOtherTransaction)
{
- return aOtherTxn.mTextNode == mTextNode &&
- aOtherTxn.mOffset == mOffset + mStringToInsert.Length();
+ return aOtherTransaction.mTextNode == mTextNode &&
+ aOtherTransaction.mOffset == mOffset + mStringToInsert.Length();
}
+
+} // namespace mozilla
rename from editor/libeditor/InsertTextTxn.h
rename to editor/libeditor/InsertTextTransaction.h
--- a/editor/libeditor/InsertTextTxn.h
+++ b/editor/libeditor/InsertTextTransaction.h
@@ -1,78 +1,81 @@
/* -*- 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 InsertTextTxn_h__
-#define InsertTextTxn_h__
+#ifndef InsertTextTransaction_h
+#define InsertTextTransaction_h
#include "EditTxn.h" // base class
#include "nsCycleCollectionParticipant.h" // various macros
#include "nsID.h" // NS_DECLARE_STATIC_IID_ACCESSOR
#include "nsISupportsImpl.h" // NS_DECL_ISUPPORTS_INHERITED
#include "nsString.h" // nsString members
#include "nscore.h" // NS_IMETHOD, nsAString
class nsEditor;
class nsITransaction;
#define NS_INSERTTEXTTXN_IID \
{ 0x8c9ad77f, 0x22a7, 0x4d01, \
{ 0xb1, 0x59, 0x8a, 0x0f, 0xdb, 0x1d, 0x08, 0xe9 } }
namespace mozilla {
+
namespace dom {
-
class Text;
+} // namespace dom
/**
- * A transaction that inserts text into a content node.
- */
-class InsertTextTxn : public EditTxn
+ * A transaction that inserts text into a content node.
+ */
+class InsertTextTransaction final : public EditTxn
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INSERTTEXTTXN_IID)
- /** @param aElement the text content node
- * @param aOffset the location in aElement to do the insertion
- * @param aString the new text to insert
- * @param aPresShell used to get and set the selection
- */
- InsertTextTxn(Text& aTextNode, uint32_t aOffset, const nsAString& aString,
- nsEditor& aEditor);
+ /**
+ * @param aElement The text content node.
+ * @param aOffset The location in aElement to do the insertion.
+ * @param aString The new text to insert.
+ * @param aPresShell Used to get and set the selection.
+ */
+ InsertTextTransaction(dom::Text& aTextNode, uint32_t aOffset,
+ const nsAString& aString, nsEditor& aEditor);
NS_DECL_ISUPPORTS_INHERITED
- NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertTextTxn, EditTxn)
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertTextTransaction, EditTxn)
NS_DECL_EDITTXN
NS_IMETHOD Merge(nsITransaction* aTransaction, bool* aDidMerge) override;
- /** Return the string data associated with this transaction */
+ /**
+ * Return the string data associated with this transaction.
+ */
void GetData(nsString& aResult);
private:
- virtual ~InsertTextTxn();
+ virtual ~InsertTextTransaction();
- /** Return true if aOtherTxn immediately follows this txn */
- bool IsSequentialInsert(InsertTextTxn& aOtherTxn);
+ // Return true if aOtherTransaction immediately follows this transaction.
+ bool IsSequentialInsert(InsertTextTransaction& aOtherTrasaction);
- /** The Text node to operate upon */
- RefPtr<Text> mTextNode;
+ // The Text node to operate upon.
+ RefPtr<dom::Text> mTextNode;
- /** The offset into mTextNode where the insertion is to take place */
+ // The offset into mTextNode where the insertion is to take place.
uint32_t mOffset;
- /** The text to insert into mTextNode at mOffset */
+ // The text to insert into mTextNode at mOffset.
nsString mStringToInsert;
- /** The editor, which we'll need to get the selection */
+ // The editor, which we'll need to get the selection.
nsEditor& mEditor;
};
-NS_DEFINE_STATIC_IID_ACCESSOR(InsertTextTxn, NS_INSERTTEXTTXN_IID)
+NS_DEFINE_STATIC_IID_ACCESSOR(InsertTextTransaction, NS_INSERTTEXTTXN_IID)
-} // namespace dom
} // namespace mozilla
-#endif
+#endif // #ifndef InsertTextTransaction_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -21,17 +21,17 @@ UNIFIED_SOURCES += [
'DeleteNodeTransaction.cpp',
'DeleteRangeTransaction.cpp',
'DeleteTextTransaction.cpp',
'EditAggregateTxn.cpp',
'EditorUtils.cpp',
'EditTxn.cpp',
'HTMLEditUtils.cpp',
'InsertNodeTransaction.cpp',
- 'InsertTextTxn.cpp',
+ 'InsertTextTransaction.cpp',
'JoinNodeTxn.cpp',
'nsEditor.cpp',
'nsEditorCommands.cpp',
'nsEditorController.cpp',
'nsEditorEventListener.cpp',
'nsHTMLAbsPosition.cpp',
'nsHTMLAnonymousUtils.cpp',
'nsHTMLCSSUtils.cpp',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -15,17 +15,17 @@
#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 "InsertNodeTransaction.h" // for InsertNodeTransaction
-#include "InsertTextTxn.h" // for InsertTextTxn
+#include "InsertTextTransaction.h" // for InsertTextTransaction
#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
#include "mozilla/IMEStateManager.h" // for IMEStateManager
@@ -2572,25 +2572,24 @@ nsEditor::NotifyDocumentListeners(TDocum
default:
NS_NOTREACHED("Unknown notification");
}
return rv;
}
-already_AddRefed<InsertTextTxn>
+already_AddRefed<InsertTextTransaction>
nsEditor::CreateTxnForInsertText(const nsAString& aStringToInsert,
Text& aTextNode, int32_t aOffset)
{
- RefPtr<InsertTextTxn> txn = new InsertTextTxn(aTextNode, aOffset,
- aStringToInsert, *this);
- return txn.forget();
-}
-
+ RefPtr<InsertTextTransaction> transaction =
+ new InsertTextTransaction(aTextNode, aOffset, aStringToInsert, *this);
+ return transaction.forget();
+}
nsresult
nsEditor::DeleteText(nsGenericDOMDataNode& aCharData, uint32_t aOffset,
uint32_t aLength)
{
RefPtr<DeleteTextTransaction> transaction =
CreateTxnForDeleteText(aCharData, aOffset, aLength);
NS_ENSURE_STATE(transaction);
--- a/editor/libeditor/nsEditor.h
+++ b/editor/libeditor/nsEditor.h
@@ -58,24 +58,24 @@ class AutoSelectionRestorer;
class AutoTransactionsConserveSelection;
class ChangeAttributeTransaction;
class CompositionTransaction;
class CreateElementTransaction;
class DeleteNodeTransaction;
class DeleteTextTransaction;
class ErrorResult;
class InsertNodeTransaction;
+class InsertTextTransaction;
class TextComposition;
struct EditorDOMPoint;
namespace dom {
class DataTransfer;
class Element;
class EventTarget;
-class InsertTextTxn;
class JoinNodeTxn;
class Selection;
class SplitNodeTxn;
class Text;
} // namespace dom
} // namespace mozilla
namespace mozilla {
@@ -299,17 +299,17 @@ protected:
nsINode** aNode,
int32_t* aOffset,
int32_t* aLength);
/** Create a transaction for inserting aStringToInsert into aTextNode. Never
* returns null.
*/
- already_AddRefed<mozilla::dom::InsertTextTxn>
+ already_AddRefed<mozilla::InsertTextTransaction>
CreateTxnForInsertText(const nsAString& aStringToInsert, Text& aTextNode,
int32_t aOffset);
// Never returns null.
already_AddRefed<mozilla::CompositionTransaction>
CreateTxnForComposition(const nsAString& aStringToInsert);
/** create a transaction for adding a style sheet