diff --git a/mozilla/editor/Makefile.in b/mozilla/editor/Makefile.in index 5c50eadb324..974d79921d8 100644 --- a/mozilla/editor/Makefile.in +++ b/mozilla/editor/Makefile.in @@ -26,7 +26,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = public idl base txmgr txtsvc +DIRS = txmgr public idl base txtsvc include $(topsrcdir)/config/rules.mk diff --git a/mozilla/editor/base/ChangeAttributeTxn.cpp b/mozilla/editor/base/ChangeAttributeTxn.cpp index d255647e30d..dc950dff226 100644 --- a/mozilla/editor/base/ChangeAttributeTxn.cpp +++ b/mozilla/editor/base/ChangeAttributeTxn.cpp @@ -27,8 +27,6 @@ ChangeAttributeTxn::ChangeAttributeTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } ChangeAttributeTxn::~ChangeAttributeTxn() @@ -54,7 +52,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor, return NS_OK; } -NS_IMETHODIMP ChangeAttributeTxn::Do(void) +NS_IMETHODIMP ChangeAttributeTxn::DoTransaction(void) { NS_ASSERTION(mEditor && mElement, "bad state"); if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } @@ -75,7 +73,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Do(void) return result; } -NS_IMETHODIMP ChangeAttributeTxn::Undo(void) +NS_IMETHODIMP ChangeAttributeTxn::UndoTransaction(void) { NS_ASSERTION(mEditor && mElement, "bad state"); if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } @@ -89,7 +87,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Undo(void) return result; } -NS_IMETHODIMP ChangeAttributeTxn::Redo(void) +NS_IMETHODIMP ChangeAttributeTxn::RedoTransaction(void) { NS_ASSERTION(mEditor && mElement, "bad state"); if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } @@ -104,40 +102,21 @@ NS_IMETHODIMP ChangeAttributeTxn::Redo(void) return result; } -NS_IMETHODIMP ChangeAttributeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP ChangeAttributeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP ChangeAttributeTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP ChangeAttributeTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} + aString.Assign(NS_LITERAL_STRING("ChangeAttributeTxn: ")); -NS_IMETHODIMP ChangeAttributeTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - if (PR_FALSE==mRemoveAttribute) - aString->AssignWithConversion("Change Attribute: "); - else - aString->AssignWithConversion("Remove Attribute: "); - *aString += mAttribute; - } - return NS_OK; -} - -NS_IMETHODIMP ChangeAttributeTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - if (PR_FALSE==mRemoveAttribute) - aString->AssignWithConversion("Change Attribute: "); - else - aString->AssignWithConversion("Add Attribute: "); - *aString += mAttribute; - } + if (PR_FALSE==mRemoveAttribute) + aString += NS_LITERAL_STRING("[mRemoveAttribute == false] "); + else + aString += NS_LITERAL_STRING("[mRemoveAttribute == true] "); + aString += mAttribute; return NS_OK; } diff --git a/mozilla/editor/base/ChangeAttributeTxn.h b/mozilla/editor/base/ChangeAttributeTxn.h index 30585863dc8..e9459b800f4 100644 --- a/mozilla/editor/base/ChangeAttributeTxn.h +++ b/mozilla/editor/base/ChangeAttributeTxn.h @@ -63,21 +63,15 @@ private: public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11180 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/base/CreateElementTxn.cpp b/mozilla/editor/base/CreateElementTxn.cpp index e7080bd959c..dabc508b114 100644 --- a/mozilla/editor/base/CreateElementTxn.cpp +++ b/mozilla/editor/base/CreateElementTxn.cpp @@ -40,8 +40,6 @@ static const PRBool gNoisy = PR_FALSE; CreateElementTxn::CreateElementTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor, @@ -72,7 +70,7 @@ CreateElementTxn::~CreateElementTxn() { } -NS_IMETHODIMP CreateElementTxn::Do(void) +NS_IMETHODIMP CreateElementTxn::DoTransaction(void) { if (gNoisy) { @@ -170,7 +168,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void) return result; } -NS_IMETHODIMP CreateElementTxn::Undo(void) +NS_IMETHODIMP CreateElementTxn::UndoTransaction(void) { if (gNoisy) { printf("Undo Create Element, mParent = %p, node = %p\n", mParent.get(), mNewNode.get()); } @@ -182,7 +180,7 @@ NS_IMETHODIMP CreateElementTxn::Undo(void) return result; } -NS_IMETHODIMP CreateElementTxn::Redo(void) +NS_IMETHODIMP CreateElementTxn::RedoTransaction(void) { if (gNoisy) { printf("Redo Create Element\n"); } NS_ASSERTION(mEditor && mParent, "bad state"); @@ -203,35 +201,17 @@ NS_IMETHODIMP CreateElementTxn::Redo(void) return result; } -NS_IMETHODIMP CreateElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP CreateElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP CreateElementTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP CreateElementTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP CreateElementTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Element: "); - *aString += mTag; - } - return NS_OK; -} - -NS_IMETHODIMP CreateElementTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Create Element: "); - *aString += mTag; - } + aString.Assign(NS_LITERAL_STRING("CreateElementTxn: ")); + aString += mTag; return NS_OK; } diff --git a/mozilla/editor/base/CreateElementTxn.h b/mozilla/editor/base/CreateElementTxn.h index 5948557029e..733921e0d34 100644 --- a/mozilla/editor/base/CreateElementTxn.h +++ b/mozilla/editor/base/CreateElementTxn.h @@ -63,24 +63,18 @@ public: virtual ~CreateElementTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); - enum { kTransactionID = 11140 }; - protected: /** the document into which the new node will be inserted */ diff --git a/mozilla/editor/base/DeleteElementTxn.cpp b/mozilla/editor/base/DeleteElementTxn.cpp index 928e3a6f6ce..eca72b49d62 100644 --- a/mozilla/editor/base/DeleteElementTxn.cpp +++ b/mozilla/editor/base/DeleteElementTxn.cpp @@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE; DeleteElementTxn::DeleteElementTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP DeleteElementTxn::Init(nsIDOMNode *aElement) @@ -54,7 +52,7 @@ DeleteElementTxn::~DeleteElementTxn() { } -NS_IMETHODIMP DeleteElementTxn::Do(void) +NS_IMETHODIMP DeleteElementTxn::DoTransaction(void) { if (gNoisy) { printf("%p Do Delete Element element = %p\n", this, mElement.get()); } if (!mElement) return NS_ERROR_NOT_INITIALIZED; @@ -96,7 +94,7 @@ NS_IMETHODIMP DeleteElementTxn::Do(void) return result; } -NS_IMETHODIMP DeleteElementTxn::Undo(void) +NS_IMETHODIMP DeleteElementTxn::UndoTransaction(void) { if (gNoisy) { printf("%p Undo Delete Element element = %p, parent = %p\n", this, mElement.get(), mParent.get()); } if (!mParent) { return NS_OK; } // this is a legal state, the txn is a no-op @@ -132,7 +130,7 @@ NS_IMETHODIMP DeleteElementTxn::Undo(void) return result; } -NS_IMETHODIMP DeleteElementTxn::Redo(void) +NS_IMETHODIMP DeleteElementTxn::RedoTransaction(void) { if (gNoisy) { printf("%p Redo Delete Element element = %p, parent = %p\n", this, mElement.get(), mParent.get()); } if (!mParent) { return NS_OK; } // this is a legal state, the txn is a no-op @@ -144,32 +142,15 @@ NS_IMETHODIMP DeleteElementTxn::Redo(void) } -NS_IMETHODIMP DeleteElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP DeleteElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP DeleteElementTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP DeleteElementTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP DeleteElementTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Element: "); - } - return NS_OK; -} - -NS_IMETHODIMP DeleteElementTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Element: "); - } + aString.Assign(NS_LITERAL_STRING("DeleteElementTxn")); return NS_OK; } diff --git a/mozilla/editor/base/DeleteElementTxn.h b/mozilla/editor/base/DeleteElementTxn.h index 264ca48911b..1f920cace0f 100644 --- a/mozilla/editor/base/DeleteElementTxn.h +++ b/mozilla/editor/base/DeleteElementTxn.h @@ -53,21 +53,15 @@ public: virtual ~DeleteElementTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11160 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/base/DeleteRangeTxn.cpp b/mozilla/editor/base/DeleteRangeTxn.cpp index 213e80b2aa8..3713f1f0cbd 100644 --- a/mozilla/editor/base/DeleteRangeTxn.cpp +++ b/mozilla/editor/base/DeleteRangeTxn.cpp @@ -47,8 +47,6 @@ static const PRBool gNoisy = PR_FALSE; DeleteRangeTxn::DeleteRangeTxn() : EditAggregateTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP DeleteRangeTxn::Init(nsIEditor *aEditor, nsIDOMRange *aRange) @@ -112,7 +110,7 @@ DeleteRangeTxn::~DeleteRangeTxn() { } -NS_IMETHODIMP DeleteRangeTxn::Do(void) +NS_IMETHODIMP DeleteRangeTxn::DoTransaction(void) { if (gNoisy) { printf("Do Delete Range\n"); } if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) @@ -143,7 +141,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void) // if we've successfully built this aggregate transaction, then do it. if (NS_SUCCEEDED(result)) { - result = EditAggregateTxn::Do(); + result = EditAggregateTxn::DoTransaction(); } if (NS_FAILED(result)) return result; @@ -167,53 +165,36 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void) return result; } -NS_IMETHODIMP DeleteRangeTxn::Undo(void) +NS_IMETHODIMP DeleteRangeTxn::UndoTransaction(void) { if (gNoisy) { printf("Undo Delete Range\n"); } if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) return NS_ERROR_NOT_INITIALIZED; - nsresult result = EditAggregateTxn::Undo(); + nsresult result = EditAggregateTxn::UndoTransaction(); return result; } -NS_IMETHODIMP DeleteRangeTxn::Redo(void) +NS_IMETHODIMP DeleteRangeTxn::RedoTransaction(void) { if (gNoisy) { printf("Redo Delete Range\n"); } if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) return NS_ERROR_NOT_INITIALIZED; - nsresult result = EditAggregateTxn::Redo(); + nsresult result = EditAggregateTxn::RedoTransaction(); return result; } -NS_IMETHODIMP DeleteRangeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP DeleteRangeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP DeleteRangeTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP DeleteRangeTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP DeleteRangeTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Range: "); - } - return NS_OK; -} - -NS_IMETHODIMP DeleteRangeTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Range: "); - } + aString.Assign(NS_LITERAL_STRING("DeleteRangeTxn")); return NS_OK; } diff --git a/mozilla/editor/base/DeleteRangeTxn.h b/mozilla/editor/base/DeleteRangeTxn.h index 638b2b6f546..fe1081c3748 100644 --- a/mozilla/editor/base/DeleteRangeTxn.h +++ b/mozilla/editor/base/DeleteRangeTxn.h @@ -61,21 +61,15 @@ public: virtual ~DeleteRangeTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11170 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/base/DeleteTextTxn.cpp b/mozilla/editor/base/DeleteTextTxn.cpp index 88db0665f0f..c188fb406a7 100644 --- a/mozilla/editor/base/DeleteTextTxn.cpp +++ b/mozilla/editor/base/DeleteTextTxn.cpp @@ -33,8 +33,6 @@ static const PRBool gNoisy = PR_FALSE; DeleteTextTxn::DeleteTextTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } DeleteTextTxn::~DeleteTextTxn() @@ -62,7 +60,7 @@ NS_IMETHODIMP DeleteTextTxn::Init(nsIEditor *aEditor, return NS_OK; } -NS_IMETHODIMP DeleteTextTxn::Do(void) +NS_IMETHODIMP DeleteTextTxn::DoTransaction(void) { if (gNoisy) { printf("Do Delete Text\n"); } NS_ASSERTION(mEditor && mElement, "bad state"); @@ -94,7 +92,7 @@ NS_IMETHODIMP DeleteTextTxn::Do(void) //XXX: we may want to store the selection state and restore it properly // was it an insertion point or an extended selection? -NS_IMETHODIMP DeleteTextTxn::Undo(void) +NS_IMETHODIMP DeleteTextTxn::UndoTransaction(void) { if (gNoisy) { printf("Undo Delete Text\n"); } NS_ASSERTION(mEditor && mElement, "bad state"); @@ -105,34 +103,16 @@ NS_IMETHODIMP DeleteTextTxn::Undo(void) return result; } -NS_IMETHODIMP DeleteTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP DeleteTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP DeleteTextTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP DeleteTextTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP DeleteTextTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Text: "); - *aString += mDeletedText; - } - return NS_OK; -} - -NS_IMETHODIMP DeleteTextTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Text: "); - *aString += mDeletedText; - } + aString.Assign(NS_LITERAL_STRING("DeleteTextTxn: ")); + aString += mDeletedText; return NS_OK; } diff --git a/mozilla/editor/base/DeleteTextTxn.h b/mozilla/editor/base/DeleteTextTxn.h index f5894d7c7fe..5234532d60f 100644 --- a/mozilla/editor/base/DeleteTextTxn.h +++ b/mozilla/editor/base/DeleteTextTxn.h @@ -59,19 +59,13 @@ private: public: virtual ~DeleteTextTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11130 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/base/EditAggregateTxn.cpp b/mozilla/editor/base/EditAggregateTxn.cpp index 18378c8d32b..286419fa448 100644 --- a/mozilla/editor/base/EditAggregateTxn.cpp +++ b/mozilla/editor/base/EditAggregateTxn.cpp @@ -31,8 +31,6 @@ EditAggregateTxn::EditAggregateTxn() // base class does this: NS_INIT_REFCNT(); nsresult res = NS_NewISupportsArray(getter_AddRefs(mChildren)); NS_POSTCONDITION(NS_SUCCEEDED(res), "EditAggregateTxn failed in constructor"); - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } EditAggregateTxn::~EditAggregateTxn() @@ -40,7 +38,7 @@ EditAggregateTxn::~EditAggregateTxn() // nsISupportsArray cleans up array for us at destruct time } -NS_IMETHODIMP EditAggregateTxn::Do(void) +NS_IMETHODIMP EditAggregateTxn::DoTransaction(void) { nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list if (mChildren) @@ -53,7 +51,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void) nsCOMPtr isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr txn ( do_QueryInterface(isupports) ); if (!txn) { return NS_ERROR_NULL_POINTER; } - result = txn->Do(); + result = txn->DoTransaction(); if (NS_FAILED(result)) break; } @@ -61,7 +59,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void) return result; } -NS_IMETHODIMP EditAggregateTxn::Undo(void) +NS_IMETHODIMP EditAggregateTxn::UndoTransaction(void) { nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list if (mChildren) @@ -75,7 +73,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void) nsCOMPtr isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr txn ( do_QueryInterface(isupports) ); if (!txn) { return NS_ERROR_NULL_POINTER; } - result = txn->Undo(); + result = txn->UndoTransaction(); if (NS_FAILED(result)) break; } @@ -83,7 +81,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void) return result; } -NS_IMETHODIMP EditAggregateTxn::Redo(void) +NS_IMETHODIMP EditAggregateTxn::RedoTransaction(void) { nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list if (mChildren) @@ -96,7 +94,7 @@ NS_IMETHODIMP EditAggregateTxn::Redo(void) nsCOMPtr isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr txn ( do_QueryInterface(isupports) ); if (!txn) { return NS_ERROR_NULL_POINTER; } - result = txn->Redo(); + result = txn->RedoTransaction(); if (NS_FAILED(result)) break; } @@ -111,7 +109,7 @@ NS_IMETHODIMP EditAggregateTxn::GetIsTransient(PRBool *aIsTransient) return NS_OK; } -NS_IMETHODIMP EditAggregateTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +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 if (nsnull!=aDidMerge) @@ -127,29 +125,24 @@ NS_IMETHODIMP EditAggregateTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransa nsCOMPtr isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr txn ( do_QueryInterface(isupports) ); if (!txn) { return NS_ERROR_NULL_POINTER; } - result = txn->Merge(aDidMerge, aTransaction); + result = txn->Merge(aTransaction, aDidMerge); } } return result; } -NS_IMETHODIMP EditAggregateTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP EditAggregateTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} + aString.Assign(NS_LITERAL_STRING("EditAggregateTxn: ")); -NS_IMETHODIMP EditAggregateTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - aString->SetLength(0); - return NS_OK; -} + if (mName) + { + nsAutoString name; + mName->ToString(name); + aString += name; + } -NS_IMETHODIMP EditAggregateTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - aString->SetLength(0); return NS_OK; } diff --git a/mozilla/editor/base/EditAggregateTxn.h b/mozilla/editor/base/EditAggregateTxn.h index 339466349f8..e1b8dfa2510 100644 --- a/mozilla/editor/base/EditAggregateTxn.h +++ b/mozilla/editor/base/EditAggregateTxn.h @@ -50,21 +50,17 @@ public: virtual ~EditAggregateTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); /** append a transaction to this aggregate */ NS_IMETHOD AppendChild(EditTxn *aTxn); @@ -85,8 +81,6 @@ public: /** get the name assigned to this txn */ NS_IMETHOD GetName(nsIAtom **aName); - enum { kTransactionID = 11210 }; - protected: nsCOMPtr mChildren; diff --git a/mozilla/editor/base/EditTxn.cpp b/mozilla/editor/base/EditTxn.cpp index 25aab1f397f..6f2368eca17 100644 --- a/mozilla/editor/base/EditTxn.cpp +++ b/mozilla/editor/base/EditTxn.cpp @@ -34,7 +34,6 @@ NS_IMPL_RELEASE(EditTxn) // note that aEditor is not refcounted EditTxn::EditTxn() - : mTransactionID(-1) { NS_INIT_REFCNT(); } @@ -43,19 +42,19 @@ EditTxn::~EditTxn() { } -NS_IMETHODIMP EditTxn::Do(void) +NS_IMETHODIMP EditTxn::DoTransaction(void) { return NS_OK; } -NS_IMETHODIMP EditTxn::Undo(void) +NS_IMETHODIMP EditTxn::UndoTransaction(void) { return NS_OK; } -NS_IMETHODIMP EditTxn::Redo(void) +NS_IMETHODIMP EditTxn::RedoTransaction(void) { - return Do(); + return DoTransaction(); } NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient) @@ -65,53 +64,14 @@ NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient) return NS_OK; } -NS_IMETHODIMP EditTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP EditTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { return NS_OK; } -NS_IMETHODIMP EditTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP EditTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP EditTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - aString->SetLength(0); - return NS_OK; -} - -NS_IMETHODIMP EditTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - aString->SetLength(0); - return NS_OK; -} - -NS_IMETHODIMP EditTxn::GetLogDescription(PRUnichar * *aString) -{ - if (nsnull!=aString) - *aString = mLogDescription.ToNewUnicode(); - return NS_OK; -} - -NS_IMETHODIMP EditTxn::SetLogDescription(const PRUnichar *aString) -{ - mLogDescription = (PRUnichar *)aString; - return NS_OK; -} - -NS_IMETHODIMP EditTxn::GetTransactionDescriptionID(int *aID) -{ - if (nsnull!=aID) - *aID = mTransactionID; - return NS_OK; -} - -NS_IMETHODIMP EditTxn::SetTransactionDescriptionID(int aID) -{ - mTransactionID = aID; + aString.Assign(NS_LITERAL_STRING("EditTxn")); return NS_OK; } @@ -133,12 +93,13 @@ EditTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - if (aIID.Equals(NS_GET_IID(nsITransactionDescription))) { - *aInstancePtr = (void*)(nsITransactionDescription*)this; + if (aIID.Equals(NS_GET_IID(nsPIEditorTransaction))) { + *aInstancePtr = (void*)(nsPIEditorTransaction*)this; NS_ADDREF_THIS(); return NS_OK; } + *aInstancePtr = 0; return NS_NOINTERFACE; } diff --git a/mozilla/editor/base/EditTxn.h b/mozilla/editor/base/EditTxn.h index 592dd3f73f6..8875bcce5af 100644 --- a/mozilla/editor/base/EditTxn.h +++ b/mozilla/editor/base/EditTxn.h @@ -24,8 +24,10 @@ #define EditTxn_h__ #include "nsITransaction.h" -#include "nsITransactionDescription.h" +#include "nsIOutputStream.h" +#include "nsString.h" #include "nsCOMPtr.h" +#include "nsPIEditorTransaction.h" #define EDIT_TXN_CID \ {/* c5ea31b0-ac48-11d2-86d8-000064657374 */ \ @@ -39,7 +41,7 @@ * it is never seen by the user or by any external entity. */ class EditTxn : public nsITransaction - , public nsITransactionDescription + , public nsPIEditorTransaction { public: @@ -51,27 +53,17 @@ public: virtual ~EditTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11100 }; - - NS_DECL_NSITRANSACTIONDESCRIPTION - nsString mLogDescription; - int mTransactionID; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); }; #endif diff --git a/mozilla/editor/base/IMECommitTxn.cpp b/mozilla/editor/base/IMECommitTxn.cpp index 215c8fb89d0..13ab4c7eba3 100644 --- a/mozilla/editor/base/IMECommitTxn.cpp +++ b/mozilla/editor/base/IMECommitTxn.cpp @@ -42,8 +42,6 @@ nsresult IMECommitTxn::ClassShutdown() IMECommitTxn::IMECommitTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } IMECommitTxn::~IMECommitTxn() @@ -55,7 +53,7 @@ NS_IMETHODIMP IMECommitTxn::Init(void) return NS_OK; } -NS_IMETHODIMP IMECommitTxn::Do(void) +NS_IMETHODIMP IMECommitTxn::DoTransaction(void) { #ifdef DEBUG_IME printf("Do IME Commit"); @@ -64,7 +62,7 @@ NS_IMETHODIMP IMECommitTxn::Do(void) return NS_OK; } -NS_IMETHODIMP IMECommitTxn::Undo(void) +NS_IMETHODIMP IMECommitTxn::UndoTransaction(void) { #ifdef DEBUG_IME printf("Undo IME Commit"); @@ -73,7 +71,7 @@ NS_IMETHODIMP IMECommitTxn::Undo(void) return NS_OK; } -NS_IMETHODIMP IMECommitTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP IMECommitTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { #ifdef DEBUG_IME printf("Merge IME Commit"); @@ -88,35 +86,10 @@ NS_IMETHODIMP IMECommitTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransactio return NS_OK; } -NS_IMETHODIMP IMECommitTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP IMECommitTxn::GetTxnDescription(nsAWritableString& aString) { - NS_ASSERTION(aOutputStream, "null ptr- aOutputStream"); - if(nsnull == aOutputStream) - return NS_ERROR_NULL_POINTER; - else - return NS_OK; -} - -NS_IMETHODIMP IMECommitTxn::GetUndoString(nsString *aString) -{ - NS_ASSERTION(aString, "null ptr- aString"); - if(nsnull == aString) { - return NS_ERROR_NULL_POINTER; - } else { - aString->AssignWithConversion("Remove IMECommit: "); - return NS_OK; - } -} - -NS_IMETHODIMP IMECommitTxn::GetRedoString(nsString *aString) -{ - NS_ASSERTION(aString, "null ptr- aString"); - if(nsnull == aString) { - return NS_ERROR_NULL_POINTER; - } else { - aString->AssignWithConversion("Insert IMECommit: "); - return NS_OK; - } + aString.Assign(NS_LITERAL_STRING("IMECommitTxn")); + return NS_OK; } /* ============= nsISupports implementation ====================== */ diff --git a/mozilla/editor/base/IMECommitTxn.h b/mozilla/editor/base/IMECommitTxn.h index a406413a03d..56eb63c96e2 100644 --- a/mozilla/editor/base/IMECommitTxn.h +++ b/mozilla/editor/base/IMECommitTxn.h @@ -55,17 +55,13 @@ private: public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); // nsISupports declarations @@ -78,8 +74,6 @@ public: /** must be called once we are guaranteed all IMECommitTxn have completed */ static nsresult ClassShutdown(); - enum { kTransactionID = 11230 }; - protected: friend class TransactionFactory; diff --git a/mozilla/editor/base/IMETextTxn.cpp b/mozilla/editor/base/IMETextTxn.cpp index 95aa41bd6f5..fbb37087dab 100644 --- a/mozilla/editor/base/IMETextTxn.cpp +++ b/mozilla/editor/base/IMETextTxn.cpp @@ -54,8 +54,6 @@ nsresult IMETextTxn::ClassShutdown() IMETextTxn::IMETextTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } IMETextTxn::~IMETextTxn() @@ -84,7 +82,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement, return NS_OK; } -NS_IMETHODIMP IMETextTxn::Do(void) +NS_IMETHODIMP IMETextTxn::DoTransaction(void) { #ifdef DEBUG_IMETXN @@ -108,7 +106,7 @@ NS_IMETHODIMP IMETextTxn::Do(void) return result; } -NS_IMETHODIMP IMETextTxn::Undo(void) +NS_IMETHODIMP IMETextTxn::UndoTransaction(void) { #ifdef DEBUG_IMETXN printf("Undo IME Text element = %p\n", mElement.get()); @@ -132,7 +130,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void) return result; } -NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP IMETextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { NS_ASSERTION(aDidMerge, "illegal vaule- null ptr- aDidMerge"); NS_ASSERTION(aTransaction, "illegal vaule- null ptr- aTransaction"); @@ -185,45 +183,16 @@ NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) return NS_OK; } -NS_IMETHODIMP IMETextTxn::Write(nsIOutputStream *aOutputStream) -{ - NS_ASSERTION(aOutputStream, "illegal value- null ptr- aOutputStream"); - if(nsnull == aOutputStream) - return NS_ERROR_NULL_POINTER; - return NS_OK; -} - NS_IMETHODIMP IMETextTxn::MarkFixed(void) { mFixed = PR_TRUE; return NS_OK; } -NS_IMETHODIMP IMETextTxn::GetUndoString(nsString *aString) +NS_IMETHODIMP IMETextTxn::GetTxnDescription(nsAWritableString& aString) { - NS_ASSERTION(aString, "illegal value- null ptr- aString"); - if(nsnull == aString) - return NS_ERROR_NULL_POINTER; - - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Text: "); - *aString += mStringToInsert; - } - return NS_OK; -} - -NS_IMETHODIMP IMETextTxn::GetRedoString(nsString *aString) -{ - NS_ASSERTION(aString, "illegal value- null ptr- aString"); - if(nsnull == aString) - return NS_ERROR_NULL_POINTER; - - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Text: "); - *aString += mStringToInsert; - } + aString.Assign(NS_LITERAL_STRING("IMETextTxn: ")); + aString += mStringToInsert; return NS_OK; } diff --git a/mozilla/editor/base/IMETextTxn.h b/mozilla/editor/base/IMETextTxn.h index e5f32893de8..4b27f5770fa 100644 --- a/mozilla/editor/base/IMETextTxn.h +++ b/mozilla/editor/base/IMETextTxn.h @@ -74,17 +74,13 @@ private: public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); NS_IMETHOD MarkFixed(void); @@ -102,8 +98,6 @@ public: /** must be called once we are guaranteed all IMETextTxn have completed */ static nsresult ClassShutdown(); - enum { kTransactionID = 11220 }; - protected: NS_IMETHOD CollapseTextSelection(void); diff --git a/mozilla/editor/base/InsertElementTxn.cpp b/mozilla/editor/base/InsertElementTxn.cpp index dab2e8fe6e6..f7b06ca5a91 100644 --- a/mozilla/editor/base/InsertElementTxn.cpp +++ b/mozilla/editor/base/InsertElementTxn.cpp @@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE; InsertElementTxn::InsertElementTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP InsertElementTxn::Init(nsIDOMNode *aNode, @@ -62,7 +60,7 @@ InsertElementTxn::~InsertElementTxn() { } -NS_IMETHODIMP InsertElementTxn::Do(void) +NS_IMETHODIMP InsertElementTxn::DoTransaction(void) { if (gNoisy) { @@ -119,7 +117,7 @@ NS_IMETHODIMP InsertElementTxn::Do(void) return result; } -NS_IMETHODIMP InsertElementTxn::Undo(void) +NS_IMETHODIMP InsertElementTxn::UndoTransaction(void) { if (gNoisy) { printf("%p Undo Insert Element of %p into parent %p at offset %d\n", this, mNode.get(), mParent.get(), mOffset); } @@ -130,32 +128,15 @@ NS_IMETHODIMP InsertElementTxn::Undo(void) return result; } -NS_IMETHODIMP InsertElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP InsertElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP InsertElementTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP InsertElementTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP InsertElementTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Element: "); - } - return NS_OK; -} - -NS_IMETHODIMP InsertElementTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Element: "); - } + aString.Assign(NS_LITERAL_STRING("InsertElementTxn")); return NS_OK; } diff --git a/mozilla/editor/base/InsertElementTxn.h b/mozilla/editor/base/InsertElementTxn.h index accc2a2946c..1ebfae00fd7 100644 --- a/mozilla/editor/base/InsertElementTxn.h +++ b/mozilla/editor/base/InsertElementTxn.h @@ -59,19 +59,13 @@ public: virtual ~InsertElementTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11150 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/base/InsertTextTxn.cpp b/mozilla/editor/base/InsertTextTxn.cpp index 921bfe3dec7..b60e46a451b 100644 --- a/mozilla/editor/base/InsertTextTxn.cpp +++ b/mozilla/editor/base/InsertTextTxn.cpp @@ -52,8 +52,6 @@ nsresult InsertTextTxn::ClassShutdown() InsertTextTxn::InsertTextTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } InsertTextTxn::~InsertTextTxn() @@ -83,7 +81,7 @@ NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement, return NS_OK; } -NS_IMETHODIMP InsertTextTxn::Do(void) +NS_IMETHODIMP InsertTextTxn::DoTransaction(void) { if (gNoisy) { printf("Do Insert Text element = %p\n", mElement.get()); } NS_ASSERTION(mElement && mEditor, "bad state"); @@ -112,7 +110,7 @@ NS_IMETHODIMP InsertTextTxn::Do(void) return result; } -NS_IMETHODIMP InsertTextTxn::Undo(void) +NS_IMETHODIMP InsertTextTxn::UndoTransaction(void) { if (gNoisy) { printf("Undo Insert Text element = %p\n", mElement.get()); } NS_ASSERTION(mElement && mEditor, "bad state"); @@ -124,7 +122,7 @@ NS_IMETHODIMP InsertTextTxn::Undo(void) return result; } -NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP InsertTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { // set out param default value if (nsnull!=aDidMerge) @@ -192,28 +190,10 @@ NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransacti return result; } -NS_IMETHODIMP InsertTextTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP InsertTextTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP InsertTextTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Text: "); - *aString += mStringToInsert; - } - return NS_OK; -} - -NS_IMETHODIMP InsertTextTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Text: "); - *aString += mStringToInsert; - } + aString.Assign(NS_LITERAL_STRING("InsertTextTxn: ")); + aString += mStringToInsert; return NS_OK; } diff --git a/mozilla/editor/base/InsertTextTxn.h b/mozilla/editor/base/InsertTextTxn.h index 60eebc3e7d6..577383db3a3 100644 --- a/mozilla/editor/base/InsertTextTxn.h +++ b/mozilla/editor/base/InsertTextTxn.h @@ -68,17 +68,13 @@ private: public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); // nsISupports declarations @@ -94,8 +90,6 @@ public: /** must be called once we are guaranteed all InsertTextTxn have completed */ static nsresult ClassShutdown(); - enum { kTransactionID = 11120 }; - protected: /** return PR_TRUE if aOtherTxn immediately follows this txn */ diff --git a/mozilla/editor/base/JoinElementTxn.cpp b/mozilla/editor/base/JoinElementTxn.cpp index 21cb2675bed..25dc6231e62 100644 --- a/mozilla/editor/base/JoinElementTxn.cpp +++ b/mozilla/editor/base/JoinElementTxn.cpp @@ -34,8 +34,6 @@ static const PRBool gNoisy = PR_FALSE; JoinElementTxn::JoinElementTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP JoinElementTxn::Init(nsEditor *aEditor, @@ -55,8 +53,8 @@ JoinElementTxn::~JoinElementTxn() { } -// After Do() and Redo(), the left node is removed from the content tree and right node remains. -NS_IMETHODIMP JoinElementTxn::Do(void) +// After DoTransaction() and RedoTransaction(), the left node is removed from the content tree and right node remains. +NS_IMETHODIMP JoinElementTxn::DoTransaction(void) { if (gNoisy) { printf("%p Do Join of %p and %p\n", this, mLeftNode.get(), mRightNode.get()); } NS_PRECONDITION((mEditor && mLeftNode && mRightNode), "null arg"); @@ -110,7 +108,7 @@ NS_IMETHODIMP JoinElementTxn::Do(void) //XXX: what if instead of split, we just deleted the unneeded children of mRight // and re-inserted mLeft? -NS_IMETHODIMP JoinElementTxn::Undo(void) +NS_IMETHODIMP JoinElementTxn::UndoTransaction(void) { if (gNoisy) { printf("%p Undo Join, right node = %p\n", this, mRightNode.get()); } NS_ASSERTION(mRightNode && mLeftNode && mParent, "bad state"); @@ -152,32 +150,15 @@ NS_IMETHODIMP JoinElementTxn::GetIsTransient(PRBool *aIsTransient) return NS_OK; } -nsresult JoinElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +nsresult JoinElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP JoinElementTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP JoinElementTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP JoinElementTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Join Element"); - } - return NS_OK; -} - -NS_IMETHODIMP JoinElementTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Split Element"); - } + aString.Assign(NS_LITERAL_STRING("JoinElementTxn")); return NS_OK; } diff --git a/mozilla/editor/base/JoinElementTxn.h b/mozilla/editor/base/JoinElementTxn.h index 8550de2e7a2..650cef08454 100644 --- a/mozilla/editor/base/JoinElementTxn.h +++ b/mozilla/editor/base/JoinElementTxn.h @@ -39,7 +39,8 @@ class nsEditor; * A transaction that joins two elements E1 (left node) and E2 (right node) * into a single node E. * The children of E are the children of E1 followed by the children of E2. - * After Do() and Redo(), E1 is removed from the content tree and E2 remains. + * After DoTransaction() and RedoTransaction(), E1 is removed from the content + * tree and E2 remains. */ class JoinElementTxn : public EditTxn { @@ -62,23 +63,17 @@ public: virtual ~JoinElementTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); -// NS_IMETHOD Redo(void); +// NS_IMETHOD RedoTransaction(void); NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11200 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/base/Makefile.in b/mozilla/editor/base/Makefile.in index 68b3e2b8c83..5d92900ea38 100644 --- a/mozilla/editor/base/Makefile.in +++ b/mozilla/editor/base/Makefile.in @@ -39,7 +39,6 @@ CPPSRCS = \ DeleteTextTxn.cpp \ EditAggregateTxn.cpp \ EditTxn.cpp \ - IMECommitTxn.cpp \ IMETextTxn.cpp \ InsertElementTxn.cpp \ InsertTextTxn.cpp \ diff --git a/mozilla/editor/base/PlaceholderTxn.cpp b/mozilla/editor/base/PlaceholderTxn.cpp index a03a46c31fb..68fae46d9e0 100644 --- a/mozilla/editor/base/PlaceholderTxn.cpp +++ b/mozilla/editor/base/PlaceholderTxn.cpp @@ -43,8 +43,6 @@ PlaceholderTxn::PlaceholderTxn() : EditAggregateTxn(), mEndSel(), mEditor(nsnull) { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } @@ -84,16 +82,16 @@ NS_IMETHODIMP PlaceholderTxn::Init(nsIAtom *aName, nsSelectionState *aSelState, return NS_OK; } -NS_IMETHODIMP PlaceholderTxn::Do(void) +NS_IMETHODIMP PlaceholderTxn::DoTransaction(void) { if (gNoisy) { printf("PlaceholderTxn Do\n"); } return NS_OK; } -NS_IMETHODIMP PlaceholderTxn::Undo(void) +NS_IMETHODIMP PlaceholderTxn::UndoTransaction(void) { // undo txns - nsresult res = EditAggregateTxn::Undo(); + nsresult res = EditAggregateTxn::UndoTransaction(); if (NS_FAILED(res)) return res; // now restore selection @@ -107,10 +105,10 @@ NS_IMETHODIMP PlaceholderTxn::Undo(void) } -NS_IMETHODIMP PlaceholderTxn::Redo(void) +NS_IMETHODIMP PlaceholderTxn::RedoTransaction(void) { // redo txns - nsresult res = EditAggregateTxn::Redo(); + nsresult res = EditAggregateTxn::RedoTransaction(); if (NS_FAILED(res)) return res; // now restore selection @@ -123,7 +121,7 @@ NS_IMETHODIMP PlaceholderTxn::Redo(void) } -NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP PlaceholderTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (!aDidMerge || !aTransaction) return NS_ERROR_NULL_POINTER; @@ -155,7 +153,7 @@ NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransact else { PRBool didMerge; - mIMETextTxn->Merge(&didMerge, otherTxn); + mIMETextTxn->Merge(otherTxn, &didMerge); if (!didMerge) { // it wouldn't merge. Earlier IME txn is already commited and will @@ -218,6 +216,20 @@ NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransact return res; } +NS_IMETHODIMP PlaceholderTxn::GetTxnDescription(nsAWritableString& aString) +{ + aString.Assign(NS_LITERAL_STRING("PlaceholderTxn: ")); + + if (mName) + { + nsAutoString name; + mName->ToString(name); + aString += name; + } + + return NS_OK; +} + NS_IMETHODIMP PlaceholderTxn::GetTxnName(nsIAtom **aName) { return GetName(aName); diff --git a/mozilla/editor/base/PlaceholderTxn.h b/mozilla/editor/base/PlaceholderTxn.h index d3c792d5cd7..09df75013ac 100644 --- a/mozilla/editor/base/PlaceholderTxn.h +++ b/mozilla/editor/base/PlaceholderTxn.h @@ -65,13 +65,15 @@ public: // ------------ EditAggregateTxn ----------------------- - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); + + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); // ------------ nsIAbsorbingTransaction ----------------------- @@ -91,8 +93,6 @@ public: friend class TransactionFactory; - enum { kTransactionID = 11260 }; - protected: /** the presentation shell, which we'll need to get the selection */ @@ -103,7 +103,8 @@ protected: PRBool mCommitted; // do we stop auto absorbing any matching placeholder txns? // these next two members store the state of the selection in a safe way. // selection at the start of the txn is stored, as is the selection at the end. - // This is so that Undo() and Redo() can restore the selection properly. + // This is so that UndoTransaction() and RedoTransaction() can restore the + // selection properly. nsSelectionState *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/base/SetDocTitleTxn.cpp b/mozilla/editor/base/SetDocTitleTxn.cpp index 501438f5990..aa879c9651c 100644 --- a/mozilla/editor/base/SetDocTitleTxn.cpp +++ b/mozilla/editor/base/SetDocTitleTxn.cpp @@ -36,8 +36,6 @@ SetDocTitleTxn::SetDocTitleTxn() : EditTxn() , mIsTransient(PR_FALSE) { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor, @@ -57,7 +55,7 @@ SetDocTitleTxn::~SetDocTitleTxn() { } -NS_IMETHODIMP SetDocTitleTxn::Do(void) +NS_IMETHODIMP SetDocTitleTxn::DoTransaction(void) { nsresult res = SetDomTitle(mValue); if (NS_FAILED(res)) return res; @@ -65,12 +63,12 @@ NS_IMETHODIMP SetDocTitleTxn::Do(void) return SetDocTitle(mValue); } -NS_IMETHODIMP SetDocTitleTxn::Undo(void) +NS_IMETHODIMP SetDocTitleTxn::UndoTransaction(void) { return SetDocTitle(mUndoValue); } -NS_IMETHODIMP SetDocTitleTxn::Redo(void) +NS_IMETHODIMP SetDocTitleTxn::RedoTransaction(void) { return SetDocTitle(mValue); } @@ -208,35 +206,17 @@ nsresult SetDocTitleTxn::SetDomTitle(nsString& aTitle) return res; } -NS_IMETHODIMP SetDocTitleTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP SetDocTitleTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP SetDocTitleTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP SetDocTitleTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP SetDocTitleTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Restore Document Title: "); - *aString += mUndoValue; - } - return NS_OK; -} - -NS_IMETHODIMP SetDocTitleTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Set Document Title: "); - *aString += mValue; - } + aString.Assign(NS_LITERAL_STRING("SetDocTitleTxn: ")); + aString += mValue; return NS_OK; } diff --git a/mozilla/editor/base/SetDocTitleTxn.h b/mozilla/editor/base/SetDocTitleTxn.h index e2989a35a81..715e664e0e9 100644 --- a/mozilla/editor/base/SetDocTitleTxn.h +++ b/mozilla/editor/base/SetDocTitleTxn.h @@ -27,7 +27,6 @@ #include "nsIEditor.h" #include "nsIHTMLEditor.h" #include "nsITransaction.h" -#include "nsITransactionDescription.h" #include "nsCOMPtr.h" #define SET_DOC_TITLE_TXN_CID \ @@ -61,23 +60,17 @@ private: nsresult SetDomTitle(nsString& aTitle); public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); - - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - enum { kTransactionID = 11270 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/base/SplitElementTxn.cpp b/mozilla/editor/base/SplitElementTxn.cpp index e742f526ec6..000ba72fb95 100644 --- a/mozilla/editor/base/SplitElementTxn.cpp +++ b/mozilla/editor/base/SplitElementTxn.cpp @@ -37,8 +37,6 @@ static const PRBool gNoisy = PR_FALSE; SplitElementTxn::SplitElementTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP SplitElementTxn::Init(nsEditor *aEditor, @@ -58,7 +56,7 @@ SplitElementTxn::~SplitElementTxn() { } -NS_IMETHODIMP SplitElementTxn::Do(void) +NS_IMETHODIMP SplitElementTxn::DoTransaction(void) { if (gNoisy) { printf("%p Do Split of node %p offset %d\n", this, mExistingRightNode.get(), mOffset); } NS_ASSERTION(mExistingRightNode && mEditor, "bad state"); @@ -94,7 +92,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void) return result; } -NS_IMETHODIMP SplitElementTxn::Undo(void) +NS_IMETHODIMP SplitElementTxn::UndoTransaction(void) { if (gNoisy) { printf("%p Undo Split of existing node %p and new node %p offset %d\n", @@ -122,7 +120,7 @@ NS_IMETHODIMP SplitElementTxn::Undo(void) /* redo cannot simply resplit the right node, because subsequent transactions * on the redo stack may depend on the left node existing in its previous state. */ -NS_IMETHODIMP SplitElementTxn::Redo(void) +NS_IMETHODIMP SplitElementTxn::RedoTransaction(void) { NS_ASSERTION(mEditor && mExistingRightNode && mNewLeftNode && mParent, "bad state"); if (!mEditor || !mExistingRightNode || !mNewLeftNode || !mParent) { @@ -182,33 +180,16 @@ NS_IMETHODIMP SplitElementTxn::Redo(void) } -NS_IMETHODIMP SplitElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP SplitElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP SplitElementTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP SplitElementTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP SplitElementTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Join Element"); - } - return NS_OK; -} - -NS_IMETHODIMP SplitElementTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Split Element"); - } + aString.Assign(NS_LITERAL_STRING("SplitElementTxn")); return NS_OK; } diff --git a/mozilla/editor/base/SplitElementTxn.h b/mozilla/editor/base/SplitElementTxn.h index 0e03c5831d7..bc096cf86a6 100644 --- a/mozilla/editor/base/SplitElementTxn.h +++ b/mozilla/editor/base/SplitElementTxn.h @@ -61,24 +61,18 @@ protected: public: virtual ~SplitElementTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); - enum { kTransactionID = 11190 }; - protected: /** the element to operate upon */ diff --git a/mozilla/editor/base/makefile.win b/mozilla/editor/base/makefile.win index af29fa9b071..0133feb46c3 100644 --- a/mozilla/editor/base/makefile.win +++ b/mozilla/editor/base/makefile.win @@ -39,7 +39,6 @@ CPPSRCS = \ DeleteTextTxn.cpp \ EditAggregateTxn.cpp \ EditTxn.cpp \ - IMECommitTxn.cpp \ IMETextTxn.cpp \ InsertElementTxn.cpp \ InsertTextTxn.cpp \ @@ -70,7 +69,6 @@ CPP_OBJS = \ .\$(OBJDIR)\DeleteTextTxn.obj \ .\$(OBJDIR)\EditAggregateTxn.obj \ .\$(OBJDIR)\EditTxn.obj \ - .\$(OBJDIR)\IMECommitTxn.obj \ .\$(OBJDIR)\IMETextTxn.obj \ .\$(OBJDIR)\InsertElementTxn.obj \ .\$(OBJDIR)\InsertTextTxn.obj \ diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index b3def864b9f..1be8202b590 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -423,10 +423,10 @@ nsEditor::Do(nsITransaction *aTxn) selPrivate->StartBatchChanges(); if (mTxnMgr) { - result = mTxnMgr->Do(aTxn); + result = mTxnMgr->DoTransaction(aTxn); } else { - result = aTxn->Do(); + result = aTxn->DoTransaction(); } if (NS_SUCCEEDED(result)) { result = DoAfterDoTransaction(aTxn); @@ -500,7 +500,7 @@ nsEditor::Undo(PRUint32 aCount) PRUint32 i=0; for ( ; iUndo(); + result = mTxnMgr->UndoTransaction(); if (NS_SUCCEEDED(result)) result = DoAfterUndoTransaction(); @@ -544,7 +544,7 @@ nsEditor::Redo(PRUint32 aCount) PRUint32 i=0; for ( ; iRedo(); + result = mTxnMgr->RedoTransaction(); if (NS_SUCCEEDED(result)) result = DoAfterRedoTransaction(); @@ -1015,7 +1015,7 @@ NS_IMETHODIMP nsEditor::CreateNode(const nsString& aTag, if (NS_SUCCEEDED(result)) { result = txn->GetNewNode(aNewNode); - NS_ASSERTION((NS_SUCCEEDED(result)), "GetNewNode can't fail if txn::Do succeeded."); + NS_ASSERTION((NS_SUCCEEDED(result)), "GetNewNode can't fail if txn::DoTransaction succeeded."); } } // The transaction system (if any) has taken ownwership of txn @@ -1771,9 +1771,8 @@ nsEditor::EndComposition(void) // Note that this means IME won't work without an undo stack! if (mTxnMgr) { - nsITransaction *txn; - result = mTxnMgr->PeekUndoStack(&txn); - // PeekUndoStack does not addref + nsCOMPtr txn; + result = mTxnMgr->PeekUndoStack(getter_AddRefs(txn)); nsCOMPtr plcTxn = do_QueryInterface(txn); if (plcTxn) { diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index a38aafddab2..44b3d2dcbc8 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -2299,6 +2299,17 @@ nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval) return rv; } +NS_IMETHODIMP +nsEditorShell::GetTransactionManager(nsITransactionManager **aTxnMgr) +{ + nsCOMPtr editor = do_QueryInterface(mEditor); + + if (!editor) + return NS_ERROR_FAILURE; + + return editor->GetTransactionManager(aTxnMgr); +} + NS_IMETHODIMP nsEditorShell::Undo() { diff --git a/mozilla/editor/base/nsEditorTxnLog.cpp b/mozilla/editor/base/nsEditorTxnLog.cpp index 2638a6ae177..330868a2e24 100644 --- a/mozilla/editor/base/nsEditorTxnLog.cpp +++ b/mozilla/editor/base/nsEditorTxnLog.cpp @@ -24,6 +24,7 @@ #include #include "nsHTMLEditorLog.h" #include "nsEditorTxnLog.h" +#include "nsPIEditorTransaction.h" #define LOCK_LOG(doc) #define UNLOCK_LOG(doc) @@ -361,7 +362,12 @@ nsEditorTxnLog::GetString(nsITransaction *aTransaction, char *aBuffer, PRInt32 a nsString str; - aTransaction->GetRedoString(&str); + nsCOMPtr txn = do_QueryInterface(aTransaction); + + if (!txn) + return aBuffer; + + txn->GetTxnDescription(str); if (str.Length() == 0) str.AssignWithConversion(""); diff --git a/mozilla/editor/base/nsStyleSheetTxns.cpp b/mozilla/editor/base/nsStyleSheetTxns.cpp index 3f885a83944..fd02431441e 100644 --- a/mozilla/editor/base/nsStyleSheetTxns.cpp +++ b/mozilla/editor/base/nsStyleSheetTxns.cpp @@ -38,8 +38,6 @@ AddStyleSheetTxn::AddStyleSheetTxn() : EditTxn() , mEditor(NULL) { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } AddStyleSheetTxn::~AddStyleSheetTxn() @@ -63,7 +61,7 @@ AddStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet) NS_IMETHODIMP -AddStyleSheetTxn::Do() +AddStyleSheetTxn::DoTransaction() { if (!mEditor || !mSheet) return NS_ERROR_NOT_INITIALIZED; @@ -100,7 +98,7 @@ AddStyleSheetTxn::Do() } NS_IMETHODIMP -AddStyleSheetTxn::Undo() +AddStyleSheetTxn::UndoTransaction() { if (!mEditor || !mSheet) return NS_ERROR_NOT_INITIALIZED; @@ -136,13 +134,13 @@ AddStyleSheetTxn::Undo() } NS_IMETHODIMP -AddStyleSheetTxn::Redo() +AddStyleSheetTxn::RedoTransaction() { - return Do(); + return DoTransaction(); } NS_IMETHODIMP -AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +AddStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { // set out param default value if (!aDidMerge) @@ -153,28 +151,9 @@ AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) } NS_IMETHODIMP -AddStyleSheetTxn::Write(nsIOutputStream *aOutputStream) +AddStyleSheetTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP -AddStyleSheetTxn::GetUndoString(nsString *aString) -{ - if (aString) - { - aString->AssignWithConversion("Remove Style Sheet"); - } - return NS_OK; -} - -NS_IMETHODIMP -AddStyleSheetTxn::GetRedoString(nsString *aString) -{ - if (aString) - { - aString->AssignWithConversion("Add Style Sheet"); - } + aString.Assign(NS_LITERAL_STRING("AddStyleSheetTxn")); return NS_OK; } @@ -187,7 +166,6 @@ RemoveStyleSheetTxn::RemoveStyleSheetTxn() : EditTxn() , mEditor(NULL) { - SetTransactionDescriptionID( kTransactionID ); } RemoveStyleSheetTxn::~RemoveStyleSheetTxn() @@ -211,7 +189,7 @@ RemoveStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet) NS_IMETHODIMP -RemoveStyleSheetTxn::Do() +RemoveStyleSheetTxn::DoTransaction() { if (!mEditor || !mSheet) return NS_ERROR_NOT_INITIALIZED; @@ -247,7 +225,7 @@ RemoveStyleSheetTxn::Do() } NS_IMETHODIMP -RemoveStyleSheetTxn::Undo() +RemoveStyleSheetTxn::UndoTransaction() { if (!mEditor || !mSheet) return NS_ERROR_NOT_INITIALIZED; @@ -283,13 +261,13 @@ RemoveStyleSheetTxn::Undo() } NS_IMETHODIMP -RemoveStyleSheetTxn::Redo() +RemoveStyleSheetTxn::RedoTransaction() { - return Do(); + return DoTransaction(); } NS_IMETHODIMP -RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +RemoveStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { // set out param default value if (!aDidMerge) @@ -300,27 +278,8 @@ RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) } NS_IMETHODIMP -RemoveStyleSheetTxn::Write(nsIOutputStream *aOutputStream) +RemoveStyleSheetTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP -RemoveStyleSheetTxn::GetUndoString(nsString *aString) -{ - if (aString) - { - aString->AssignWithConversion("Add Style Sheet"); - } - return NS_OK; -} - -NS_IMETHODIMP -RemoveStyleSheetTxn::GetRedoString(nsString *aString) -{ - if (aString) - { - aString->AssignWithConversion("Remove Style Sheet"); - } + aString.Assign(NS_LITERAL_STRING("RemoveStyleSheetTxn")); return NS_OK; } diff --git a/mozilla/editor/base/nsStyleSheetTxns.h b/mozilla/editor/base/nsStyleSheetTxns.h index c1a1193998e..c7fe5614c12 100644 --- a/mozilla/editor/base/nsStyleSheetTxns.h +++ b/mozilla/editor/base/nsStyleSheetTxns.h @@ -59,21 +59,15 @@ private: public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11240 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: @@ -105,21 +99,15 @@ private: public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11250 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index a38aafddab2..44b3d2dcbc8 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -2299,6 +2299,17 @@ nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval) return rv; } +NS_IMETHODIMP +nsEditorShell::GetTransactionManager(nsITransactionManager **aTxnMgr) +{ + nsCOMPtr editor = do_QueryInterface(mEditor); + + if (!editor) + return NS_ERROR_FAILURE; + + return editor->GetTransactionManager(aTxnMgr); +} + NS_IMETHODIMP nsEditorShell::Undo() { diff --git a/mozilla/editor/idl/MANIFEST b/mozilla/editor/idl/MANIFEST index 0c9f1336788..51fbd21cb82 100644 --- a/mozilla/editor/idl/MANIFEST +++ b/mozilla/editor/idl/MANIFEST @@ -26,3 +26,4 @@ nsIEditorSpellCheck.idl nsIDocumentStateListener.idl nsIEditorService.idl nsIEditorController.idl +nsPIEditorTransaction.idl diff --git a/mozilla/editor/idl/Makefile.in b/mozilla/editor/idl/Makefile.in index 7ddb4e0b303..c2b03e4b8ec 100644 --- a/mozilla/editor/idl/Makefile.in +++ b/mozilla/editor/idl/Makefile.in @@ -35,6 +35,7 @@ XPIDLSRCS = \ nsIDocumentStateListener.idl \ nsIEditorService.idl \ nsIEditorController.idl \ + nsPIEditorTransaction.idl \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/mozilla/editor/idl/makefile.win b/mozilla/editor/idl/makefile.win index cdcad44335a..86eb8e1a1ae 100644 --- a/mozilla/editor/idl/makefile.win +++ b/mozilla/editor/idl/makefile.win @@ -23,16 +23,16 @@ DEPTH=..\.. - MODULE=editor XPIDL_MODULE=editor -XPIDLSRCS = .\nsIEditorShell.idl \ - .\nsIPlaintextEditor.idl \ - .\nsIEditorSpellCheck.idl \ - .\nsIDocumentStateListener.idl \ - .\nsIEditorService.idl \ - .\nsIEditorController.idl \ - $(NULL) +XPIDLSRCS = .\nsIEditorShell.idl \ + .\nsIPlaintextEditor.idl \ + .\nsIEditorSpellCheck.idl \ + .\nsIDocumentStateListener.idl \ + .\nsIEditorService.idl \ + .\nsIEditorController.idl \ + .\nsPIEditorTransaction.idl \ + $(NULL) include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/editor/idl/nsIEditorShell.idl b/mozilla/editor/idl/nsIEditorShell.idl index 63a99246c46..8cba8ae5ec6 100644 --- a/mozilla/editor/idl/nsIEditorShell.idl +++ b/mozilla/editor/idl/nsIEditorShell.idl @@ -26,6 +26,7 @@ #include "nsISupportsArray.idl" #include "nsIDocumentStateListener.idl" #include "nsISelectionController.idl" +#include "nsITransactionManager.idl" %{C++ @@ -42,15 +43,16 @@ interface nsIEditor; [scriptable, uuid(9afff72b-ca9a-11d2-96c9-0060b0fb9956)] interface nsIEditorShell : nsISupports { - readonly attribute nsIDOMDocument editorDocument; - readonly attribute nsISelection editorSelection; - readonly attribute nsISelectionController selectionController; + readonly attribute nsIDOMDocument editorDocument; + readonly attribute nsISelection editorSelection; + readonly attribute nsISelectionController selectionController; + readonly attribute nsITransactionManager transactionManager; - attribute nsIDOMWindowInternal webShellWindow; - attribute nsIDOMWindowInternal contentWindow; - attribute wstring editorType; + attribute nsIDOMWindowInternal webShellWindow; + attribute nsIDOMWindowInternal contentWindow; + attribute wstring editorType; - [noscript] readonly attribute nsIEditor editor; + [noscript] readonly attribute nsIEditor editor; %{C++ diff --git a/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp b/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp index d255647e30d..dc950dff226 100644 --- a/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp +++ b/mozilla/editor/libeditor/base/ChangeAttributeTxn.cpp @@ -27,8 +27,6 @@ ChangeAttributeTxn::ChangeAttributeTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } ChangeAttributeTxn::~ChangeAttributeTxn() @@ -54,7 +52,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor, return NS_OK; } -NS_IMETHODIMP ChangeAttributeTxn::Do(void) +NS_IMETHODIMP ChangeAttributeTxn::DoTransaction(void) { NS_ASSERTION(mEditor && mElement, "bad state"); if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } @@ -75,7 +73,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Do(void) return result; } -NS_IMETHODIMP ChangeAttributeTxn::Undo(void) +NS_IMETHODIMP ChangeAttributeTxn::UndoTransaction(void) { NS_ASSERTION(mEditor && mElement, "bad state"); if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } @@ -89,7 +87,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Undo(void) return result; } -NS_IMETHODIMP ChangeAttributeTxn::Redo(void) +NS_IMETHODIMP ChangeAttributeTxn::RedoTransaction(void) { NS_ASSERTION(mEditor && mElement, "bad state"); if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } @@ -104,40 +102,21 @@ NS_IMETHODIMP ChangeAttributeTxn::Redo(void) return result; } -NS_IMETHODIMP ChangeAttributeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP ChangeAttributeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP ChangeAttributeTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP ChangeAttributeTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} + aString.Assign(NS_LITERAL_STRING("ChangeAttributeTxn: ")); -NS_IMETHODIMP ChangeAttributeTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - if (PR_FALSE==mRemoveAttribute) - aString->AssignWithConversion("Change Attribute: "); - else - aString->AssignWithConversion("Remove Attribute: "); - *aString += mAttribute; - } - return NS_OK; -} - -NS_IMETHODIMP ChangeAttributeTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - if (PR_FALSE==mRemoveAttribute) - aString->AssignWithConversion("Change Attribute: "); - else - aString->AssignWithConversion("Add Attribute: "); - *aString += mAttribute; - } + if (PR_FALSE==mRemoveAttribute) + aString += NS_LITERAL_STRING("[mRemoveAttribute == false] "); + else + aString += NS_LITERAL_STRING("[mRemoveAttribute == true] "); + aString += mAttribute; return NS_OK; } diff --git a/mozilla/editor/libeditor/base/ChangeAttributeTxn.h b/mozilla/editor/libeditor/base/ChangeAttributeTxn.h index 30585863dc8..e9459b800f4 100644 --- a/mozilla/editor/libeditor/base/ChangeAttributeTxn.h +++ b/mozilla/editor/libeditor/base/ChangeAttributeTxn.h @@ -63,21 +63,15 @@ private: public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11180 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/libeditor/base/CreateElementTxn.cpp b/mozilla/editor/libeditor/base/CreateElementTxn.cpp index e7080bd959c..dabc508b114 100644 --- a/mozilla/editor/libeditor/base/CreateElementTxn.cpp +++ b/mozilla/editor/libeditor/base/CreateElementTxn.cpp @@ -40,8 +40,6 @@ static const PRBool gNoisy = PR_FALSE; CreateElementTxn::CreateElementTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor, @@ -72,7 +70,7 @@ CreateElementTxn::~CreateElementTxn() { } -NS_IMETHODIMP CreateElementTxn::Do(void) +NS_IMETHODIMP CreateElementTxn::DoTransaction(void) { if (gNoisy) { @@ -170,7 +168,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void) return result; } -NS_IMETHODIMP CreateElementTxn::Undo(void) +NS_IMETHODIMP CreateElementTxn::UndoTransaction(void) { if (gNoisy) { printf("Undo Create Element, mParent = %p, node = %p\n", mParent.get(), mNewNode.get()); } @@ -182,7 +180,7 @@ NS_IMETHODIMP CreateElementTxn::Undo(void) return result; } -NS_IMETHODIMP CreateElementTxn::Redo(void) +NS_IMETHODIMP CreateElementTxn::RedoTransaction(void) { if (gNoisy) { printf("Redo Create Element\n"); } NS_ASSERTION(mEditor && mParent, "bad state"); @@ -203,35 +201,17 @@ NS_IMETHODIMP CreateElementTxn::Redo(void) return result; } -NS_IMETHODIMP CreateElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP CreateElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP CreateElementTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP CreateElementTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP CreateElementTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Element: "); - *aString += mTag; - } - return NS_OK; -} - -NS_IMETHODIMP CreateElementTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Create Element: "); - *aString += mTag; - } + aString.Assign(NS_LITERAL_STRING("CreateElementTxn: ")); + aString += mTag; return NS_OK; } diff --git a/mozilla/editor/libeditor/base/CreateElementTxn.h b/mozilla/editor/libeditor/base/CreateElementTxn.h index 5948557029e..733921e0d34 100644 --- a/mozilla/editor/libeditor/base/CreateElementTxn.h +++ b/mozilla/editor/libeditor/base/CreateElementTxn.h @@ -63,24 +63,18 @@ public: virtual ~CreateElementTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); - enum { kTransactionID = 11140 }; - protected: /** the document into which the new node will be inserted */ diff --git a/mozilla/editor/libeditor/base/DeleteElementTxn.cpp b/mozilla/editor/libeditor/base/DeleteElementTxn.cpp index 928e3a6f6ce..eca72b49d62 100644 --- a/mozilla/editor/libeditor/base/DeleteElementTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteElementTxn.cpp @@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE; DeleteElementTxn::DeleteElementTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP DeleteElementTxn::Init(nsIDOMNode *aElement) @@ -54,7 +52,7 @@ DeleteElementTxn::~DeleteElementTxn() { } -NS_IMETHODIMP DeleteElementTxn::Do(void) +NS_IMETHODIMP DeleteElementTxn::DoTransaction(void) { if (gNoisy) { printf("%p Do Delete Element element = %p\n", this, mElement.get()); } if (!mElement) return NS_ERROR_NOT_INITIALIZED; @@ -96,7 +94,7 @@ NS_IMETHODIMP DeleteElementTxn::Do(void) return result; } -NS_IMETHODIMP DeleteElementTxn::Undo(void) +NS_IMETHODIMP DeleteElementTxn::UndoTransaction(void) { if (gNoisy) { printf("%p Undo Delete Element element = %p, parent = %p\n", this, mElement.get(), mParent.get()); } if (!mParent) { return NS_OK; } // this is a legal state, the txn is a no-op @@ -132,7 +130,7 @@ NS_IMETHODIMP DeleteElementTxn::Undo(void) return result; } -NS_IMETHODIMP DeleteElementTxn::Redo(void) +NS_IMETHODIMP DeleteElementTxn::RedoTransaction(void) { if (gNoisy) { printf("%p Redo Delete Element element = %p, parent = %p\n", this, mElement.get(), mParent.get()); } if (!mParent) { return NS_OK; } // this is a legal state, the txn is a no-op @@ -144,32 +142,15 @@ NS_IMETHODIMP DeleteElementTxn::Redo(void) } -NS_IMETHODIMP DeleteElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP DeleteElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP DeleteElementTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP DeleteElementTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP DeleteElementTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Element: "); - } - return NS_OK; -} - -NS_IMETHODIMP DeleteElementTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Element: "); - } + aString.Assign(NS_LITERAL_STRING("DeleteElementTxn")); return NS_OK; } diff --git a/mozilla/editor/libeditor/base/DeleteElementTxn.h b/mozilla/editor/libeditor/base/DeleteElementTxn.h index 264ca48911b..1f920cace0f 100644 --- a/mozilla/editor/libeditor/base/DeleteElementTxn.h +++ b/mozilla/editor/libeditor/base/DeleteElementTxn.h @@ -53,21 +53,15 @@ public: virtual ~DeleteElementTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11160 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp index 213e80b2aa8..3713f1f0cbd 100644 --- a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp @@ -47,8 +47,6 @@ static const PRBool gNoisy = PR_FALSE; DeleteRangeTxn::DeleteRangeTxn() : EditAggregateTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP DeleteRangeTxn::Init(nsIEditor *aEditor, nsIDOMRange *aRange) @@ -112,7 +110,7 @@ DeleteRangeTxn::~DeleteRangeTxn() { } -NS_IMETHODIMP DeleteRangeTxn::Do(void) +NS_IMETHODIMP DeleteRangeTxn::DoTransaction(void) { if (gNoisy) { printf("Do Delete Range\n"); } if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) @@ -143,7 +141,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void) // if we've successfully built this aggregate transaction, then do it. if (NS_SUCCEEDED(result)) { - result = EditAggregateTxn::Do(); + result = EditAggregateTxn::DoTransaction(); } if (NS_FAILED(result)) return result; @@ -167,53 +165,36 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void) return result; } -NS_IMETHODIMP DeleteRangeTxn::Undo(void) +NS_IMETHODIMP DeleteRangeTxn::UndoTransaction(void) { if (gNoisy) { printf("Undo Delete Range\n"); } if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) return NS_ERROR_NOT_INITIALIZED; - nsresult result = EditAggregateTxn::Undo(); + nsresult result = EditAggregateTxn::UndoTransaction(); return result; } -NS_IMETHODIMP DeleteRangeTxn::Redo(void) +NS_IMETHODIMP DeleteRangeTxn::RedoTransaction(void) { if (gNoisy) { printf("Redo Delete Range\n"); } if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) return NS_ERROR_NOT_INITIALIZED; - nsresult result = EditAggregateTxn::Redo(); + nsresult result = EditAggregateTxn::RedoTransaction(); return result; } -NS_IMETHODIMP DeleteRangeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP DeleteRangeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP DeleteRangeTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP DeleteRangeTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP DeleteRangeTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Range: "); - } - return NS_OK; -} - -NS_IMETHODIMP DeleteRangeTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Range: "); - } + aString.Assign(NS_LITERAL_STRING("DeleteRangeTxn")); return NS_OK; } diff --git a/mozilla/editor/libeditor/base/DeleteRangeTxn.h b/mozilla/editor/libeditor/base/DeleteRangeTxn.h index 638b2b6f546..fe1081c3748 100644 --- a/mozilla/editor/libeditor/base/DeleteRangeTxn.h +++ b/mozilla/editor/libeditor/base/DeleteRangeTxn.h @@ -61,21 +61,15 @@ public: virtual ~DeleteRangeTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11170 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/libeditor/base/DeleteTextTxn.cpp b/mozilla/editor/libeditor/base/DeleteTextTxn.cpp index 88db0665f0f..c188fb406a7 100644 --- a/mozilla/editor/libeditor/base/DeleteTextTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteTextTxn.cpp @@ -33,8 +33,6 @@ static const PRBool gNoisy = PR_FALSE; DeleteTextTxn::DeleteTextTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } DeleteTextTxn::~DeleteTextTxn() @@ -62,7 +60,7 @@ NS_IMETHODIMP DeleteTextTxn::Init(nsIEditor *aEditor, return NS_OK; } -NS_IMETHODIMP DeleteTextTxn::Do(void) +NS_IMETHODIMP DeleteTextTxn::DoTransaction(void) { if (gNoisy) { printf("Do Delete Text\n"); } NS_ASSERTION(mEditor && mElement, "bad state"); @@ -94,7 +92,7 @@ NS_IMETHODIMP DeleteTextTxn::Do(void) //XXX: we may want to store the selection state and restore it properly // was it an insertion point or an extended selection? -NS_IMETHODIMP DeleteTextTxn::Undo(void) +NS_IMETHODIMP DeleteTextTxn::UndoTransaction(void) { if (gNoisy) { printf("Undo Delete Text\n"); } NS_ASSERTION(mEditor && mElement, "bad state"); @@ -105,34 +103,16 @@ NS_IMETHODIMP DeleteTextTxn::Undo(void) return result; } -NS_IMETHODIMP DeleteTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP DeleteTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP DeleteTextTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP DeleteTextTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP DeleteTextTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Text: "); - *aString += mDeletedText; - } - return NS_OK; -} - -NS_IMETHODIMP DeleteTextTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Text: "); - *aString += mDeletedText; - } + aString.Assign(NS_LITERAL_STRING("DeleteTextTxn: ")); + aString += mDeletedText; return NS_OK; } diff --git a/mozilla/editor/libeditor/base/DeleteTextTxn.h b/mozilla/editor/libeditor/base/DeleteTextTxn.h index f5894d7c7fe..5234532d60f 100644 --- a/mozilla/editor/libeditor/base/DeleteTextTxn.h +++ b/mozilla/editor/libeditor/base/DeleteTextTxn.h @@ -59,19 +59,13 @@ private: public: virtual ~DeleteTextTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11130 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/libeditor/base/EditAggregateTxn.cpp b/mozilla/editor/libeditor/base/EditAggregateTxn.cpp index 18378c8d32b..286419fa448 100644 --- a/mozilla/editor/libeditor/base/EditAggregateTxn.cpp +++ b/mozilla/editor/libeditor/base/EditAggregateTxn.cpp @@ -31,8 +31,6 @@ EditAggregateTxn::EditAggregateTxn() // base class does this: NS_INIT_REFCNT(); nsresult res = NS_NewISupportsArray(getter_AddRefs(mChildren)); NS_POSTCONDITION(NS_SUCCEEDED(res), "EditAggregateTxn failed in constructor"); - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } EditAggregateTxn::~EditAggregateTxn() @@ -40,7 +38,7 @@ EditAggregateTxn::~EditAggregateTxn() // nsISupportsArray cleans up array for us at destruct time } -NS_IMETHODIMP EditAggregateTxn::Do(void) +NS_IMETHODIMP EditAggregateTxn::DoTransaction(void) { nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list if (mChildren) @@ -53,7 +51,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void) nsCOMPtr isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr txn ( do_QueryInterface(isupports) ); if (!txn) { return NS_ERROR_NULL_POINTER; } - result = txn->Do(); + result = txn->DoTransaction(); if (NS_FAILED(result)) break; } @@ -61,7 +59,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void) return result; } -NS_IMETHODIMP EditAggregateTxn::Undo(void) +NS_IMETHODIMP EditAggregateTxn::UndoTransaction(void) { nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list if (mChildren) @@ -75,7 +73,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void) nsCOMPtr isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr txn ( do_QueryInterface(isupports) ); if (!txn) { return NS_ERROR_NULL_POINTER; } - result = txn->Undo(); + result = txn->UndoTransaction(); if (NS_FAILED(result)) break; } @@ -83,7 +81,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void) return result; } -NS_IMETHODIMP EditAggregateTxn::Redo(void) +NS_IMETHODIMP EditAggregateTxn::RedoTransaction(void) { nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list if (mChildren) @@ -96,7 +94,7 @@ NS_IMETHODIMP EditAggregateTxn::Redo(void) nsCOMPtr isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr txn ( do_QueryInterface(isupports) ); if (!txn) { return NS_ERROR_NULL_POINTER; } - result = txn->Redo(); + result = txn->RedoTransaction(); if (NS_FAILED(result)) break; } @@ -111,7 +109,7 @@ NS_IMETHODIMP EditAggregateTxn::GetIsTransient(PRBool *aIsTransient) return NS_OK; } -NS_IMETHODIMP EditAggregateTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +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 if (nsnull!=aDidMerge) @@ -127,29 +125,24 @@ NS_IMETHODIMP EditAggregateTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransa nsCOMPtr isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr txn ( do_QueryInterface(isupports) ); if (!txn) { return NS_ERROR_NULL_POINTER; } - result = txn->Merge(aDidMerge, aTransaction); + result = txn->Merge(aTransaction, aDidMerge); } } return result; } -NS_IMETHODIMP EditAggregateTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP EditAggregateTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} + aString.Assign(NS_LITERAL_STRING("EditAggregateTxn: ")); -NS_IMETHODIMP EditAggregateTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - aString->SetLength(0); - return NS_OK; -} + if (mName) + { + nsAutoString name; + mName->ToString(name); + aString += name; + } -NS_IMETHODIMP EditAggregateTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - aString->SetLength(0); return NS_OK; } diff --git a/mozilla/editor/libeditor/base/EditAggregateTxn.h b/mozilla/editor/libeditor/base/EditAggregateTxn.h index 339466349f8..e1b8dfa2510 100644 --- a/mozilla/editor/libeditor/base/EditAggregateTxn.h +++ b/mozilla/editor/libeditor/base/EditAggregateTxn.h @@ -50,21 +50,17 @@ public: virtual ~EditAggregateTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); /** append a transaction to this aggregate */ NS_IMETHOD AppendChild(EditTxn *aTxn); @@ -85,8 +81,6 @@ public: /** get the name assigned to this txn */ NS_IMETHOD GetName(nsIAtom **aName); - enum { kTransactionID = 11210 }; - protected: nsCOMPtr mChildren; diff --git a/mozilla/editor/libeditor/base/EditTxn.cpp b/mozilla/editor/libeditor/base/EditTxn.cpp index 25aab1f397f..6f2368eca17 100644 --- a/mozilla/editor/libeditor/base/EditTxn.cpp +++ b/mozilla/editor/libeditor/base/EditTxn.cpp @@ -34,7 +34,6 @@ NS_IMPL_RELEASE(EditTxn) // note that aEditor is not refcounted EditTxn::EditTxn() - : mTransactionID(-1) { NS_INIT_REFCNT(); } @@ -43,19 +42,19 @@ EditTxn::~EditTxn() { } -NS_IMETHODIMP EditTxn::Do(void) +NS_IMETHODIMP EditTxn::DoTransaction(void) { return NS_OK; } -NS_IMETHODIMP EditTxn::Undo(void) +NS_IMETHODIMP EditTxn::UndoTransaction(void) { return NS_OK; } -NS_IMETHODIMP EditTxn::Redo(void) +NS_IMETHODIMP EditTxn::RedoTransaction(void) { - return Do(); + return DoTransaction(); } NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient) @@ -65,53 +64,14 @@ NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient) return NS_OK; } -NS_IMETHODIMP EditTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP EditTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { return NS_OK; } -NS_IMETHODIMP EditTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP EditTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP EditTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - aString->SetLength(0); - return NS_OK; -} - -NS_IMETHODIMP EditTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - aString->SetLength(0); - return NS_OK; -} - -NS_IMETHODIMP EditTxn::GetLogDescription(PRUnichar * *aString) -{ - if (nsnull!=aString) - *aString = mLogDescription.ToNewUnicode(); - return NS_OK; -} - -NS_IMETHODIMP EditTxn::SetLogDescription(const PRUnichar *aString) -{ - mLogDescription = (PRUnichar *)aString; - return NS_OK; -} - -NS_IMETHODIMP EditTxn::GetTransactionDescriptionID(int *aID) -{ - if (nsnull!=aID) - *aID = mTransactionID; - return NS_OK; -} - -NS_IMETHODIMP EditTxn::SetTransactionDescriptionID(int aID) -{ - mTransactionID = aID; + aString.Assign(NS_LITERAL_STRING("EditTxn")); return NS_OK; } @@ -133,12 +93,13 @@ EditTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - if (aIID.Equals(NS_GET_IID(nsITransactionDescription))) { - *aInstancePtr = (void*)(nsITransactionDescription*)this; + if (aIID.Equals(NS_GET_IID(nsPIEditorTransaction))) { + *aInstancePtr = (void*)(nsPIEditorTransaction*)this; NS_ADDREF_THIS(); return NS_OK; } + *aInstancePtr = 0; return NS_NOINTERFACE; } diff --git a/mozilla/editor/libeditor/base/EditTxn.h b/mozilla/editor/libeditor/base/EditTxn.h index 592dd3f73f6..8875bcce5af 100644 --- a/mozilla/editor/libeditor/base/EditTxn.h +++ b/mozilla/editor/libeditor/base/EditTxn.h @@ -24,8 +24,10 @@ #define EditTxn_h__ #include "nsITransaction.h" -#include "nsITransactionDescription.h" +#include "nsIOutputStream.h" +#include "nsString.h" #include "nsCOMPtr.h" +#include "nsPIEditorTransaction.h" #define EDIT_TXN_CID \ {/* c5ea31b0-ac48-11d2-86d8-000064657374 */ \ @@ -39,7 +41,7 @@ * it is never seen by the user or by any external entity. */ class EditTxn : public nsITransaction - , public nsITransactionDescription + , public nsPIEditorTransaction { public: @@ -51,27 +53,17 @@ public: virtual ~EditTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11100 }; - - NS_DECL_NSITRANSACTIONDESCRIPTION - nsString mLogDescription; - int mTransactionID; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); }; #endif diff --git a/mozilla/editor/libeditor/base/IMETextTxn.cpp b/mozilla/editor/libeditor/base/IMETextTxn.cpp index 95aa41bd6f5..fbb37087dab 100644 --- a/mozilla/editor/libeditor/base/IMETextTxn.cpp +++ b/mozilla/editor/libeditor/base/IMETextTxn.cpp @@ -54,8 +54,6 @@ nsresult IMETextTxn::ClassShutdown() IMETextTxn::IMETextTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } IMETextTxn::~IMETextTxn() @@ -84,7 +82,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement, return NS_OK; } -NS_IMETHODIMP IMETextTxn::Do(void) +NS_IMETHODIMP IMETextTxn::DoTransaction(void) { #ifdef DEBUG_IMETXN @@ -108,7 +106,7 @@ NS_IMETHODIMP IMETextTxn::Do(void) return result; } -NS_IMETHODIMP IMETextTxn::Undo(void) +NS_IMETHODIMP IMETextTxn::UndoTransaction(void) { #ifdef DEBUG_IMETXN printf("Undo IME Text element = %p\n", mElement.get()); @@ -132,7 +130,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void) return result; } -NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP IMETextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { NS_ASSERTION(aDidMerge, "illegal vaule- null ptr- aDidMerge"); NS_ASSERTION(aTransaction, "illegal vaule- null ptr- aTransaction"); @@ -185,45 +183,16 @@ NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) return NS_OK; } -NS_IMETHODIMP IMETextTxn::Write(nsIOutputStream *aOutputStream) -{ - NS_ASSERTION(aOutputStream, "illegal value- null ptr- aOutputStream"); - if(nsnull == aOutputStream) - return NS_ERROR_NULL_POINTER; - return NS_OK; -} - NS_IMETHODIMP IMETextTxn::MarkFixed(void) { mFixed = PR_TRUE; return NS_OK; } -NS_IMETHODIMP IMETextTxn::GetUndoString(nsString *aString) +NS_IMETHODIMP IMETextTxn::GetTxnDescription(nsAWritableString& aString) { - NS_ASSERTION(aString, "illegal value- null ptr- aString"); - if(nsnull == aString) - return NS_ERROR_NULL_POINTER; - - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Text: "); - *aString += mStringToInsert; - } - return NS_OK; -} - -NS_IMETHODIMP IMETextTxn::GetRedoString(nsString *aString) -{ - NS_ASSERTION(aString, "illegal value- null ptr- aString"); - if(nsnull == aString) - return NS_ERROR_NULL_POINTER; - - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Text: "); - *aString += mStringToInsert; - } + aString.Assign(NS_LITERAL_STRING("IMETextTxn: ")); + aString += mStringToInsert; return NS_OK; } diff --git a/mozilla/editor/libeditor/base/IMETextTxn.h b/mozilla/editor/libeditor/base/IMETextTxn.h index e5f32893de8..4b27f5770fa 100644 --- a/mozilla/editor/libeditor/base/IMETextTxn.h +++ b/mozilla/editor/libeditor/base/IMETextTxn.h @@ -74,17 +74,13 @@ private: public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); NS_IMETHOD MarkFixed(void); @@ -102,8 +98,6 @@ public: /** must be called once we are guaranteed all IMETextTxn have completed */ static nsresult ClassShutdown(); - enum { kTransactionID = 11220 }; - protected: NS_IMETHOD CollapseTextSelection(void); diff --git a/mozilla/editor/libeditor/base/InsertElementTxn.cpp b/mozilla/editor/libeditor/base/InsertElementTxn.cpp index dab2e8fe6e6..f7b06ca5a91 100644 --- a/mozilla/editor/libeditor/base/InsertElementTxn.cpp +++ b/mozilla/editor/libeditor/base/InsertElementTxn.cpp @@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE; InsertElementTxn::InsertElementTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP InsertElementTxn::Init(nsIDOMNode *aNode, @@ -62,7 +60,7 @@ InsertElementTxn::~InsertElementTxn() { } -NS_IMETHODIMP InsertElementTxn::Do(void) +NS_IMETHODIMP InsertElementTxn::DoTransaction(void) { if (gNoisy) { @@ -119,7 +117,7 @@ NS_IMETHODIMP InsertElementTxn::Do(void) return result; } -NS_IMETHODIMP InsertElementTxn::Undo(void) +NS_IMETHODIMP InsertElementTxn::UndoTransaction(void) { if (gNoisy) { printf("%p Undo Insert Element of %p into parent %p at offset %d\n", this, mNode.get(), mParent.get(), mOffset); } @@ -130,32 +128,15 @@ NS_IMETHODIMP InsertElementTxn::Undo(void) return result; } -NS_IMETHODIMP InsertElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP InsertElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP InsertElementTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP InsertElementTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP InsertElementTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Element: "); - } - return NS_OK; -} - -NS_IMETHODIMP InsertElementTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Element: "); - } + aString.Assign(NS_LITERAL_STRING("InsertElementTxn")); return NS_OK; } diff --git a/mozilla/editor/libeditor/base/InsertElementTxn.h b/mozilla/editor/libeditor/base/InsertElementTxn.h index accc2a2946c..1ebfae00fd7 100644 --- a/mozilla/editor/libeditor/base/InsertElementTxn.h +++ b/mozilla/editor/libeditor/base/InsertElementTxn.h @@ -59,19 +59,13 @@ public: virtual ~InsertElementTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11150 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/libeditor/base/InsertTextTxn.cpp b/mozilla/editor/libeditor/base/InsertTextTxn.cpp index 921bfe3dec7..b60e46a451b 100644 --- a/mozilla/editor/libeditor/base/InsertTextTxn.cpp +++ b/mozilla/editor/libeditor/base/InsertTextTxn.cpp @@ -52,8 +52,6 @@ nsresult InsertTextTxn::ClassShutdown() InsertTextTxn::InsertTextTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } InsertTextTxn::~InsertTextTxn() @@ -83,7 +81,7 @@ NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement, return NS_OK; } -NS_IMETHODIMP InsertTextTxn::Do(void) +NS_IMETHODIMP InsertTextTxn::DoTransaction(void) { if (gNoisy) { printf("Do Insert Text element = %p\n", mElement.get()); } NS_ASSERTION(mElement && mEditor, "bad state"); @@ -112,7 +110,7 @@ NS_IMETHODIMP InsertTextTxn::Do(void) return result; } -NS_IMETHODIMP InsertTextTxn::Undo(void) +NS_IMETHODIMP InsertTextTxn::UndoTransaction(void) { if (gNoisy) { printf("Undo Insert Text element = %p\n", mElement.get()); } NS_ASSERTION(mElement && mEditor, "bad state"); @@ -124,7 +122,7 @@ NS_IMETHODIMP InsertTextTxn::Undo(void) return result; } -NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP InsertTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { // set out param default value if (nsnull!=aDidMerge) @@ -192,28 +190,10 @@ NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransacti return result; } -NS_IMETHODIMP InsertTextTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP InsertTextTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP InsertTextTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Remove Text: "); - *aString += mStringToInsert; - } - return NS_OK; -} - -NS_IMETHODIMP InsertTextTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Insert Text: "); - *aString += mStringToInsert; - } + aString.Assign(NS_LITERAL_STRING("InsertTextTxn: ")); + aString += mStringToInsert; return NS_OK; } diff --git a/mozilla/editor/libeditor/base/InsertTextTxn.h b/mozilla/editor/libeditor/base/InsertTextTxn.h index 60eebc3e7d6..577383db3a3 100644 --- a/mozilla/editor/libeditor/base/InsertTextTxn.h +++ b/mozilla/editor/libeditor/base/InsertTextTxn.h @@ -68,17 +68,13 @@ private: public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); // nsISupports declarations @@ -94,8 +90,6 @@ public: /** must be called once we are guaranteed all InsertTextTxn have completed */ static nsresult ClassShutdown(); - enum { kTransactionID = 11120 }; - protected: /** return PR_TRUE if aOtherTxn immediately follows this txn */ diff --git a/mozilla/editor/libeditor/base/JoinElementTxn.cpp b/mozilla/editor/libeditor/base/JoinElementTxn.cpp index 21cb2675bed..25dc6231e62 100644 --- a/mozilla/editor/libeditor/base/JoinElementTxn.cpp +++ b/mozilla/editor/libeditor/base/JoinElementTxn.cpp @@ -34,8 +34,6 @@ static const PRBool gNoisy = PR_FALSE; JoinElementTxn::JoinElementTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP JoinElementTxn::Init(nsEditor *aEditor, @@ -55,8 +53,8 @@ JoinElementTxn::~JoinElementTxn() { } -// After Do() and Redo(), the left node is removed from the content tree and right node remains. -NS_IMETHODIMP JoinElementTxn::Do(void) +// After DoTransaction() and RedoTransaction(), the left node is removed from the content tree and right node remains. +NS_IMETHODIMP JoinElementTxn::DoTransaction(void) { if (gNoisy) { printf("%p Do Join of %p and %p\n", this, mLeftNode.get(), mRightNode.get()); } NS_PRECONDITION((mEditor && mLeftNode && mRightNode), "null arg"); @@ -110,7 +108,7 @@ NS_IMETHODIMP JoinElementTxn::Do(void) //XXX: what if instead of split, we just deleted the unneeded children of mRight // and re-inserted mLeft? -NS_IMETHODIMP JoinElementTxn::Undo(void) +NS_IMETHODIMP JoinElementTxn::UndoTransaction(void) { if (gNoisy) { printf("%p Undo Join, right node = %p\n", this, mRightNode.get()); } NS_ASSERTION(mRightNode && mLeftNode && mParent, "bad state"); @@ -152,32 +150,15 @@ NS_IMETHODIMP JoinElementTxn::GetIsTransient(PRBool *aIsTransient) return NS_OK; } -nsresult JoinElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +nsresult JoinElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP JoinElementTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP JoinElementTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP JoinElementTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Join Element"); - } - return NS_OK; -} - -NS_IMETHODIMP JoinElementTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Split Element"); - } + aString.Assign(NS_LITERAL_STRING("JoinElementTxn")); return NS_OK; } diff --git a/mozilla/editor/libeditor/base/JoinElementTxn.h b/mozilla/editor/libeditor/base/JoinElementTxn.h index 8550de2e7a2..650cef08454 100644 --- a/mozilla/editor/libeditor/base/JoinElementTxn.h +++ b/mozilla/editor/libeditor/base/JoinElementTxn.h @@ -39,7 +39,8 @@ class nsEditor; * A transaction that joins two elements E1 (left node) and E2 (right node) * into a single node E. * The children of E are the children of E1 followed by the children of E2. - * After Do() and Redo(), E1 is removed from the content tree and E2 remains. + * After DoTransaction() and RedoTransaction(), E1 is removed from the content + * tree and E2 remains. */ class JoinElementTxn : public EditTxn { @@ -62,23 +63,17 @@ public: virtual ~JoinElementTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); -// NS_IMETHOD Redo(void); +// NS_IMETHOD RedoTransaction(void); NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11200 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/libeditor/base/PlaceholderTxn.cpp b/mozilla/editor/libeditor/base/PlaceholderTxn.cpp index a03a46c31fb..68fae46d9e0 100644 --- a/mozilla/editor/libeditor/base/PlaceholderTxn.cpp +++ b/mozilla/editor/libeditor/base/PlaceholderTxn.cpp @@ -43,8 +43,6 @@ PlaceholderTxn::PlaceholderTxn() : EditAggregateTxn(), mEndSel(), mEditor(nsnull) { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } @@ -84,16 +82,16 @@ NS_IMETHODIMP PlaceholderTxn::Init(nsIAtom *aName, nsSelectionState *aSelState, return NS_OK; } -NS_IMETHODIMP PlaceholderTxn::Do(void) +NS_IMETHODIMP PlaceholderTxn::DoTransaction(void) { if (gNoisy) { printf("PlaceholderTxn Do\n"); } return NS_OK; } -NS_IMETHODIMP PlaceholderTxn::Undo(void) +NS_IMETHODIMP PlaceholderTxn::UndoTransaction(void) { // undo txns - nsresult res = EditAggregateTxn::Undo(); + nsresult res = EditAggregateTxn::UndoTransaction(); if (NS_FAILED(res)) return res; // now restore selection @@ -107,10 +105,10 @@ NS_IMETHODIMP PlaceholderTxn::Undo(void) } -NS_IMETHODIMP PlaceholderTxn::Redo(void) +NS_IMETHODIMP PlaceholderTxn::RedoTransaction(void) { // redo txns - nsresult res = EditAggregateTxn::Redo(); + nsresult res = EditAggregateTxn::RedoTransaction(); if (NS_FAILED(res)) return res; // now restore selection @@ -123,7 +121,7 @@ NS_IMETHODIMP PlaceholderTxn::Redo(void) } -NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP PlaceholderTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (!aDidMerge || !aTransaction) return NS_ERROR_NULL_POINTER; @@ -155,7 +153,7 @@ NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransact else { PRBool didMerge; - mIMETextTxn->Merge(&didMerge, otherTxn); + mIMETextTxn->Merge(otherTxn, &didMerge); if (!didMerge) { // it wouldn't merge. Earlier IME txn is already commited and will @@ -218,6 +216,20 @@ NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransact return res; } +NS_IMETHODIMP PlaceholderTxn::GetTxnDescription(nsAWritableString& aString) +{ + aString.Assign(NS_LITERAL_STRING("PlaceholderTxn: ")); + + if (mName) + { + nsAutoString name; + mName->ToString(name); + aString += name; + } + + return NS_OK; +} + NS_IMETHODIMP PlaceholderTxn::GetTxnName(nsIAtom **aName) { return GetName(aName); diff --git a/mozilla/editor/libeditor/base/PlaceholderTxn.h b/mozilla/editor/libeditor/base/PlaceholderTxn.h index d3c792d5cd7..09df75013ac 100644 --- a/mozilla/editor/libeditor/base/PlaceholderTxn.h +++ b/mozilla/editor/libeditor/base/PlaceholderTxn.h @@ -65,13 +65,15 @@ public: // ------------ EditAggregateTxn ----------------------- - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); + + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); // ------------ nsIAbsorbingTransaction ----------------------- @@ -91,8 +93,6 @@ public: friend class TransactionFactory; - enum { kTransactionID = 11260 }; - protected: /** the presentation shell, which we'll need to get the selection */ @@ -103,7 +103,8 @@ protected: PRBool mCommitted; // do we stop auto absorbing any matching placeholder txns? // these next two members store the state of the selection in a safe way. // selection at the start of the txn is stored, as is the selection at the end. - // This is so that Undo() and Redo() can restore the selection properly. + // This is so that UndoTransaction() and RedoTransaction() can restore the + // selection properly. nsSelectionState *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 501438f5990..aa879c9651c 100644 --- a/mozilla/editor/libeditor/base/SetDocTitleTxn.cpp +++ b/mozilla/editor/libeditor/base/SetDocTitleTxn.cpp @@ -36,8 +36,6 @@ SetDocTitleTxn::SetDocTitleTxn() : EditTxn() , mIsTransient(PR_FALSE) { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor, @@ -57,7 +55,7 @@ SetDocTitleTxn::~SetDocTitleTxn() { } -NS_IMETHODIMP SetDocTitleTxn::Do(void) +NS_IMETHODIMP SetDocTitleTxn::DoTransaction(void) { nsresult res = SetDomTitle(mValue); if (NS_FAILED(res)) return res; @@ -65,12 +63,12 @@ NS_IMETHODIMP SetDocTitleTxn::Do(void) return SetDocTitle(mValue); } -NS_IMETHODIMP SetDocTitleTxn::Undo(void) +NS_IMETHODIMP SetDocTitleTxn::UndoTransaction(void) { return SetDocTitle(mUndoValue); } -NS_IMETHODIMP SetDocTitleTxn::Redo(void) +NS_IMETHODIMP SetDocTitleTxn::RedoTransaction(void) { return SetDocTitle(mValue); } @@ -208,35 +206,17 @@ nsresult SetDocTitleTxn::SetDomTitle(nsString& aTitle) return res; } -NS_IMETHODIMP SetDocTitleTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP SetDocTitleTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP SetDocTitleTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP SetDocTitleTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP SetDocTitleTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Restore Document Title: "); - *aString += mUndoValue; - } - return NS_OK; -} - -NS_IMETHODIMP SetDocTitleTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Set Document Title: "); - *aString += mValue; - } + aString.Assign(NS_LITERAL_STRING("SetDocTitleTxn: ")); + aString += mValue; return NS_OK; } diff --git a/mozilla/editor/libeditor/base/SetDocTitleTxn.h b/mozilla/editor/libeditor/base/SetDocTitleTxn.h index e2989a35a81..715e664e0e9 100644 --- a/mozilla/editor/libeditor/base/SetDocTitleTxn.h +++ b/mozilla/editor/libeditor/base/SetDocTitleTxn.h @@ -27,7 +27,6 @@ #include "nsIEditor.h" #include "nsIHTMLEditor.h" #include "nsITransaction.h" -#include "nsITransactionDescription.h" #include "nsCOMPtr.h" #define SET_DOC_TITLE_TXN_CID \ @@ -61,23 +60,17 @@ private: nsresult SetDomTitle(nsString& aTitle); public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); - - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - enum { kTransactionID = 11270 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/libeditor/base/SplitElementTxn.cpp b/mozilla/editor/libeditor/base/SplitElementTxn.cpp index e742f526ec6..000ba72fb95 100644 --- a/mozilla/editor/libeditor/base/SplitElementTxn.cpp +++ b/mozilla/editor/libeditor/base/SplitElementTxn.cpp @@ -37,8 +37,6 @@ static const PRBool gNoisy = PR_FALSE; SplitElementTxn::SplitElementTxn() : EditTxn() { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } NS_IMETHODIMP SplitElementTxn::Init(nsEditor *aEditor, @@ -58,7 +56,7 @@ SplitElementTxn::~SplitElementTxn() { } -NS_IMETHODIMP SplitElementTxn::Do(void) +NS_IMETHODIMP SplitElementTxn::DoTransaction(void) { if (gNoisy) { printf("%p Do Split of node %p offset %d\n", this, mExistingRightNode.get(), mOffset); } NS_ASSERTION(mExistingRightNode && mEditor, "bad state"); @@ -94,7 +92,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void) return result; } -NS_IMETHODIMP SplitElementTxn::Undo(void) +NS_IMETHODIMP SplitElementTxn::UndoTransaction(void) { if (gNoisy) { printf("%p Undo Split of existing node %p and new node %p offset %d\n", @@ -122,7 +120,7 @@ NS_IMETHODIMP SplitElementTxn::Undo(void) /* redo cannot simply resplit the right node, because subsequent transactions * on the redo stack may depend on the left node existing in its previous state. */ -NS_IMETHODIMP SplitElementTxn::Redo(void) +NS_IMETHODIMP SplitElementTxn::RedoTransaction(void) { NS_ASSERTION(mEditor && mExistingRightNode && mNewLeftNode && mParent, "bad state"); if (!mEditor || !mExistingRightNode || !mNewLeftNode || !mParent) { @@ -182,33 +180,16 @@ NS_IMETHODIMP SplitElementTxn::Redo(void) } -NS_IMETHODIMP SplitElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +NS_IMETHODIMP SplitElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (nsnull!=aDidMerge) *aDidMerge=PR_FALSE; return NS_OK; } -NS_IMETHODIMP SplitElementTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP SplitElementTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP SplitElementTxn::GetUndoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Join Element"); - } - return NS_OK; -} - -NS_IMETHODIMP SplitElementTxn::GetRedoString(nsString *aString) -{ - if (nsnull!=aString) - { - aString->AssignWithConversion("Split Element"); - } + aString.Assign(NS_LITERAL_STRING("SplitElementTxn")); return NS_OK; } diff --git a/mozilla/editor/libeditor/base/SplitElementTxn.h b/mozilla/editor/libeditor/base/SplitElementTxn.h index 0e03c5831d7..bc096cf86a6 100644 --- a/mozilla/editor/libeditor/base/SplitElementTxn.h +++ b/mozilla/editor/libeditor/base/SplitElementTxn.h @@ -61,24 +61,18 @@ protected: public: virtual ~SplitElementTxn(); - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); - enum { kTransactionID = 11190 }; - protected: /** the element to operate upon */ diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index b3def864b9f..1be8202b590 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -423,10 +423,10 @@ nsEditor::Do(nsITransaction *aTxn) selPrivate->StartBatchChanges(); if (mTxnMgr) { - result = mTxnMgr->Do(aTxn); + result = mTxnMgr->DoTransaction(aTxn); } else { - result = aTxn->Do(); + result = aTxn->DoTransaction(); } if (NS_SUCCEEDED(result)) { result = DoAfterDoTransaction(aTxn); @@ -500,7 +500,7 @@ nsEditor::Undo(PRUint32 aCount) PRUint32 i=0; for ( ; iUndo(); + result = mTxnMgr->UndoTransaction(); if (NS_SUCCEEDED(result)) result = DoAfterUndoTransaction(); @@ -544,7 +544,7 @@ nsEditor::Redo(PRUint32 aCount) PRUint32 i=0; for ( ; iRedo(); + result = mTxnMgr->RedoTransaction(); if (NS_SUCCEEDED(result)) result = DoAfterRedoTransaction(); @@ -1015,7 +1015,7 @@ NS_IMETHODIMP nsEditor::CreateNode(const nsString& aTag, if (NS_SUCCEEDED(result)) { result = txn->GetNewNode(aNewNode); - NS_ASSERTION((NS_SUCCEEDED(result)), "GetNewNode can't fail if txn::Do succeeded."); + NS_ASSERTION((NS_SUCCEEDED(result)), "GetNewNode can't fail if txn::DoTransaction succeeded."); } } // The transaction system (if any) has taken ownwership of txn @@ -1771,9 +1771,8 @@ nsEditor::EndComposition(void) // Note that this means IME won't work without an undo stack! if (mTxnMgr) { - nsITransaction *txn; - result = mTxnMgr->PeekUndoStack(&txn); - // PeekUndoStack does not addref + nsCOMPtr txn; + result = mTxnMgr->PeekUndoStack(getter_AddRefs(txn)); nsCOMPtr plcTxn = do_QueryInterface(txn); if (plcTxn) { diff --git a/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp b/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp index 3f885a83944..fd02431441e 100644 --- a/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp +++ b/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp @@ -38,8 +38,6 @@ AddStyleSheetTxn::AddStyleSheetTxn() : EditTxn() , mEditor(NULL) { - SetTransactionDescriptionID( kTransactionID ); - /* log description initialized in parent constructor */ } AddStyleSheetTxn::~AddStyleSheetTxn() @@ -63,7 +61,7 @@ AddStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet) NS_IMETHODIMP -AddStyleSheetTxn::Do() +AddStyleSheetTxn::DoTransaction() { if (!mEditor || !mSheet) return NS_ERROR_NOT_INITIALIZED; @@ -100,7 +98,7 @@ AddStyleSheetTxn::Do() } NS_IMETHODIMP -AddStyleSheetTxn::Undo() +AddStyleSheetTxn::UndoTransaction() { if (!mEditor || !mSheet) return NS_ERROR_NOT_INITIALIZED; @@ -136,13 +134,13 @@ AddStyleSheetTxn::Undo() } NS_IMETHODIMP -AddStyleSheetTxn::Redo() +AddStyleSheetTxn::RedoTransaction() { - return Do(); + return DoTransaction(); } NS_IMETHODIMP -AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +AddStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { // set out param default value if (!aDidMerge) @@ -153,28 +151,9 @@ AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) } NS_IMETHODIMP -AddStyleSheetTxn::Write(nsIOutputStream *aOutputStream) +AddStyleSheetTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP -AddStyleSheetTxn::GetUndoString(nsString *aString) -{ - if (aString) - { - aString->AssignWithConversion("Remove Style Sheet"); - } - return NS_OK; -} - -NS_IMETHODIMP -AddStyleSheetTxn::GetRedoString(nsString *aString) -{ - if (aString) - { - aString->AssignWithConversion("Add Style Sheet"); - } + aString.Assign(NS_LITERAL_STRING("AddStyleSheetTxn")); return NS_OK; } @@ -187,7 +166,6 @@ RemoveStyleSheetTxn::RemoveStyleSheetTxn() : EditTxn() , mEditor(NULL) { - SetTransactionDescriptionID( kTransactionID ); } RemoveStyleSheetTxn::~RemoveStyleSheetTxn() @@ -211,7 +189,7 @@ RemoveStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet) NS_IMETHODIMP -RemoveStyleSheetTxn::Do() +RemoveStyleSheetTxn::DoTransaction() { if (!mEditor || !mSheet) return NS_ERROR_NOT_INITIALIZED; @@ -247,7 +225,7 @@ RemoveStyleSheetTxn::Do() } NS_IMETHODIMP -RemoveStyleSheetTxn::Undo() +RemoveStyleSheetTxn::UndoTransaction() { if (!mEditor || !mSheet) return NS_ERROR_NOT_INITIALIZED; @@ -283,13 +261,13 @@ RemoveStyleSheetTxn::Undo() } NS_IMETHODIMP -RemoveStyleSheetTxn::Redo() +RemoveStyleSheetTxn::RedoTransaction() { - return Do(); + return DoTransaction(); } NS_IMETHODIMP -RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) +RemoveStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { // set out param default value if (!aDidMerge) @@ -300,27 +278,8 @@ RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) } NS_IMETHODIMP -RemoveStyleSheetTxn::Write(nsIOutputStream *aOutputStream) +RemoveStyleSheetTxn::GetTxnDescription(nsAWritableString& aString) { - return NS_OK; -} - -NS_IMETHODIMP -RemoveStyleSheetTxn::GetUndoString(nsString *aString) -{ - if (aString) - { - aString->AssignWithConversion("Add Style Sheet"); - } - return NS_OK; -} - -NS_IMETHODIMP -RemoveStyleSheetTxn::GetRedoString(nsString *aString) -{ - if (aString) - { - aString->AssignWithConversion("Remove Style Sheet"); - } + aString.Assign(NS_LITERAL_STRING("RemoveStyleSheetTxn")); return NS_OK; } diff --git a/mozilla/editor/libeditor/base/nsStyleSheetTxns.h b/mozilla/editor/libeditor/base/nsStyleSheetTxns.h index c1a1193998e..c7fe5614c12 100644 --- a/mozilla/editor/libeditor/base/nsStyleSheetTxns.h +++ b/mozilla/editor/libeditor/base/nsStyleSheetTxns.h @@ -59,21 +59,15 @@ private: public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11240 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: @@ -105,21 +99,15 @@ private: public: - NS_IMETHOD Do(void); + NS_IMETHOD DoTransaction(void); - NS_IMETHOD Undo(void); + NS_IMETHOD UndoTransaction(void); - NS_IMETHOD Redo(void); + NS_IMETHOD RedoTransaction(void); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - - NS_IMETHOD GetRedoString(nsString *aString); - - enum { kTransactionID = 11250 }; + NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription); protected: diff --git a/mozilla/editor/libeditor/html/nsEditorTxnLog.cpp b/mozilla/editor/libeditor/html/nsEditorTxnLog.cpp index 2638a6ae177..330868a2e24 100644 --- a/mozilla/editor/libeditor/html/nsEditorTxnLog.cpp +++ b/mozilla/editor/libeditor/html/nsEditorTxnLog.cpp @@ -24,6 +24,7 @@ #include #include "nsHTMLEditorLog.h" #include "nsEditorTxnLog.h" +#include "nsPIEditorTransaction.h" #define LOCK_LOG(doc) #define UNLOCK_LOG(doc) @@ -361,7 +362,12 @@ nsEditorTxnLog::GetString(nsITransaction *aTransaction, char *aBuffer, PRInt32 a nsString str; - aTransaction->GetRedoString(&str); + nsCOMPtr txn = do_QueryInterface(aTransaction); + + if (!txn) + return aBuffer; + + txn->GetTxnDescription(str); if (str.Length() == 0) str.AssignWithConversion(""); diff --git a/mozilla/editor/makefile.win b/mozilla/editor/makefile.win index 544cec5e0ce..389b13ec9e7 100644 --- a/mozilla/editor/makefile.win +++ b/mozilla/editor/makefile.win @@ -25,7 +25,7 @@ DEPTH=.. !if defined(DISABLE_EDITOR) DIRS= public idl !else -DIRS= public idl base txmgr ui txtsvc +DIRS= txmgr public idl base ui txtsvc !endif include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/editor/txmgr/idl/MANIFEST b/mozilla/editor/txmgr/idl/MANIFEST index db05dd1e9bd..4572b749b74 100644 --- a/mozilla/editor/txmgr/idl/MANIFEST +++ b/mozilla/editor/txmgr/idl/MANIFEST @@ -20,4 +20,7 @@ # Contributor(s): # -nsITransactionDescription.idl +nsITransaction.idl +nsITransactionList.idl +nsITransactionListener.idl +nsITransactionManager.idl diff --git a/mozilla/editor/txmgr/idl/Makefile.in b/mozilla/editor/txmgr/idl/Makefile.in index dc3e3219ddc..ddb4e98009f 100644 --- a/mozilla/editor/txmgr/idl/Makefile.in +++ b/mozilla/editor/txmgr/idl/Makefile.in @@ -20,18 +20,21 @@ # Contributor(s): # -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -MODULE = txmgr +MODULE = txmgr -XPIDLSRCS = \ - nsITransactionDescription.idl \ - $(NULL) +XPIDLSRCS = \ + nsITransaction.idl \ + nsITransactionList.idl \ + nsITransactionListener.idl \ + nsITransactionManager.idl \ + $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/mozilla/editor/txmgr/idl/makefile.win b/mozilla/editor/txmgr/idl/makefile.win index e62f4f64b7b..16bf41241a9 100644 --- a/mozilla/editor/txmgr/idl/makefile.win +++ b/mozilla/editor/txmgr/idl/makefile.win @@ -25,8 +25,11 @@ DEPTH=..\..\.. MODULE=txmgr XPIDL_MODULE=txmgr -XPIDLSRCS = \ - .\nsITransactionDescription.idl \ +XPIDLSRCS = \ + .\nsITransaction.idl \ + .\nsITransactionList.idl \ + .\nsITransactionListener.idl \ + .\nsITransactionManager.idl \ $(NULL) include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/editor/txmgr/idl/nsITransactionManager.idl b/mozilla/editor/txmgr/idl/nsITransactionManager.idl index 737f07d8d8e..43706ceac13 100644 --- a/mozilla/editor/txmgr/idl/nsITransactionManager.idl +++ b/mozilla/editor/txmgr/idl/nsITransactionManager.idl @@ -24,7 +24,6 @@ #include "nsITransaction.idl" #include "nsITransactionList.idl" #include "nsITransactionListener.idl" -#include "nsIOutputStream.idl" %{ C++ @@ -138,14 +137,6 @@ interface nsITransactionManager : nsISupports */ nsITransactionList getRedoList(); - /** - * Writes a stream representation of the transaction manager and it's - * execution stacks. Calls the Write() method of each transaction on the - * execution stacks. - * @param aOutputStream the stream to write to. - */ - void Write(in nsIOutputStream aOutputStream); - /** * Adds a listener to the transaction manager's notification list. Listeners * are notified whenever a transaction is done, undone, or redone. diff --git a/mozilla/editor/txmgr/public/MANIFEST b/mozilla/editor/txmgr/public/MANIFEST index 707e141679c..bce2353fc06 100644 --- a/mozilla/editor/txmgr/public/MANIFEST +++ b/mozilla/editor/txmgr/public/MANIFEST @@ -2,7 +2,4 @@ # This is a list of local files which get copied to the mozilla:dist:editor directory # -nsITransaction.h -nsITransactionListener.h -nsITransactionManager.h nsTransactionManagerCID.h diff --git a/mozilla/editor/txmgr/public/Makefile.in b/mozilla/editor/txmgr/public/Makefile.in index edb4a43f488..25714e5d2db 100644 --- a/mozilla/editor/txmgr/public/Makefile.in +++ b/mozilla/editor/txmgr/public/Makefile.in @@ -29,9 +29,6 @@ include $(DEPTH)/config/autoconf.mk MODULE = txmgr EXPORTS = \ - nsITransaction.h \ - nsITransactionListener.h \ - nsITransactionManager.h \ nsTransactionManagerCID.h \ $(NULL) diff --git a/mozilla/editor/txmgr/public/makefile.win b/mozilla/editor/txmgr/public/makefile.win index c3a086d087c..cb3eb9f3c64 100644 --- a/mozilla/editor/txmgr/public/makefile.win +++ b/mozilla/editor/txmgr/public/makefile.win @@ -23,9 +23,6 @@ DEPTH=..\..\.. EXPORTS = \ - nsITransaction.h \ - nsITransactionListener.h \ - nsITransactionManager.h \ nsTransactionManagerCID.h \ $(NULL) diff --git a/mozilla/editor/txmgr/src/Makefile.in b/mozilla/editor/txmgr/src/Makefile.in index e98d40e6dee..199d76bda83 100644 --- a/mozilla/editor/txmgr/src/Makefile.in +++ b/mozilla/editor/txmgr/src/Makefile.in @@ -33,6 +33,7 @@ REQUIRES = xpcom string editor CPPSRCS = \ nsTransactionItem.cpp \ + nsTransactionList.cpp \ nsTransactionManager.cpp \ nsTransactionManagerFactory.cpp \ nsTransactionStack.cpp \ diff --git a/mozilla/editor/txmgr/src/makefile.win b/mozilla/editor/txmgr/src/makefile.win index 60ab22d4392..feb5bd242cc 100644 --- a/mozilla/editor/txmgr/src/makefile.win +++ b/mozilla/editor/txmgr/src/makefile.win @@ -26,6 +26,7 @@ LIBRARY_NAME=txmgr CPPSRCS = \ nsTransactionItem.cpp \ + nsTransactionList.cpp \ nsTransactionManager.cpp \ nsTransactionManagerFactory.cpp \ nsTransactionStack.cpp \ @@ -33,6 +34,7 @@ CPPSRCS = \ CPP_OBJS = \ .\$(OBJDIR)\nsTransactionItem.obj \ + .\$(OBJDIR)\nsTransactionList.obj \ .\$(OBJDIR)\nsTransactionManager.obj \ .\$(OBJDIR)\nsTransactionStack.obj \ .\$(OBJDIR)\nsTransactionManagerFactory.obj \ diff --git a/mozilla/editor/txmgr/src/nsTransactionItem.cpp b/mozilla/editor/txmgr/src/nsTransactionItem.cpp index 520521e961c..230e603da70 100644 --- a/mozilla/editor/txmgr/src/nsTransactionItem.cpp +++ b/mozilla/editor/txmgr/src/nsTransactionItem.cpp @@ -21,7 +21,6 @@ */ #include "nsITransaction.h" -#include "nsITransactionManager.h" #include "nsTransactionStack.h" #include "nsTransactionManager.h" #include "nsTransactionItem.h" @@ -71,6 +70,17 @@ nsTransactionItem::GetTransaction(nsITransaction **aTransaction) return NS_OK; } +nsresult +nsTransactionItem::GetIsBatch(PRBool *aIsBatch) +{ + if (!aIsBatch) + return NS_ERROR_NULL_POINTER; + + *aIsBatch = !mTransaction; + + return NS_OK; +} + nsresult nsTransactionItem::GetNumberOfChildren(PRInt32 *aNumChildren) { @@ -100,15 +110,64 @@ nsTransactionItem::GetNumberOfChildren(PRInt32 *aNumChildren) } nsresult -nsTransactionItem::Do() +nsTransactionItem::GetChild(PRInt32 aIndex, nsTransactionItem **aChild) +{ + if (!aChild) + return NS_ERROR_NULL_POINTER; + + *aChild = 0; + + PRInt32 numItems = 0; + nsresult result = GetNumberOfChildren(&numItems); + + if (NS_FAILED(result)) + return result; + + if (aIndex < 0 || aIndex >= numItems) + return NS_ERROR_FAILURE; + + // Children are expected to be in the order they were added, + // so the child first added would be at the bottom of the undo + // stack, or if there are no items on the undo stack, it would + // be at the top of the redo stack. + + result = GetNumberOfUndoItems(&numItems); + + if (NS_FAILED(result)) + return result; + + if (numItems > 0 && aIndex < numItems) { + if (!mUndoStack) + return NS_ERROR_FAILURE; + + return mUndoStack->GetItem(aIndex, aChild); + } + + // Adjust the index for the redo stack: + + aIndex -= numItems; + + result = GetNumberOfRedoItems(&numItems); + + if (NS_FAILED(result)) + return result; + + if (!mRedoStack || numItems == 0 || aIndex >= numItems) + return NS_ERROR_FAILURE; + + return mRedoStack->GetItem(numItems - aIndex - 1, aChild); +} + +nsresult +nsTransactionItem::DoTransaction() { if (mTransaction) - return mTransaction->Do(); + return mTransaction->DoTransaction(); return NS_OK; } nsresult -nsTransactionItem::Undo(nsTransactionManager *aTxMgr) +nsTransactionItem::UndoTransaction(nsTransactionManager *aTxMgr) { nsresult result = UndoChildren(aTxMgr); @@ -120,7 +179,7 @@ nsTransactionItem::Undo(nsTransactionManager *aTxMgr) if (!mTransaction) return NS_OK; - result = mTransaction->Undo(); + result = mTransaction->UndoTransaction(); if (NS_FAILED(result)) { RecoverFromUndoError(aTxMgr); @@ -177,7 +236,7 @@ nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr) return NS_OK; } - result = item->Undo(aTxMgr); + result = item->UndoTransaction(aTxMgr); if (NS_SUCCEEDED(result)) { result = mUndoStack->Pop(&item); @@ -203,12 +262,12 @@ nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr) } nsresult -nsTransactionItem::Redo(nsTransactionManager *aTxMgr) +nsTransactionItem::RedoTransaction(nsTransactionManager *aTxMgr) { nsresult result; if (mTransaction) { - result = mTransaction->Redo(); + result = mTransaction->RedoTransaction(); if (NS_FAILED(result)) return result; @@ -268,7 +327,7 @@ nsTransactionItem::RedoChildren(nsTransactionManager *aTxMgr) return NS_OK; } - result = item->Redo(aTxMgr); + result = item->RedoTransaction(aTxMgr); if (NS_SUCCEEDED(result)) { result = mRedoStack->Pop(&item); @@ -319,34 +378,12 @@ nsTransactionItem::GetNumberOfRedoItems(PRInt32 *aNumItems) return mRedoStack->GetSize(aNumItems); } -nsresult -nsTransactionItem::Write(nsIOutputStream *aOutputStream) -{ - PRUint32 len; - - if (mTransaction) - mTransaction->Write(aOutputStream); - - aOutputStream->Write(" ItemUndoStack:\n", 19, &len); - if (mUndoStack) { - mUndoStack->Write(aOutputStream); - } - - aOutputStream->Write("\n ItemRedoStack:\n", 20, &len); - if (mRedoStack) { - mRedoStack->Write(aOutputStream); - } - aOutputStream->Write("\n", 1, &len); - - return NS_OK; -} - nsresult nsTransactionItem::RecoverFromUndoError(nsTransactionManager *aTxMgr) { // // If this method gets called, we never got to the point where we - // successfully called Undo() for the transaction item itself. + // successfully called UndoTransaction() for the transaction item itself. // Just redo any children that successfully called undo! // return RedoChildren(aTxMgr); @@ -356,9 +393,10 @@ nsresult nsTransactionItem::RecoverFromRedoError(nsTransactionManager *aTxMgr) { // - // If this method gets called, we already successfully called Redo() - // for the transaction item itself. Undo all the children that successfully - // called Redo(), then undo the transaction item itself. + // If this method gets called, we already successfully called + // RedoTransaction() for the transaction item itself. Undo all + // the children that successfully called RedoTransaction(), + // then undo the transaction item itself. // nsresult result; @@ -372,6 +410,6 @@ nsTransactionItem::RecoverFromRedoError(nsTransactionManager *aTxMgr) if (!mTransaction) return NS_OK; - return mTransaction->Undo(); + return mTransaction->UndoTransaction(); } diff --git a/mozilla/editor/txmgr/src/nsTransactionItem.h b/mozilla/editor/txmgr/src/nsTransactionItem.h index 509a7ced7e6..e08c20ecb09 100644 --- a/mozilla/editor/txmgr/src/nsTransactionItem.h +++ b/mozilla/editor/txmgr/src/nsTransactionItem.h @@ -41,12 +41,13 @@ public: virtual nsresult AddChild(nsTransactionItem *aTransactionItem); virtual nsresult GetTransaction(nsITransaction **aTransaction); + virtual nsresult GetIsBatch(PRBool *aIsBatch); virtual nsresult GetNumberOfChildren(PRInt32 *aNumChildren); + virtual nsresult GetChild(PRInt32 aIndex, nsTransactionItem **aChild); - virtual nsresult Do(void); - virtual nsresult Undo(nsTransactionManager *aTxMgr); - virtual nsresult Redo(nsTransactionManager *aTxMgr); - virtual nsresult Write(nsIOutputStream *aOutputStream); + virtual nsresult DoTransaction(void); + virtual nsresult UndoTransaction(nsTransactionManager *aTxMgr); + virtual nsresult RedoTransaction(nsTransactionManager *aTxMgr); private: diff --git a/mozilla/editor/txmgr/src/nsTransactionList.cpp b/mozilla/editor/txmgr/src/nsTransactionList.cpp index ac1caa03c99..cabec3b1ebf 100644 --- a/mozilla/editor/txmgr/src/nsTransactionList.cpp +++ b/mozilla/editor/txmgr/src/nsTransactionList.cpp @@ -22,7 +22,6 @@ #include "nsITransactionManager.h" #include "nsTransactionItem.h" -#include "nsITransactionList.h" #include "nsTransactionList.h" #include "nsTransactionStack.h" diff --git a/mozilla/editor/txmgr/src/nsTransactionList.h b/mozilla/editor/txmgr/src/nsTransactionList.h index 39433d96002..2512a23fb5d 100644 --- a/mozilla/editor/txmgr/src/nsTransactionList.h +++ b/mozilla/editor/txmgr/src/nsTransactionList.h @@ -24,6 +24,7 @@ #define nsTransactionList_h__ #include "nsWeakReference.h" +#include "nsITransactionList.h" class nsITransaction; class nsITransactionManager; diff --git a/mozilla/editor/txmgr/src/nsTransactionManager.cpp b/mozilla/editor/txmgr/src/nsTransactionManager.cpp index 4125ea93820..f895f621e86 100644 --- a/mozilla/editor/txmgr/src/nsTransactionManager.cpp +++ b/mozilla/editor/txmgr/src/nsTransactionManager.cpp @@ -21,13 +21,13 @@ */ #include "nsITransaction.h" -#include "nsITransactionManager.h" #include "nsITransactionListener.h" #include "nsTransactionItem.h" #include "nsTransactionStack.h" #include "nsVoidArray.h" #include "nsTransactionManager.h" +#include "nsTransactionList.h" #include "nsCOMPtr.h" @@ -86,16 +86,16 @@ nsrefcnt nsTransactionManager::Release(void) return mRefCnt; } -NS_IMPL_QUERY_INTERFACE1(nsTransactionManager, nsITransactionManager) +NS_IMPL_QUERY_INTERFACE2(nsTransactionManager, nsITransactionManager, nsISupportsWeakReference) #else -NS_IMPL_ISUPPORTS(nsTransactionManager, NS_GET_IID(nsITransactionManager)) +NS_IMPL_ISUPPORTS2(nsTransactionManager, nsITransactionManager, nsISupportsWeakReference) #endif NS_IMETHODIMP -nsTransactionManager::Do(nsITransaction *aTransaction) +nsTransactionManager::DoTransaction(nsITransaction *aTransaction) { nsresult result; @@ -139,16 +139,16 @@ nsTransactionManager::Do(nsITransaction *aTransaction) } NS_IMETHODIMP -nsTransactionManager::Undo() +nsTransactionManager::UndoTransaction() { nsresult result = NS_OK; nsTransactionItem *tx = 0; LOCK_TX_MANAGER(this); - // It is illegal to call Undo() while the transaction manager is - // executing a transaction's Do() method! If this happens, the Undo() - // request is ignored, and we return NS_ERROR_FAILURE. + // It is illegal to call UndoTransaction() while the transaction manager is + // executing a transaction's DoTransaction() method! If this happens, + // the UndoTransaction() request is ignored, and we return NS_ERROR_FAILURE. result = mDoStack.Peek(&tx); @@ -200,7 +200,7 @@ nsTransactionManager::Undo() return NS_OK; } - result = tx->Undo(this); + result = tx->UndoTransaction(this); if (NS_SUCCEEDED(result)) { result = mUndoStack.Pop(&tx); @@ -220,16 +220,16 @@ nsTransactionManager::Undo() } NS_IMETHODIMP -nsTransactionManager::Redo() +nsTransactionManager::RedoTransaction() { nsresult result = NS_OK; nsTransactionItem *tx = 0; LOCK_TX_MANAGER(this); - // It is illegal to call Redo() while the transaction manager is - // executing a transaction's Do() method! If this happens, the Redo() - // request is ignored, and we return NS_ERROR_FAILURE. + // It is illegal to call RedoTransaction() while the transaction manager is + // executing a transaction's DoTransaction() method! If this happens, + // the RedoTransaction() request is ignored, and we return NS_ERROR_FAILURE. result = mDoStack.Peek(&tx); @@ -281,7 +281,7 @@ nsTransactionManager::Redo() return NS_OK; } - result = tx->Redo(this); + result = tx->RedoTransaction(this); if (NS_SUCCEEDED(result)) { result = mRedoStack.Pop(&tx); @@ -371,7 +371,7 @@ nsTransactionManager::EndBatch() // XXX: Need to add some mechanism to detect the case where the transaction // at the top of the do stack isn't the dummy transaction, so we can // throw an error!! This can happen if someone calls EndBatch() within - // the Do() method of a transaction. + // the DoTransaction() method of a transaction. // // For now, we can detect this case by checking the value of the // dummy transaction's mTransaction field. If it is our dummy @@ -444,6 +444,19 @@ nsTransactionManager::GetNumberOfRedoItems(PRInt32 *aNumItems) return result; } +NS_IMETHODIMP +nsTransactionManager::GetMaxTransactionCount(PRInt32 *aMaxCount) +{ + if (!aMaxCount) + return NS_ERROR_NULL_POINTER; + + LOCK_TX_MANAGER(this); + *aMaxCount = mMaxTransactionCount; + UNLOCK_TX_MANAGER(this); + + return NS_OK; +} + NS_IMETHODIMP nsTransactionManager::SetMaxTransactionCount(PRInt32 aMaxCount) { @@ -454,9 +467,10 @@ nsTransactionManager::SetMaxTransactionCount(PRInt32 aMaxCount) LOCK_TX_MANAGER(this); // It is illegal to call SetMaxTransactionCount() while the transaction - // manager is executing a transaction's Do() method because the undo and - // redo stacks might get pruned! If this happens, the SetMaxTransactionCount() - // request is ignored, and we return NS_ERROR_FAILURE. + // manager is executing a transaction's DoTransaction() method because + // the undo and redo stacks might get pruned! If this happens, the + // SetMaxTransactionCount() request is ignored, and we return + // NS_ERROR_FAILURE. result = mDoStack.Peek(&tx); @@ -570,6 +584,8 @@ nsTransactionManager::PeekUndoStack(nsITransaction **aTransaction) UNLOCK_TX_MANAGER(this); + NS_IF_ADDREF(*aTransaction); + return result; } @@ -597,24 +613,35 @@ nsTransactionManager::PeekRedoStack(nsITransaction **aTransaction) UNLOCK_TX_MANAGER(this); + NS_IF_ADDREF(*aTransaction); + return result; } NS_IMETHODIMP -nsTransactionManager::Write(nsIOutputStream *aOutputStream) +nsTransactionManager::GetUndoList(nsITransactionList **aTransactionList) { - PRUint32 len; - - if (!aOutputStream) + if (!aTransactionList) return NS_ERROR_NULL_POINTER; - aOutputStream->Write("UndoStack:\n\n", 12, &len); - mUndoStack.Write(aOutputStream); + *aTransactionList = (nsITransactionList *)new nsTransactionList(this, &mUndoStack); - aOutputStream->Write("\nRedoStack:\n\n", 13, &len); - mRedoStack.Write(aOutputStream); + NS_IF_ADDREF(*aTransactionList); - return NS_OK; + return (! *aTransactionList) ? NS_ERROR_OUT_OF_MEMORY : NS_OK; +} + +NS_IMETHODIMP +nsTransactionManager::GetRedoList(nsITransactionList **aTransactionList) +{ + if (!aTransactionList) + return NS_ERROR_NULL_POINTER; + + *aTransactionList = (nsITransactionList *)new nsTransactionList(this, &mRedoStack); + + NS_IF_ADDREF(*aTransactionList); + + return (! *aTransactionList) ? NS_ERROR_OUT_OF_MEMORY : NS_OK; } NS_IMETHODIMP @@ -1030,7 +1057,7 @@ nsTransactionManager::BeginTransaction(nsITransaction *aTransaction) return result; } - result = tx->Do(); + result = tx->DoTransaction(); if (NS_FAILED(result)) { mDoStack.Pop(&tx); @@ -1137,7 +1164,7 @@ nsTransactionManager::EndTransaction() return result; if (!doInterrupt) { - result = topTransaction->Merge(&didMerge, tint); + result = topTransaction->Merge(tint, &didMerge); nsresult result2 = DidMergeNotify(topTransaction, tint, didMerge, result); diff --git a/mozilla/editor/txmgr/src/nsTransactionManager.h b/mozilla/editor/txmgr/src/nsTransactionManager.h index ca8e63ae806..a9c3a3c0dac 100644 --- a/mozilla/editor/txmgr/src/nsTransactionManager.h +++ b/mozilla/editor/txmgr/src/nsTransactionManager.h @@ -24,9 +24,10 @@ #define nsTransactionManager_h__ #include "prmon.h" +#include "nsWeakReference.h" +#include "nsITransactionManager.h" class nsITransaction; -class nsITransactionManager; class nsITransactionListener; class nsTransactionItem; class nsTransactionStack; @@ -37,6 +38,7 @@ class nsVoidArray; * */ class nsTransactionManager : public nsITransactionManager + , public nsSupportsWeakReference { private: @@ -62,27 +64,14 @@ public: NS_DECL_ISUPPORTS /* nsITransactionManager method implementations. */ - NS_IMETHOD Do(nsITransaction *aTransaction); - NS_IMETHOD Undo(void); - NS_IMETHOD Redo(void); - NS_IMETHOD Clear(void); - NS_IMETHOD BeginBatch(void); - NS_IMETHOD EndBatch(void); - NS_IMETHOD GetNumberOfUndoItems(PRInt32 *aNumItems); - NS_IMETHOD GetNumberOfRedoItems(PRInt32 *aNumItems); - NS_IMETHOD SetMaxTransactionCount(PRInt32 aMaxCount); - NS_IMETHOD PeekUndoStack(nsITransaction **aTransaction); - NS_IMETHOD PeekRedoStack(nsITransaction **aTransaction); - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - NS_IMETHOD AddListener(nsITransactionListener *aListener); - NS_IMETHOD RemoveListener(nsITransactionListener *aListener); + NS_DECL_NSITRANSACTIONMANAGER /* nsTransactionManager specific methods. */ virtual nsresult ClearUndoStack(void); virtual nsresult ClearRedoStack(void); virtual nsresult WillDoNotify(nsITransaction *aTransaction, PRBool *aInterrupt); - virtual nsresult DidDoNotify(nsITransaction *aTransaction, nsresult aDoResult); + virtual nsresult DidDoNotify(nsITransaction *aTransaction, nsresult aExecuteResult); virtual nsresult WillUndoNotify(nsITransaction *aTransaction, PRBool *aInterrupt); virtual nsresult DidUndoNotify(nsITransaction *aTransaction, nsresult aUndoResult); virtual nsresult WillRedoNotify(nsITransaction *aTransaction, PRBool *aInterrupt); diff --git a/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp b/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp index 020d6557aae..88570a248d4 100644 --- a/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp +++ b/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp @@ -23,7 +23,6 @@ #include "nsIGenericFactory.h" #include "nsTransactionManagerCID.h" -#include "nsITransactionManager.h" #include "nsTransactionStack.h" #include "nsTransactionManager.h" @@ -40,7 +39,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransactionManager) // class name. // static nsModuleComponentInfo components[] = { - { NULL, NS_TRANSACTIONMANAGER_CID, NULL, nsTransactionManagerConstructor }, + { "nsTransactionManager", NS_TRANSACTIONMANAGER_CID, NS_TRANSACTIONMANAGER_CONTRACTID, nsTransactionManagerConstructor }, }; //////////////////////////////////////////////////////////////////////// diff --git a/mozilla/editor/txmgr/src/nsTransactionStack.cpp b/mozilla/editor/txmgr/src/nsTransactionStack.cpp index b783bf96155..51d32ddf768 100644 --- a/mozilla/editor/txmgr/src/nsTransactionStack.cpp +++ b/mozilla/editor/txmgr/src/nsTransactionStack.cpp @@ -94,6 +94,20 @@ nsTransactionStack::Peek(nsTransactionItem **aTransaction) return NS_OK; } +nsresult +nsTransactionStack::GetItem(PRInt32 aIndex, nsTransactionItem **aTransaction) +{ + if (!aTransaction) + return NS_ERROR_NULL_POINTER; + + if (aIndex < 0 || aIndex >= mQue.GetSize()) + return NS_ERROR_FAILURE; + + *aTransaction = (nsTransactionItem *)(mQue.ObjectAt(aIndex)); + + return NS_OK; +} + nsresult nsTransactionStack::Clear(void) { @@ -130,24 +144,6 @@ nsTransactionStack::GetSize(PRInt32 *aStackSize) return NS_OK; } -nsresult -nsTransactionStack::Write(nsIOutputStream *aOutputStream) -{ - /* Call Write() for every transaction on the stack. Start - * from the top of the stack. - */ - - nsDequeIterator di = mQue.End(); - nsTransactionItem *tx = (nsTransactionItem *)--di; - - while (tx) { - tx->Write(aOutputStream); - tx = (nsTransactionItem *)--di; - } - return NS_OK; -} - - nsTransactionRedoStack::~nsTransactionRedoStack() { Clear(); diff --git a/mozilla/editor/txmgr/src/nsTransactionStack.h b/mozilla/editor/txmgr/src/nsTransactionStack.h index 87e6250748e..99499f60c23 100644 --- a/mozilla/editor/txmgr/src/nsTransactionStack.h +++ b/mozilla/editor/txmgr/src/nsTransactionStack.h @@ -49,9 +49,9 @@ public: virtual nsresult Pop(nsTransactionItem **aTransactionItem); virtual nsresult PopBottom(nsTransactionItem **aTransactionItem); virtual nsresult Peek(nsTransactionItem **aTransactionItem); + virtual nsresult GetItem(PRInt32 aIndex, nsTransactionItem **aTransactionItem); virtual nsresult Clear(void); virtual nsresult GetSize(PRInt32 *aStackSize); - virtual nsresult Write(nsIOutputStream *aOutputStream); }; class nsTransactionRedoStack: public nsTransactionStack diff --git a/mozilla/editor/txmgr/tests/TestTXMgr.cpp b/mozilla/editor/txmgr/tests/TestTXMgr.cpp index 1fbcc27ac57..762d6d98928 100644 --- a/mozilla/editor/txmgr/tests/TestTXMgr.cpp +++ b/mozilla/editor/txmgr/tests/TestTXMgr.cpp @@ -22,7 +22,6 @@ #include #include "nsITransactionManager.h" -#include "nsTransactionManagerCID.h" #include "nsIComponentManager.h" static PRInt32 sConstructorCount = 0; @@ -417,14 +416,10 @@ PRInt32 sAggregateBatchTestRedoOrderArr[] = { 295, 296, 297, 298, 299, 300, 301, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458 }; -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kITransactionIID, NS_ITRANSACTION_IID); -static NS_DEFINE_IID(kITransactionManagerIID, NS_ITRANSACTIONMANAGER_IID); -static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID); - +#ifdef MUST_REGISTER_TXMGR_DLL +#include "nsTransactionManagerCID.h" static NS_DEFINE_CID(kCTransactionManagerCID, NS_TRANSACTIONMANAGER_CID); - #ifdef XP_PC #define TRANSACTION_MANAGER_DLL "txmgr.dll" #else @@ -434,124 +429,21 @@ static NS_DEFINE_CID(kCTransactionManagerCID, NS_TRANSACTIONMANAGER_CID); #define TRANSACTION_MANAGER_DLL "libtxmgr"MOZ_DLL_SUFFIX #endif #endif +#endif /* MUST_REGISTER_TXMGR_DLL */ - -class ConsoleOutput : public nsIOutputStream -{ -public: - ConsoleOutput() {} - virtual ~ConsoleOutput() {} - - NS_DECL_ISUPPORTS - - NS_IMETHOD Close(void) {return NS_OK;} - NS_IMETHOD Write(const char *str, PRUint32 len, PRUint32 *wcnt) - { - *wcnt = fwrite(str, 1, len, stdout); - fflush(stdout); - return NS_OK; - } - NS_IMETHOD Flush() - { - fflush(stdout); - return NS_OK; - } - - - NS_IMETHOD - WriteFrom(nsIInputStream *inStr, PRUint32 count, PRUint32 *_retval) { - NS_NOTREACHED("WriteFrom"); - return NS_ERROR_NOT_IMPLEMENTED; - } - - NS_IMETHOD - WriteSegments(nsReadSegmentFun reader, void * closure, PRUint32 count, PRUint32 *_retval) { - NS_NOTREACHED("WriteSegments"); - return NS_ERROR_NOT_IMPLEMENTED; - } - - NS_IMETHOD - GetNonBlocking(PRBool *aNonBlocking) { - NS_NOTREACHED("GetNonBlocking"); - return NS_ERROR_NOT_IMPLEMENTED; - } - - NS_IMETHOD - SetNonBlocking(PRBool aNonBlocking) { - NS_NOTREACHED("SetNonBlocking"); - return NS_ERROR_NOT_IMPLEMENTED; - } - - NS_IMETHOD - GetObserver(nsIOutputStreamObserver * *aObserver) { - NS_NOTREACHED("GetObserver"); - return NS_ERROR_NOT_IMPLEMENTED; - } - - NS_IMETHOD - SetObserver(nsIOutputStreamObserver * aObserver) { - NS_NOTREACHED("SetObserver"); - return NS_ERROR_NOT_IMPLEMENTED; - } -}; - -NS_IMPL_ADDREF(ConsoleOutput) -NS_IMPL_RELEASE(ConsoleOutput) - -nsresult -ConsoleOutput::QueryInterface(REFNSIID aIID, void** aInstancePtr) -{ - if (nsnull == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*)(nsISupports*)this; - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kIOutputStreamIID)) { - *aInstancePtr = (void*)(nsITransaction*)this; - NS_ADDREF_THIS(); - return NS_OK; - } - *aInstancePtr = 0; - return NS_NOINTERFACE; -} - -ConsoleOutput console; +#define TEST_TXMGR_IF_RELEASE(tx) if (tx) tx->Release(); // Release but don't clear pointer! class TestTransaction : public nsITransaction { public: - TestTransaction() : mRefCnt(0) {} + TestTransaction() { NS_INIT_REFCNT(); } virtual ~TestTransaction() {} NS_DECL_ISUPPORTS }; -NS_IMPL_ADDREF(TestTransaction) -NS_IMPL_RELEASE(TestTransaction) - -nsresult -TestTransaction::QueryInterface(REFNSIID aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*)(nsISupports*)this; - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kITransactionIID)) { - *aInstancePtr = (void*)(nsITransaction*)this; - NS_ADDREF_THIS(); - return NS_OK; - } - *aInstancePtr = 0; - return NS_NOINTERFACE; -} +NS_IMPL_ISUPPORTS(TestTransaction, NS_GET_IID(nsITransaction)) class SimpleTransaction : public TestTransaction { @@ -596,10 +488,10 @@ public: mVal = -1; } - NS_IMETHOD Do() + NS_IMETHOD DoTransaction() { // - // Make sure Do() is called in the order we expect! + // Make sure DoTransaction() is called in the order we expect! // Notice that we don't check to see if we go past the end of the array. // This is done on purpose since we want to crash if the order array is out // of date. @@ -613,16 +505,16 @@ public: ++sDoCount; #ifdef ENABLE_DEBUG_PRINTFS - printf("\nSimpleTransaction.Do: %d - 0x%.8x\n", mVal, (PRInt32)this); + printf("\nSimpleTransaction.DoTransaction: %d - 0x%.8x\n", mVal, (PRInt32)this); #endif // ENABLE_DEBUG_PRINTFS return (mFlags & THROWS_DO_ERROR_FLAG) ? NS_ERROR_FAILURE : NS_OK; } - NS_IMETHOD Undo() + NS_IMETHOD UndoTransaction() { // - // Make sure Undo() is called in the order we expect! + // Make sure UndoTransaction() is called in the order we expect! // Notice that we don't check to see if we go past the end of the array. // This is done on purpose since we want to crash if the order array is out // of date. @@ -642,10 +534,10 @@ public: return (mFlags & THROWS_UNDO_ERROR_FLAG) ? NS_ERROR_FAILURE : NS_OK; } - NS_IMETHOD Redo() + NS_IMETHOD RedoTransaction() { // - // Make sure Redo() is called in the order we expect! + // Make sure RedoTransaction() is called in the order we expect! // Notice that we don't check to see if we go past the end of the array. // This is done on purpose since we want to crash if the order array is out // of date. @@ -673,37 +565,13 @@ public: return NS_OK; } - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction) + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (aDidMerge) *aDidMerge = (mFlags & MERGE_FLAG) ? PR_TRUE : PR_FALSE; return NS_OK; } - - NS_IMETHOD Write(nsIOutputStream *aOutputStream) - { - char buf[256]; - PRUint32 amt; - - sprintf(buf, "Transaction: %d - 0x%.8x\n", mVal, (PRInt32)this); - return aOutputStream->Write(buf, strlen(buf), &amt); - } - - NS_IMETHOD GetUndoString(nsString *aString) - { - if (aString) - aString->SetLength(0); - return NS_OK; - } - - NS_IMETHOD GetRedoString(nsString *aString) - { - if (aString) - aString->SetLength(0) ; - return NS_OK; - } - }; class AggregateTransaction : public SimpleTransaction @@ -754,14 +622,14 @@ public: // printf("~AggregateTransaction(0x%.8x) - %3d (%3d)\n", this, mLevel, mVal); } - NS_IMETHOD Do() + NS_IMETHOD DoTransaction() { if (mLevel >= mMaxLevel) { // Only leaf nodes can throw errors! mFlags |= mErrorFlags; } - nsresult result = SimpleTransaction::Do(); + nsresult result = SimpleTransaction::DoTransaction(); if (NS_FAILED(result)) { // printf("ERROR: QueryInterface() failed for transaction level %d. (%d)\n", @@ -813,7 +681,7 @@ public: } nsITransaction *tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d, level %d. (%d)\n", i, mLevel, result); @@ -824,7 +692,7 @@ public: return result; } - result = mTXMgr->Do(tx); + result = mTXMgr->DoTransaction(tx); if (NS_FAILED(result)) { // printf("ERROR: Failed to execute transaction %d, level %d. (%d)\n", @@ -916,15 +784,15 @@ quick_test(TestTransactionFactory *factory) printf("Create transaction manager instance ... "); PRInt32 i, numitems = 0; - nsITransactionManager *mgr = 0; - nsITransaction *tx = 0; - TestTransaction *tximpl = 0; + nsITransactionManager *mgr = 0; + nsITransaction *tx = 0; + TestTransaction *tximpl = 0; nsITransaction *u1 = 0, *u2 = 0; nsITransaction *r1 = 0, *r2 = 0; nsresult result; - result = nsComponentManager::CreateInstance(kCTransactionManagerCID, nsnull, - kITransactionManagerIID, (void **)&mgr); + result = nsComponentManager::CreateInstance(NS_TRANSACTIONMANAGER_CONTRACTID, nsnull, + NS_GET_IID(nsITransactionManager), (void **)&mgr); if (NS_FAILED(result) || !mgr) { printf("ERROR: Failed to create Transaction Manager instance.\n"); @@ -935,16 +803,16 @@ quick_test(TestTransactionFactory *factory) /******************************************************************* * - * Call Do() with a null transaction: + * Call DoTransaction() with a null transaction: * *******************************************************************/ - printf("Call Do() with null transaction ... "); - result = mgr->Do(0); + printf("Call DoTransaction() with null transaction ... "); + result = mgr->DoTransaction(0); if (NS_FAILED(result) && result != NS_ERROR_NULL_POINTER) { - printf("ERROR: Do() returned unexpected error. (%d)\n", result); + printf("ERROR: DoTransaction() returned unexpected error. (%d)\n", result); return result; } @@ -952,12 +820,12 @@ quick_test(TestTransactionFactory *factory) /******************************************************************* * - * Call Undo() with an empty undo stack: + * Call UndoTransaction() with an empty undo stack: * *******************************************************************/ - printf("Call Undo() with empty undo stack ... "); - result = mgr->Undo(); + printf("Call UndoTransaction() with empty undo stack ... "); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Undo on empty undo stack failed. (%d)\n", result); @@ -968,12 +836,12 @@ quick_test(TestTransactionFactory *factory) /******************************************************************* * - * Call Redo() with an empty redo stack: + * Call RedoTransaction() with an empty redo stack: * *******************************************************************/ - printf("Call Redo() with empty redo stack ... "); - result = mgr->Redo(); + printf("Call RedoTransaction() with empty redo stack ... "); + result = mgr->RedoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Redo on empty redo stack failed. (%d)\n", result); @@ -1105,6 +973,8 @@ quick_test(TestTransactionFactory *factory) tx = 0; result = mgr->PeekUndoStack(&tx); + TEST_TXMGR_IF_RELEASE(tx); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: PeekUndoStack() on empty undo stack failed. (%d)\n", result); return result; @@ -1128,6 +998,8 @@ quick_test(TestTransactionFactory *factory) tx = 0; result = mgr->PeekRedoStack(&tx); + TEST_TXMGR_IF_RELEASE(tx); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: PeekRedoStack() on empty redo stack failed. (%d)\n", result); return result; @@ -1140,24 +1012,6 @@ quick_test(TestTransactionFactory *factory) printf("passed\n"); - /******************************************************************* - * - * Call Write() with a null output stream: - * - *******************************************************************/ - - printf("Call Write() with null output stream ... "); - - result = mgr->Write(0); - - if (NS_FAILED(result) - && result != NS_ERROR_NULL_POINTER) { - printf("ERROR: Write() returned unexpected error. (%d)\n", result); - return result; - } - - printf("passed\n"); - /******************************************************************* * * Call AddListener() with a null listener pointer: @@ -1222,7 +1076,7 @@ quick_test(TestTransactionFactory *factory) tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for initial transaction. (%d)\n", @@ -1230,7 +1084,7 @@ quick_test(TestTransactionFactory *factory) return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute initial transaction. (%d)\n", result); @@ -1243,6 +1097,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -1255,6 +1111,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; @@ -1269,14 +1127,14 @@ quick_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -1287,6 +1145,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -1299,6 +1159,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -1364,14 +1226,14 @@ quick_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -1423,6 +1285,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -1430,6 +1294,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; @@ -1444,14 +1310,14 @@ quick_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -1462,6 +1328,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -1474,6 +1342,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -1524,7 +1394,7 @@ quick_test(TestTransactionFactory *factory) printf("Undo 4 transactions ... "); for (i = 1; i <= 4; i++) { - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction %d. (%d)\n", i, result); return result; @@ -1571,7 +1441,7 @@ quick_test(TestTransactionFactory *factory) printf("Redo 2 transactions ... "); for (i = 1; i <= 2; ++i) { - result = mgr->Redo(); + result = mgr->RedoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to redo transaction %d. (%d)\n", i, result); return result; @@ -1625,14 +1495,14 @@ quick_test(TestTransactionFactory *factory) tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction. (%d)\n", result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction. (%d)\n", result); return result; @@ -1679,7 +1549,7 @@ quick_test(TestTransactionFactory *factory) printf("Undo 4 transactions then clear the undo and redo stacks ... "); for (i = 1; i <= 4; ++i) { - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction %d. (%d)\n", i, result); return result; @@ -1769,14 +1639,14 @@ quick_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -1817,11 +1687,11 @@ quick_test(TestTransactionFactory *factory) /******************************************************************* * - * Test transaction Do() error: + * Test transaction DoTransaction() error: * *******************************************************************/ - printf("Test transaction Do() error ... "); + printf("Test transaction DoTransaction() error ... "); tximpl = factory->create(mgr, THROWS_DO_ERROR_FLAG); @@ -1832,7 +1702,7 @@ quick_test(TestTransactionFactory *factory) tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction. (%d)\n", result); @@ -1843,6 +1713,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -1850,15 +1722,17 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result) && result != NS_ERROR_FAILURE) { - printf("ERROR: Do() returned unexpected error. (%d)\n", result); + printf("ERROR: DoTransaction() returned unexpected error. (%d)\n", result); return result; } @@ -1866,6 +1740,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -1878,6 +1754,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -1920,11 +1798,11 @@ quick_test(TestTransactionFactory *factory) /******************************************************************* * - * Test transaction Undo() error: + * Test transaction UndoTransaction() error: * *******************************************************************/ - printf("Test transaction Undo() error ... "); + printf("Test transaction UndoTransaction() error ... "); tximpl = factory->create(mgr, THROWS_UNDO_ERROR_FLAG); @@ -1935,17 +1813,17 @@ quick_test(TestTransactionFactory *factory) tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction. (%d)\n", result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { - printf("ERROR: Do() returned unexpected error. (%d)\n", result); + printf("ERROR: DoTransaction() returned unexpected error. (%d)\n", result); return result; } @@ -1955,6 +1833,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -1962,20 +1842,24 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; } - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result) && result != NS_ERROR_FAILURE) { - printf("ERROR: Undo() returned unexpected error. (%d)\n", result); + printf("ERROR: UndoTransaction() returned unexpected error. (%d)\n", result); return result; } result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -1988,6 +1872,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -2030,11 +1916,11 @@ quick_test(TestTransactionFactory *factory) /******************************************************************* * - * Test transaction Redo() error: + * Test transaction RedoTransaction() error: * *******************************************************************/ - printf("Test transaction Redo() error ... "); + printf("Test transaction RedoTransaction() error ... "); tximpl = factory->create(mgr, THROWS_REDO_ERROR_FLAG); @@ -2045,7 +1931,7 @@ quick_test(TestTransactionFactory *factory) tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for RedoErrorTransaction. (%d)\n", @@ -2053,10 +1939,10 @@ quick_test(TestTransactionFactory *factory) return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { - printf("ERROR: Do() returned unexpected error. (%d)\n", result); + printf("ERROR: DoTransaction() returned unexpected error. (%d)\n", result); return result; } @@ -2075,17 +1961,17 @@ quick_test(TestTransactionFactory *factory) tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction. (%d)\n", result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { - printf("ERROR: Do() returned unexpected error. (%d)\n", result); + printf("ERROR: DoTransaction() returned unexpected error. (%d)\n", result); return result; } @@ -2096,7 +1982,7 @@ quick_test(TestTransactionFactory *factory) // for (i = 1; i <= 2; ++i) { - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction %d. (%d)\n", i, result); return result; @@ -2111,6 +1997,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -2118,20 +2006,24 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; } - result = mgr->Redo(); + result = mgr->RedoTransaction(); if (NS_FAILED(result) && result != NS_ERROR_FAILURE) { - printf("ERROR: Redo() returned unexpected error. (%d)\n", result); + printf("ERROR: RedoTransaction() returned unexpected error. (%d)\n", result); return result; } result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -2144,6 +2036,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -2238,14 +2132,14 @@ quick_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -2312,14 +2206,14 @@ quick_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -2358,7 +2252,7 @@ quick_test(TestTransactionFactory *factory) for (i = 1; i <= 10; i++) { - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction %d. (%d)\n", i, result); return result; @@ -2396,6 +2290,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -2403,6 +2299,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; @@ -2417,6 +2315,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -2429,6 +2329,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -2483,6 +2385,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -2490,6 +2394,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; @@ -2504,6 +2410,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -2516,6 +2424,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -2570,6 +2480,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -2577,6 +2489,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; @@ -2591,6 +2505,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -2603,6 +2519,8 @@ quick_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -2670,14 +2588,14 @@ quick_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -2716,7 +2634,7 @@ quick_test(TestTransactionFactory *factory) for (i = 1; i <= 10; i++) { - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction %d. (%d)\n", i, result); return result; @@ -2863,8 +2781,8 @@ quick_batch_test(TestTransactionFactory *factory) nsITransaction *r1 = 0, *r2 = 0; nsresult result; - result = nsComponentManager::CreateInstance(kCTransactionManagerCID, nsnull, - kITransactionManagerIID, (void **)&mgr); + result = nsComponentManager::CreateInstance(NS_TRANSACTIONMANAGER_CONTRACTID, nsnull, + NS_GET_IID(nsITransactionManager), (void **)&mgr); if (NS_FAILED(result) || !mgr) { printf("ERROR: Failed to create Transaction Manager instance.\n"); @@ -3012,14 +2930,14 @@ quick_batch_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -3078,6 +2996,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -3085,6 +3005,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; @@ -3106,14 +3028,14 @@ quick_batch_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -3131,6 +3053,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -3143,6 +3067,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -3207,13 +3133,13 @@ quick_batch_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction. (%d)\n", result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction. (%d)\n", result); return result; @@ -3250,13 +3176,13 @@ quick_batch_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction. (%d)\n", result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction. (%d)\n", result); return result; @@ -3293,13 +3219,13 @@ quick_batch_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction. (%d)\n", result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction. (%d)\n", result); return result; @@ -3368,7 +3294,7 @@ quick_batch_test(TestTransactionFactory *factory) printf("Undo 2 batch transactions ... "); for (i = 1; i <= 2; ++i) { - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction %d. (%d)\n", i, result); return result; @@ -3416,7 +3342,7 @@ quick_batch_test(TestTransactionFactory *factory) printf("Redo 2 batch transactions ... "); for (i = 1; i <= 2; ++i) { - result = mgr->Redo(); + result = mgr->RedoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction %d. (%d)\n", i, result); return result; @@ -3462,7 +3388,7 @@ quick_batch_test(TestTransactionFactory *factory) printf("Undo a batched transaction that was redone ... "); - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction. (%d)\n", result); @@ -3653,14 +3579,14 @@ quick_batch_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -3745,7 +3671,7 @@ quick_batch_test(TestTransactionFactory *factory) // Move a transaction over to the redo stack, so that we have one // transaction on the undo stack, and one on the redo stack! - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction. (%d)\n", result); @@ -3784,11 +3710,11 @@ quick_batch_test(TestTransactionFactory *factory) /******************************************************************* * - * Test transaction Do() error: + * Test transaction DoTransaction() error: * *******************************************************************/ - printf("Test transaction Do() error ... "); + printf("Test transaction DoTransaction() error ... "); tximpl = factory->create(mgr, THROWS_DO_ERROR_FLAG); @@ -3800,7 +3726,7 @@ quick_batch_test(TestTransactionFactory *factory) tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction. (%d)\n", result); @@ -3811,6 +3737,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -3818,6 +3746,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; @@ -3830,10 +3760,10 @@ quick_batch_test(TestTransactionFactory *factory) return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result) && result != NS_ERROR_FAILURE) { - printf("ERROR: Do() returned unexpected error. (%d)\n", result); + printf("ERROR: DoTransaction() returned unexpected error. (%d)\n", result); return result; } @@ -3848,6 +3778,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -3860,6 +3792,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -3902,11 +3836,11 @@ quick_batch_test(TestTransactionFactory *factory) /******************************************************************* * - * Test transaction Undo() error: + * Test transaction UndoTransaction() error: * *******************************************************************/ - printf("Test transaction Undo() error ... "); + printf("Test transaction UndoTransaction() error ... "); tximpl = factory->create(mgr, THROWS_UNDO_ERROR_FLAG); @@ -3917,7 +3851,7 @@ quick_batch_test(TestTransactionFactory *factory) tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction. (%d)\n", result); @@ -3931,10 +3865,10 @@ quick_batch_test(TestTransactionFactory *factory) return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { - printf("ERROR: Do() returned unexpected error. (%d)\n", result); + printf("ERROR: DoTransaction() returned unexpected error. (%d)\n", result); return result; } @@ -3951,6 +3885,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -3958,20 +3894,24 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; } - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result) && result != NS_ERROR_FAILURE) { - printf("ERROR: Undo() returned unexpected error. (%d)\n", result); + printf("ERROR: UndoTransaction() returned unexpected error. (%d)\n", result); return result; } result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -3984,6 +3924,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -4026,11 +3968,11 @@ quick_batch_test(TestTransactionFactory *factory) /******************************************************************* * - * Test transaction Redo() error: + * Test transaction RedoTransaction() error: * *******************************************************************/ - printf("Test transaction Redo() error ... "); + printf("Test transaction RedoTransaction() error ... "); tximpl = factory->create(mgr, THROWS_REDO_ERROR_FLAG); @@ -4041,7 +3983,7 @@ quick_batch_test(TestTransactionFactory *factory) tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for RedoErrorTransaction. (%d)\n", @@ -4056,10 +3998,10 @@ quick_batch_test(TestTransactionFactory *factory) return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { - printf("ERROR: Do() returned unexpected error. (%d)\n", result); + printf("ERROR: DoTransaction() returned unexpected error. (%d)\n", result); return result; } @@ -4085,17 +4027,17 @@ quick_batch_test(TestTransactionFactory *factory) tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction. (%d)\n", result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { - printf("ERROR: Do() returned unexpected error. (%d)\n", result); + printf("ERROR: DoTransaction() returned unexpected error. (%d)\n", result); return result; } @@ -4106,7 +4048,7 @@ quick_batch_test(TestTransactionFactory *factory) // for (i = 1; i <= 2; ++i) { - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction %d. (%d)\n", i, result); return result; @@ -4121,6 +4063,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekUndoStack(&u1); + TEST_TXMGR_IF_RELEASE(u1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekUndoStack() failed. (%d)\n", result); return result; @@ -4128,20 +4072,24 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r1); + TEST_TXMGR_IF_RELEASE(r1); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Initial PeekRedoStack() failed. (%d)\n", result); return result; } - result = mgr->Redo(); + result = mgr->RedoTransaction(); if (NS_FAILED(result) && result != NS_ERROR_FAILURE) { - printf("ERROR: Redo() returned unexpected error. (%d)\n", result); + printf("ERROR: RedoTransaction() returned unexpected error. (%d)\n", result); return result; } result = mgr->PeekUndoStack(&u2); + TEST_TXMGR_IF_RELEASE(u2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekUndoStack() failed. (%d)\n", result); return result; @@ -4154,6 +4102,8 @@ quick_batch_test(TestTransactionFactory *factory) result = mgr->PeekRedoStack(&r2); + TEST_TXMGR_IF_RELEASE(r2); // Don't hold onto any references! + if (NS_FAILED(result)) { printf("ERROR: Second PeekRedoStack() failed. (%d)\n", result); return result; @@ -4248,7 +4198,7 @@ quick_batch_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); @@ -4262,7 +4212,7 @@ quick_batch_test(TestTransactionFactory *factory) return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -4335,7 +4285,7 @@ quick_batch_test(TestTransactionFactory *factory) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); @@ -4349,7 +4299,7 @@ quick_batch_test(TestTransactionFactory *factory) return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -4395,7 +4345,7 @@ quick_batch_test(TestTransactionFactory *factory) for (i = 1; i <= 10; i++) { - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction %d. (%d)\n", i, result); return result; @@ -4541,8 +4491,8 @@ stress_test(TestTransactionFactory *factory, PRInt32 iterations) nsITransaction *tx = 0; nsresult result; - result = nsComponentManager::CreateInstance(kCTransactionManagerCID, nsnull, - kITransactionManagerIID, (void **)&mgr); + result = nsComponentManager::CreateInstance(NS_TRANSACTIONMANAGER_CONTRACTID, nsnull, + NS_GET_IID(nsITransactionManager), (void **)&mgr); if (NS_FAILED(result) || !mgr) { printf("ERROR: Failed to create Transaction Manager instance.\n"); @@ -4565,14 +4515,14 @@ stress_test(TestTransactionFactory *factory, PRInt32 iterations) } tx = 0; - result = tximpl->QueryInterface(kITransactionIID, (void **)&tx); + result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); if (NS_FAILED(result)) { printf("ERROR: QueryInterface() failed for transaction %d. (%d)\n", i, result); return result; } - result = mgr->Do(tx); + result = mgr->DoTransaction(tx); if (NS_FAILED(result)) { printf("ERROR: Failed to execute transaction %d. (%d)\n", i, result); return result; @@ -4588,7 +4538,7 @@ stress_test(TestTransactionFactory *factory, PRInt32 iterations) *******************************************************************/ for (j = 1; j <= i; j++) { - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction %d-%d. (%d)\n", i, j, result); return result; @@ -4602,7 +4552,7 @@ stress_test(TestTransactionFactory *factory, PRInt32 iterations) *******************************************************************/ for (j = 1; j <= i; j++) { - result = mgr->Redo(); + result = mgr->RedoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to redo transaction %d-%d. (%d)\n", i, j, result); return result; @@ -4618,7 +4568,7 @@ stress_test(TestTransactionFactory *factory, PRInt32 iterations) *******************************************************************/ for (j = 1; j <= i; j++) { - result = mgr->Undo(); + result = mgr->UndoTransaction(); if (NS_FAILED(result)) { printf("ERROR: Failed to undo transaction %d-%d. (%d)\n", i, j, result); return result; @@ -4740,8 +4690,11 @@ main (int argc, char *argv[]) { nsresult result; - nsComponentManager::RegisterComponent(kCTransactionManagerCID, NULL, NULL, +#ifdef MUST_REGISTER_TXMGR_DLL + nsComponentManager::RegisterComponent(kCTransactionManagerCID, + NULL, NS_TRANSACTIONMANAGER_CONTRACTID, TRANSACTION_MANAGER_DLL, PR_FALSE, PR_FALSE); +#endif /* MUST_REGISTER_TXMGR_DLL */ result = simple_test(); diff --git a/mozilla/editor/ui/composer/content/EditorCommandsDebug.js b/mozilla/editor/ui/composer/content/EditorCommandsDebug.js index c0206f7e546..aee2fa194da 100644 --- a/mozilla/editor/ui/composer/content/EditorCommandsDebug.js +++ b/mozilla/editor/ui/composer/content/EditorCommandsDebug.js @@ -385,3 +385,69 @@ function EditorTableize() window._content.focus(); } +// --------------------------- TransactionManager --------------------------- + + +function DumpUndoStack() +{ + try { + var txmgr = editorShell.transactionManager; + + if (!txmgr) + { + dump("**** Editor has no TransactionManager!\n"); + return; + } + + dump("---------------------- BEGIN UNDO STACK DUMP\n"); + dump("\n"); + PrintTxnList(txmgr.getUndoList(), ""); + dump("\n"); + dump("Num Undo Items: " + txmgr.numberOfUndoItems + "\n"); + dump("---------------------- END UNDO STACK DUMP\n"); + } catch (e) { + dump("ERROR: DumpUndoStack() failed: " + e); + } +} + +function DumpRedoStack() +{ + try { + var txmgr = editorShell.transactionManager; + + if (!txmgr) + { + dump("**** Editor has no TransactionManager!\n"); + return; + } + + dump("---------------------- BEGIN REDO STACK DUMP\n"); + dump("\n"); + PrintTxnList(txmgr.getRedoList(), ""); + dump("\n"); + dump("Num Redo Items: " + txmgr.numberOfRedoItems + "\n"); + dump("---------------------- END REDO STACK DUMP\n"); + } catch (e) { + dump("ERROR: DumpUndoStack() failed: " + e); + } +} + +function PrintTxnList(txnList, prefixStr) +{ + var i; + + for (i=0 ; i < txnList.numItems; i++) + { + var txn = txnList.getItem(i); + var desc = "TXMgr Batch"; + + if (txn) + { + txn = txn.QueryInterface(Components.interfaces.nsPIEditorTransaction); + desc = txn.txnDescription; + } + dump(prefixStr + "+ " + desc + "\n"); + PrintTxnList(txnList.getChildListForItem(i), prefixStr + "| "); + } +} + diff --git a/mozilla/editor/ui/composer/content/editorOverlay.xul b/mozilla/editor/ui/composer/content/editorOverlay.xul index 577fcdb13f2..37e93b213a5 100644 --- a/mozilla/editor/ui/composer/content/editorOverlay.xul +++ b/mozilla/editor/ui/composer/content/editorOverlay.xul @@ -836,6 +836,11 @@ + + + + + diff --git a/mozilla/mailnews/base/src/nsMessenger.cpp b/mozilla/mailnews/base/src/nsMessenger.cpp index da974df10e1..3094a2e4b76 100644 --- a/mozilla/mailnews/base/src/nsMessenger.cpp +++ b/mozilla/mailnews/base/src/nsMessenger.cpp @@ -1204,9 +1204,8 @@ NS_IMETHODIMP nsMessenger::GetUndoTransactionType(PRUint32 *txnType) if (!txnType || !mTxnMgr) return rv; *txnType = nsMessenger::eUnknown; - nsITransaction *txn = nsnull; - // ** jt -- too bad PeekUndoStack not AddRef'ing - rv = mTxnMgr->PeekUndoStack(&txn); + nsCOMPtr txn; + rv = mTxnMgr->PeekUndoStack(getter_AddRefs(txn)); if (NS_SUCCEEDED(rv) && txn) { nsCOMPtr msgTxn = do_QueryInterface(txn, &rv); @@ -1235,9 +1234,8 @@ NS_IMETHODIMP nsMessenger::GetRedoTransactionType(PRUint32 *txnType) if (!txnType || !mTxnMgr) return rv; *txnType = nsMessenger::eUnknown; - nsITransaction *txn = nsnull; - // ** jt - too bad PeekRedoStack not AddRef'ing - rv = mTxnMgr->PeekRedoStack(&txn); + nsCOMPtr txn; + rv = mTxnMgr->PeekRedoStack(getter_AddRefs(txn)); if (NS_SUCCEEDED(rv) && txn) { nsCOMPtr msgTxn = do_QueryInterface(txn, &rv); @@ -1270,16 +1268,15 @@ nsMessenger::Undo(nsIMsgWindow *msgWindow) rv = mTxnMgr->GetNumberOfUndoItems(&numTxn); if (NS_SUCCEEDED(rv) && numTxn > 0) { - nsITransaction *txn = nsnull; - // ** jt -- PeekUndoStack not AddRef'ing - rv = mTxnMgr->PeekUndoStack(&txn); + nsCOMPtr txn; + rv = mTxnMgr->PeekUndoStack(getter_AddRefs(txn)); if (NS_SUCCEEDED(rv) && txn) { nsCOMPtr msgTxn = do_QueryInterface(txn, &rv); if (NS_SUCCEEDED(rv) && msgTxn) msgTxn->SetMsgWindow(msgWindow); } - mTxnMgr->Undo(); + mTxnMgr->UndoTransaction(); } } return rv; @@ -1295,16 +1292,15 @@ nsMessenger::Redo(nsIMsgWindow *msgWindow) rv = mTxnMgr->GetNumberOfRedoItems(&numTxn); if (NS_SUCCEEDED(rv) && numTxn > 0) { - nsITransaction *txn = nsnull; - // jt -- PeekRedoStack not AddRef'ing - rv = mTxnMgr->PeekRedoStack(&txn); + nsCOMPtr txn; + rv = mTxnMgr->PeekRedoStack(getter_AddRefs(txn)); if (NS_SUCCEEDED(rv) && txn) { nsCOMPtr msgTxn = do_QueryInterface(txn, &rv); if (NS_SUCCEEDED(rv) && msgTxn) msgTxn->SetMsgWindow(msgWindow); } - mTxnMgr->Redo(); + mTxnMgr->RedoTransaction(); } } return rv; diff --git a/mozilla/mailnews/base/util/nsMsgTxn.cpp b/mozilla/mailnews/base/util/nsMsgTxn.cpp index 08b128d196e..130ecef9672 100644 --- a/mozilla/mailnews/base/util/nsMsgTxn.cpp +++ b/mozilla/mailnews/base/util/nsMsgTxn.cpp @@ -32,15 +32,13 @@ nsMsgTxn::nsMsgTxn() { NS_INIT_REFCNT(); m_txnType = 0; - m_undoString.AssignWithConversion("Undo"); - m_redoString.AssignWithConversion("Redo"); } nsMsgTxn::~nsMsgTxn() { } -NS_IMETHODIMP nsMsgTxn::Do(void) +NS_IMETHODIMP nsMsgTxn::DoTransaction(void) { return NS_OK; } @@ -54,12 +52,7 @@ NS_IMETHODIMP nsMsgTxn::GetIsTransient(PRBool *aIsTransient) return NS_OK; } -NS_IMETHODIMP nsMsgTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP nsMsgTxn::Write(nsIOutputStream *aOutputStream) +NS_IMETHODIMP nsMsgTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -80,39 +73,6 @@ NS_IMETHODIMP nsMsgTxn::SetMsgWindow(nsIMsgWindow *msgWindow) return NS_OK; } -NS_IMETHODIMP -nsMsgTxn::SetUndoString(nsString *aString) -{ - if (!aString) return NS_ERROR_NULL_POINTER; - m_undoString = *aString; - return NS_OK; -} - -NS_IMETHODIMP -nsMsgTxn::SetRedoString(nsString* aString) -{ - if (!aString) return NS_ERROR_NULL_POINTER; - m_redoString = *aString; - return NS_OK; -} - -NS_IMETHODIMP -nsMsgTxn::GetUndoString(nsString* aString) -{ - if (!aString) return NS_ERROR_NULL_POINTER; - *aString = m_undoString; - return NS_OK; -} - -NS_IMETHODIMP -nsMsgTxn::GetRedoString(nsString* aString) -{ - if (!aString) return NS_ERROR_NULL_POINTER; - *aString = m_redoString; - return NS_OK; -} - - NS_IMETHODIMP nsMsgTxn::GetTransactionType(PRUint32 *txnType) { diff --git a/mozilla/mailnews/base/util/nsMsgTxn.h b/mozilla/mailnews/base/util/nsMsgTxn.h index a85c6af61d7..a030b4bcb5b 100644 --- a/mozilla/mailnews/base/util/nsMsgTxn.h +++ b/mozilla/mailnews/base/util/nsMsgTxn.h @@ -42,22 +42,15 @@ class NS_MSG_BASE nsMsgTxn : public nsITransaction nsMsgTxn(); virtual ~nsMsgTxn(); - NS_IMETHOD Do(void); - - NS_IMETHOD Undo(void) = 0; - - NS_IMETHOD Redo(void) = 0; + NS_IMETHOD DoTransaction(void); + + NS_IMETHOD UndoTransaction(void) = 0; + + NS_IMETHOD RedoTransaction(void) = 0; NS_IMETHOD GetIsTransient(PRBool *aIsTransient); - NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); - - NS_IMETHOD Write(nsIOutputStream *aOutputStream); - - NS_IMETHOD GetUndoString(nsString *aString); - NS_IMETHOD SetUndoString(nsString *aString); - NS_IMETHOD GetRedoString(nsString *aString); - NS_IMETHOD SetRedoString(nsString *aString); + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge); NS_IMETHOD GetMsgWindow(nsIMsgWindow **msgWindow); NS_IMETHOD SetMsgWindow(nsIMsgWindow *msgWindow); @@ -66,8 +59,6 @@ class NS_MSG_BASE nsMsgTxn : public nsITransaction protected: nsCOMPtr m_msgWindow; - nsString m_undoString; - nsString m_redoString; PRUint32 m_txnType; }; diff --git a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp index b72084f6d5f..9b29d0ed913 100644 --- a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp @@ -1816,7 +1816,7 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMessages(nsISupportsArray *messages, // we're adding this undo action before the delete is successful. This is evil, // but 4.5 did it as well. if (m_transactionManager) - m_transactionManager->Do(undoMsgTxn); + m_transactionManager->DoTransaction(undoMsgTxn); rv = StoreImapFlags(kImapMsgDeletedFlag, PR_TRUE, srcKeyArray); if (NS_SUCCEEDED(rv)) @@ -3749,7 +3749,7 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode) srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom); } if (m_transactionManager) - m_transactionManager->Do(m_copyState->m_undoMsgTxn); + m_transactionManager->DoTransaction(m_copyState->m_undoMsgTxn); } ClearCopyState(aExitCode); } @@ -3822,7 +3822,7 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode) if (m_copyState->m_curIndex >= m_copyState->m_totalCount) { if (m_transactionManager && m_copyState->m_undoMsgTxn) - m_transactionManager->Do(m_copyState->m_undoMsgTxn); + m_transactionManager->DoTransaction(m_copyState->m_undoMsgTxn); ClearCopyState(aExitCode); } else diff --git a/mozilla/mailnews/imap/src/nsImapUndoTxn.cpp b/mozilla/mailnews/imap/src/nsImapUndoTxn.cpp index 5c79558901c..080e82a016c 100644 --- a/mozilla/mailnews/imap/src/nsImapUndoTxn.cpp +++ b/mozilla/mailnews/imap/src/nsImapUndoTxn.cpp @@ -69,42 +69,6 @@ nsImapMoveCopyMsgTxn::Init( m_urlListener = do_QueryInterface(urlListener, &rv); m_srcKeyArray.CopyArray(srcKeyArray); m_dupKeyArray.CopyArray(srcKeyArray); - if (srcKeyArray->GetSize() > 1) - { - if (isMove) - { - m_undoString.AssignWithConversion("Undo Move Messages"); - m_redoString.AssignWithConversion("Redo Move Messages"); - } - else if (!dstFolder) - { - m_undoString.AssignWithConversion("Undo Imap Deletes"); - m_redoString.AssignWithConversion("Redo Imap Deletes"); - } - else - { - m_undoString.AssignWithConversion("Undo Copy Messages"); - m_redoString.AssignWithConversion("Redo Copy Messages"); - } - } - else - { - if (isMove) - { - m_undoString.AssignWithConversion("Undo Move Message"); - m_redoString.AssignWithConversion("Redo Move Message"); - } - else if (!dstFolder) - { - m_undoString.AssignWithConversion("Undo Imap Deletes"); - m_redoString.AssignWithConversion("Redo Imap Deletes"); - } - else - { - m_undoString.AssignWithConversion("Undo Copy Message"); - m_redoString.AssignWithConversion("Redo Copy Message"); - } - } char *uri = nsnull; rv = m_srcFolder->GetURI(&uri); nsCString protocolType(uri); @@ -182,7 +146,7 @@ nsImapMoveCopyMsgTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr) } NS_IMETHODIMP -nsImapMoveCopyMsgTxn::Undo(void) +nsImapMoveCopyMsgTxn::UndoTransaction(void) { nsresult rv = NS_OK; NS_WITH_SERVICE(nsIImapService, imapService, kCImapService, &rv); @@ -237,7 +201,7 @@ nsImapMoveCopyMsgTxn::Undo(void) } NS_IMETHODIMP -nsImapMoveCopyMsgTxn::Redo(void) +nsImapMoveCopyMsgTxn::RedoTransaction(void) { nsresult rv = NS_OK; NS_WITH_SERVICE(nsIImapService, imapService, kCImapService, &rv); diff --git a/mozilla/mailnews/imap/src/nsImapUndoTxn.h b/mozilla/mailnews/imap/src/nsImapUndoTxn.h index dff8f37149a..2e374b6a565 100644 --- a/mozilla/mailnews/imap/src/nsImapUndoTxn.h +++ b/mozilla/mailnews/imap/src/nsImapUndoTxn.h @@ -52,8 +52,8 @@ public: NS_DECL_ISUPPORTS_INHERITED - NS_IMETHOD Undo(void); - NS_IMETHOD Redo(void); + NS_IMETHOD UndoTransaction(void); + NS_IMETHOD RedoTransaction(void); // helper nsresult SetCopyResponseUid(nsMsgKeyArray* keyArray, @@ -82,8 +82,6 @@ private: nsCString m_dstMsgIdString; nsCOMPtr m_eventQueue; nsCOMPtr m_urlListener; - nsString m_undoString; - nsString m_redoString; PRBool m_idsAreUids; PRBool m_isMove; PRBool m_srcIsPop3; diff --git a/mozilla/mailnews/local/src/nsLocalMailFolder.cpp b/mozilla/mailnews/local/src/nsLocalMailFolder.cpp index 08bd002c396..86e9d4fac8e 100644 --- a/mozilla/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mozilla/mailnews/local/src/nsLocalMailFolder.cpp @@ -2429,7 +2429,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded) copyService->NotifyCompletion(mCopyState->m_srcSupport, this, rv); if (mTxnMgr && NS_SUCCEEDED(rv) && mCopyState->m_undoMsgTxn) - mTxnMgr->Do(mCopyState->m_undoMsgTxn); + mTxnMgr->DoTransaction(mCopyState->m_undoMsgTxn); if (srcFolder && !mCopyState->m_isFolder) @@ -2474,7 +2474,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndMove() copyService->NotifyCompletion(mCopyState->m_srcSupport, this, NS_OK); if (mTxnMgr && mCopyState->m_undoMsgTxn) - mTxnMgr->Do(mCopyState->m_undoMsgTxn); + mTxnMgr->DoTransaction(mCopyState->m_undoMsgTxn); ClearCopyState(); } diff --git a/mozilla/mailnews/local/src/nsLocalUndoTxn.cpp b/mozilla/mailnews/local/src/nsLocalUndoTxn.cpp index d491f946123..6d0f8d48e03 100644 --- a/mozilla/mailnews/local/src/nsLocalUndoTxn.cpp +++ b/mozilla/mailnews/local/src/nsLocalUndoTxn.cpp @@ -203,7 +203,7 @@ nsLocalMoveCopyMsgTxn::UndoImapDeleteFlag(nsIMsgFolder* folder, NS_IMETHODIMP -nsLocalMoveCopyMsgTxn::Undo() +nsLocalMoveCopyMsgTxn::UndoTransaction() { nsresult rv = NS_ERROR_FAILURE; nsCOMPtr srcDB; @@ -256,7 +256,7 @@ nsLocalMoveCopyMsgTxn::Undo() } NS_IMETHODIMP -nsLocalMoveCopyMsgTxn::Redo() +nsLocalMoveCopyMsgTxn::RedoTransaction() { nsresult rv = NS_ERROR_FAILURE; nsCOMPtr srcDB; diff --git a/mozilla/mailnews/local/src/nsLocalUndoTxn.h b/mozilla/mailnews/local/src/nsLocalUndoTxn.h index 017d2ce8a63..f00722a7858 100644 --- a/mozilla/mailnews/local/src/nsLocalUndoTxn.h +++ b/mozilla/mailnews/local/src/nsLocalUndoTxn.h @@ -50,8 +50,8 @@ public: NS_DECL_ISUPPORTS_INHERITED // overloading nsITransaction methods - NS_IMETHOD Undo(void); - NS_IMETHOD Redo(void); + NS_IMETHOD UndoTransaction(void); + NS_IMETHOD RedoTransaction(void); // helper nsresult AddSrcKey(nsMsgKey aKey);