From 1cd9fcb69d3244cc640960770291726c380aee95 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Fri, 24 Apr 2009 15:45:34 -0700 Subject: [PATCH] Remove nsTransactionFactory and most transaction CIDs. (Bug 489851) r+sr=peterv --- editor/libeditor/base/ChangeAttributeTxn.h | 12 -- .../libeditor/base/ChangeCSSInlineStyleTxn.h | 12 +- editor/libeditor/base/CreateElementTxn.h | 13 -- editor/libeditor/base/DeleteElementTxn.h | 13 -- editor/libeditor/base/DeleteRangeTxn.cpp | 33 ++-- editor/libeditor/base/DeleteRangeTxn.h | 13 -- editor/libeditor/base/DeleteTextTxn.h | 13 -- editor/libeditor/base/EditAggregateTxn.cpp | 5 - editor/libeditor/base/EditAggregateTxn.h | 8 - editor/libeditor/base/EditTxn.h | 8 - editor/libeditor/base/IMETextTxn.h | 7 +- editor/libeditor/base/InsertElementTxn.h | 13 -- editor/libeditor/base/InsertTextTxn.h | 7 +- editor/libeditor/base/JoinElementTxn.h | 14 +- editor/libeditor/base/Makefile.in | 1 - editor/libeditor/base/PlaceholderTxn.h | 12 -- editor/libeditor/base/SetDocTitleTxn.h | 12 +- editor/libeditor/base/SplitElementTxn.h | 14 +- editor/libeditor/base/TransactionFactory.cpp | 120 ------------ editor/libeditor/base/TransactionFactory.h | 64 ------- editor/libeditor/base/nsEditor.cpp | 175 ++++++++---------- editor/libeditor/base/nsStyleSheetTxns.h | 23 --- editor/libeditor/html/nsHTMLCSSUtils.cpp | 18 +- editor/libeditor/html/nsHTMLEditor.cpp | 24 +-- 24 files changed, 114 insertions(+), 520 deletions(-) delete mode 100644 editor/libeditor/base/TransactionFactory.cpp delete mode 100644 editor/libeditor/base/TransactionFactory.h diff --git a/editor/libeditor/base/ChangeAttributeTxn.h b/editor/libeditor/base/ChangeAttributeTxn.h index 5d98b61434dc..c8d00cb5745e 100644 --- a/editor/libeditor/base/ChangeAttributeTxn.h +++ b/editor/libeditor/base/ChangeAttributeTxn.h @@ -43,11 +43,6 @@ #include "nsIDOMElement.h" #include "nsIEditor.h" -#define CHANGE_ATTRIBUTE_TXN_CID \ -{/* 97818860-ac48-11d2-86d8-000064657374 */ \ -0x97818860, 0xac48, 0x11d2, \ -{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } - /** * A transaction that changes an attribute of a content node. * This transaction covers add, remove, and change attribute. @@ -55,9 +50,6 @@ class ChangeAttributeTxn : public EditTxn { public: - - static const nsIID& GetCID() { static const nsIID iid = CHANGE_ATTRIBUTE_TXN_CID; return iid; } - /** Initialize the transaction. * @param aEditor the object providing core editing operations * @param aNode the node whose attribute will be changed @@ -71,10 +63,8 @@ public: const nsAString& aValue, PRBool aRemoveAttribute); -private: ChangeAttributeTxn(); -public: NS_DECL_EDITTXN @@ -102,8 +92,6 @@ protected: /** PR_TRUE if the operation is to remove mAttribute from mElement */ PRBool mRemoveAttribute; - - friend class TransactionFactory; }; #endif diff --git a/editor/libeditor/base/ChangeCSSInlineStyleTxn.h b/editor/libeditor/base/ChangeCSSInlineStyleTxn.h index 153eabc265aa..8e16a41b47cb 100644 --- a/editor/libeditor/base/ChangeCSSInlineStyleTxn.h +++ b/editor/libeditor/base/ChangeCSSInlineStyleTxn.h @@ -44,11 +44,6 @@ #include "nsIDOMElement.h" #include "nsIEditor.h" -#define CHANGE_CSSINLINESTYLE_TXN_CID \ -{/* a2185c9e-1dd1-11b2-88d6-d89704bf7a5a */ \ -0xa2185c9e, 0x1dd1, 0x11b2, \ -{0x88, 0xd6, 0xd8, 0x97, 0x04, 0xbf, 0x7a, 0x5a} } - /** * A transaction that changes the value of a CSS inline style of a content node. * This transaction covers add, remove, and change a property's value. @@ -56,9 +51,6 @@ class ChangeCSSInlineStyleTxn : public EditTxn { public: - - static const nsIID& GetCID() { static const nsIID iid = CHANGE_CSSINLINESTYLE_TXN_CID; return iid; } - /** Initialize the transaction. * @param aEditor [IN] the object providing core editing operations * @param aNode [IN] the node whose style attribute will be changed @@ -88,9 +80,9 @@ public: */ NS_IMETHOD AddValueToMultivalueProperty(nsAString & aValues, const nsAString & aNewValue); -private: ChangeCSSInlineStyleTxn(); +private: /** returns true if the property accepts more than one value * * @return true if the property accepts more than one value @@ -141,8 +133,6 @@ protected: /** PR_TRUE if the operation is to remove mProperty from mElement */ PRBool mRemoveProperty; - - friend class TransactionFactory; }; #endif diff --git a/editor/libeditor/base/CreateElementTxn.h b/editor/libeditor/base/CreateElementTxn.h index 8b452ccf9ed5..3e449e157402 100644 --- a/editor/libeditor/base/CreateElementTxn.h +++ b/editor/libeditor/base/CreateElementTxn.h @@ -43,20 +43,12 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#define CREATE_ELEMENT_TXN_CID \ -{/* 7a6393c0-ac48-11d2-86d8-000064657374 */ \ -0x7a6393c0, 0xac48, 0x11d2, \ -{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } - /** * A transaction that creates a new node in the content tree. */ class CreateElementTxn : public EditTxn { public: - - static const nsIID& GetCID() { static const nsIID iid = CREATE_ELEMENT_TXN_CID; return iid; } - enum { eAppend=-1 }; /** Initialize the transaction. @@ -71,10 +63,8 @@ public: nsIDOMNode *aParent, PRUint32 aOffsetInParent); -private: CreateElementTxn(); -public: NS_DECL_EDITTXN NS_IMETHOD RedoTransaction(); @@ -100,9 +90,6 @@ protected: /** the node we will insert mNewNode before. We compute this ourselves. */ nsCOMPtr mRefNode; - - friend class TransactionFactory; - }; #endif diff --git a/editor/libeditor/base/DeleteElementTxn.h b/editor/libeditor/base/DeleteElementTxn.h index 0337856d5eed..816b206db568 100644 --- a/editor/libeditor/base/DeleteElementTxn.h +++ b/editor/libeditor/base/DeleteElementTxn.h @@ -44,11 +44,6 @@ #include "nsIEditor.h" #include "nsCOMPtr.h" -#define DELETE_ELEMENT_TXN_CID \ -{/* 6fd77770-ac49-11d2-86d8-000064657374 */ \ -0x6fd77770, 0xac49, 0x11d2, \ -{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } - class nsRangeUpdater; /** @@ -57,18 +52,13 @@ class nsRangeUpdater; class DeleteElementTxn : public EditTxn { public: - - static const nsIID& GetCID() { static const nsIID iid = DELETE_ELEMENT_TXN_CID; return iid; } - /** initialize the transaction. * @param aElement the node to delete */ NS_IMETHOD Init(nsIEditor *aEditor, nsIDOMNode *aElement, nsRangeUpdater *aRangeUpdater); -private: DeleteElementTxn(); -public: NS_DECL_EDITTXN NS_IMETHOD RedoTransaction(); @@ -89,9 +79,6 @@ protected: /** range updater object */ nsRangeUpdater *mRangeUpdater; - - friend class TransactionFactory; - }; #endif diff --git a/editor/libeditor/base/DeleteRangeTxn.cpp b/editor/libeditor/base/DeleteRangeTxn.cpp index d3dae9d2bd42..ec654f29ad97 100644 --- a/editor/libeditor/base/DeleteRangeTxn.cpp +++ b/editor/libeditor/base/DeleteRangeTxn.cpp @@ -43,7 +43,6 @@ #include "nsISelection.h" #include "DeleteTextTxn.h" #include "DeleteElementTxn.h" -#include "TransactionFactory.h" #include "nsIContentIterator.h" #include "nsIContent.h" #include "nsComponentManagerUtils.h" @@ -237,10 +236,9 @@ DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent, nsCOMPtr textNode = do_QueryInterface(aStartParent); if (textNode) { // if the node is a text node, then delete text content - DeleteTextTxn *txn; - result = TransactionFactory::GetNewTransaction(DeleteTextTxn::GetCID(), (EditTxn **)&txn); - if (NS_FAILED(result)) return result; - if (!txn) return NS_ERROR_NULL_POINTER; + nsRefPtr txn = new DeleteTextTxn(); + if (!txn) + return NS_ERROR_OUT_OF_MEMORY; PRInt32 numToDel; if (aStartOffset==aEndOffset) @@ -250,7 +248,6 @@ DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent, result = txn->Init(mEditor, textNode, aStartOffset, numToDel, mRangeUpdater); if (NS_SUCCEEDED(result)) AppendChild(txn); - NS_RELEASE(txn); } else { @@ -272,15 +269,13 @@ DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent, if (NS_FAILED(result)) return result; if (!child) return NS_ERROR_NULL_POINTER; - DeleteElementTxn *txn; - result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)&txn); - if (NS_FAILED(result)) return result; - if (!txn) return NS_ERROR_NULL_POINTER; + nsRefPtr txn = new DeleteElementTxn(); + if (!txn) + return NS_ERROR_OUT_OF_MEMORY; result = txn->Init(mEditor, child, mRangeUpdater); if (NS_SUCCEEDED(result)) AppendChild(txn); - NS_RELEASE(txn); } } return result; @@ -310,15 +305,13 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteContent(nsIDOMNode *aParent, if (numToDelete) { - DeleteTextTxn *txn; - result = TransactionFactory::GetNewTransaction(DeleteTextTxn::GetCID(), (EditTxn **)&txn); - if (NS_FAILED(result)) return result; - if (!txn) return NS_ERROR_NULL_POINTER; + nsRefPtr txn = new DeleteTextTxn(); + if (!txn) + return NS_ERROR_OUT_OF_MEMORY; result = txn->Init(mEditor, textNode, start, numToDelete, mRangeUpdater); if (NS_SUCCEEDED(result)) AppendChild(txn); - NS_RELEASE(txn); } } @@ -339,15 +332,13 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteNodesBetween() if (!node) return NS_ERROR_NULL_POINTER; - DeleteElementTxn *txn; - result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)&txn); - if (NS_FAILED(result)) return result; - if (!txn) return NS_ERROR_NULL_POINTER; + nsRefPtr txn = new DeleteElementTxn(); + if (!txn) + return NS_ERROR_OUT_OF_MEMORY; result = txn->Init(mEditor, node, mRangeUpdater); if (NS_SUCCEEDED(result)) AppendChild(txn); - NS_RELEASE(txn); iter->Next(); } return result; diff --git a/editor/libeditor/base/DeleteRangeTxn.h b/editor/libeditor/base/DeleteRangeTxn.h index d24ed8f4ae13..2904309e8db6 100644 --- a/editor/libeditor/base/DeleteRangeTxn.h +++ b/editor/libeditor/base/DeleteRangeTxn.h @@ -44,11 +44,6 @@ #include "nsIEditor.h" #include "nsCOMPtr.h" -#define DELETE_RANGE_TXN_CID \ -{/* 5ec6b260-ac49-11d2-86d8-000064657374 */ \ -0x5ec6b260, 0xac49, 0x11d2, \ -{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } - class nsIDOMRange; class nsIEditor; class nsRangeUpdater; @@ -59,9 +54,6 @@ class nsRangeUpdater; class DeleteRangeTxn : public EditAggregateTxn { public: - - static const nsIID& GetCID() { static const nsIID iid = DELETE_RANGE_TXN_CID; return iid; } - /** initialize the transaction. * @param aEditor the object providing basic editing operations * @param aRange the range to delete @@ -70,10 +62,8 @@ public: nsIDOMRange *aRange, nsRangeUpdater *aRangeUpdater); -private: DeleteRangeTxn(); -public: NS_DECL_EDITTXN NS_IMETHOD RedoTransaction(); @@ -115,9 +105,6 @@ protected: /** range updater object */ nsRangeUpdater *mRangeUpdater; - - friend class TransactionFactory; - }; #endif diff --git a/editor/libeditor/base/DeleteTextTxn.h b/editor/libeditor/base/DeleteTextTxn.h index f655119efad4..906783c306cf 100644 --- a/editor/libeditor/base/DeleteTextTxn.h +++ b/editor/libeditor/base/DeleteTextTxn.h @@ -43,11 +43,6 @@ #include "nsIDOMCharacterData.h" #include "nsCOMPtr.h" -#define DELETE_TEXT_TXN_CID \ -{/* 4d3a2720-ac49-11d2-86d8-000064657374 */ \ -0x4d3a2720, 0xac49, 0x11d2, \ -{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } - class nsRangeUpdater; /** @@ -56,9 +51,6 @@ class nsRangeUpdater; class DeleteTextTxn : public EditTxn { public: - - static const nsIID& GetCID() { static const nsIID iid = DELETE_TEXT_TXN_CID; return iid; } - /** initialize the transaction. * @param aEditor the provider of basic editing operations * @param aElement the content node to remove text from @@ -71,10 +63,8 @@ public: PRUint32 aNumCharsToDelete, nsRangeUpdater *aRangeUpdater); -private: DeleteTextTxn(); -public: NS_DECL_EDITTXN PRUint32 GetOffset() { return mOffset; } @@ -100,9 +90,6 @@ protected: /** range updater object */ nsRangeUpdater *mRangeUpdater; - - friend class TransactionFactory; - }; #endif diff --git a/editor/libeditor/base/EditAggregateTxn.cpp b/editor/libeditor/base/EditAggregateTxn.cpp index 4561774baf1b..b1d8baa54389 100644 --- a/editor/libeditor/base/EditAggregateTxn.cpp +++ b/editor/libeditor/base/EditAggregateTxn.cpp @@ -184,11 +184,6 @@ NS_IMETHODIMP EditAggregateTxn::QueryInterface(REFNSIID aIID, void** aInstancePt { if (!aInstancePtr) return NS_ERROR_NULL_POINTER; - if (aIID.Equals(EditAggregateTxn::GetCID())) { - *aInstancePtr = static_cast(this); - NS_ADDREF_THIS(); - return NS_OK; - } return EditTxn::QueryInterface(aIID, aInstancePtr); } diff --git a/editor/libeditor/base/EditAggregateTxn.h b/editor/libeditor/base/EditAggregateTxn.h index f12b2caa391c..fa04dd7b92e0 100644 --- a/editor/libeditor/base/EditAggregateTxn.h +++ b/editor/libeditor/base/EditAggregateTxn.h @@ -44,12 +44,6 @@ #include "nsTArray.h" #include "nsAutoPtr.h" -#define EDIT_AGGREGATE_TXN_CID \ -{/* 345921a0-ac49-11d2-86d8-000064657374 */ \ -0x345921a0, 0xac49, 0x11d2, \ -{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } - - /** * base class for all document editing transactions that require aggregation. * provides a list of child transactions. @@ -59,8 +53,6 @@ class EditAggregateTxn : public EditTxn public: NS_IMETHOD QueryInterface(REFNSIID aIID, void **aInstancePtr); - static const nsIID& GetCID() { static const nsIID cid = EDIT_AGGREGATE_TXN_CID; return cid; } - EditAggregateTxn(); NS_DECL_EDITTXN diff --git a/editor/libeditor/base/EditTxn.h b/editor/libeditor/base/EditTxn.h index a71dbbd29e96..b47e772e8b7f 100644 --- a/editor/libeditor/base/EditTxn.h +++ b/editor/libeditor/base/EditTxn.h @@ -42,11 +42,6 @@ #include "nsString.h" #include "nsPIEditorTransaction.h" -#define EDIT_TXN_CID \ -{/* c5ea31b0-ac48-11d2-86d8-000064657374 */ \ -0xc5ea31b0, 0xac48, 0x11d2, \ -{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } - /** * Base class for all document editing transactions. */ @@ -54,9 +49,6 @@ class EditTxn : public nsITransaction, public nsPIEditorTransaction { public: - - static const nsIID& GetCID() { static const nsIID iid = EDIT_TXN_CID; return iid; } - NS_DECL_ISUPPORTS virtual ~EditTxn(); diff --git a/editor/libeditor/base/IMETextTxn.h b/editor/libeditor/base/IMETextTxn.h index fed17bfa76a9..d1a2c4b5f841 100644 --- a/editor/libeditor/base/IMETextTxn.h +++ b/editor/libeditor/base/IMETextTxn.h @@ -77,11 +77,8 @@ public: const nsAString& aString, nsWeakPtr aSelCon); -private: - - IMETextTxn(); + IMETextTxn(); -public: NS_DECL_EDITTXN NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); @@ -118,8 +115,6 @@ protected: nsWeakPtr mSelConWeak; // use a weak reference PRBool mFixed; - - friend class TransactionFactory; }; #endif diff --git a/editor/libeditor/base/InsertElementTxn.h b/editor/libeditor/base/InsertElementTxn.h index a2cfa59588aa..f0a4e4037142 100644 --- a/editor/libeditor/base/InsertElementTxn.h +++ b/editor/libeditor/base/InsertElementTxn.h @@ -43,20 +43,12 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#define INSERT_ELEMENT_TXN_CID \ -{/* b5762440-cbb0-11d2-86db-000064657374 */ \ -0xb5762440, 0xcbb0, 0x11d2, \ -{0x86, 0xdb, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } - /** * A transaction that inserts a single element */ class InsertElementTxn : public EditTxn { public: - - static const nsIID& GetCID() { static const nsIID iid = INSERT_ELEMENT_TXN_CID; return iid; } - /** initialize the transaction. * @param aNode the node to insert * @param aParent the node to insert into @@ -67,10 +59,8 @@ public: PRInt32 aOffset, nsIEditor *aEditor); -private: InsertElementTxn(); -public: NS_DECL_EDITTXN protected: @@ -86,9 +76,6 @@ protected: /** the index in mParent for the new node */ PRInt32 mOffset; - - friend class TransactionFactory; - }; #endif diff --git a/editor/libeditor/base/InsertTextTxn.h b/editor/libeditor/base/InsertTextTxn.h index 16eeb443b38d..41e3ac7f004c 100644 --- a/editor/libeditor/base/InsertTextTxn.h +++ b/editor/libeditor/base/InsertTextTxn.h @@ -68,11 +68,8 @@ public: const nsAString& aString, nsIEditor *aEditor); -private: - - InsertTextTxn(); + InsertTextTxn(); -public: NS_DECL_EDITTXN @@ -102,8 +99,6 @@ protected: /** the editor, which we'll need to get the selection */ nsIEditor *mEditor; - - friend class TransactionFactory; }; #endif diff --git a/editor/libeditor/base/JoinElementTxn.h b/editor/libeditor/base/JoinElementTxn.h index dbfd601d22c2..2f10436c76e8 100644 --- a/editor/libeditor/base/JoinElementTxn.h +++ b/editor/libeditor/base/JoinElementTxn.h @@ -43,11 +43,6 @@ #include "nsCOMPtr.h" #include "nsIEditor.h" -#define JOIN_ELEMENT_TXN_CID \ -{/* 9bc5f9f0-ac48-11d2-86d8-000064657374 */ \ -0x9bc5f9f0, 0xac48, 0x11d2, \ -{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } - class nsEditor; /** @@ -60,9 +55,6 @@ class nsEditor; class JoinElementTxn : public EditTxn { public: - - static const nsIID& GetCID() { static const nsIID iid = JOIN_ELEMENT_TXN_CID; return iid; } - /** initialize the transaction * @param aEditor the provider of core editing operations * @param aLeftNode the first of two nodes to join @@ -71,10 +63,9 @@ public: NS_IMETHOD Init(nsEditor *aEditor, nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode); -protected: + JoinElementTxn(); -public: NS_DECL_EDITTXN protected: @@ -94,9 +85,6 @@ protected: /** the parent node containing mLeftNode and mRightNode */ nsCOMPtr mParent; nsEditor* mEditor; - - friend class TransactionFactory; - }; #endif diff --git a/editor/libeditor/base/Makefile.in b/editor/libeditor/base/Makefile.in index 3e7a0d0d59d4..76b0e84bcd71 100644 --- a/editor/libeditor/base/Makefile.in +++ b/editor/libeditor/base/Makefile.in @@ -100,7 +100,6 @@ CPPSRCS += \ SetDocTitleTxn.cpp \ SplitElementTxn.cpp \ nsStyleSheetTxns.cpp \ - TransactionFactory.cpp \ $(NULL) # don't want the shared lib; force the creation of a static lib. diff --git a/editor/libeditor/base/PlaceholderTxn.h b/editor/libeditor/base/PlaceholderTxn.h index 4eb481a9fd29..3d27e05e455c 100644 --- a/editor/libeditor/base/PlaceholderTxn.h +++ b/editor/libeditor/base/PlaceholderTxn.h @@ -47,11 +47,6 @@ #include "nsWeakReference.h" #include "nsAutoPtr.h" -#define PLACEHOLDER_TXN_CID \ -{/* {0CE9FB00-D9D1-11d2-86DE-000064657374} */ \ -0x0CE9FB00, 0xD9D1, 0x11d2, \ -{0x86, 0xde, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } - class nsHTMLEditor; class IMETextTxn; @@ -67,15 +62,10 @@ class PlaceholderTxn : public EditAggregateTxn, public nsSupportsWeakReference { public: - - static const nsIID& GetCID() { static const nsIID iid = PLACEHOLDER_TXN_CID; return iid; } - NS_DECL_ISUPPORTS_INHERITED -private: PlaceholderTxn(); -public: // ------------ EditAggregateTxn ----------------------- NS_DECL_EDITTXN @@ -98,8 +88,6 @@ public: NS_IMETHOD Commit(); NS_IMETHOD RememberEndingSelection(); - - friend class TransactionFactory; protected: diff --git a/editor/libeditor/base/SetDocTitleTxn.h b/editor/libeditor/base/SetDocTitleTxn.h index a919d53b508c..8083922837e3 100644 --- a/editor/libeditor/base/SetDocTitleTxn.h +++ b/editor/libeditor/base/SetDocTitleTxn.h @@ -44,11 +44,6 @@ #include "nsITransaction.h" #include "nsCOMPtr.h" -#define SET_DOC_TITLE_TXN_CID \ -{ /*7FC508B5-ED8F-11d4-AF02-0050040AE132 */ \ -0x7fc508b5, 0xed8f, 0x11d4, \ -{ 0xaf, 0x2, 0x0, 0x50, 0x4, 0xa, 0xe1, 0x32 } } - /** * A transaction that changes the document's title, * which is a text node under the tag in a page's <head> section @@ -57,17 +52,14 @@ class SetDocTitleTxn : public EditTxn { public: - - static const nsIID& GetCID() { static const nsIID iid = SET_DOC_TITLE_TXN_CID; return iid; } - /** Initialize the transaction. * @param aEditor the object providing core editing operations * @param aValue the new value for document title */ NS_IMETHOD Init(nsIHTMLEditor *aEditor, const nsAString *aValue); -private: SetDocTitleTxn(); +private: nsresult SetDomTitle(const nsAString& aTitle); public: @@ -89,8 +81,6 @@ protected: /** Set true if we dont' really change the title during Do() */ PRPackedBool mIsTransient; - - friend class TransactionFactory; }; #endif diff --git a/editor/libeditor/base/SplitElementTxn.h b/editor/libeditor/base/SplitElementTxn.h index f9a345693ce4..90f9cd98fd4b 100644 --- a/editor/libeditor/base/SplitElementTxn.h +++ b/editor/libeditor/base/SplitElementTxn.h @@ -43,11 +43,6 @@ #include "nsCOMPtr.h" #include "nsIEditor.h" -#define SPLIT_ELEMENT_TXN_CID \ -{/* 690c6290-ac48-11d2-86d8-000064657374 */ \ -0x690c6290, 0xac48, 0x11d2, \ -{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} } - class nsEditor; /** @@ -57,9 +52,6 @@ class nsEditor; class SplitElementTxn : public EditTxn { public: - - static const nsIID& GetCID() { static const nsIID iid = SPLIT_ELEMENT_TXN_CID; return iid; } - /** initialize the transaction. * @param aEditor the provider of core editing operations * @param aNode the node to split @@ -70,10 +62,9 @@ public: NS_IMETHOD Init (nsEditor *aEditor, nsIDOMNode *aNode, PRInt32 aOffset); -protected: + SplitElementTxn(); -public: NS_DECL_EDITTXN NS_IMETHOD RedoTransaction(void); @@ -97,9 +88,6 @@ protected: /** the parent shared by mExistingRightNode and mNewLeftNode */ nsCOMPtr<nsIDOMNode> mParent; nsEditor* mEditor; - - friend class TransactionFactory; - }; #endif diff --git a/editor/libeditor/base/TransactionFactory.cpp b/editor/libeditor/base/TransactionFactory.cpp deleted file mode 100644 index 405bad11316d..000000000000 --- a/editor/libeditor/base/TransactionFactory.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Daniel Glazman <glazman@netscape.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "TransactionFactory.h" -// transactions this factory knows how to build -#include "EditAggregateTxn.h" -#include "PlaceholderTxn.h" -#include "InsertTextTxn.h" -#include "DeleteTextTxn.h" -#include "CreateElementTxn.h" -#include "InsertElementTxn.h" -#include "DeleteElementTxn.h" -#include "DeleteRangeTxn.h" -#include "ChangeAttributeTxn.h" -#include "SplitElementTxn.h" -#include "JoinElementTxn.h" -#include "nsStyleSheetTxns.h" -#include "IMETextTxn.h" - -#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY -#include "SetDocTitleTxn.h" -#include "ChangeCSSInlineStyleTxn.h" -#endif // MOZILLA_PLAINTEXT_EDITOR_ONLY - -TransactionFactory::TransactionFactory() -{ -} - -TransactionFactory::~TransactionFactory() -{ -} - -nsresult -TransactionFactory::GetNewTransaction(REFNSIID aTxnType, EditTxn **aResult) -{ - nsresult result = NS_OK; - *aResult = nsnull; - if (aTxnType.Equals(InsertTextTxn::GetCID())) - *aResult = new InsertTextTxn(); - else if (aTxnType.Equals(DeleteTextTxn::GetCID())) - *aResult = new DeleteTextTxn(); - else if (aTxnType.Equals(CreateElementTxn::GetCID())) - *aResult = new CreateElementTxn(); - else if (aTxnType.Equals(InsertElementTxn::GetCID())) - *aResult = new InsertElementTxn(); - else if (aTxnType.Equals(DeleteElementTxn::GetCID())) - *aResult = new DeleteElementTxn(); - else if (aTxnType.Equals(DeleteRangeTxn::GetCID())) - *aResult = new DeleteRangeTxn(); - else if (aTxnType.Equals(ChangeAttributeTxn::GetCID())) - *aResult = new ChangeAttributeTxn(); -#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY - else if (aTxnType.Equals(ChangeCSSInlineStyleTxn::GetCID())) - *aResult = new ChangeCSSInlineStyleTxn(); -#endif // MOZILLA_PLAINTEXT_EDITOR_ONLY - else if (aTxnType.Equals(SplitElementTxn::GetCID())) - *aResult = new SplitElementTxn(); - else if (aTxnType.Equals(JoinElementTxn::GetCID())) - *aResult = new JoinElementTxn(); - else if (aTxnType.Equals(EditAggregateTxn::GetCID())) - *aResult = new EditAggregateTxn(); - else if (aTxnType.Equals(IMETextTxn::GetCID())) - *aResult = new IMETextTxn(); - else if (aTxnType.Equals(AddStyleSheetTxn::GetCID())) - *aResult = new AddStyleSheetTxn(); - else if (aTxnType.Equals(RemoveStyleSheetTxn::GetCID())) - *aResult = new RemoveStyleSheetTxn(); -#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY - else if (aTxnType.Equals(SetDocTitleTxn::GetCID())) - *aResult = new SetDocTitleTxn(); -#endif // MOZILLA_PLAINTEXT_EDITOR_ONLY - else if (aTxnType.Equals(PlaceholderTxn::GetCID())) - *aResult = new PlaceholderTxn(); - else - result = NS_ERROR_NO_INTERFACE; - - if (NS_SUCCEEDED(result) && !*aResult) - result = NS_ERROR_OUT_OF_MEMORY; - - if (NS_SUCCEEDED(result)) - NS_ADDREF(*aResult); - - return result; -} - diff --git a/editor/libeditor/base/TransactionFactory.h b/editor/libeditor/base/TransactionFactory.h deleted file mode 100644 index 0c74694b2f4d..000000000000 --- a/editor/libeditor/base/TransactionFactory.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef TransactionFactory_h__ -#define TransactionFactory_h__ - -#include "nsISupports.h" - -class EditTxn; - -/** - * This class instantiates and optionally recycles edit transactions - * A recycler would be a separate static object, since this class does not get instantiated - */ -class TransactionFactory -{ -protected: - TransactionFactory(); - virtual ~TransactionFactory(); - -public: - /** return a transaction object of aTxnType, refcounted - * @return NS_ERROR_NO_INTERFACE if aTxnType is unknown, - * NS_ERROR_OUT_OF_MEMORY if the allocations fails. - */ - static nsresult GetNewTransaction(REFNSIID aTxnType, EditTxn **aResult); - -}; - -#endif diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index eba2ee5158e0..b0615d13f55c 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -90,7 +90,6 @@ #include "nsServiceManagerUtils.h" // transactions the editor knows how to build -#include "TransactionFactory.h" #include "EditAggregateTxn.h" #include "PlaceholderTxn.h" #include "ChangeAttributeTxn.h" @@ -622,11 +621,8 @@ nsEditor::DoTransaction(nsITransaction *aTxn) // this transaction goes through here. I bet this is a record. // We start off with an EditTxn since that's what the factory returns. - nsRefPtr<EditTxn> editTxn; - result = TransactionFactory::GetNewTransaction(PlaceholderTxn::GetCID(), - getter_AddRefs(editTxn)); - if (NS_FAILED(result)) { return result; } - if (!editTxn) { return NS_ERROR_NULL_POINTER; } + nsRefPtr<EditTxn> editTxn = new PlaceholderTxn(); + if (!editTxn) { return NS_ERROR_OUT_OF_MEMORY; } // Then we QI to an nsIAbsorbingTransaction to get at placeholder functionality nsCOMPtr<nsIAbsorbingTransaction> plcTxn; @@ -2788,9 +2784,9 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsAString & aStringToInsert if (!aTextNode || !aTxn) return NS_ERROR_NULL_POINTER; nsresult result; - result = TransactionFactory::GetNewTransaction(InsertTextTxn::GetCID(), (EditTxn **)aTxn); - if (NS_FAILED(result)) return result; + *aTxn = new InsertTextTxn(); if (!*aTxn) return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); result = (*aTxn)->Init(aTextNode, aOffset, aStringToInsert, this); return result; } @@ -2829,11 +2825,11 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteText(nsIDOMCharacterData *aElement, if (!aElement) return NS_ERROR_NULL_POINTER; - nsresult result = TransactionFactory::GetNewTransaction(DeleteTextTxn::GetCID(), (EditTxn **)aTxn); - if (NS_SUCCEEDED(result)) { - result = (*aTxn)->Init(this, aElement, aOffset, aLength, &mRangeUpdater); - } - return result; + *aTxn = new DeleteTextTxn(); + if (!*aTxn) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); + return (*aTxn)->Init(this, aElement, aOffset, aLength, &mRangeUpdater); } @@ -2846,9 +2842,10 @@ NS_IMETHODIMP nsEditor::CreateTxnForSplitNode(nsIDOMNode *aNode, if (!aNode) return NS_ERROR_NULL_POINTER; - nsresult result = TransactionFactory::GetNewTransaction(SplitElementTxn::GetCID(), (EditTxn **)aTxn); - if (NS_FAILED(result)) - return result; + *aTxn = new SplitElementTxn(); + if (!*aTxn) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); return (*aTxn)->Init(this, aNode, aOffset); } @@ -2860,11 +2857,12 @@ NS_IMETHODIMP nsEditor::CreateTxnForJoinNode(nsIDOMNode *aLeftNode, if (!aLeftNode || !aRightNode) return NS_ERROR_NULL_POINTER; - nsresult result = TransactionFactory::GetNewTransaction(JoinElementTxn::GetCID(), (EditTxn **)aTxn); - if (NS_SUCCEEDED(result)) { - result = (*aTxn)->Init(this, aLeftNode, aRightNode); - } - return result; + *aTxn = new JoinElementTxn(); + if (!*aTxn) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); + + return (*aTxn)->Init(this, aLeftNode, aRightNode); } @@ -4641,15 +4639,14 @@ nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement, const nsAString& aValue, ChangeAttributeTxn ** aTxn) { - nsresult result = NS_ERROR_NULL_POINTER; - if (nsnull != aElement) - { - result = TransactionFactory::GetNewTransaction(ChangeAttributeTxn::GetCID(), (EditTxn **)aTxn); - if (NS_SUCCEEDED(result)) { - result = (*aTxn)->Init(this, aElement, aAttribute, aValue, PR_FALSE); - } - } - return result; + if (!aElement) + return NS_ERROR_NULL_POINTER; + + *aTxn = new ChangeAttributeTxn(); + if (!*aTxn) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); + return (*aTxn)->Init(this, aElement, aAttribute, aValue, PR_FALSE); } @@ -4658,17 +4655,15 @@ nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement, const nsAString& aAttribute, ChangeAttributeTxn ** aTxn) { - nsresult result = NS_ERROR_NULL_POINTER; - if (nsnull != aElement) - { - result = TransactionFactory::GetNewTransaction(ChangeAttributeTxn::GetCID(), (EditTxn **)aTxn); - if (NS_SUCCEEDED(result)) - { - nsAutoString value; - result = (*aTxn)->Init(this, aElement, aAttribute, value, PR_TRUE); - } - } - return result; + if (!aElement) + return NS_ERROR_NULL_POINTER; + + *aTxn = new ChangeAttributeTxn(); + if (!*aTxn) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); + + return (*aTxn)->Init(this, aElement, aAttribute, EmptyString(), PR_TRUE); } @@ -4677,15 +4672,15 @@ NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsAString& aTag, PRInt32 aPosition, CreateElementTxn ** aTxn) { - nsresult result = NS_ERROR_NULL_POINTER; - if (nsnull != aParent) - { - result = TransactionFactory::GetNewTransaction(CreateElementTxn::GetCID(), (EditTxn **)aTxn); - if (NS_SUCCEEDED(result)) { - result = (*aTxn)->Init(this, aTag, aParent, aPosition); - } - } - return result; + if (!aParent) + return NS_ERROR_NULL_POINTER; + + *aTxn = new CreateElementTxn(); + if (!*aTxn) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); + + return (*aTxn)->Init(this, aTag, aParent, aPosition); } @@ -4694,29 +4689,29 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertElement(nsIDOMNode * aNode, PRInt32 aPosition, InsertElementTxn ** aTxn) { - nsresult result = NS_ERROR_NULL_POINTER; - if (aNode && aParent && aTxn) - { - result = TransactionFactory::GetNewTransaction(InsertElementTxn::GetCID(), (EditTxn **)aTxn); - if (NS_SUCCEEDED(result)) { - result = (*aTxn)->Init(aNode, aParent, aPosition, this); - } - } - return result; + if (!aNode || !aParent) + return NS_ERROR_NULL_POINTER; + + *aTxn = new InsertElementTxn(); + if (!*aTxn) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); + + return (*aTxn)->Init(aNode, aParent, aPosition, this); } NS_IMETHODIMP nsEditor::CreateTxnForDeleteElement(nsIDOMNode * aElement, DeleteElementTxn ** aTxn) { - nsresult result = NS_ERROR_NULL_POINTER; - if (nsnull != aElement) - { - result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)aTxn); - if (NS_SUCCEEDED(result)) { - result = (*aTxn)->Init(this, aElement, &mRangeUpdater); - } - } - return result; + if (!aElement) + return NS_ERROR_NULL_POINTER; + + *aTxn = new DeleteElementTxn(); + if (!*aTxn) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); + + return (*aTxn)->Init(this, aElement, &mRangeUpdater); } NS_IMETHODIMP @@ -4724,30 +4719,24 @@ nsEditor::CreateTxnForIMEText(const nsAString& aStringToInsert, IMETextTxn ** aTxn) { NS_ASSERTION(aTxn, "illegal value- null ptr- aTxn"); - if(!aTxn) return NS_ERROR_NULL_POINTER; - nsresult result; + *aTxn = new IMETextTxn(); + if (!*aTxn) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); - result = TransactionFactory::GetNewTransaction(IMETextTxn::GetCID(), (EditTxn **)aTxn); - if (nsnull!=*aTxn) { - result = (*aTxn)->Init(mIMETextNode,mIMETextOffset,mIMEBufferLength,mIMETextRangeList,aStringToInsert,mSelConWeak); - } - else { - result = NS_ERROR_OUT_OF_MEMORY; - } - return result; + return (*aTxn)->Init(mIMETextNode, mIMETextOffset, mIMEBufferLength, + mIMETextRangeList, aStringToInsert, mSelConWeak); } NS_IMETHODIMP nsEditor::CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn) { - nsresult rv = TransactionFactory::GetNewTransaction(AddStyleSheetTxn::GetCID(), (EditTxn **)aTxn); - if (NS_FAILED(rv)) - return rv; - + *aTxn = new AddStyleSheetTxn(); if (! *aTxn) return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); return (*aTxn)->Init(this, aSheet); } @@ -4757,12 +4746,10 @@ nsEditor::CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* NS_IMETHODIMP nsEditor::CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn) { - nsresult rv = TransactionFactory::GetNewTransaction(RemoveStyleSheetTxn::GetCID(), (EditTxn **)aTxn); - if (NS_FAILED(rv)) - return rv; - + *aTxn = new RemoveStyleSheetTxn(); if (! *aTxn) return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); return (*aTxn)->Init(this, aSheet); } @@ -4793,10 +4780,11 @@ nsEditor::CreateTxnForDeleteSelection(nsIEditor::EDirection aAction, return NS_OK; // allocate the out-param transaction - result = TransactionFactory::GetNewTransaction(EditAggregateTxn::GetCID(), (EditTxn **)aTxn); - if (NS_FAILED(result)) { - return result; + *aTxn = new EditAggregateTxn(); + if (!*aTxn) { + return NS_ERROR_OUT_OF_MEMORY; } + NS_ADDREF(*aTxn); nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(selection)); nsCOMPtr<nsIEnumerator> enumerator; @@ -4813,13 +4801,8 @@ nsEditor::CreateTxnForDeleteSelection(nsIEditor::EDirection aAction, range->GetCollapsed(&isCollapsed); if (!isCollapsed) { - nsRefPtr<EditTxn> editTxn; - result = - TransactionFactory::GetNewTransaction(DeleteRangeTxn::GetCID(), - getter_AddRefs(editTxn)); - nsRefPtr<DeleteRangeTxn> txn = - static_cast<DeleteRangeTxn*>(editTxn.get()); - if (NS_SUCCEEDED(result) && txn) + nsRefPtr<DeleteRangeTxn> txn = new DeleteRangeTxn(); + if (txn) { txn->Init(this, range, &mRangeUpdater); (*aTxn)->AppendChild(txn); diff --git a/editor/libeditor/base/nsStyleSheetTxns.h b/editor/libeditor/base/nsStyleSheetTxns.h index 4f449f451c22..dc79613f2929 100644 --- a/editor/libeditor/base/nsStyleSheetTxns.h +++ b/editor/libeditor/base/nsStyleSheetTxns.h @@ -43,23 +43,9 @@ #include "nsIEditor.h" #include "nsICSSStyleSheet.h" -#define ADD_STYLESHEET_TXN_CID \ -{/* d05e2980-2fbe-11d3-9ce4-e8393835307c */ \ -0xd05e2980, 0x2fbe, 0x11d3, { 0x9c, 0xe4, 0xe8, 0x39, 0x38, 0x35, 0x30, 0x7c } } - -#define REMOVE_STYLESHEET_TXN_CID \ -{/* d05e2981-2fbe-11d3-9ce4-e8393835307c */ \ -0xd05e2981, 0x2fbe, 0x11d3, { 0x9c, 0xe4, 0xe8, 0x39, 0x38, 0x35, 0x30, 0x7c } } - - class AddStyleSheetTxn : public EditTxn { - friend class TransactionFactory; - public: - - static const nsIID& GetCID() { static const nsIID iid = ADD_STYLESHEET_TXN_CID; return iid; } - /** Initialize the transaction. * @param aEditor the object providing core editing operations * @param aSheet the stylesheet to add @@ -67,10 +53,8 @@ public: NS_IMETHOD Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet); -private: AddStyleSheetTxn(); -public: NS_DECL_EDITTXN protected: @@ -83,12 +67,7 @@ protected: class RemoveStyleSheetTxn : public EditTxn { - friend class TransactionFactory; - public: - - static const nsIID& GetCID() { static const nsIID iid = REMOVE_STYLESHEET_TXN_CID; return iid; } - /** Initialize the transaction. * @param aEditor the object providing core editing operations * @param aSheet the stylesheet to remove @@ -96,10 +75,8 @@ public: NS_IMETHOD Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet); -private: RemoveStyleSheetTxn(); -public: NS_DECL_EDITTXN protected: diff --git a/editor/libeditor/html/nsHTMLCSSUtils.cpp b/editor/libeditor/html/nsHTMLCSSUtils.cpp index 73722b44b888..b177a81f42ab 100644 --- a/editor/libeditor/html/nsHTMLCSSUtils.cpp +++ b/editor/libeditor/html/nsHTMLCSSUtils.cpp @@ -45,7 +45,6 @@ #include "nsEditProperty.h" #include "ChangeCSSInlineStyleTxn.h" #include "nsIDOMElement.h" -#include "TransactionFactory.h" #include "nsIDOMElementCSSInlineStyle.h" #include "nsIDOMDocument.h" #include "nsIDOMDocumentView.h" @@ -520,15 +519,14 @@ nsHTMLCSSUtils::CreateCSSPropertyTxn(nsIDOMElement *aElement, ChangeCSSInlineStyleTxn ** aTxn, PRBool aRemoveProperty) { - nsresult result = NS_ERROR_NULL_POINTER; - if (aElement) - { - result = TransactionFactory::GetNewTransaction(ChangeCSSInlineStyleTxn::GetCID(), (EditTxn **)aTxn); - if (NS_SUCCEEDED(result)) { - result = (*aTxn)->Init(mHTMLEditor, aElement, aAttribute, aValue, aRemoveProperty); - } - } - return result; + if (!aElement) + return NS_ERROR_NULL_POINTER; + + *aTxn = new ChangeCSSInlineStyleTxn(); + if (!*aTxn) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aTxn); + return (*aTxn)->Init(mHTMLEditor, aElement, aAttribute, aValue, aRemoveProperty); } nsresult diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index b13dda5f7b35..03b5ae680bc6 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -72,8 +72,6 @@ #include "nsIDOMEventGroup.h" #include "nsILinkHandler.h" -#include "TransactionFactory.h" - #include "nsICSSLoader.h" #include "nsICSSStyleSheet.h" #include "nsIDOMStyleSheet.h" @@ -701,21 +699,17 @@ nsHTMLEditor::IsBlockNode(nsIDOMNode *aNode) NS_IMETHODIMP nsHTMLEditor::SetDocumentTitle(const nsAString &aTitle) { - nsRefPtr<EditTxn> txn; - nsresult result = TransactionFactory::GetNewTransaction(SetDocTitleTxn::GetCID(), getter_AddRefs(txn)); - if (NS_SUCCEEDED(result)) - { - result = static_cast<SetDocTitleTxn*>(txn.get())->Init(this, &aTitle); + nsRefPtr<SetDocTitleTxn> txn = new SetDocTitleTxn(); + if (!txn) + return NS_ERROR_OUT_OF_MEMORY; - if (NS_SUCCEEDED(result)) - { - //Don't let Rules System change the selection - nsAutoTxnsConserveSelection dontChangeSelection(this); + nsresult result = txn->Init(this, &aTitle); + if (NS_FAILED(result)) + return result; - result = nsEditor::DoTransaction(txn); - } - } - return result; + //Don't let Rules System change the selection + nsAutoTxnsConserveSelection dontChangeSelection(this); + return nsEditor::DoTransaction(txn); } /* ------------ Block methods moved from nsEditor -------------- */