From 539c6ed3e345cfed8715d1b897d64346e5ffc48e Mon Sep 17 00:00:00 2001 From: "peterv%propagandism.org" Date: Thu, 11 Jan 2007 14:38:02 +0000 Subject: [PATCH] Part of fix for bug 340674 (Clean up some editor transactions code). r=glazman, sr=jst. git-svn-id: svn://10.0.0.236/trunk@218197 18797224-902f-48f8-a5cc-f745e15eee43 --- .../libeditor/base/ChangeAttributeTxn.cpp | 11 ----- .../libeditor/base/ChangeAttributeTxn.h | 12 +----- .../base/ChangeCSSInlineStyleTxn.cpp | 22 ---------- .../libeditor/base/ChangeCSSInlineStyleTxn.h | 23 +--------- .../libeditor/base/CreateElementTxn.cpp | 11 ----- .../editor/libeditor/base/CreateElementTxn.h | 13 +----- .../libeditor/base/DeleteElementTxn.cpp | 12 ------ .../editor/libeditor/base/DeleteElementTxn.h | 13 +----- .../editor/libeditor/base/DeleteRangeTxn.cpp | 11 ----- .../editor/libeditor/base/DeleteRangeTxn.h | 13 +----- .../editor/libeditor/base/DeleteTextTxn.cpp | 11 ----- mozilla/editor/libeditor/base/DeleteTextTxn.h | 10 +---- .../libeditor/base/EditAggregateTxn.cpp | 24 ----------- .../editor/libeditor/base/EditAggregateTxn.h | 16 ++----- mozilla/editor/libeditor/base/EditTxn.cpp | 36 +++++----------- mozilla/editor/libeditor/base/EditTxn.h | 25 ++++------- mozilla/editor/libeditor/base/IMETextTxn.cpp | 5 --- mozilla/editor/libeditor/base/IMETextTxn.h | 9 +--- .../libeditor/base/InsertElementTxn.cpp | 11 ----- .../editor/libeditor/base/InsertElementTxn.h | 11 +---- .../editor/libeditor/base/InsertTextTxn.cpp | 4 -- mozilla/editor/libeditor/base/InsertTextTxn.h | 10 +---- .../editor/libeditor/base/JoinElementTxn.cpp | 18 -------- .../editor/libeditor/base/JoinElementTxn.h | 15 +------ .../editor/libeditor/base/PlaceholderTxn.cpp | 27 +----------- .../editor/libeditor/base/PlaceholderTxn.h | 15 ++----- .../editor/libeditor/base/SetDocTitleTxn.cpp | 11 ----- .../editor/libeditor/base/SetDocTitleTxn.h | 14 +------ .../editor/libeditor/base/SplitElementTxn.cpp | 11 ----- .../editor/libeditor/base/SplitElementTxn.h | 10 +---- .../libeditor/base/nsStyleSheetTxns.cpp | 42 ------------------- .../editor/libeditor/base/nsStyleSheetTxns.h | 26 +----------- 32 files changed, 47 insertions(+), 455 deletions(-) diff --git a/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp b/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp index d5568f07e21..c96ef5a8008 100644 --- a/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp +++ b/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp @@ -43,10 +43,6 @@ ChangeAttributeTxn::ChangeAttributeTxn() { } -ChangeAttributeTxn::~ChangeAttributeTxn() -{ -} - NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor, nsIDOMElement *aElement, const nsAString& aAttribute, @@ -115,13 +111,6 @@ NS_IMETHODIMP ChangeAttributeTxn::RedoTransaction(void) return result; } -NS_IMETHODIMP ChangeAttributeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - if (aDidMerge) - *aDidMerge=PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP ChangeAttributeTxn::GetTxnDescription(nsAString& aString) { aString.AssignLiteral("ChangeAttributeTxn: [mRemoveAttribute == "); diff --git a/mozilla/editor/libeditor/base/ChangeAttributeTxn.h b/mozilla/editor/libeditor/base/ChangeAttributeTxn.h index af8b4ae3e20..5d98b61434d 100644 --- a/mozilla/editor/libeditor/base/ChangeAttributeTxn.h +++ b/mozilla/editor/libeditor/base/ChangeAttributeTxn.h @@ -58,8 +58,6 @@ public: static const nsIID& GetCID() { static const nsIID iid = CHANGE_ATTRIBUTE_TXN_CID; return iid; } - virtual ~ChangeAttributeTxn(); - /** Initialize the transaction. * @param aEditor the object providing core editing operations * @param aNode the node whose attribute will be changed @@ -78,15 +76,9 @@ private: public: - NS_IMETHOD DoTransaction(void); + NS_DECL_EDITTXN - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD RedoTransaction(void); - - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); + NS_IMETHOD RedoTransaction(); protected: diff --git a/mozilla/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp b/mozilla/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp index 36d46a2a25f..70364c82d3d 100644 --- a/mozilla/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp +++ b/mozilla/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp @@ -47,17 +47,6 @@ #define kNullCh (PRUnichar('\0')) -void -ChangeCSSInlineStyleTxn::AppendDeclaration(nsAString & aOutputString, - const nsAString & aProperty, - const nsAString & aValues) -{ - aOutputString.Append(aProperty - + NS_LITERAL_STRING(": ") - + aValues - + NS_LITERAL_STRING("; ")); -} - // answers true if aValue is in the string list of white-space separated values aValueList // a case-sensitive search is performed if aCaseSensitive is true PRBool @@ -143,10 +132,6 @@ ChangeCSSInlineStyleTxn::ChangeCSSInlineStyleTxn() { } -ChangeCSSInlineStyleTxn::~ChangeCSSInlineStyleTxn() -{ -} - NS_IMETHODIMP ChangeCSSInlineStyleTxn::Init(nsIEditor *aEditor, nsIDOMElement *aElement, nsIAtom *aProperty, @@ -307,13 +292,6 @@ NS_IMETHODIMP ChangeCSSInlineStyleTxn::RedoTransaction(void) return SetStyle(mRedoAttributeWasSet, mRedoValue); } -NS_IMETHODIMP ChangeCSSInlineStyleTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - if (aDidMerge) - *aDidMerge = PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP ChangeCSSInlineStyleTxn::GetTxnDescription(nsAString& aString) { aString.AssignLiteral("ChangeCSSInlineStyleTxn: [mRemoveProperty == "); diff --git a/mozilla/editor/libeditor/base/ChangeCSSInlineStyleTxn.h b/mozilla/editor/libeditor/base/ChangeCSSInlineStyleTxn.h index bb9e4a543ff..153eabc265a 100644 --- a/mozilla/editor/libeditor/base/ChangeCSSInlineStyleTxn.h +++ b/mozilla/editor/libeditor/base/ChangeCSSInlineStyleTxn.h @@ -59,8 +59,6 @@ public: static const nsIID& GetCID() { static const nsIID iid = CHANGE_CSSINLINESTYLE_TXN_CID; return iid; } - virtual ~ChangeCSSInlineStyleTxn(); - /** Initialize the transaction. * @param aEditor [IN] the object providing core editing operations * @param aNode [IN] the node whose style attribute will be changed @@ -106,16 +104,6 @@ private: */ void RemoveValueFromListOfValues(nsAString & aValues, const nsAString & aRemoveValue); - /** appends 'property : value' to the string - * - * @param aOutputString [IN/OUT] the string - * @param aPropert [IN] the css property string - * @param aValues [IN] the value string for the css property - */ - void AppendDeclaration(nsAString & aOutputString, - const nsAString & aProperty, - const nsAString & aValues); - /** If the boolean is true and if the value is not the empty string, * set the property in the transaction to that value; if the value * is empty, remove the property from element's styles. If the boolean @@ -124,16 +112,9 @@ private: nsresult SetStyle(PRBool aAttributeWasSet, nsAString & aValue); public: + NS_DECL_EDITTXN - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD RedoTransaction(void); - - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); + NS_IMETHOD RedoTransaction(); protected: diff --git a/mozilla/editor/libeditor/base/CreateElementTxn.cpp b/mozilla/editor/libeditor/base/CreateElementTxn.cpp index c424c38bb23..8521105d2de 100644 --- a/mozilla/editor/libeditor/base/CreateElementTxn.cpp +++ b/mozilla/editor/libeditor/base/CreateElementTxn.cpp @@ -80,10 +80,6 @@ NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor, } -CreateElementTxn::~CreateElementTxn() -{ -} - NS_IMETHODIMP CreateElementTxn::DoTransaction(void) { #ifdef NS_DEBUG @@ -220,13 +216,6 @@ NS_IMETHODIMP CreateElementTxn::RedoTransaction(void) return mParent->InsertBefore(mNewNode, mRefNode, getter_AddRefs(resultNode)); } -NS_IMETHODIMP CreateElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - if (aDidMerge) - *aDidMerge=PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP CreateElementTxn::GetTxnDescription(nsAString& aString) { aString.AssignLiteral("CreateElementTxn: "); diff --git a/mozilla/editor/libeditor/base/CreateElementTxn.h b/mozilla/editor/libeditor/base/CreateElementTxn.h index 7825d284bc7..8b452ccf9ed 100644 --- a/mozilla/editor/libeditor/base/CreateElementTxn.h +++ b/mozilla/editor/libeditor/base/CreateElementTxn.h @@ -75,18 +75,9 @@ private: CreateElementTxn(); public: + NS_DECL_EDITTXN - virtual ~CreateElementTxn(); - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD RedoTransaction(void); - - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); + NS_IMETHOD RedoTransaction(); NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); diff --git a/mozilla/editor/libeditor/base/DeleteElementTxn.cpp b/mozilla/editor/libeditor/base/DeleteElementTxn.cpp index 34a86778a99..9ea120068a6 100644 --- a/mozilla/editor/libeditor/base/DeleteElementTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteElementTxn.cpp @@ -68,10 +68,6 @@ NS_IMETHODIMP DeleteElementTxn::Init(nsIDOMNode *aElement, } -DeleteElementTxn::~DeleteElementTxn() -{ -} - NS_IMETHODIMP DeleteElementTxn::DoTransaction(void) { #ifdef NS_DEBUG @@ -173,14 +169,6 @@ NS_IMETHODIMP DeleteElementTxn::RedoTransaction(void) return mParent->RemoveChild(mElement, getter_AddRefs(resultNode)); } - -NS_IMETHODIMP DeleteElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - if (aDidMerge) - *aDidMerge = PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP DeleteElementTxn::GetTxnDescription(nsAString& aString) { aString.AssignLiteral("DeleteElementTxn"); diff --git a/mozilla/editor/libeditor/base/DeleteElementTxn.h b/mozilla/editor/libeditor/base/DeleteElementTxn.h index 012cb85e3c2..14610eef383 100644 --- a/mozilla/editor/libeditor/base/DeleteElementTxn.h +++ b/mozilla/editor/libeditor/base/DeleteElementTxn.h @@ -68,18 +68,9 @@ private: DeleteElementTxn(); public: + NS_DECL_EDITTXN - virtual ~DeleteElementTxn(); - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD RedoTransaction(void); - - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); + NS_IMETHOD RedoTransaction(); protected: diff --git a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp index 36ba0909cb5..abbdbe73ce1 100644 --- a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp @@ -128,10 +128,6 @@ NS_IMETHODIMP DeleteRangeTxn::Init(nsIEditor *aEditor, } -DeleteRangeTxn::~DeleteRangeTxn() -{ -} - NS_IMETHODIMP DeleteRangeTxn::DoTransaction(void) { #ifdef NS_DEBUG @@ -214,13 +210,6 @@ NS_IMETHODIMP DeleteRangeTxn::RedoTransaction(void) return EditAggregateTxn::RedoTransaction(); } -NS_IMETHODIMP DeleteRangeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - if (aDidMerge) - *aDidMerge = PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP DeleteRangeTxn::GetTxnDescription(nsAString& aString) { aString.AssignLiteral("DeleteRangeTxn"); diff --git a/mozilla/editor/libeditor/base/DeleteRangeTxn.h b/mozilla/editor/libeditor/base/DeleteRangeTxn.h index 56637b44857..d24ed8f4ae1 100644 --- a/mozilla/editor/libeditor/base/DeleteRangeTxn.h +++ b/mozilla/editor/libeditor/base/DeleteRangeTxn.h @@ -74,18 +74,9 @@ private: DeleteRangeTxn(); public: + NS_DECL_EDITTXN - virtual ~DeleteRangeTxn(); - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD RedoTransaction(void); - - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); + NS_IMETHOD RedoTransaction(); protected: diff --git a/mozilla/editor/libeditor/base/DeleteTextTxn.cpp b/mozilla/editor/libeditor/base/DeleteTextTxn.cpp index 5b1e014222f..e5e3f84fbb1 100644 --- a/mozilla/editor/libeditor/base/DeleteTextTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteTextTxn.cpp @@ -54,10 +54,6 @@ DeleteTextTxn::DeleteTextTxn() { } -DeleteTextTxn::~DeleteTextTxn() -{ -} - NS_IMETHODIMP DeleteTextTxn::Init(nsIEditor *aEditor, nsIDOMCharacterData *aElement, PRUint32 aOffset, @@ -131,13 +127,6 @@ NS_IMETHODIMP DeleteTextTxn::UndoTransaction(void) return mElement->InsertData(mOffset, mDeletedText); } -NS_IMETHODIMP DeleteTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - if (aDidMerge) - *aDidMerge = PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP DeleteTextTxn::GetTxnDescription(nsAString& aString) { aString.AssignLiteral("DeleteTextTxn: "); diff --git a/mozilla/editor/libeditor/base/DeleteTextTxn.h b/mozilla/editor/libeditor/base/DeleteTextTxn.h index e53a7a6be47..f655119efad 100644 --- a/mozilla/editor/libeditor/base/DeleteTextTxn.h +++ b/mozilla/editor/libeditor/base/DeleteTextTxn.h @@ -75,15 +75,7 @@ private: DeleteTextTxn(); public: - virtual ~DeleteTextTxn(); - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); + NS_DECL_EDITTXN PRUint32 GetOffset() { return mOffset; } diff --git a/mozilla/editor/libeditor/base/EditAggregateTxn.cpp b/mozilla/editor/libeditor/base/EditAggregateTxn.cpp index 8cd19534f5f..936d42ff622 100644 --- a/mozilla/editor/libeditor/base/EditAggregateTxn.cpp +++ b/mozilla/editor/libeditor/base/EditAggregateTxn.cpp @@ -45,11 +45,6 @@ EditAggregateTxn::EditAggregateTxn() NS_POSTCONDITION(NS_SUCCEEDED(res), "EditAggregateTxn failed in constructor"); } -EditAggregateTxn::~EditAggregateTxn() -{ - // nsISupportsArray cleans up array for us at destruct time -} - NS_IMETHODIMP EditAggregateTxn::DoTransaction(void) { nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list @@ -111,13 +106,6 @@ NS_IMETHODIMP EditAggregateTxn::RedoTransaction(void) return result; } -NS_IMETHODIMP EditAggregateTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP EditAggregateTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list @@ -223,18 +211,6 @@ NS_IMETHODIMP EditAggregateTxn::GetName(nsIAtom **aName) return NS_ERROR_NULL_POINTER; } -NS_IMETHODIMP_(nsrefcnt) EditAggregateTxn::AddRef(void) -{ - return EditTxn::AddRef(); -} - -//NS_IMPL_RELEASE_INHERITED(Class, Super) -NS_IMETHODIMP_(nsrefcnt) EditAggregateTxn::Release(void) -{ - return EditTxn::Release(); -} - -//NS_IMPL_QUERY_INTERFACE_INHERITED1(Class, Super, AdditionalInterface) NS_IMETHODIMP EditAggregateTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) { if (!aInstancePtr) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/libeditor/base/EditAggregateTxn.h b/mozilla/editor/libeditor/base/EditAggregateTxn.h index e214cc149c1..db404c5b222 100644 --- a/mozilla/editor/libeditor/base/EditAggregateTxn.h +++ b/mozilla/editor/libeditor/base/EditAggregateTxn.h @@ -56,27 +56,17 @@ class EditAggregateTxn : public EditTxn { public: - - NS_DECL_ISUPPORTS_INHERITED + NS_IMETHOD QueryInterface(REFNSIID aIID, void **aInstancePtr); static const nsIID& GetCID() { static const nsIID cid = EDIT_AGGREGATE_TXN_CID; return cid; } EditAggregateTxn(); - virtual ~EditAggregateTxn(); - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD RedoTransaction(void); - - NS_IMETHOD GetIsTransient(PRBool *aIsTransient); + NS_DECL_EDITTXN + NS_IMETHOD RedoTransaction(); NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); - /** append a transaction to this aggregate */ NS_IMETHOD AppendChild(EditTxn *aTxn); diff --git a/mozilla/editor/libeditor/base/EditTxn.cpp b/mozilla/editor/libeditor/base/EditTxn.cpp index 644829c0139..68d0a70abab 100644 --- a/mozilla/editor/libeditor/base/EditTxn.cpp +++ b/mozilla/editor/libeditor/base/EditTxn.cpp @@ -40,44 +40,28 @@ NS_IMPL_ISUPPORTS2(EditTxn, nsITransaction, nsPIEditorTransaction) -EditTxn::EditTxn() -{ -} - EditTxn::~EditTxn() { } -NS_IMETHODIMP EditTxn::DoTransaction(void) -{ - return NS_OK; -} - -NS_IMETHODIMP EditTxn::UndoTransaction(void) -{ - return NS_OK; -} - -NS_IMETHODIMP EditTxn::RedoTransaction(void) +NS_IMETHODIMP +EditTxn::RedoTransaction(void) { return DoTransaction(); } -NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient) +NS_IMETHODIMP +EditTxn::GetIsTransient(PRBool *aIsTransient) { - if (aIsTransient) - *aIsTransient = PR_FALSE; + *aIsTransient = PR_FALSE; + return NS_OK; } -NS_IMETHODIMP EditTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) +NS_IMETHODIMP +EditTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { + *aDidMerge = PR_FALSE; + return NS_OK; } - -NS_IMETHODIMP EditTxn::GetTxnDescription(nsAString& aString) -{ - aString.AssignLiteral("EditTxn"); - return NS_OK; -} - diff --git a/mozilla/editor/libeditor/base/EditTxn.h b/mozilla/editor/libeditor/base/EditTxn.h index 58e3b06fa86..a71dbbd29e9 100644 --- a/mozilla/editor/libeditor/base/EditTxn.h +++ b/mozilla/editor/libeditor/base/EditTxn.h @@ -40,7 +40,6 @@ #include "nsITransaction.h" #include "nsString.h" -#include "nsCOMPtr.h" #include "nsPIEditorTransaction.h" #define EDIT_TXN_CID \ @@ -49,13 +48,10 @@ {0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } /** - * base class for all document editing transactions. - * provides default concrete behavior for all nsITransaction methods. - * EditTxns optionally have a name. This name is for internal purposes only, - * it is never seen by the user or by any external entity. + * Base class for all document editing transactions. */ -class EditTxn : public nsITransaction - , public nsPIEditorTransaction +class EditTxn : public nsITransaction, + public nsPIEditorTransaction { public: @@ -63,21 +59,16 @@ public: NS_DECL_ISUPPORTS - EditTxn(); virtual ~EditTxn(); - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - NS_IMETHOD RedoTransaction(void); - NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); }; +#define NS_DECL_EDITTXN \ + NS_IMETHOD DoTransaction(); \ + NS_IMETHOD UndoTransaction(); \ + NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); + #endif diff --git a/mozilla/editor/libeditor/base/IMETextTxn.cpp b/mozilla/editor/libeditor/base/IMETextTxn.cpp index 281247ec6af..d1e9e459d67 100644 --- a/mozilla/editor/libeditor/base/IMETextTxn.cpp +++ b/mozilla/editor/libeditor/base/IMETextTxn.cpp @@ -52,11 +52,6 @@ IMETextTxn::IMETextTxn() { } -IMETextTxn::~IMETextTxn() -{ - mRangeList = do_QueryInterface(nsnull); -} - NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement, PRUint32 aOffset, PRUint32 aReplaceLength, diff --git a/mozilla/editor/libeditor/base/IMETextTxn.h b/mozilla/editor/libeditor/base/IMETextTxn.h index 73801ad3492..cfd3578bb0f 100644 --- a/mozilla/editor/libeditor/base/IMETextTxn.h +++ b/mozilla/editor/libeditor/base/IMETextTxn.h @@ -63,8 +63,6 @@ class IMETextTxn : public EditTxn public: static const nsIID& GetCID() { static const nsIID iid = IME_TEXT_TXN_CID; return iid; } - virtual ~IMETextTxn(); - /** initialize the transaction * @param aElement the text content node * @param aOffset the location in aElement to do the insertion @@ -84,15 +82,10 @@ private: IMETextTxn(); public: - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); + NS_DECL_EDITTXN NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); - NS_IMETHOD MarkFixed(void); // nsISupports declarations diff --git a/mozilla/editor/libeditor/base/InsertElementTxn.cpp b/mozilla/editor/libeditor/base/InsertElementTxn.cpp index d365d2522f2..040631c4e95 100644 --- a/mozilla/editor/libeditor/base/InsertElementTxn.cpp +++ b/mozilla/editor/libeditor/base/InsertElementTxn.cpp @@ -70,10 +70,6 @@ NS_IMETHODIMP InsertElementTxn::Init(nsIDOMNode *aNode, } -InsertElementTxn::~InsertElementTxn() -{ -} - NS_IMETHODIMP InsertElementTxn::DoTransaction(void) { #ifdef NS_DEBUG @@ -148,13 +144,6 @@ NS_IMETHODIMP InsertElementTxn::UndoTransaction(void) return mParent->RemoveChild(mNode, getter_AddRefs(resultNode)); } -NS_IMETHODIMP InsertElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - if (aDidMerge) - *aDidMerge = PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP InsertElementTxn::GetTxnDescription(nsAString& aString) { aString.AssignLiteral("InsertElementTxn"); diff --git a/mozilla/editor/libeditor/base/InsertElementTxn.h b/mozilla/editor/libeditor/base/InsertElementTxn.h index d41c9da0362..a2cfa59588a 100644 --- a/mozilla/editor/libeditor/base/InsertElementTxn.h +++ b/mozilla/editor/libeditor/base/InsertElementTxn.h @@ -71,16 +71,7 @@ private: InsertElementTxn(); public: - - virtual ~InsertElementTxn(); - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); + NS_DECL_EDITTXN protected: diff --git a/mozilla/editor/libeditor/base/InsertTextTxn.cpp b/mozilla/editor/libeditor/base/InsertTextTxn.cpp index bef5a822fb9..3b4767ba308 100644 --- a/mozilla/editor/libeditor/base/InsertTextTxn.cpp +++ b/mozilla/editor/libeditor/base/InsertTextTxn.cpp @@ -49,10 +49,6 @@ InsertTextTxn::InsertTextTxn() { } -InsertTextTxn::~InsertTextTxn() -{ -} - NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement, PRUint32 aOffset, const nsAString &aStringToInsert, diff --git a/mozilla/editor/libeditor/base/InsertTextTxn.h b/mozilla/editor/libeditor/base/InsertTextTxn.h index 47cead1d1c2..cab137b2d35 100644 --- a/mozilla/editor/libeditor/base/InsertTextTxn.h +++ b/mozilla/editor/libeditor/base/InsertTextTxn.h @@ -48,8 +48,6 @@ 0x93276f00, 0xab2c, 0x11d2, \ {0x8f, 0xb4, 0x0, 0x60, 0x8, 0x15, 0x9b, 0xc} } -class nsIPresShell; - /** * A transaction that inserts text into a content node. */ @@ -59,8 +57,6 @@ public: static const nsIID& GetCID() { static const nsIID iid = INSERT_TEXT_TXN_CID; return iid; } - virtual ~InsertTextTxn(); - /** initialize the transaction * @param aElement the text content node * @param aOffset the location in aElement to do the insertion @@ -78,14 +74,10 @@ private: public: - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); + NS_DECL_EDITTXN NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); - // nsISupports declarations // override QueryInterface to handle InsertTextTxn request diff --git a/mozilla/editor/libeditor/base/JoinElementTxn.cpp b/mozilla/editor/libeditor/base/JoinElementTxn.cpp index 424be2b7343..e0d631777af 100644 --- a/mozilla/editor/libeditor/base/JoinElementTxn.cpp +++ b/mozilla/editor/libeditor/base/JoinElementTxn.cpp @@ -62,10 +62,6 @@ NS_IMETHODIMP JoinElementTxn::Init(nsEditor *aEditor, return NS_OK; } -JoinElementTxn::~JoinElementTxn() -{ -} - // After DoTransaction() and RedoTransaction(), the left node is removed from the content tree and right node remains. NS_IMETHODIMP JoinElementTxn::DoTransaction(void) { @@ -162,20 +158,6 @@ NS_IMETHODIMP JoinElementTxn::UndoTransaction(void) } -NS_IMETHODIMP JoinElementTxn::GetIsTransient(PRBool *aIsTransient) -{ - if (aIsTransient) - *aIsTransient = PR_FALSE; - return NS_OK; -} - -nsresult JoinElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - if (aDidMerge) - *aDidMerge = PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP JoinElementTxn::GetTxnDescription(nsAString& aString) { aString.AssignLiteral("JoinElementTxn"); diff --git a/mozilla/editor/libeditor/base/JoinElementTxn.h b/mozilla/editor/libeditor/base/JoinElementTxn.h index 400f439147c..dbfd601d22c 100644 --- a/mozilla/editor/libeditor/base/JoinElementTxn.h +++ b/mozilla/editor/libeditor/base/JoinElementTxn.h @@ -75,20 +75,7 @@ protected: JoinElementTxn(); public: - - virtual ~JoinElementTxn(); - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - -// NS_IMETHOD RedoTransaction(void); - - NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); + NS_DECL_EDITTXN protected: diff --git a/mozilla/editor/libeditor/base/PlaceholderTxn.cpp b/mozilla/editor/libeditor/base/PlaceholderTxn.cpp index 67dd1bba47d..818385f79c1 100644 --- a/mozilla/editor/libeditor/base/PlaceholderTxn.cpp +++ b/mozilla/editor/libeditor/base/PlaceholderTxn.cpp @@ -52,31 +52,8 @@ PlaceholderTxn::PlaceholderTxn() : EditAggregateTxn(), } -PlaceholderTxn::~PlaceholderTxn() -{ - delete mStartSel; -} - -NS_IMPL_ADDREF_INHERITED(PlaceholderTxn, EditAggregateTxn) -NS_IMPL_RELEASE_INHERITED(PlaceholderTxn, EditAggregateTxn) - -//NS_IMPL_QUERY_INTERFACE_INHERITED1(Class, Super, AdditionalInterface) -NS_IMETHODIMP PlaceholderTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) -{ - if (!aInstancePtr) return NS_ERROR_NULL_POINTER; - - if (aIID.Equals(NS_GET_IID(nsIAbsorbingTransaction))) { - *aInstancePtr = (nsISupports*)(nsIAbsorbingTransaction*)(this); - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsISupportsWeakReference))) { - *aInstancePtr = (nsISupports*)(nsISupportsWeakReference*) this; - NS_ADDREF_THIS(); - return NS_OK; - } - return EditAggregateTxn::QueryInterface(aIID, aInstancePtr); -} +NS_IMPL_ISUPPORTS_INHERITED2(PlaceholderTxn, EditAggregateTxn, + nsIAbsorbingTransaction, nsISupportsWeakReference) NS_IMETHODIMP PlaceholderTxn::Init(nsIAtom *aName, nsSelectionState *aSelState, nsIEditor *aEditor) { diff --git a/mozilla/editor/libeditor/base/PlaceholderTxn.h b/mozilla/editor/libeditor/base/PlaceholderTxn.h index 5c4ca311ca5..4eb481a9fd2 100644 --- a/mozilla/editor/libeditor/base/PlaceholderTxn.h +++ b/mozilla/editor/libeditor/base/PlaceholderTxn.h @@ -45,6 +45,7 @@ #include "nsCOMPtr.h" #include "nsWeakPtr.h" #include "nsWeakReference.h" +#include "nsAutoPtr.h" #define PLACEHOLDER_TXN_CID \ {/* {0CE9FB00-D9D1-11d2-86DE-000064657374} */ \ @@ -75,21 +76,13 @@ private: PlaceholderTxn(); public: - - virtual ~PlaceholderTxn(); - // ------------ EditAggregateTxn ----------------------- - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD RedoTransaction(void); + NS_DECL_EDITTXN + NS_IMETHOD RedoTransaction(); NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); - // ------------ nsIAbsorbingTransaction ----------------------- NS_IMETHOD Init(nsIAtom *aName, nsSelectionState *aSelState, nsIEditor *aEditor); @@ -120,7 +113,7 @@ protected: // selection at the start of the txn is stored, as is the selection at the end. // This is so that UndoTransaction() and RedoTransaction() can restore the // selection properly. - nsSelectionState *mStartSel; // use a pointer because this is constructed before we exist + nsAutoPtr mStartSel; // use a pointer because this is constructed before we exist nsSelectionState mEndSel; nsIEditor* mEditor; /** the editor for this transaction */ }; diff --git a/mozilla/editor/libeditor/base/SetDocTitleTxn.cpp b/mozilla/editor/libeditor/base/SetDocTitleTxn.cpp index aeb9314f393..5dc9f856c3d 100644 --- a/mozilla/editor/libeditor/base/SetDocTitleTxn.cpp +++ b/mozilla/editor/libeditor/base/SetDocTitleTxn.cpp @@ -64,10 +64,6 @@ NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor, return NS_OK; } -SetDocTitleTxn::~SetDocTitleTxn() -{ -} - NS_IMETHODIMP SetDocTitleTxn::DoTransaction(void) { nsresult res = SetDomTitle(mValue); @@ -217,13 +213,6 @@ nsresult SetDocTitleTxn::SetDomTitle(const nsAString& aTitle) return res; } -NS_IMETHODIMP SetDocTitleTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - if (aDidMerge) - *aDidMerge = PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP SetDocTitleTxn::GetTxnDescription(nsAString& aString) { aString.AssignLiteral("SetDocTitleTxn: "); diff --git a/mozilla/editor/libeditor/base/SetDocTitleTxn.h b/mozilla/editor/libeditor/base/SetDocTitleTxn.h index 0806cd274cb..30a1735b460 100644 --- a/mozilla/editor/libeditor/base/SetDocTitleTxn.h +++ b/mozilla/editor/libeditor/base/SetDocTitleTxn.h @@ -60,9 +60,6 @@ public: static const nsIID& GetCID() { static const nsIID iid = SET_DOC_TITLE_TXN_CID; return iid; } - virtual ~SetDocTitleTxn(); - - /** Initialize the transaction. * @param aEditor the object providing core editing operations * @param aValue the new value for document title @@ -75,18 +72,11 @@ private: nsresult SetDomTitle(const nsAString& aTitle); public: - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD RedoTransaction(void); - - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); + NS_DECL_EDITTXN + NS_IMETHOD RedoTransaction(); NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); - protected: /** the editor that created this transaction */ diff --git a/mozilla/editor/libeditor/base/SplitElementTxn.cpp b/mozilla/editor/libeditor/base/SplitElementTxn.cpp index 1ad362f6954..3e16f114b16 100644 --- a/mozilla/editor/libeditor/base/SplitElementTxn.cpp +++ b/mozilla/editor/libeditor/base/SplitElementTxn.cpp @@ -65,10 +65,6 @@ NS_IMETHODIMP SplitElementTxn::Init(nsEditor *aEditor, return NS_OK; } -SplitElementTxn::~SplitElementTxn() -{ -} - NS_IMETHODIMP SplitElementTxn::DoTransaction(void) { #ifdef NS_DEBUG @@ -213,13 +209,6 @@ NS_IMETHODIMP SplitElementTxn::RedoTransaction(void) } -NS_IMETHODIMP SplitElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - if (aDidMerge) - *aDidMerge = PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP SplitElementTxn::GetTxnDescription(nsAString& aString) { aString.AssignLiteral("SplitElementTxn"); diff --git a/mozilla/editor/libeditor/base/SplitElementTxn.h b/mozilla/editor/libeditor/base/SplitElementTxn.h index e3de4ed4856..f9a345693ce 100644 --- a/mozilla/editor/libeditor/base/SplitElementTxn.h +++ b/mozilla/editor/libeditor/base/SplitElementTxn.h @@ -74,18 +74,10 @@ protected: SplitElementTxn(); public: - virtual ~SplitElementTxn(); - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); + NS_DECL_EDITTXN NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); - NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); protected: diff --git a/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp b/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp index e5f1e91dc2e..dc93f803e19 100644 --- a/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp +++ b/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp @@ -79,10 +79,6 @@ AddStyleSheetTxn::AddStyleSheetTxn() { } -AddStyleSheetTxn::~AddStyleSheetTxn() -{ -} - NS_IMETHODIMP AddStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet) { @@ -119,23 +115,6 @@ AddStyleSheetTxn::UndoTransaction() return NS_OK; } -NS_IMETHODIMP -AddStyleSheetTxn::RedoTransaction() -{ - return DoTransaction(); -} - -NS_IMETHODIMP -AddStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - // set out param default value - if (!aDidMerge) - return NS_ERROR_NULL_POINTER; - - *aDidMerge = PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP AddStyleSheetTxn::GetTxnDescription(nsAString& aString) { @@ -154,10 +133,6 @@ RemoveStyleSheetTxn::RemoveStyleSheetTxn() { } -RemoveStyleSheetTxn::~RemoveStyleSheetTxn() -{ -} - NS_IMETHODIMP RemoveStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet) { @@ -194,23 +169,6 @@ RemoveStyleSheetTxn::UndoTransaction() return NS_OK; } -NS_IMETHODIMP -RemoveStyleSheetTxn::RedoTransaction() -{ - return DoTransaction(); -} - -NS_IMETHODIMP -RemoveStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) -{ - // set out param default value - if (!aDidMerge) - return NS_ERROR_NULL_POINTER; - - *aDidMerge = PR_FALSE; - return NS_OK; -} - NS_IMETHODIMP RemoveStyleSheetTxn::GetTxnDescription(nsAString& aString) { diff --git a/mozilla/editor/libeditor/base/nsStyleSheetTxns.h b/mozilla/editor/libeditor/base/nsStyleSheetTxns.h index dc07e91cb52..4f449f451c2 100644 --- a/mozilla/editor/libeditor/base/nsStyleSheetTxns.h +++ b/mozilla/editor/libeditor/base/nsStyleSheetTxns.h @@ -60,8 +60,6 @@ public: static const nsIID& GetCID() { static const nsIID iid = ADD_STYLESHEET_TXN_CID; return iid; } - virtual ~AddStyleSheetTxn(); - /** Initialize the transaction. * @param aEditor the object providing core editing operations * @param aSheet the stylesheet to add @@ -73,16 +71,7 @@ private: AddStyleSheetTxn(); public: - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD RedoTransaction(void); - - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); + NS_DECL_EDITTXN protected: @@ -100,8 +89,6 @@ public: static const nsIID& GetCID() { static const nsIID iid = REMOVE_STYLESHEET_TXN_CID; return iid; } - virtual ~RemoveStyleSheetTxn(); - /** Initialize the transaction. * @param aEditor the object providing core editing operations * @param aSheet the stylesheet to remove @@ -113,16 +100,7 @@ private: RemoveStyleSheetTxn(); public: - - NS_IMETHOD DoTransaction(void); - - NS_IMETHOD UndoTransaction(void); - - NS_IMETHOD RedoTransaction(void); - - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - - NS_IMETHOD GetTxnDescription(nsAString& aTxnDescription); + NS_DECL_EDITTXN protected: