Fixes for bug #66308 ([embed] XPIDL'ize transaction manager)

sr=sfraser@netscape.com,mscott@netscape.com r=jfrancis@netscape.com

* nsITransaction, nsITransactionListenter, nsITransactionManager have
  been XPIDL'ized and moved into mozilla/editor/txmgr/idl. The versions
  of these interfaces in mozilla/editor/txmgr/public are being CVS removed.

* Renamed Do(), Undo(), and Redo() to DoTransaction(), UndoTransaction(),
  and RedoTransaction() to avoid reserved word problems in languages like
  JS. I did a sweep through editor and mailnews to remove these methods.

* PeekUndoStack() and PeekRedoStack() now return an AddRef'd pointer.

* Removed GetUndoString(), GetRedoString() and Write() from the
  nsITransaction interface. Neither editor or mailnews really made
  use of these methods.

* Removed Write() from the nsITransactionManager.cpp interface.

* The Transaction Manager now supports weak references.

* Added support for nsITransactionList to the TransactionManager
  to allow access to all transactions on the Undo and Redo stacks, as
  well as auto-aggregated transactions.

* Removed all references to nsITransactionDescription from txmgr and editor.

* Added nsPIEditorTransaction and made all Editor internal transactions
  inherit from it so we can distinguish between our transactions and
  ones from 3rd parties.

New files checked in:

  editor/txmgr/idl/nsITransaction.idl
  editor/txmgr/idl/nsITransactionList.idl
  editor/txmgr/idl/nsITransactionListener.idl
  editor/txmgr/idl/nsITransactionManager.idl
  editor/txmgr/src/nsITransactionList.cpp
  editor/txmgr/src/nsITransactionList.h
  editor/idl/nsPIEditorTransaction.idl

Files that were CVS removed:

  editor/txmgr/public/nsITransaction.h
  editor/txmgr/public/nsITransactionListener.h
  editor/txmgr/public/nsITransactionManager.h
  editor/txmgr/idl/nsITransactionDescription.h
  editor/base/IMECommitTxn.cpp
  editor/base/IMECommitTxn.h

Files modified:

  editor/Makefile.in
  editor/makefile.win
  editor/base/ChangeAttributeTxn.cpp
  editor/base/ChangeAttributeTxn.h
  editor/base/CreateElementTxn.cpp
  editor/base/CreateElementTxn.h
  editor/base/DeleteElementTxn.cpp
  editor/base/DeleteElementTxn.h
  editor/base/DeleteRangeTxn.cpp
  editor/base/DeleteRangeTxn.h
  editor/base/DeleteTextTxn.cpp
  editor/base/DeleteTextTxn.h
  editor/base/EditAggregateTxn.cpp
  editor/base/EditAggregateTxn.h
  editor/base/EditTxn.cpp
  editor/base/EditTxn.h
  editor/base/IMECommitTxn.cpp
  editor/base/IMECommitTxn.h
  editor/base/IMETextTxn.cpp
  editor/base/IMETextTxn.h
  editor/base/InsertElementTxn.cpp
  editor/base/InsertElementTxn.h
  editor/base/InsertTextTxn.cpp
  editor/base/InsertTextTxn.h
  editor/base/JoinElementTxn.cpp
  editor/base/JoinElementTxn.h
  editor/base/nsEditor.cpp
  editor/base/nsEditorShell.cpp
  editor/base/nsEditorShell.h
  editor/base/nsEditorTxnLog.cpp
  editor/base/nsStyleSheetTxns.cpp
  editor/base/nsStyleSheetTxns.h
  editor/base/PlaceholderTxn.cpp
  editor/base/PlaceholderTxn.h
  editor/base/SetDocTitleTxn.cpp
  editor/base/SetDocTitleTxn.h
  editor/base/SplitElementTxn.cpp
  editor/base/SplitElementTxn.h
  editor/idl/Makefile.in
  editor/idl/makefile.win
  editor/idl/MANIFEST
  editor/idl/nsIEditorShell.idl
  editor/macbuild/editor.mcp
  editor/macbuild/EditorIDL.mcp
  editor/txmgr/idl/Makefile.in
  editor/txmgr/idl/makefile.win
  editor/txmgr/idl/MANIFEST
  editor/txmgr/idl/nsITransactionManager.idl
  editor/txmgr/macbuild/txmgr.mcp
  editor/txmgr/macbuild/txmgrIDL.mcp
  editor/txmgr/public/Makefile.in
  editor/txmgr/public/makefile.win
  editor/txmgr/public/MANIFEST
  editor/txmgr/src/Makefile.in
  editor/txmgr/src/makefile.win
  editor/txmgr/src/nsTransactionItem.cpp
  editor/txmgr/src/nsTransactionItem.h
  editor/txmgr/src/nsTransactionList.cpp
  editor/txmgr/src/nsTransactionList.h
  editor/txmgr/src/nsTransactionManager.cpp
  editor/txmgr/src/nsTransactionManager.h
  editor/txmgr/src/nsTransactionManagerFactory.cpp
  editor/txmgr/src/nsTransactionStack.cpp
  editor/txmgr/src/nsTransactionStack.h
  editor/txmgr/tests/TestTXMgr.cpp
  editor/ui/composer/content/EditorCommandsDebug.js
  editor/ui/composer/content/editorOverlay.xul
  editor/ui/composer/locale/en-US/editorOverlay.dtd
  mailnews/base/src/nsMessenger.cpp
  mailnews/base/util/nsMsgTxn.cpp
  mailnews/base/util/nsMsgTxn.h
  mailnews/imap/src/nsImapMailFolder.cpp
  mailnews/imap/src/nsImapUndoTxn.cpp
  mailnews/imap/src/nsImapUndoTxn.h
  mailnews/local/src/nsLocalMailFolder.cpp
  mailnews/local/src/nsLocalUndoTxn.cpp
  mailnews/local/src/nsLocalUndoTxn.h
This commit is contained in:
kin%netscape.com 2001-03-09 14:23:59 +00:00
Родитель 71a198358a
Коммит 6501ce84d9
107 изменённых файлов: 1024 добавлений и 2125 удалений

Просмотреть файл

@ -26,7 +26,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk include $(DEPTH)/config/autoconf.mk
DIRS = public idl base txmgr txtsvc DIRS = txmgr public idl base txtsvc
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -27,8 +27,6 @@
ChangeAttributeTxn::ChangeAttributeTxn() ChangeAttributeTxn::ChangeAttributeTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
ChangeAttributeTxn::~ChangeAttributeTxn() ChangeAttributeTxn::~ChangeAttributeTxn()
@ -54,7 +52,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP ChangeAttributeTxn::Do(void) NS_IMETHODIMP ChangeAttributeTxn::DoTransaction(void)
{ {
NS_ASSERTION(mEditor && mElement, "bad state"); NS_ASSERTION(mEditor && mElement, "bad state");
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
@ -75,7 +73,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP ChangeAttributeTxn::Undo(void) NS_IMETHODIMP ChangeAttributeTxn::UndoTransaction(void)
{ {
NS_ASSERTION(mEditor && mElement, "bad state"); NS_ASSERTION(mEditor && mElement, "bad state");
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
@ -89,7 +87,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Undo(void)
return result; return result;
} }
NS_IMETHODIMP ChangeAttributeTxn::Redo(void) NS_IMETHODIMP ChangeAttributeTxn::RedoTransaction(void)
{ {
NS_ASSERTION(mEditor && mElement, "bad state"); NS_ASSERTION(mEditor && mElement, "bad state");
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
@ -104,40 +102,21 @@ NS_IMETHODIMP ChangeAttributeTxn::Redo(void)
return result; return result;
} }
NS_IMETHODIMP ChangeAttributeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP ChangeAttributeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; 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 (PR_FALSE==mRemoveAttribute)
{ aString += NS_LITERAL_STRING("[mRemoveAttribute == false] ");
if (nsnull!=aString) else
{ aString += NS_LITERAL_STRING("[mRemoveAttribute == true] ");
if (PR_FALSE==mRemoveAttribute) aString += mAttribute;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -63,21 +63,15 @@ private:
public: 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11180 };
protected: protected:

Просмотреть файл

@ -40,8 +40,6 @@ static const PRBool gNoisy = PR_FALSE;
CreateElementTxn::CreateElementTxn() CreateElementTxn::CreateElementTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor, NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor,
@ -72,7 +70,7 @@ CreateElementTxn::~CreateElementTxn()
{ {
} }
NS_IMETHODIMP CreateElementTxn::Do(void) NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
{ {
if (gNoisy) if (gNoisy)
{ {
@ -170,7 +168,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP CreateElementTxn::Undo(void) NS_IMETHODIMP CreateElementTxn::UndoTransaction(void)
{ {
if (gNoisy) { printf("Undo Create Element, mParent = %p, node = %p\n", if (gNoisy) { printf("Undo Create Element, mParent = %p, node = %p\n",
mParent.get(), mNewNode.get()); } mParent.get(), mNewNode.get()); }
@ -182,7 +180,7 @@ NS_IMETHODIMP CreateElementTxn::Undo(void)
return result; return result;
} }
NS_IMETHODIMP CreateElementTxn::Redo(void) NS_IMETHODIMP CreateElementTxn::RedoTransaction(void)
{ {
if (gNoisy) { printf("Redo Create Element\n"); } if (gNoisy) { printf("Redo Create Element\n"); }
NS_ASSERTION(mEditor && mParent, "bad state"); NS_ASSERTION(mEditor && mParent, "bad state");
@ -203,35 +201,17 @@ NS_IMETHODIMP CreateElementTxn::Redo(void)
return result; return result;
} }
NS_IMETHODIMP CreateElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP CreateElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP CreateElementTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP CreateElementTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("CreateElementTxn: "));
} aString += mTag;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -63,24 +63,18 @@ public:
virtual ~CreateElementTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
enum { kTransactionID = 11140 };
protected: protected:
/** the document into which the new node will be inserted */ /** the document into which the new node will be inserted */

Просмотреть файл

@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE;
DeleteElementTxn::DeleteElementTxn() DeleteElementTxn::DeleteElementTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP DeleteElementTxn::Init(nsIDOMNode *aElement) 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 (gNoisy) { printf("%p Do Delete Element element = %p\n", this, mElement.get()); }
if (!mElement) return NS_ERROR_NOT_INITIALIZED; if (!mElement) return NS_ERROR_NOT_INITIALIZED;
@ -96,7 +94,7 @@ NS_IMETHODIMP DeleteElementTxn::Do(void)
return result; 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 (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 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; 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 (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 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) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP DeleteElementTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP DeleteElementTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("DeleteElementTxn"));
}
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: ");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -53,21 +53,15 @@ public:
virtual ~DeleteElementTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11160 };
protected: protected:

Просмотреть файл

@ -47,8 +47,6 @@ static const PRBool gNoisy = PR_FALSE;
DeleteRangeTxn::DeleteRangeTxn() DeleteRangeTxn::DeleteRangeTxn()
: EditAggregateTxn() : EditAggregateTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP DeleteRangeTxn::Init(nsIEditor *aEditor, nsIDOMRange *aRange) 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 (gNoisy) { printf("Do Delete Range\n"); }
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) 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 we've successfully built this aggregate transaction, then do it.
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = EditAggregateTxn::Do(); result = EditAggregateTxn::DoTransaction();
} }
if (NS_FAILED(result)) return result; if (NS_FAILED(result)) return result;
@ -167,53 +165,36 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP DeleteRangeTxn::Undo(void) NS_IMETHODIMP DeleteRangeTxn::UndoTransaction(void)
{ {
if (gNoisy) { printf("Undo Delete Range\n"); } if (gNoisy) { printf("Undo Delete Range\n"); }
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) if (!mStartParent || !mEndParent || !mCommonParent || !mEditor)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
nsresult result = EditAggregateTxn::Undo(); nsresult result = EditAggregateTxn::UndoTransaction();
return result; return result;
} }
NS_IMETHODIMP DeleteRangeTxn::Redo(void) NS_IMETHODIMP DeleteRangeTxn::RedoTransaction(void)
{ {
if (gNoisy) { printf("Redo Delete Range\n"); } if (gNoisy) { printf("Redo Delete Range\n"); }
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) if (!mStartParent || !mEndParent || !mCommonParent || !mEditor)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
nsresult result = EditAggregateTxn::Redo(); nsresult result = EditAggregateTxn::RedoTransaction();
return result; return result;
} }
NS_IMETHODIMP DeleteRangeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP DeleteRangeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP DeleteRangeTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP DeleteRangeTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("DeleteRangeTxn"));
}
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: ");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -61,21 +61,15 @@ public:
virtual ~DeleteRangeTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11170 };
protected: protected:

Просмотреть файл

@ -33,8 +33,6 @@ static const PRBool gNoisy = PR_FALSE;
DeleteTextTxn::DeleteTextTxn() DeleteTextTxn::DeleteTextTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
DeleteTextTxn::~DeleteTextTxn() DeleteTextTxn::~DeleteTextTxn()
@ -62,7 +60,7 @@ NS_IMETHODIMP DeleteTextTxn::Init(nsIEditor *aEditor,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP DeleteTextTxn::Do(void) NS_IMETHODIMP DeleteTextTxn::DoTransaction(void)
{ {
if (gNoisy) { printf("Do Delete Text\n"); } if (gNoisy) { printf("Do Delete Text\n"); }
NS_ASSERTION(mEditor && mElement, "bad state"); 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 //XXX: we may want to store the selection state and restore it properly
// was it an insertion point or an extended selection? // 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"); } if (gNoisy) { printf("Undo Delete Text\n"); }
NS_ASSERTION(mEditor && mElement, "bad state"); NS_ASSERTION(mEditor && mElement, "bad state");
@ -105,34 +103,16 @@ NS_IMETHODIMP DeleteTextTxn::Undo(void)
return result; return result;
} }
NS_IMETHODIMP DeleteTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP DeleteTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP DeleteTextTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP DeleteTextTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("DeleteTextTxn: "));
} aString += mDeletedText;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -59,19 +59,13 @@ private:
public: public:
virtual ~DeleteTextTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11130 };
protected: protected:

Просмотреть файл

@ -31,8 +31,6 @@ EditAggregateTxn::EditAggregateTxn()
// base class does this: NS_INIT_REFCNT(); // base class does this: NS_INIT_REFCNT();
nsresult res = NS_NewISupportsArray(getter_AddRefs(mChildren)); nsresult res = NS_NewISupportsArray(getter_AddRefs(mChildren));
NS_POSTCONDITION(NS_SUCCEEDED(res), "EditAggregateTxn failed in constructor"); NS_POSTCONDITION(NS_SUCCEEDED(res), "EditAggregateTxn failed in constructor");
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
EditAggregateTxn::~EditAggregateTxn() EditAggregateTxn::~EditAggregateTxn()
@ -40,7 +38,7 @@ EditAggregateTxn::~EditAggregateTxn()
// nsISupportsArray cleans up array for us at destruct time // 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 nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
if (mChildren) if (mChildren)
@ -53,7 +51,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void)
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) ); nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
if (!txn) { return NS_ERROR_NULL_POINTER; } if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->Do(); result = txn->DoTransaction();
if (NS_FAILED(result)) if (NS_FAILED(result))
break; break;
} }
@ -61,7 +59,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void)
return result; 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 nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
if (mChildren) if (mChildren)
@ -75,7 +73,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void)
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) ); nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
if (!txn) { return NS_ERROR_NULL_POINTER; } if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->Undo(); result = txn->UndoTransaction();
if (NS_FAILED(result)) if (NS_FAILED(result))
break; break;
} }
@ -83,7 +81,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void)
return result; 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 nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
if (mChildren) if (mChildren)
@ -96,7 +94,7 @@ NS_IMETHODIMP EditAggregateTxn::Redo(void)
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) ); nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
if (!txn) { return NS_ERROR_NULL_POINTER; } if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->Redo(); result = txn->RedoTransaction();
if (NS_FAILED(result)) if (NS_FAILED(result))
break; break;
} }
@ -111,7 +109,7 @@ NS_IMETHODIMP EditAggregateTxn::GetIsTransient(PRBool *aIsTransient)
return NS_OK; 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 nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
@ -127,29 +125,24 @@ NS_IMETHODIMP EditAggregateTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransa
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) ); nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
if (!txn) { return NS_ERROR_NULL_POINTER; } if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->Merge(aDidMerge, aTransaction); result = txn->Merge(aTransaction, aDidMerge);
} }
} }
return result; 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 (mName)
{ {
if (nsnull!=aString) nsAutoString name;
aString->SetLength(0); mName->ToString(name);
return NS_OK; aString += name;
} }
NS_IMETHODIMP EditAggregateTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
aString->SetLength(0);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -50,21 +50,17 @@ public:
virtual ~EditAggregateTxn(); 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 GetIsTransient(PRBool *aIsTransient);
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
NS_IMETHOD Write(nsIOutputStream *aOutputStream); NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
/** append a transaction to this aggregate */ /** append a transaction to this aggregate */
NS_IMETHOD AppendChild(EditTxn *aTxn); NS_IMETHOD AppendChild(EditTxn *aTxn);
@ -85,8 +81,6 @@ public:
/** get the name assigned to this txn */ /** get the name assigned to this txn */
NS_IMETHOD GetName(nsIAtom **aName); NS_IMETHOD GetName(nsIAtom **aName);
enum { kTransactionID = 11210 };
protected: protected:
nsCOMPtr<nsISupportsArray> mChildren; nsCOMPtr<nsISupportsArray> mChildren;

Просмотреть файл

@ -34,7 +34,6 @@ NS_IMPL_RELEASE(EditTxn)
// note that aEditor is not refcounted // note that aEditor is not refcounted
EditTxn::EditTxn() EditTxn::EditTxn()
: mTransactionID(-1)
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
} }
@ -43,19 +42,19 @@ EditTxn::~EditTxn()
{ {
} }
NS_IMETHODIMP EditTxn::Do(void) NS_IMETHODIMP EditTxn::DoTransaction(void)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP EditTxn::Undo(void) NS_IMETHODIMP EditTxn::UndoTransaction(void)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP EditTxn::Redo(void) NS_IMETHODIMP EditTxn::RedoTransaction(void)
{ {
return Do(); return DoTransaction();
} }
NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient) NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient)
@ -65,53 +64,14 @@ NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP EditTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP EditTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP EditTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP EditTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("EditTxn"));
}
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;
return NS_OK; return NS_OK;
} }
@ -133,12 +93,13 @@ EditTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_ADDREF_THIS(); NS_ADDREF_THIS();
return NS_OK; return NS_OK;
} }
if (aIID.Equals(NS_GET_IID(nsITransactionDescription))) { if (aIID.Equals(NS_GET_IID(nsPIEditorTransaction))) {
*aInstancePtr = (void*)(nsITransactionDescription*)this; *aInstancePtr = (void*)(nsPIEditorTransaction*)this;
NS_ADDREF_THIS(); NS_ADDREF_THIS();
return NS_OK; return NS_OK;
} }
*aInstancePtr = 0; *aInstancePtr = 0;
return NS_NOINTERFACE; return NS_NOINTERFACE;
} }

Просмотреть файл

@ -24,8 +24,10 @@
#define EditTxn_h__ #define EditTxn_h__
#include "nsITransaction.h" #include "nsITransaction.h"
#include "nsITransactionDescription.h" #include "nsIOutputStream.h"
#include "nsString.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsPIEditorTransaction.h"
#define EDIT_TXN_CID \ #define EDIT_TXN_CID \
{/* c5ea31b0-ac48-11d2-86d8-000064657374 */ \ {/* c5ea31b0-ac48-11d2-86d8-000064657374 */ \
@ -39,7 +41,7 @@
* it is never seen by the user or by any external entity. * it is never seen by the user or by any external entity.
*/ */
class EditTxn : public nsITransaction class EditTxn : public nsITransaction
, public nsITransactionDescription , public nsPIEditorTransaction
{ {
public: public:
@ -51,27 +53,17 @@ public:
virtual ~EditTxn(); 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 GetIsTransient(PRBool *aIsTransient);
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
NS_IMETHOD Write(nsIOutputStream *aOutputStream); NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11100 };
NS_DECL_NSITRANSACTIONDESCRIPTION
nsString mLogDescription;
int mTransactionID;
}; };
#endif #endif

Просмотреть файл

@ -1,138 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "IMECommitTxn.h"
#include "nsEditor.h"
// #define DEBUG_IME
nsIAtom *IMECommitTxn::gIMECommitTxnName = nsnull;
nsresult IMECommitTxn::ClassInit()
{
if (nsnull==gIMECommitTxnName)
gIMECommitTxnName = NS_NewAtom("NS_IMECommitTxn");
return NS_OK;
}
nsresult IMECommitTxn::ClassShutdown()
{
NS_IF_RELEASE(gIMECommitTxnName);
return NS_OK;
}
IMECommitTxn::IMECommitTxn()
: EditTxn()
{
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
}
IMECommitTxn::~IMECommitTxn()
{
}
NS_IMETHODIMP IMECommitTxn::Init(void)
{
return NS_OK;
}
NS_IMETHODIMP IMECommitTxn::Do(void)
{
#ifdef DEBUG_IME
printf("Do IME Commit");
#endif
return NS_OK;
}
NS_IMETHODIMP IMECommitTxn::Undo(void)
{
#ifdef DEBUG_IME
printf("Undo IME Commit");
#endif
return NS_OK;
}
NS_IMETHODIMP IMECommitTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
{
#ifdef DEBUG_IME
printf("Merge IME Commit");
#endif
NS_ASSERTION(aDidMerge, "null ptr- aDidMerge");
NS_ASSERTION(aTransaction, "null ptr- aTransaction");
if((nsnull == aDidMerge) || (nsnull == aTransaction))
return NS_ERROR_NULL_POINTER;
*aDidMerge=PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP IMECommitTxn::Write(nsIOutputStream *aOutputStream)
{
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;
}
}
/* ============= nsISupports implementation ====================== */
NS_IMETHODIMP
IMECommitTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(IMECommitTxn::GetCID())) {
*aInstancePtr = (void*)(IMECommitTxn*)this;
NS_ADDREF_THIS();
return NS_OK;
}
return (EditTxn::QueryInterface(aIID, aInstancePtr));
}

Просмотреть файл

@ -1,91 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef IMECommitTxn_h__
#define IMECommitTxn_h__
#include "EditTxn.h"
#include "nsIDOMCharacterData.h"
#include "nsCOMPtr.h"
// {9C4994A1-281C-11d3-9EA3-0060089FE59B}
#define IME_COMMIT_TXN_CID \
{ 0x9c4994a1, 0x281c, 0x11d3, \
{ 0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }}
/**
* A transaction representing an IME commit operation
*/
class IMECommitTxn : public EditTxn
{
public:
static const nsIID& GetCID() { static nsIID iid = IME_COMMIT_TXN_CID; return iid; }
virtual ~IMECommitTxn();
static nsIAtom *gIMECommitTxnName;
/** initialize the transaction
*/
NS_IMETHOD Init(void);
private:
IMECommitTxn();
public:
NS_IMETHOD Do(void);
NS_IMETHOD Undo(void);
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
// nsISupports declarations
// override QueryInterface to handle IMECommitTxn request
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
/** must be called before any IMECommitTxn is instantiated */
static nsresult ClassInit();
/** must be called once we are guaranteed all IMECommitTxn have completed */
static nsresult ClassShutdown();
enum { kTransactionID = 11230 };
protected:
friend class TransactionFactory;
friend class nsDerivedSafe<IMECommitTxn>; // work around for a compiler bug
};
#endif

Просмотреть файл

@ -54,8 +54,6 @@ nsresult IMETextTxn::ClassShutdown()
IMETextTxn::IMETextTxn() IMETextTxn::IMETextTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
IMETextTxn::~IMETextTxn() IMETextTxn::~IMETextTxn()
@ -84,7 +82,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP IMETextTxn::Do(void) NS_IMETHODIMP IMETextTxn::DoTransaction(void)
{ {
#ifdef DEBUG_IMETXN #ifdef DEBUG_IMETXN
@ -108,7 +106,7 @@ NS_IMETHODIMP IMETextTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP IMETextTxn::Undo(void) NS_IMETHODIMP IMETextTxn::UndoTransaction(void)
{ {
#ifdef DEBUG_IMETXN #ifdef DEBUG_IMETXN
printf("Undo IME Text element = %p\n", mElement.get()); printf("Undo IME Text element = %p\n", mElement.get());
@ -132,7 +130,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void)
return result; 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(aDidMerge, "illegal vaule- null ptr- aDidMerge");
NS_ASSERTION(aTransaction, "illegal vaule- null ptr- aTransaction"); NS_ASSERTION(aTransaction, "illegal vaule- null ptr- aTransaction");
@ -185,45 +183,16 @@ NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
return NS_OK; 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) NS_IMETHODIMP IMETextTxn::MarkFixed(void)
{ {
mFixed = PR_TRUE; mFixed = PR_TRUE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP IMETextTxn::GetUndoString(nsString *aString) NS_IMETHODIMP IMETextTxn::GetTxnDescription(nsAWritableString& aString)
{ {
NS_ASSERTION(aString, "illegal value- null ptr- aString"); aString.Assign(NS_LITERAL_STRING("IMETextTxn: "));
if(nsnull == aString) aString += mStringToInsert;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -74,17 +74,13 @@ private:
public: 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
NS_IMETHOD MarkFixed(void); NS_IMETHOD MarkFixed(void);
@ -102,8 +98,6 @@ public:
/** must be called once we are guaranteed all IMETextTxn have completed */ /** must be called once we are guaranteed all IMETextTxn have completed */
static nsresult ClassShutdown(); static nsresult ClassShutdown();
enum { kTransactionID = 11220 };
protected: protected:
NS_IMETHOD CollapseTextSelection(void); NS_IMETHOD CollapseTextSelection(void);

Просмотреть файл

@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE;
InsertElementTxn::InsertElementTxn() InsertElementTxn::InsertElementTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP InsertElementTxn::Init(nsIDOMNode *aNode, NS_IMETHODIMP InsertElementTxn::Init(nsIDOMNode *aNode,
@ -62,7 +60,7 @@ InsertElementTxn::~InsertElementTxn()
{ {
} }
NS_IMETHODIMP InsertElementTxn::Do(void) NS_IMETHODIMP InsertElementTxn::DoTransaction(void)
{ {
if (gNoisy) if (gNoisy)
{ {
@ -119,7 +117,7 @@ NS_IMETHODIMP InsertElementTxn::Do(void)
return result; 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", if (gNoisy) { printf("%p Undo Insert Element of %p into parent %p at offset %d\n",
this, mNode.get(), mParent.get(), mOffset); } this, mNode.get(), mParent.get(), mOffset); }
@ -130,32 +128,15 @@ NS_IMETHODIMP InsertElementTxn::Undo(void)
return result; return result;
} }
NS_IMETHODIMP InsertElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP InsertElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP InsertElementTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP InsertElementTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("InsertElementTxn"));
}
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: ");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -59,19 +59,13 @@ public:
virtual ~InsertElementTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11150 };
protected: protected:

Просмотреть файл

@ -52,8 +52,6 @@ nsresult InsertTextTxn::ClassShutdown()
InsertTextTxn::InsertTextTxn() InsertTextTxn::InsertTextTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
InsertTextTxn::~InsertTextTxn() InsertTextTxn::~InsertTextTxn()
@ -83,7 +81,7 @@ NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP InsertTextTxn::Do(void) NS_IMETHODIMP InsertTextTxn::DoTransaction(void)
{ {
if (gNoisy) { printf("Do Insert Text element = %p\n", mElement.get()); } if (gNoisy) { printf("Do Insert Text element = %p\n", mElement.get()); }
NS_ASSERTION(mElement && mEditor, "bad state"); NS_ASSERTION(mElement && mEditor, "bad state");
@ -112,7 +110,7 @@ NS_IMETHODIMP InsertTextTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP InsertTextTxn::Undo(void) NS_IMETHODIMP InsertTextTxn::UndoTransaction(void)
{ {
if (gNoisy) { printf("Undo Insert Text element = %p\n", mElement.get()); } if (gNoisy) { printf("Undo Insert Text element = %p\n", mElement.get()); }
NS_ASSERTION(mElement && mEditor, "bad state"); NS_ASSERTION(mElement && mEditor, "bad state");
@ -124,7 +122,7 @@ NS_IMETHODIMP InsertTextTxn::Undo(void)
return result; return result;
} }
NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP InsertTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
// set out param default value // set out param default value
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
@ -192,28 +190,10 @@ NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransacti
return result; return result;
} }
NS_IMETHODIMP InsertTextTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP InsertTextTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("InsertTextTxn: "));
} aString += mStringToInsert;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -68,17 +68,13 @@ private:
public: 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
// nsISupports declarations // nsISupports declarations
@ -94,8 +90,6 @@ public:
/** must be called once we are guaranteed all InsertTextTxn have completed */ /** must be called once we are guaranteed all InsertTextTxn have completed */
static nsresult ClassShutdown(); static nsresult ClassShutdown();
enum { kTransactionID = 11120 };
protected: protected:
/** return PR_TRUE if aOtherTxn immediately follows this txn */ /** return PR_TRUE if aOtherTxn immediately follows this txn */

Просмотреть файл

@ -34,8 +34,6 @@ static const PRBool gNoisy = PR_FALSE;
JoinElementTxn::JoinElementTxn() JoinElementTxn::JoinElementTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP JoinElementTxn::Init(nsEditor *aEditor, 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. // After DoTransaction() and RedoTransaction(), the left node is removed from the content tree and right node remains.
NS_IMETHODIMP JoinElementTxn::Do(void) NS_IMETHODIMP JoinElementTxn::DoTransaction(void)
{ {
if (gNoisy) { printf("%p Do Join of %p and %p\n", this, mLeftNode.get(), mRightNode.get()); } if (gNoisy) { printf("%p Do Join of %p and %p\n", this, mLeftNode.get(), mRightNode.get()); }
NS_PRECONDITION((mEditor && mLeftNode && mRightNode), "null arg"); 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 //XXX: what if instead of split, we just deleted the unneeded children of mRight
// and re-inserted mLeft? // 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()); } if (gNoisy) { printf("%p Undo Join, right node = %p\n", this, mRightNode.get()); }
NS_ASSERTION(mRightNode && mLeftNode && mParent, "bad state"); NS_ASSERTION(mRightNode && mLeftNode && mParent, "bad state");
@ -152,32 +150,15 @@ NS_IMETHODIMP JoinElementTxn::GetIsTransient(PRBool *aIsTransient)
return NS_OK; return NS_OK;
} }
nsresult JoinElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) nsresult JoinElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP JoinElementTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP JoinElementTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("JoinElementTxn"));
}
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");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -39,7 +39,8 @@ class nsEditor;
* A transaction that joins two elements E1 (left node) and E2 (right node) * A transaction that joins two elements E1 (left node) and E2 (right node)
* into a single node E. * into a single node E.
* The children of E are the children of E1 followed by the children of E2. * 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 class JoinElementTxn : public EditTxn
{ {
@ -62,23 +63,17 @@ public:
virtual ~JoinElementTxn(); 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 GetIsTransient(PRBool *aIsTransient);
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
NS_IMETHOD Write(nsIOutputStream *aOutputStream); NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11200 };
protected: protected:

Просмотреть файл

@ -39,7 +39,6 @@ CPPSRCS = \
DeleteTextTxn.cpp \ DeleteTextTxn.cpp \
EditAggregateTxn.cpp \ EditAggregateTxn.cpp \
EditTxn.cpp \ EditTxn.cpp \
IMECommitTxn.cpp \
IMETextTxn.cpp \ IMETextTxn.cpp \
InsertElementTxn.cpp \ InsertElementTxn.cpp \
InsertTextTxn.cpp \ InsertTextTxn.cpp \

Просмотреть файл

@ -43,8 +43,6 @@ PlaceholderTxn::PlaceholderTxn() : EditAggregateTxn(),
mEndSel(), mEndSel(),
mEditor(nsnull) 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; return NS_OK;
} }
NS_IMETHODIMP PlaceholderTxn::Do(void) NS_IMETHODIMP PlaceholderTxn::DoTransaction(void)
{ {
if (gNoisy) { printf("PlaceholderTxn Do\n"); } if (gNoisy) { printf("PlaceholderTxn Do\n"); }
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP PlaceholderTxn::Undo(void) NS_IMETHODIMP PlaceholderTxn::UndoTransaction(void)
{ {
// undo txns // undo txns
nsresult res = EditAggregateTxn::Undo(); nsresult res = EditAggregateTxn::UndoTransaction();
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
// now restore selection // now restore selection
@ -107,10 +105,10 @@ NS_IMETHODIMP PlaceholderTxn::Undo(void)
} }
NS_IMETHODIMP PlaceholderTxn::Redo(void) NS_IMETHODIMP PlaceholderTxn::RedoTransaction(void)
{ {
// redo txns // redo txns
nsresult res = EditAggregateTxn::Redo(); nsresult res = EditAggregateTxn::RedoTransaction();
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
// now restore selection // 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; if (!aDidMerge || !aTransaction) return NS_ERROR_NULL_POINTER;
@ -155,7 +153,7 @@ NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransact
else else
{ {
PRBool didMerge; PRBool didMerge;
mIMETextTxn->Merge(&didMerge, otherTxn); mIMETextTxn->Merge(otherTxn, &didMerge);
if (!didMerge) if (!didMerge)
{ {
// it wouldn't merge. Earlier IME txn is already commited and will // 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; 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) NS_IMETHODIMP PlaceholderTxn::GetTxnName(nsIAtom **aName)
{ {
return GetName(aName); return GetName(aName);

Просмотреть файл

@ -65,13 +65,15 @@ public:
// ------------ EditAggregateTxn ----------------------- // ------------ 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 ----------------------- // ------------ nsIAbsorbingTransaction -----------------------
@ -91,8 +93,6 @@ public:
friend class TransactionFactory; friend class TransactionFactory;
enum { kTransactionID = 11260 };
protected: protected:
/** the presentation shell, which we'll need to get the selection */ /** 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? 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. // 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. // 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 *mStartSel; // use a pointer because this is constructed before we exist
nsSelectionState mEndSel; nsSelectionState mEndSel;
nsIEditor* mEditor; /** the editor for this transaction */ nsIEditor* mEditor; /** the editor for this transaction */

Просмотреть файл

@ -36,8 +36,6 @@ SetDocTitleTxn::SetDocTitleTxn()
: EditTxn() : EditTxn()
, mIsTransient(PR_FALSE) , mIsTransient(PR_FALSE)
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor, 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); nsresult res = SetDomTitle(mValue);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
@ -65,12 +63,12 @@ NS_IMETHODIMP SetDocTitleTxn::Do(void)
return SetDocTitle(mValue); return SetDocTitle(mValue);
} }
NS_IMETHODIMP SetDocTitleTxn::Undo(void) NS_IMETHODIMP SetDocTitleTxn::UndoTransaction(void)
{ {
return SetDocTitle(mUndoValue); return SetDocTitle(mUndoValue);
} }
NS_IMETHODIMP SetDocTitleTxn::Redo(void) NS_IMETHODIMP SetDocTitleTxn::RedoTransaction(void)
{ {
return SetDocTitle(mValue); return SetDocTitle(mValue);
} }
@ -208,35 +206,17 @@ nsresult SetDocTitleTxn::SetDomTitle(nsString& aTitle)
return res; return res;
} }
NS_IMETHODIMP SetDocTitleTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP SetDocTitleTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP SetDocTitleTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP SetDocTitleTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("SetDocTitleTxn: "));
} aString += mValue;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -27,7 +27,6 @@
#include "nsIEditor.h" #include "nsIEditor.h"
#include "nsIHTMLEditor.h" #include "nsIHTMLEditor.h"
#include "nsITransaction.h" #include "nsITransaction.h"
#include "nsITransactionDescription.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#define SET_DOC_TITLE_TXN_CID \ #define SET_DOC_TITLE_TXN_CID \
@ -61,23 +60,17 @@ private:
nsresult SetDomTitle(nsString& aTitle); nsresult SetDomTitle(nsString& aTitle);
public: 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);
NS_IMETHOD GetIsTransient(PRBool *aIsTransient); NS_IMETHOD GetIsTransient(PRBool *aIsTransient);
enum { kTransactionID = 11270 }; NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
protected: protected:

Просмотреть файл

@ -37,8 +37,6 @@ static const PRBool gNoisy = PR_FALSE;
SplitElementTxn::SplitElementTxn() SplitElementTxn::SplitElementTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP SplitElementTxn::Init(nsEditor *aEditor, 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); } if (gNoisy) { printf("%p Do Split of node %p offset %d\n", this, mExistingRightNode.get(), mOffset); }
NS_ASSERTION(mExistingRightNode && mEditor, "bad state"); NS_ASSERTION(mExistingRightNode && mEditor, "bad state");
@ -94,7 +92,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP SplitElementTxn::Undo(void) NS_IMETHODIMP SplitElementTxn::UndoTransaction(void)
{ {
if (gNoisy) { if (gNoisy) {
printf("%p Undo Split of existing node %p and new node %p offset %d\n", 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 /* 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. * 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"); NS_ASSERTION(mEditor && mExistingRightNode && mNewLeftNode && mParent, "bad state");
if (!mEditor || !mExistingRightNode || !mNewLeftNode || !mParent) { 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) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP SplitElementTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP SplitElementTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("SplitElementTxn"));
}
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");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -61,24 +61,18 @@ protected:
public: public:
virtual ~SplitElementTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
enum { kTransactionID = 11190 };
protected: protected:
/** the element to operate upon */ /** the element to operate upon */

Просмотреть файл

@ -39,7 +39,6 @@ CPPSRCS = \
DeleteTextTxn.cpp \ DeleteTextTxn.cpp \
EditAggregateTxn.cpp \ EditAggregateTxn.cpp \
EditTxn.cpp \ EditTxn.cpp \
IMECommitTxn.cpp \
IMETextTxn.cpp \ IMETextTxn.cpp \
InsertElementTxn.cpp \ InsertElementTxn.cpp \
InsertTextTxn.cpp \ InsertTextTxn.cpp \
@ -70,7 +69,6 @@ CPP_OBJS = \
.\$(OBJDIR)\DeleteTextTxn.obj \ .\$(OBJDIR)\DeleteTextTxn.obj \
.\$(OBJDIR)\EditAggregateTxn.obj \ .\$(OBJDIR)\EditAggregateTxn.obj \
.\$(OBJDIR)\EditTxn.obj \ .\$(OBJDIR)\EditTxn.obj \
.\$(OBJDIR)\IMECommitTxn.obj \
.\$(OBJDIR)\IMETextTxn.obj \ .\$(OBJDIR)\IMETextTxn.obj \
.\$(OBJDIR)\InsertElementTxn.obj \ .\$(OBJDIR)\InsertElementTxn.obj \
.\$(OBJDIR)\InsertTextTxn.obj \ .\$(OBJDIR)\InsertTextTxn.obj \

Просмотреть файл

@ -423,10 +423,10 @@ nsEditor::Do(nsITransaction *aTxn)
selPrivate->StartBatchChanges(); selPrivate->StartBatchChanges();
if (mTxnMgr) { if (mTxnMgr) {
result = mTxnMgr->Do(aTxn); result = mTxnMgr->DoTransaction(aTxn);
} }
else { else {
result = aTxn->Do(); result = aTxn->DoTransaction();
} }
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = DoAfterDoTransaction(aTxn); result = DoAfterDoTransaction(aTxn);
@ -500,7 +500,7 @@ nsEditor::Undo(PRUint32 aCount)
PRUint32 i=0; PRUint32 i=0;
for ( ; i<aCount; i++) for ( ; i<aCount; i++)
{ {
result = mTxnMgr->Undo(); result = mTxnMgr->UndoTransaction();
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result))
result = DoAfterUndoTransaction(); result = DoAfterUndoTransaction();
@ -544,7 +544,7 @@ nsEditor::Redo(PRUint32 aCount)
PRUint32 i=0; PRUint32 i=0;
for ( ; i<aCount; i++) for ( ; i<aCount; i++)
{ {
result = mTxnMgr->Redo(); result = mTxnMgr->RedoTransaction();
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result))
result = DoAfterRedoTransaction(); result = DoAfterRedoTransaction();
@ -1015,7 +1015,7 @@ NS_IMETHODIMP nsEditor::CreateNode(const nsString& aTag,
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result))
{ {
result = txn->GetNewNode(aNewNode); 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 // 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! // Note that this means IME won't work without an undo stack!
if (mTxnMgr) if (mTxnMgr)
{ {
nsITransaction *txn; nsCOMPtr<nsITransaction> txn;
result = mTxnMgr->PeekUndoStack(&txn); result = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));
// PeekUndoStack does not addref
nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryInterface(txn); nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryInterface(txn);
if (plcTxn) if (plcTxn)
{ {

Просмотреть файл

@ -2299,6 +2299,17 @@ nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval)
return rv; return rv;
} }
NS_IMETHODIMP
nsEditorShell::GetTransactionManager(nsITransactionManager **aTxnMgr)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (!editor)
return NS_ERROR_FAILURE;
return editor->GetTransactionManager(aTxnMgr);
}
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::Undo() nsEditorShell::Undo()
{ {

Просмотреть файл

@ -24,6 +24,7 @@
#include <stdio.h> #include <stdio.h>
#include "nsHTMLEditorLog.h" #include "nsHTMLEditorLog.h"
#include "nsEditorTxnLog.h" #include "nsEditorTxnLog.h"
#include "nsPIEditorTransaction.h"
#define LOCK_LOG(doc) #define LOCK_LOG(doc)
#define UNLOCK_LOG(doc) #define UNLOCK_LOG(doc)
@ -361,7 +362,12 @@ nsEditorTxnLog::GetString(nsITransaction *aTransaction, char *aBuffer, PRInt32 a
nsString str; nsString str;
aTransaction->GetRedoString(&str); nsCOMPtr<nsPIEditorTransaction> txn = do_QueryInterface(aTransaction);
if (!txn)
return aBuffer;
txn->GetTxnDescription(str);
if (str.Length() == 0) if (str.Length() == 0)
str.AssignWithConversion("<NULL>"); str.AssignWithConversion("<NULL>");

Просмотреть файл

@ -38,8 +38,6 @@ AddStyleSheetTxn::AddStyleSheetTxn()
: EditTxn() : EditTxn()
, mEditor(NULL) , mEditor(NULL)
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
AddStyleSheetTxn::~AddStyleSheetTxn() AddStyleSheetTxn::~AddStyleSheetTxn()
@ -63,7 +61,7 @@ AddStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet)
NS_IMETHODIMP NS_IMETHODIMP
AddStyleSheetTxn::Do() AddStyleSheetTxn::DoTransaction()
{ {
if (!mEditor || !mSheet) if (!mEditor || !mSheet)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
@ -100,7 +98,7 @@ AddStyleSheetTxn::Do()
} }
NS_IMETHODIMP NS_IMETHODIMP
AddStyleSheetTxn::Undo() AddStyleSheetTxn::UndoTransaction()
{ {
if (!mEditor || !mSheet) if (!mEditor || !mSheet)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
@ -136,13 +134,13 @@ AddStyleSheetTxn::Undo()
} }
NS_IMETHODIMP NS_IMETHODIMP
AddStyleSheetTxn::Redo() AddStyleSheetTxn::RedoTransaction()
{ {
return Do(); return DoTransaction();
} }
NS_IMETHODIMP NS_IMETHODIMP
AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) AddStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
// set out param default value // set out param default value
if (!aDidMerge) if (!aDidMerge)
@ -153,28 +151,9 @@ AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
} }
NS_IMETHODIMP NS_IMETHODIMP
AddStyleSheetTxn::Write(nsIOutputStream *aOutputStream) AddStyleSheetTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("AddStyleSheetTxn"));
}
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");
}
return NS_OK; return NS_OK;
} }
@ -187,7 +166,6 @@ RemoveStyleSheetTxn::RemoveStyleSheetTxn()
: EditTxn() : EditTxn()
, mEditor(NULL) , mEditor(NULL)
{ {
SetTransactionDescriptionID( kTransactionID );
} }
RemoveStyleSheetTxn::~RemoveStyleSheetTxn() RemoveStyleSheetTxn::~RemoveStyleSheetTxn()
@ -211,7 +189,7 @@ RemoveStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet)
NS_IMETHODIMP NS_IMETHODIMP
RemoveStyleSheetTxn::Do() RemoveStyleSheetTxn::DoTransaction()
{ {
if (!mEditor || !mSheet) if (!mEditor || !mSheet)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
@ -247,7 +225,7 @@ RemoveStyleSheetTxn::Do()
} }
NS_IMETHODIMP NS_IMETHODIMP
RemoveStyleSheetTxn::Undo() RemoveStyleSheetTxn::UndoTransaction()
{ {
if (!mEditor || !mSheet) if (!mEditor || !mSheet)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
@ -283,13 +261,13 @@ RemoveStyleSheetTxn::Undo()
} }
NS_IMETHODIMP NS_IMETHODIMP
RemoveStyleSheetTxn::Redo() RemoveStyleSheetTxn::RedoTransaction()
{ {
return Do(); return DoTransaction();
} }
NS_IMETHODIMP NS_IMETHODIMP
RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) RemoveStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
// set out param default value // set out param default value
if (!aDidMerge) if (!aDidMerge)
@ -300,27 +278,8 @@ RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
} }
NS_IMETHODIMP NS_IMETHODIMP
RemoveStyleSheetTxn::Write(nsIOutputStream *aOutputStream) RemoveStyleSheetTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("RemoveStyleSheetTxn"));
}
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");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -59,21 +59,15 @@ private:
public: 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11240 };
protected: protected:
@ -105,21 +99,15 @@ private:
public: 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11250 };
protected: protected:

Просмотреть файл

@ -2299,6 +2299,17 @@ nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval)
return rv; return rv;
} }
NS_IMETHODIMP
nsEditorShell::GetTransactionManager(nsITransactionManager **aTxnMgr)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (!editor)
return NS_ERROR_FAILURE;
return editor->GetTransactionManager(aTxnMgr);
}
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::Undo() nsEditorShell::Undo()
{ {

Просмотреть файл

@ -26,3 +26,4 @@ nsIEditorSpellCheck.idl
nsIDocumentStateListener.idl nsIDocumentStateListener.idl
nsIEditorService.idl nsIEditorService.idl
nsIEditorController.idl nsIEditorController.idl
nsPIEditorTransaction.idl

Просмотреть файл

@ -35,6 +35,7 @@ XPIDLSRCS = \
nsIDocumentStateListener.idl \ nsIDocumentStateListener.idl \
nsIEditorService.idl \ nsIEditorService.idl \
nsIEditorController.idl \ nsIEditorController.idl \
nsPIEditorTransaction.idl \
$(NULL) $(NULL)
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -23,16 +23,16 @@
DEPTH=..\.. DEPTH=..\..
MODULE=editor MODULE=editor
XPIDL_MODULE=editor XPIDL_MODULE=editor
XPIDLSRCS = .\nsIEditorShell.idl \ XPIDLSRCS = .\nsIEditorShell.idl \
.\nsIPlaintextEditor.idl \ .\nsIPlaintextEditor.idl \
.\nsIEditorSpellCheck.idl \ .\nsIEditorSpellCheck.idl \
.\nsIDocumentStateListener.idl \ .\nsIDocumentStateListener.idl \
.\nsIEditorService.idl \ .\nsIEditorService.idl \
.\nsIEditorController.idl \ .\nsIEditorController.idl \
$(NULL) .\nsPIEditorTransaction.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak> include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -26,6 +26,7 @@
#include "nsISupportsArray.idl" #include "nsISupportsArray.idl"
#include "nsIDocumentStateListener.idl" #include "nsIDocumentStateListener.idl"
#include "nsISelectionController.idl" #include "nsISelectionController.idl"
#include "nsITransactionManager.idl"
%{C++ %{C++
@ -42,15 +43,16 @@ interface nsIEditor;
[scriptable, uuid(9afff72b-ca9a-11d2-96c9-0060b0fb9956)] [scriptable, uuid(9afff72b-ca9a-11d2-96c9-0060b0fb9956)]
interface nsIEditorShell : nsISupports interface nsIEditorShell : nsISupports
{ {
readonly attribute nsIDOMDocument editorDocument; readonly attribute nsIDOMDocument editorDocument;
readonly attribute nsISelection editorSelection; readonly attribute nsISelection editorSelection;
readonly attribute nsISelectionController selectionController; readonly attribute nsISelectionController selectionController;
readonly attribute nsITransactionManager transactionManager;
attribute nsIDOMWindowInternal webShellWindow; attribute nsIDOMWindowInternal webShellWindow;
attribute nsIDOMWindowInternal contentWindow; attribute nsIDOMWindowInternal contentWindow;
attribute wstring editorType; attribute wstring editorType;
[noscript] readonly attribute nsIEditor editor; [noscript] readonly attribute nsIEditor editor;
%{C++ %{C++

Просмотреть файл

@ -27,8 +27,6 @@
ChangeAttributeTxn::ChangeAttributeTxn() ChangeAttributeTxn::ChangeAttributeTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
ChangeAttributeTxn::~ChangeAttributeTxn() ChangeAttributeTxn::~ChangeAttributeTxn()
@ -54,7 +52,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP ChangeAttributeTxn::Do(void) NS_IMETHODIMP ChangeAttributeTxn::DoTransaction(void)
{ {
NS_ASSERTION(mEditor && mElement, "bad state"); NS_ASSERTION(mEditor && mElement, "bad state");
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
@ -75,7 +73,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP ChangeAttributeTxn::Undo(void) NS_IMETHODIMP ChangeAttributeTxn::UndoTransaction(void)
{ {
NS_ASSERTION(mEditor && mElement, "bad state"); NS_ASSERTION(mEditor && mElement, "bad state");
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
@ -89,7 +87,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Undo(void)
return result; return result;
} }
NS_IMETHODIMP ChangeAttributeTxn::Redo(void) NS_IMETHODIMP ChangeAttributeTxn::RedoTransaction(void)
{ {
NS_ASSERTION(mEditor && mElement, "bad state"); NS_ASSERTION(mEditor && mElement, "bad state");
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
@ -104,40 +102,21 @@ NS_IMETHODIMP ChangeAttributeTxn::Redo(void)
return result; return result;
} }
NS_IMETHODIMP ChangeAttributeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP ChangeAttributeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; 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 (PR_FALSE==mRemoveAttribute)
{ aString += NS_LITERAL_STRING("[mRemoveAttribute == false] ");
if (nsnull!=aString) else
{ aString += NS_LITERAL_STRING("[mRemoveAttribute == true] ");
if (PR_FALSE==mRemoveAttribute) aString += mAttribute;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -63,21 +63,15 @@ private:
public: 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11180 };
protected: protected:

Просмотреть файл

@ -40,8 +40,6 @@ static const PRBool gNoisy = PR_FALSE;
CreateElementTxn::CreateElementTxn() CreateElementTxn::CreateElementTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor, NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor,
@ -72,7 +70,7 @@ CreateElementTxn::~CreateElementTxn()
{ {
} }
NS_IMETHODIMP CreateElementTxn::Do(void) NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
{ {
if (gNoisy) if (gNoisy)
{ {
@ -170,7 +168,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP CreateElementTxn::Undo(void) NS_IMETHODIMP CreateElementTxn::UndoTransaction(void)
{ {
if (gNoisy) { printf("Undo Create Element, mParent = %p, node = %p\n", if (gNoisy) { printf("Undo Create Element, mParent = %p, node = %p\n",
mParent.get(), mNewNode.get()); } mParent.get(), mNewNode.get()); }
@ -182,7 +180,7 @@ NS_IMETHODIMP CreateElementTxn::Undo(void)
return result; return result;
} }
NS_IMETHODIMP CreateElementTxn::Redo(void) NS_IMETHODIMP CreateElementTxn::RedoTransaction(void)
{ {
if (gNoisy) { printf("Redo Create Element\n"); } if (gNoisy) { printf("Redo Create Element\n"); }
NS_ASSERTION(mEditor && mParent, "bad state"); NS_ASSERTION(mEditor && mParent, "bad state");
@ -203,35 +201,17 @@ NS_IMETHODIMP CreateElementTxn::Redo(void)
return result; return result;
} }
NS_IMETHODIMP CreateElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP CreateElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP CreateElementTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP CreateElementTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("CreateElementTxn: "));
} aString += mTag;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -63,24 +63,18 @@ public:
virtual ~CreateElementTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
enum { kTransactionID = 11140 };
protected: protected:
/** the document into which the new node will be inserted */ /** the document into which the new node will be inserted */

Просмотреть файл

@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE;
DeleteElementTxn::DeleteElementTxn() DeleteElementTxn::DeleteElementTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP DeleteElementTxn::Init(nsIDOMNode *aElement) 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 (gNoisy) { printf("%p Do Delete Element element = %p\n", this, mElement.get()); }
if (!mElement) return NS_ERROR_NOT_INITIALIZED; if (!mElement) return NS_ERROR_NOT_INITIALIZED;
@ -96,7 +94,7 @@ NS_IMETHODIMP DeleteElementTxn::Do(void)
return result; 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 (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 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; 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 (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 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) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP DeleteElementTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP DeleteElementTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("DeleteElementTxn"));
}
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: ");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -53,21 +53,15 @@ public:
virtual ~DeleteElementTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11160 };
protected: protected:

Просмотреть файл

@ -47,8 +47,6 @@ static const PRBool gNoisy = PR_FALSE;
DeleteRangeTxn::DeleteRangeTxn() DeleteRangeTxn::DeleteRangeTxn()
: EditAggregateTxn() : EditAggregateTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP DeleteRangeTxn::Init(nsIEditor *aEditor, nsIDOMRange *aRange) 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 (gNoisy) { printf("Do Delete Range\n"); }
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) 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 we've successfully built this aggregate transaction, then do it.
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = EditAggregateTxn::Do(); result = EditAggregateTxn::DoTransaction();
} }
if (NS_FAILED(result)) return result; if (NS_FAILED(result)) return result;
@ -167,53 +165,36 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP DeleteRangeTxn::Undo(void) NS_IMETHODIMP DeleteRangeTxn::UndoTransaction(void)
{ {
if (gNoisy) { printf("Undo Delete Range\n"); } if (gNoisy) { printf("Undo Delete Range\n"); }
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) if (!mStartParent || !mEndParent || !mCommonParent || !mEditor)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
nsresult result = EditAggregateTxn::Undo(); nsresult result = EditAggregateTxn::UndoTransaction();
return result; return result;
} }
NS_IMETHODIMP DeleteRangeTxn::Redo(void) NS_IMETHODIMP DeleteRangeTxn::RedoTransaction(void)
{ {
if (gNoisy) { printf("Redo Delete Range\n"); } if (gNoisy) { printf("Redo Delete Range\n"); }
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor) if (!mStartParent || !mEndParent || !mCommonParent || !mEditor)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
nsresult result = EditAggregateTxn::Redo(); nsresult result = EditAggregateTxn::RedoTransaction();
return result; return result;
} }
NS_IMETHODIMP DeleteRangeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP DeleteRangeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP DeleteRangeTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP DeleteRangeTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("DeleteRangeTxn"));
}
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: ");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -61,21 +61,15 @@ public:
virtual ~DeleteRangeTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11170 };
protected: protected:

Просмотреть файл

@ -33,8 +33,6 @@ static const PRBool gNoisy = PR_FALSE;
DeleteTextTxn::DeleteTextTxn() DeleteTextTxn::DeleteTextTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
DeleteTextTxn::~DeleteTextTxn() DeleteTextTxn::~DeleteTextTxn()
@ -62,7 +60,7 @@ NS_IMETHODIMP DeleteTextTxn::Init(nsIEditor *aEditor,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP DeleteTextTxn::Do(void) NS_IMETHODIMP DeleteTextTxn::DoTransaction(void)
{ {
if (gNoisy) { printf("Do Delete Text\n"); } if (gNoisy) { printf("Do Delete Text\n"); }
NS_ASSERTION(mEditor && mElement, "bad state"); 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 //XXX: we may want to store the selection state and restore it properly
// was it an insertion point or an extended selection? // 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"); } if (gNoisy) { printf("Undo Delete Text\n"); }
NS_ASSERTION(mEditor && mElement, "bad state"); NS_ASSERTION(mEditor && mElement, "bad state");
@ -105,34 +103,16 @@ NS_IMETHODIMP DeleteTextTxn::Undo(void)
return result; return result;
} }
NS_IMETHODIMP DeleteTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP DeleteTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP DeleteTextTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP DeleteTextTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("DeleteTextTxn: "));
} aString += mDeletedText;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -59,19 +59,13 @@ private:
public: public:
virtual ~DeleteTextTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11130 };
protected: protected:

Просмотреть файл

@ -31,8 +31,6 @@ EditAggregateTxn::EditAggregateTxn()
// base class does this: NS_INIT_REFCNT(); // base class does this: NS_INIT_REFCNT();
nsresult res = NS_NewISupportsArray(getter_AddRefs(mChildren)); nsresult res = NS_NewISupportsArray(getter_AddRefs(mChildren));
NS_POSTCONDITION(NS_SUCCEEDED(res), "EditAggregateTxn failed in constructor"); NS_POSTCONDITION(NS_SUCCEEDED(res), "EditAggregateTxn failed in constructor");
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
EditAggregateTxn::~EditAggregateTxn() EditAggregateTxn::~EditAggregateTxn()
@ -40,7 +38,7 @@ EditAggregateTxn::~EditAggregateTxn()
// nsISupportsArray cleans up array for us at destruct time // 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 nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
if (mChildren) if (mChildren)
@ -53,7 +51,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void)
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) ); nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
if (!txn) { return NS_ERROR_NULL_POINTER; } if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->Do(); result = txn->DoTransaction();
if (NS_FAILED(result)) if (NS_FAILED(result))
break; break;
} }
@ -61,7 +59,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void)
return result; 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 nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
if (mChildren) if (mChildren)
@ -75,7 +73,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void)
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) ); nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
if (!txn) { return NS_ERROR_NULL_POINTER; } if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->Undo(); result = txn->UndoTransaction();
if (NS_FAILED(result)) if (NS_FAILED(result))
break; break;
} }
@ -83,7 +81,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void)
return result; 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 nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
if (mChildren) if (mChildren)
@ -96,7 +94,7 @@ NS_IMETHODIMP EditAggregateTxn::Redo(void)
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) ); nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
if (!txn) { return NS_ERROR_NULL_POINTER; } if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->Redo(); result = txn->RedoTransaction();
if (NS_FAILED(result)) if (NS_FAILED(result))
break; break;
} }
@ -111,7 +109,7 @@ NS_IMETHODIMP EditAggregateTxn::GetIsTransient(PRBool *aIsTransient)
return NS_OK; 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 nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
@ -127,29 +125,24 @@ NS_IMETHODIMP EditAggregateTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransa
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i)); nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) ); nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
if (!txn) { return NS_ERROR_NULL_POINTER; } if (!txn) { return NS_ERROR_NULL_POINTER; }
result = txn->Merge(aDidMerge, aTransaction); result = txn->Merge(aTransaction, aDidMerge);
} }
} }
return result; 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 (mName)
{ {
if (nsnull!=aString) nsAutoString name;
aString->SetLength(0); mName->ToString(name);
return NS_OK; aString += name;
} }
NS_IMETHODIMP EditAggregateTxn::GetRedoString(nsString *aString)
{
if (nsnull!=aString)
aString->SetLength(0);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -50,21 +50,17 @@ public:
virtual ~EditAggregateTxn(); 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 GetIsTransient(PRBool *aIsTransient);
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
NS_IMETHOD Write(nsIOutputStream *aOutputStream); NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
/** append a transaction to this aggregate */ /** append a transaction to this aggregate */
NS_IMETHOD AppendChild(EditTxn *aTxn); NS_IMETHOD AppendChild(EditTxn *aTxn);
@ -85,8 +81,6 @@ public:
/** get the name assigned to this txn */ /** get the name assigned to this txn */
NS_IMETHOD GetName(nsIAtom **aName); NS_IMETHOD GetName(nsIAtom **aName);
enum { kTransactionID = 11210 };
protected: protected:
nsCOMPtr<nsISupportsArray> mChildren; nsCOMPtr<nsISupportsArray> mChildren;

Просмотреть файл

@ -34,7 +34,6 @@ NS_IMPL_RELEASE(EditTxn)
// note that aEditor is not refcounted // note that aEditor is not refcounted
EditTxn::EditTxn() EditTxn::EditTxn()
: mTransactionID(-1)
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
} }
@ -43,19 +42,19 @@ EditTxn::~EditTxn()
{ {
} }
NS_IMETHODIMP EditTxn::Do(void) NS_IMETHODIMP EditTxn::DoTransaction(void)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP EditTxn::Undo(void) NS_IMETHODIMP EditTxn::UndoTransaction(void)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP EditTxn::Redo(void) NS_IMETHODIMP EditTxn::RedoTransaction(void)
{ {
return Do(); return DoTransaction();
} }
NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient) NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient)
@ -65,53 +64,14 @@ NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP EditTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP EditTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP EditTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP EditTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("EditTxn"));
}
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;
return NS_OK; return NS_OK;
} }
@ -133,12 +93,13 @@ EditTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_ADDREF_THIS(); NS_ADDREF_THIS();
return NS_OK; return NS_OK;
} }
if (aIID.Equals(NS_GET_IID(nsITransactionDescription))) { if (aIID.Equals(NS_GET_IID(nsPIEditorTransaction))) {
*aInstancePtr = (void*)(nsITransactionDescription*)this; *aInstancePtr = (void*)(nsPIEditorTransaction*)this;
NS_ADDREF_THIS(); NS_ADDREF_THIS();
return NS_OK; return NS_OK;
} }
*aInstancePtr = 0; *aInstancePtr = 0;
return NS_NOINTERFACE; return NS_NOINTERFACE;
} }

Просмотреть файл

@ -24,8 +24,10 @@
#define EditTxn_h__ #define EditTxn_h__
#include "nsITransaction.h" #include "nsITransaction.h"
#include "nsITransactionDescription.h" #include "nsIOutputStream.h"
#include "nsString.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsPIEditorTransaction.h"
#define EDIT_TXN_CID \ #define EDIT_TXN_CID \
{/* c5ea31b0-ac48-11d2-86d8-000064657374 */ \ {/* c5ea31b0-ac48-11d2-86d8-000064657374 */ \
@ -39,7 +41,7 @@
* it is never seen by the user or by any external entity. * it is never seen by the user or by any external entity.
*/ */
class EditTxn : public nsITransaction class EditTxn : public nsITransaction
, public nsITransactionDescription , public nsPIEditorTransaction
{ {
public: public:
@ -51,27 +53,17 @@ public:
virtual ~EditTxn(); 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 GetIsTransient(PRBool *aIsTransient);
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
NS_IMETHOD Write(nsIOutputStream *aOutputStream); NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11100 };
NS_DECL_NSITRANSACTIONDESCRIPTION
nsString mLogDescription;
int mTransactionID;
}; };
#endif #endif

Просмотреть файл

@ -54,8 +54,6 @@ nsresult IMETextTxn::ClassShutdown()
IMETextTxn::IMETextTxn() IMETextTxn::IMETextTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
IMETextTxn::~IMETextTxn() IMETextTxn::~IMETextTxn()
@ -84,7 +82,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP IMETextTxn::Do(void) NS_IMETHODIMP IMETextTxn::DoTransaction(void)
{ {
#ifdef DEBUG_IMETXN #ifdef DEBUG_IMETXN
@ -108,7 +106,7 @@ NS_IMETHODIMP IMETextTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP IMETextTxn::Undo(void) NS_IMETHODIMP IMETextTxn::UndoTransaction(void)
{ {
#ifdef DEBUG_IMETXN #ifdef DEBUG_IMETXN
printf("Undo IME Text element = %p\n", mElement.get()); printf("Undo IME Text element = %p\n", mElement.get());
@ -132,7 +130,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void)
return result; 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(aDidMerge, "illegal vaule- null ptr- aDidMerge");
NS_ASSERTION(aTransaction, "illegal vaule- null ptr- aTransaction"); NS_ASSERTION(aTransaction, "illegal vaule- null ptr- aTransaction");
@ -185,45 +183,16 @@ NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
return NS_OK; 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) NS_IMETHODIMP IMETextTxn::MarkFixed(void)
{ {
mFixed = PR_TRUE; mFixed = PR_TRUE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP IMETextTxn::GetUndoString(nsString *aString) NS_IMETHODIMP IMETextTxn::GetTxnDescription(nsAWritableString& aString)
{ {
NS_ASSERTION(aString, "illegal value- null ptr- aString"); aString.Assign(NS_LITERAL_STRING("IMETextTxn: "));
if(nsnull == aString) aString += mStringToInsert;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -74,17 +74,13 @@ private:
public: 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
NS_IMETHOD MarkFixed(void); NS_IMETHOD MarkFixed(void);
@ -102,8 +98,6 @@ public:
/** must be called once we are guaranteed all IMETextTxn have completed */ /** must be called once we are guaranteed all IMETextTxn have completed */
static nsresult ClassShutdown(); static nsresult ClassShutdown();
enum { kTransactionID = 11220 };
protected: protected:
NS_IMETHOD CollapseTextSelection(void); NS_IMETHOD CollapseTextSelection(void);

Просмотреть файл

@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE;
InsertElementTxn::InsertElementTxn() InsertElementTxn::InsertElementTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP InsertElementTxn::Init(nsIDOMNode *aNode, NS_IMETHODIMP InsertElementTxn::Init(nsIDOMNode *aNode,
@ -62,7 +60,7 @@ InsertElementTxn::~InsertElementTxn()
{ {
} }
NS_IMETHODIMP InsertElementTxn::Do(void) NS_IMETHODIMP InsertElementTxn::DoTransaction(void)
{ {
if (gNoisy) if (gNoisy)
{ {
@ -119,7 +117,7 @@ NS_IMETHODIMP InsertElementTxn::Do(void)
return result; 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", if (gNoisy) { printf("%p Undo Insert Element of %p into parent %p at offset %d\n",
this, mNode.get(), mParent.get(), mOffset); } this, mNode.get(), mParent.get(), mOffset); }
@ -130,32 +128,15 @@ NS_IMETHODIMP InsertElementTxn::Undo(void)
return result; return result;
} }
NS_IMETHODIMP InsertElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP InsertElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP InsertElementTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP InsertElementTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("InsertElementTxn"));
}
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: ");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -59,19 +59,13 @@ public:
virtual ~InsertElementTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11150 };
protected: protected:

Просмотреть файл

@ -52,8 +52,6 @@ nsresult InsertTextTxn::ClassShutdown()
InsertTextTxn::InsertTextTxn() InsertTextTxn::InsertTextTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
InsertTextTxn::~InsertTextTxn() InsertTextTxn::~InsertTextTxn()
@ -83,7 +81,7 @@ NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP InsertTextTxn::Do(void) NS_IMETHODIMP InsertTextTxn::DoTransaction(void)
{ {
if (gNoisy) { printf("Do Insert Text element = %p\n", mElement.get()); } if (gNoisy) { printf("Do Insert Text element = %p\n", mElement.get()); }
NS_ASSERTION(mElement && mEditor, "bad state"); NS_ASSERTION(mElement && mEditor, "bad state");
@ -112,7 +110,7 @@ NS_IMETHODIMP InsertTextTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP InsertTextTxn::Undo(void) NS_IMETHODIMP InsertTextTxn::UndoTransaction(void)
{ {
if (gNoisy) { printf("Undo Insert Text element = %p\n", mElement.get()); } if (gNoisy) { printf("Undo Insert Text element = %p\n", mElement.get()); }
NS_ASSERTION(mElement && mEditor, "bad state"); NS_ASSERTION(mElement && mEditor, "bad state");
@ -124,7 +122,7 @@ NS_IMETHODIMP InsertTextTxn::Undo(void)
return result; return result;
} }
NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP InsertTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
// set out param default value // set out param default value
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
@ -192,28 +190,10 @@ NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransacti
return result; return result;
} }
NS_IMETHODIMP InsertTextTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP InsertTextTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("InsertTextTxn: "));
} aString += mStringToInsert;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -68,17 +68,13 @@ private:
public: 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
// nsISupports declarations // nsISupports declarations
@ -94,8 +90,6 @@ public:
/** must be called once we are guaranteed all InsertTextTxn have completed */ /** must be called once we are guaranteed all InsertTextTxn have completed */
static nsresult ClassShutdown(); static nsresult ClassShutdown();
enum { kTransactionID = 11120 };
protected: protected:
/** return PR_TRUE if aOtherTxn immediately follows this txn */ /** return PR_TRUE if aOtherTxn immediately follows this txn */

Просмотреть файл

@ -34,8 +34,6 @@ static const PRBool gNoisy = PR_FALSE;
JoinElementTxn::JoinElementTxn() JoinElementTxn::JoinElementTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP JoinElementTxn::Init(nsEditor *aEditor, 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. // After DoTransaction() and RedoTransaction(), the left node is removed from the content tree and right node remains.
NS_IMETHODIMP JoinElementTxn::Do(void) NS_IMETHODIMP JoinElementTxn::DoTransaction(void)
{ {
if (gNoisy) { printf("%p Do Join of %p and %p\n", this, mLeftNode.get(), mRightNode.get()); } if (gNoisy) { printf("%p Do Join of %p and %p\n", this, mLeftNode.get(), mRightNode.get()); }
NS_PRECONDITION((mEditor && mLeftNode && mRightNode), "null arg"); 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 //XXX: what if instead of split, we just deleted the unneeded children of mRight
// and re-inserted mLeft? // 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()); } if (gNoisy) { printf("%p Undo Join, right node = %p\n", this, mRightNode.get()); }
NS_ASSERTION(mRightNode && mLeftNode && mParent, "bad state"); NS_ASSERTION(mRightNode && mLeftNode && mParent, "bad state");
@ -152,32 +150,15 @@ NS_IMETHODIMP JoinElementTxn::GetIsTransient(PRBool *aIsTransient)
return NS_OK; return NS_OK;
} }
nsresult JoinElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) nsresult JoinElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP JoinElementTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP JoinElementTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("JoinElementTxn"));
}
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");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -39,7 +39,8 @@ class nsEditor;
* A transaction that joins two elements E1 (left node) and E2 (right node) * A transaction that joins two elements E1 (left node) and E2 (right node)
* into a single node E. * into a single node E.
* The children of E are the children of E1 followed by the children of E2. * 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 class JoinElementTxn : public EditTxn
{ {
@ -62,23 +63,17 @@ public:
virtual ~JoinElementTxn(); 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 GetIsTransient(PRBool *aIsTransient);
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction); NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
NS_IMETHOD Write(nsIOutputStream *aOutputStream); NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11200 };
protected: protected:

Просмотреть файл

@ -43,8 +43,6 @@ PlaceholderTxn::PlaceholderTxn() : EditAggregateTxn(),
mEndSel(), mEndSel(),
mEditor(nsnull) 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; return NS_OK;
} }
NS_IMETHODIMP PlaceholderTxn::Do(void) NS_IMETHODIMP PlaceholderTxn::DoTransaction(void)
{ {
if (gNoisy) { printf("PlaceholderTxn Do\n"); } if (gNoisy) { printf("PlaceholderTxn Do\n"); }
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP PlaceholderTxn::Undo(void) NS_IMETHODIMP PlaceholderTxn::UndoTransaction(void)
{ {
// undo txns // undo txns
nsresult res = EditAggregateTxn::Undo(); nsresult res = EditAggregateTxn::UndoTransaction();
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
// now restore selection // now restore selection
@ -107,10 +105,10 @@ NS_IMETHODIMP PlaceholderTxn::Undo(void)
} }
NS_IMETHODIMP PlaceholderTxn::Redo(void) NS_IMETHODIMP PlaceholderTxn::RedoTransaction(void)
{ {
// redo txns // redo txns
nsresult res = EditAggregateTxn::Redo(); nsresult res = EditAggregateTxn::RedoTransaction();
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
// now restore selection // 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; if (!aDidMerge || !aTransaction) return NS_ERROR_NULL_POINTER;
@ -155,7 +153,7 @@ NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransact
else else
{ {
PRBool didMerge; PRBool didMerge;
mIMETextTxn->Merge(&didMerge, otherTxn); mIMETextTxn->Merge(otherTxn, &didMerge);
if (!didMerge) if (!didMerge)
{ {
// it wouldn't merge. Earlier IME txn is already commited and will // 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; 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) NS_IMETHODIMP PlaceholderTxn::GetTxnName(nsIAtom **aName)
{ {
return GetName(aName); return GetName(aName);

Просмотреть файл

@ -65,13 +65,15 @@ public:
// ------------ EditAggregateTxn ----------------------- // ------------ 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 ----------------------- // ------------ nsIAbsorbingTransaction -----------------------
@ -91,8 +93,6 @@ public:
friend class TransactionFactory; friend class TransactionFactory;
enum { kTransactionID = 11260 };
protected: protected:
/** the presentation shell, which we'll need to get the selection */ /** 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? 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. // 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. // 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 *mStartSel; // use a pointer because this is constructed before we exist
nsSelectionState mEndSel; nsSelectionState mEndSel;
nsIEditor* mEditor; /** the editor for this transaction */ nsIEditor* mEditor; /** the editor for this transaction */

Просмотреть файл

@ -36,8 +36,6 @@ SetDocTitleTxn::SetDocTitleTxn()
: EditTxn() : EditTxn()
, mIsTransient(PR_FALSE) , mIsTransient(PR_FALSE)
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor, 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); nsresult res = SetDomTitle(mValue);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
@ -65,12 +63,12 @@ NS_IMETHODIMP SetDocTitleTxn::Do(void)
return SetDocTitle(mValue); return SetDocTitle(mValue);
} }
NS_IMETHODIMP SetDocTitleTxn::Undo(void) NS_IMETHODIMP SetDocTitleTxn::UndoTransaction(void)
{ {
return SetDocTitle(mUndoValue); return SetDocTitle(mUndoValue);
} }
NS_IMETHODIMP SetDocTitleTxn::Redo(void) NS_IMETHODIMP SetDocTitleTxn::RedoTransaction(void)
{ {
return SetDocTitle(mValue); return SetDocTitle(mValue);
} }
@ -208,35 +206,17 @@ nsresult SetDocTitleTxn::SetDomTitle(nsString& aTitle)
return res; return res;
} }
NS_IMETHODIMP SetDocTitleTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP SetDocTitleTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
if (nsnull!=aDidMerge) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP SetDocTitleTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP SetDocTitleTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("SetDocTitleTxn: "));
} aString += mValue;
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;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -27,7 +27,6 @@
#include "nsIEditor.h" #include "nsIEditor.h"
#include "nsIHTMLEditor.h" #include "nsIHTMLEditor.h"
#include "nsITransaction.h" #include "nsITransaction.h"
#include "nsITransactionDescription.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#define SET_DOC_TITLE_TXN_CID \ #define SET_DOC_TITLE_TXN_CID \
@ -61,23 +60,17 @@ private:
nsresult SetDomTitle(nsString& aTitle); nsresult SetDomTitle(nsString& aTitle);
public: 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);
NS_IMETHOD GetIsTransient(PRBool *aIsTransient); NS_IMETHOD GetIsTransient(PRBool *aIsTransient);
enum { kTransactionID = 11270 }; NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
protected: protected:

Просмотреть файл

@ -37,8 +37,6 @@ static const PRBool gNoisy = PR_FALSE;
SplitElementTxn::SplitElementTxn() SplitElementTxn::SplitElementTxn()
: EditTxn() : EditTxn()
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
NS_IMETHODIMP SplitElementTxn::Init(nsEditor *aEditor, 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); } if (gNoisy) { printf("%p Do Split of node %p offset %d\n", this, mExistingRightNode.get(), mOffset); }
NS_ASSERTION(mExistingRightNode && mEditor, "bad state"); NS_ASSERTION(mExistingRightNode && mEditor, "bad state");
@ -94,7 +92,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void)
return result; return result;
} }
NS_IMETHODIMP SplitElementTxn::Undo(void) NS_IMETHODIMP SplitElementTxn::UndoTransaction(void)
{ {
if (gNoisy) { if (gNoisy) {
printf("%p Undo Split of existing node %p and new node %p offset %d\n", 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 /* 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. * 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"); NS_ASSERTION(mEditor && mExistingRightNode && mNewLeftNode && mParent, "bad state");
if (!mEditor || !mExistingRightNode || !mNewLeftNode || !mParent) { 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) if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE; *aDidMerge=PR_FALSE;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP SplitElementTxn::Write(nsIOutputStream *aOutputStream) NS_IMETHODIMP SplitElementTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("SplitElementTxn"));
}
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");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -61,24 +61,18 @@ protected:
public: public:
virtual ~SplitElementTxn(); 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode); NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
enum { kTransactionID = 11190 };
protected: protected:
/** the element to operate upon */ /** the element to operate upon */

Просмотреть файл

@ -423,10 +423,10 @@ nsEditor::Do(nsITransaction *aTxn)
selPrivate->StartBatchChanges(); selPrivate->StartBatchChanges();
if (mTxnMgr) { if (mTxnMgr) {
result = mTxnMgr->Do(aTxn); result = mTxnMgr->DoTransaction(aTxn);
} }
else { else {
result = aTxn->Do(); result = aTxn->DoTransaction();
} }
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = DoAfterDoTransaction(aTxn); result = DoAfterDoTransaction(aTxn);
@ -500,7 +500,7 @@ nsEditor::Undo(PRUint32 aCount)
PRUint32 i=0; PRUint32 i=0;
for ( ; i<aCount; i++) for ( ; i<aCount; i++)
{ {
result = mTxnMgr->Undo(); result = mTxnMgr->UndoTransaction();
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result))
result = DoAfterUndoTransaction(); result = DoAfterUndoTransaction();
@ -544,7 +544,7 @@ nsEditor::Redo(PRUint32 aCount)
PRUint32 i=0; PRUint32 i=0;
for ( ; i<aCount; i++) for ( ; i<aCount; i++)
{ {
result = mTxnMgr->Redo(); result = mTxnMgr->RedoTransaction();
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result))
result = DoAfterRedoTransaction(); result = DoAfterRedoTransaction();
@ -1015,7 +1015,7 @@ NS_IMETHODIMP nsEditor::CreateNode(const nsString& aTag,
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result))
{ {
result = txn->GetNewNode(aNewNode); 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 // 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! // Note that this means IME won't work without an undo stack!
if (mTxnMgr) if (mTxnMgr)
{ {
nsITransaction *txn; nsCOMPtr<nsITransaction> txn;
result = mTxnMgr->PeekUndoStack(&txn); result = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));
// PeekUndoStack does not addref
nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryInterface(txn); nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryInterface(txn);
if (plcTxn) if (plcTxn)
{ {

Просмотреть файл

@ -38,8 +38,6 @@ AddStyleSheetTxn::AddStyleSheetTxn()
: EditTxn() : EditTxn()
, mEditor(NULL) , mEditor(NULL)
{ {
SetTransactionDescriptionID( kTransactionID );
/* log description initialized in parent constructor */
} }
AddStyleSheetTxn::~AddStyleSheetTxn() AddStyleSheetTxn::~AddStyleSheetTxn()
@ -63,7 +61,7 @@ AddStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet)
NS_IMETHODIMP NS_IMETHODIMP
AddStyleSheetTxn::Do() AddStyleSheetTxn::DoTransaction()
{ {
if (!mEditor || !mSheet) if (!mEditor || !mSheet)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
@ -100,7 +98,7 @@ AddStyleSheetTxn::Do()
} }
NS_IMETHODIMP NS_IMETHODIMP
AddStyleSheetTxn::Undo() AddStyleSheetTxn::UndoTransaction()
{ {
if (!mEditor || !mSheet) if (!mEditor || !mSheet)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
@ -136,13 +134,13 @@ AddStyleSheetTxn::Undo()
} }
NS_IMETHODIMP NS_IMETHODIMP
AddStyleSheetTxn::Redo() AddStyleSheetTxn::RedoTransaction()
{ {
return Do(); return DoTransaction();
} }
NS_IMETHODIMP NS_IMETHODIMP
AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) AddStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
// set out param default value // set out param default value
if (!aDidMerge) if (!aDidMerge)
@ -153,28 +151,9 @@ AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
} }
NS_IMETHODIMP NS_IMETHODIMP
AddStyleSheetTxn::Write(nsIOutputStream *aOutputStream) AddStyleSheetTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("AddStyleSheetTxn"));
}
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");
}
return NS_OK; return NS_OK;
} }
@ -187,7 +166,6 @@ RemoveStyleSheetTxn::RemoveStyleSheetTxn()
: EditTxn() : EditTxn()
, mEditor(NULL) , mEditor(NULL)
{ {
SetTransactionDescriptionID( kTransactionID );
} }
RemoveStyleSheetTxn::~RemoveStyleSheetTxn() RemoveStyleSheetTxn::~RemoveStyleSheetTxn()
@ -211,7 +189,7 @@ RemoveStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet)
NS_IMETHODIMP NS_IMETHODIMP
RemoveStyleSheetTxn::Do() RemoveStyleSheetTxn::DoTransaction()
{ {
if (!mEditor || !mSheet) if (!mEditor || !mSheet)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
@ -247,7 +225,7 @@ RemoveStyleSheetTxn::Do()
} }
NS_IMETHODIMP NS_IMETHODIMP
RemoveStyleSheetTxn::Undo() RemoveStyleSheetTxn::UndoTransaction()
{ {
if (!mEditor || !mSheet) if (!mEditor || !mSheet)
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
@ -283,13 +261,13 @@ RemoveStyleSheetTxn::Undo()
} }
NS_IMETHODIMP NS_IMETHODIMP
RemoveStyleSheetTxn::Redo() RemoveStyleSheetTxn::RedoTransaction()
{ {
return Do(); return DoTransaction();
} }
NS_IMETHODIMP NS_IMETHODIMP
RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) RemoveStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{ {
// set out param default value // set out param default value
if (!aDidMerge) if (!aDidMerge)
@ -300,27 +278,8 @@ RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
} }
NS_IMETHODIMP NS_IMETHODIMP
RemoveStyleSheetTxn::Write(nsIOutputStream *aOutputStream) RemoveStyleSheetTxn::GetTxnDescription(nsAWritableString& aString)
{ {
return NS_OK; aString.Assign(NS_LITERAL_STRING("RemoveStyleSheetTxn"));
}
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");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -59,21 +59,15 @@ private:
public: 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11240 };
protected: protected:
@ -105,21 +99,15 @@ private:
public: 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 GetTxnDescription(nsAWritableString& aTxnDescription);
NS_IMETHOD GetUndoString(nsString *aString);
NS_IMETHOD GetRedoString(nsString *aString);
enum { kTransactionID = 11250 };
protected: protected:

Просмотреть файл

@ -24,6 +24,7 @@
#include <stdio.h> #include <stdio.h>
#include "nsHTMLEditorLog.h" #include "nsHTMLEditorLog.h"
#include "nsEditorTxnLog.h" #include "nsEditorTxnLog.h"
#include "nsPIEditorTransaction.h"
#define LOCK_LOG(doc) #define LOCK_LOG(doc)
#define UNLOCK_LOG(doc) #define UNLOCK_LOG(doc)
@ -361,7 +362,12 @@ nsEditorTxnLog::GetString(nsITransaction *aTransaction, char *aBuffer, PRInt32 a
nsString str; nsString str;
aTransaction->GetRedoString(&str); nsCOMPtr<nsPIEditorTransaction> txn = do_QueryInterface(aTransaction);
if (!txn)
return aBuffer;
txn->GetTxnDescription(str);
if (str.Length() == 0) if (str.Length() == 0)
str.AssignWithConversion("<NULL>"); str.AssignWithConversion("<NULL>");

Просмотреть файл

@ -25,7 +25,7 @@ DEPTH=..
!if defined(DISABLE_EDITOR) !if defined(DISABLE_EDITOR)
DIRS= public idl DIRS= public idl
!else !else
DIRS= public idl base txmgr ui txtsvc DIRS= txmgr public idl base ui txtsvc
!endif !endif
include <$(DEPTH)\config\rules.mak> include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -1,23 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is Mozilla Communicator client code, released
# March 31, 1998.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
nsITransactionDescription.idl

Просмотреть файл

@ -20,18 +20,21 @@
# Contributor(s): # Contributor(s):
# #
DEPTH = ../../.. DEPTH = ../../..
topsrcdir = @top_srcdir@ topsrcdir = @top_srcdir@
srcdir = @srcdir@ srcdir = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk include $(DEPTH)/config/autoconf.mk
MODULE = txmgr MODULE = txmgr
XPIDLSRCS = \ XPIDLSRCS = \
nsITransactionDescription.idl \ nsITransaction.idl \
$(NULL) nsITransactionList.idl \
nsITransactionListener.idl \
nsITransactionManager.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,32 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is Mozilla Communicator client code, released
# March 31, 1998.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH=..\..\..
MODULE=txmgr
XPIDL_MODULE=txmgr
XPIDLSRCS = \
.\nsITransactionDescription.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -24,7 +24,6 @@
#include "nsITransaction.idl" #include "nsITransaction.idl"
#include "nsITransactionList.idl" #include "nsITransactionList.idl"
#include "nsITransactionListener.idl" #include "nsITransactionListener.idl"
#include "nsIOutputStream.idl"
%{ C++ %{ C++
@ -138,14 +137,6 @@ interface nsITransactionManager : nsISupports
*/ */
nsITransactionList getRedoList(); 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 * Adds a listener to the transaction manager's notification list. Listeners
* are notified whenever a transaction is done, undone, or redone. * are notified whenever a transaction is done, undone, or redone.

Просмотреть файл

@ -1,8 +0,0 @@
#
# This is a list of local files which get copied to the mozilla:dist:editor directory
#
nsITransaction.h
nsITransactionListener.h
nsITransactionManager.h
nsTransactionManagerCID.h

Просмотреть файл

@ -29,9 +29,6 @@ include $(DEPTH)/config/autoconf.mk
MODULE = txmgr MODULE = txmgr
EXPORTS = \ EXPORTS = \
nsITransaction.h \
nsITransactionListener.h \
nsITransactionManager.h \
nsTransactionManagerCID.h \ nsTransactionManagerCID.h \
$(NULL) $(NULL)

Просмотреть файл

@ -1,35 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
EXPORTS = \
nsITransaction.h \
nsITransactionListener.h \
nsITransactionManager.h \
nsTransactionManagerCID.h \
$(NULL)
MODULE = txmgr
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -33,6 +33,7 @@ REQUIRES = xpcom string editor
CPPSRCS = \ CPPSRCS = \
nsTransactionItem.cpp \ nsTransactionItem.cpp \
nsTransactionList.cpp \
nsTransactionManager.cpp \ nsTransactionManager.cpp \
nsTransactionManagerFactory.cpp \ nsTransactionManagerFactory.cpp \
nsTransactionStack.cpp \ nsTransactionStack.cpp \

Просмотреть файл

@ -26,6 +26,7 @@ LIBRARY_NAME=txmgr
CPPSRCS = \ CPPSRCS = \
nsTransactionItem.cpp \ nsTransactionItem.cpp \
nsTransactionList.cpp \
nsTransactionManager.cpp \ nsTransactionManager.cpp \
nsTransactionManagerFactory.cpp \ nsTransactionManagerFactory.cpp \
nsTransactionStack.cpp \ nsTransactionStack.cpp \
@ -33,6 +34,7 @@ CPPSRCS = \
CPP_OBJS = \ CPP_OBJS = \
.\$(OBJDIR)\nsTransactionItem.obj \ .\$(OBJDIR)\nsTransactionItem.obj \
.\$(OBJDIR)\nsTransactionList.obj \
.\$(OBJDIR)\nsTransactionManager.obj \ .\$(OBJDIR)\nsTransactionManager.obj \
.\$(OBJDIR)\nsTransactionStack.obj \ .\$(OBJDIR)\nsTransactionStack.obj \
.\$(OBJDIR)\nsTransactionManagerFactory.obj \ .\$(OBJDIR)\nsTransactionManagerFactory.obj \

Просмотреть файл

@ -21,7 +21,6 @@
*/ */
#include "nsITransaction.h" #include "nsITransaction.h"
#include "nsITransactionManager.h"
#include "nsTransactionStack.h" #include "nsTransactionStack.h"
#include "nsTransactionManager.h" #include "nsTransactionManager.h"
#include "nsTransactionItem.h" #include "nsTransactionItem.h"
@ -71,6 +70,17 @@ nsTransactionItem::GetTransaction(nsITransaction **aTransaction)
return NS_OK; return NS_OK;
} }
nsresult
nsTransactionItem::GetIsBatch(PRBool *aIsBatch)
{
if (!aIsBatch)
return NS_ERROR_NULL_POINTER;
*aIsBatch = !mTransaction;
return NS_OK;
}
nsresult nsresult
nsTransactionItem::GetNumberOfChildren(PRInt32 *aNumChildren) nsTransactionItem::GetNumberOfChildren(PRInt32 *aNumChildren)
{ {
@ -100,15 +110,64 @@ nsTransactionItem::GetNumberOfChildren(PRInt32 *aNumChildren)
} }
nsresult 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) if (mTransaction)
return mTransaction->Do(); return mTransaction->DoTransaction();
return NS_OK; return NS_OK;
} }
nsresult nsresult
nsTransactionItem::Undo(nsTransactionManager *aTxMgr) nsTransactionItem::UndoTransaction(nsTransactionManager *aTxMgr)
{ {
nsresult result = UndoChildren(aTxMgr); nsresult result = UndoChildren(aTxMgr);
@ -120,7 +179,7 @@ nsTransactionItem::Undo(nsTransactionManager *aTxMgr)
if (!mTransaction) if (!mTransaction)
return NS_OK; return NS_OK;
result = mTransaction->Undo(); result = mTransaction->UndoTransaction();
if (NS_FAILED(result)) { if (NS_FAILED(result)) {
RecoverFromUndoError(aTxMgr); RecoverFromUndoError(aTxMgr);
@ -177,7 +236,7 @@ nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr)
return NS_OK; return NS_OK;
} }
result = item->Undo(aTxMgr); result = item->UndoTransaction(aTxMgr);
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = mUndoStack->Pop(&item); result = mUndoStack->Pop(&item);
@ -203,12 +262,12 @@ nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr)
} }
nsresult nsresult
nsTransactionItem::Redo(nsTransactionManager *aTxMgr) nsTransactionItem::RedoTransaction(nsTransactionManager *aTxMgr)
{ {
nsresult result; nsresult result;
if (mTransaction) { if (mTransaction) {
result = mTransaction->Redo(); result = mTransaction->RedoTransaction();
if (NS_FAILED(result)) if (NS_FAILED(result))
return result; return result;
@ -268,7 +327,7 @@ nsTransactionItem::RedoChildren(nsTransactionManager *aTxMgr)
return NS_OK; return NS_OK;
} }
result = item->Redo(aTxMgr); result = item->RedoTransaction(aTxMgr);
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = mRedoStack->Pop(&item); result = mRedoStack->Pop(&item);
@ -319,34 +378,12 @@ nsTransactionItem::GetNumberOfRedoItems(PRInt32 *aNumItems)
return mRedoStack->GetSize(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 nsresult
nsTransactionItem::RecoverFromUndoError(nsTransactionManager *aTxMgr) nsTransactionItem::RecoverFromUndoError(nsTransactionManager *aTxMgr)
{ {
// //
// If this method gets called, we never got to the point where we // 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! // Just redo any children that successfully called undo!
// //
return RedoChildren(aTxMgr); return RedoChildren(aTxMgr);
@ -356,9 +393,10 @@ nsresult
nsTransactionItem::RecoverFromRedoError(nsTransactionManager *aTxMgr) nsTransactionItem::RecoverFromRedoError(nsTransactionManager *aTxMgr)
{ {
// //
// If this method gets called, we already successfully called Redo() // If this method gets called, we already successfully called
// for the transaction item itself. Undo all the children that successfully // RedoTransaction() for the transaction item itself. Undo all
// called Redo(), then undo the transaction item itself. // the children that successfully called RedoTransaction(),
// then undo the transaction item itself.
// //
nsresult result; nsresult result;
@ -372,6 +410,6 @@ nsTransactionItem::RecoverFromRedoError(nsTransactionManager *aTxMgr)
if (!mTransaction) if (!mTransaction)
return NS_OK; return NS_OK;
return mTransaction->Undo(); return mTransaction->UndoTransaction();
} }

Просмотреть файл

@ -41,12 +41,13 @@ public:
virtual nsresult AddChild(nsTransactionItem *aTransactionItem); virtual nsresult AddChild(nsTransactionItem *aTransactionItem);
virtual nsresult GetTransaction(nsITransaction **aTransaction); virtual nsresult GetTransaction(nsITransaction **aTransaction);
virtual nsresult GetIsBatch(PRBool *aIsBatch);
virtual nsresult GetNumberOfChildren(PRInt32 *aNumChildren); virtual nsresult GetNumberOfChildren(PRInt32 *aNumChildren);
virtual nsresult GetChild(PRInt32 aIndex, nsTransactionItem **aChild);
virtual nsresult Do(void); virtual nsresult DoTransaction(void);
virtual nsresult Undo(nsTransactionManager *aTxMgr); virtual nsresult UndoTransaction(nsTransactionManager *aTxMgr);
virtual nsresult Redo(nsTransactionManager *aTxMgr); virtual nsresult RedoTransaction(nsTransactionManager *aTxMgr);
virtual nsresult Write(nsIOutputStream *aOutputStream);
private: private:

Просмотреть файл

@ -22,7 +22,6 @@
#include "nsITransactionManager.h" #include "nsITransactionManager.h"
#include "nsTransactionItem.h" #include "nsTransactionItem.h"
#include "nsITransactionList.h"
#include "nsTransactionList.h" #include "nsTransactionList.h"
#include "nsTransactionStack.h" #include "nsTransactionStack.h"

Просмотреть файл

@ -24,6 +24,7 @@
#define nsTransactionList_h__ #define nsTransactionList_h__
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsITransactionList.h"
class nsITransaction; class nsITransaction;
class nsITransactionManager; class nsITransactionManager;

Просмотреть файл

@ -21,13 +21,13 @@
*/ */
#include "nsITransaction.h" #include "nsITransaction.h"
#include "nsITransactionManager.h"
#include "nsITransactionListener.h" #include "nsITransactionListener.h"
#include "nsTransactionItem.h" #include "nsTransactionItem.h"
#include "nsTransactionStack.h" #include "nsTransactionStack.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
#include "nsTransactionManager.h" #include "nsTransactionManager.h"
#include "nsTransactionList.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
@ -86,16 +86,16 @@ nsrefcnt nsTransactionManager::Release(void)
return mRefCnt; return mRefCnt;
} }
NS_IMPL_QUERY_INTERFACE1(nsTransactionManager, nsITransactionManager) NS_IMPL_QUERY_INTERFACE2(nsTransactionManager, nsITransactionManager, nsISupportsWeakReference)
#else #else
NS_IMPL_ISUPPORTS(nsTransactionManager, NS_GET_IID(nsITransactionManager)) NS_IMPL_ISUPPORTS2(nsTransactionManager, nsITransactionManager, nsISupportsWeakReference)
#endif #endif
NS_IMETHODIMP NS_IMETHODIMP
nsTransactionManager::Do(nsITransaction *aTransaction) nsTransactionManager::DoTransaction(nsITransaction *aTransaction)
{ {
nsresult result; nsresult result;
@ -139,16 +139,16 @@ nsTransactionManager::Do(nsITransaction *aTransaction)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsTransactionManager::Undo() nsTransactionManager::UndoTransaction()
{ {
nsresult result = NS_OK; nsresult result = NS_OK;
nsTransactionItem *tx = 0; nsTransactionItem *tx = 0;
LOCK_TX_MANAGER(this); LOCK_TX_MANAGER(this);
// It is illegal to call Undo() while the transaction manager is // It is illegal to call UndoTransaction() while the transaction manager is
// executing a transaction's Do() method! If this happens, the Undo() // executing a transaction's DoTransaction() method! If this happens,
// request is ignored, and we return NS_ERROR_FAILURE. // the UndoTransaction() request is ignored, and we return NS_ERROR_FAILURE.
result = mDoStack.Peek(&tx); result = mDoStack.Peek(&tx);
@ -200,7 +200,7 @@ nsTransactionManager::Undo()
return NS_OK; return NS_OK;
} }
result = tx->Undo(this); result = tx->UndoTransaction(this);
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = mUndoStack.Pop(&tx); result = mUndoStack.Pop(&tx);
@ -220,16 +220,16 @@ nsTransactionManager::Undo()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsTransactionManager::Redo() nsTransactionManager::RedoTransaction()
{ {
nsresult result = NS_OK; nsresult result = NS_OK;
nsTransactionItem *tx = 0; nsTransactionItem *tx = 0;
LOCK_TX_MANAGER(this); LOCK_TX_MANAGER(this);
// It is illegal to call Redo() while the transaction manager is // It is illegal to call RedoTransaction() while the transaction manager is
// executing a transaction's Do() method! If this happens, the Redo() // executing a transaction's DoTransaction() method! If this happens,
// request is ignored, and we return NS_ERROR_FAILURE. // the RedoTransaction() request is ignored, and we return NS_ERROR_FAILURE.
result = mDoStack.Peek(&tx); result = mDoStack.Peek(&tx);
@ -281,7 +281,7 @@ nsTransactionManager::Redo()
return NS_OK; return NS_OK;
} }
result = tx->Redo(this); result = tx->RedoTransaction(this);
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = mRedoStack.Pop(&tx); result = mRedoStack.Pop(&tx);
@ -371,7 +371,7 @@ nsTransactionManager::EndBatch()
// XXX: Need to add some mechanism to detect the case where the transaction // 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 // 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 // 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 // For now, we can detect this case by checking the value of the
// dummy transaction's mTransaction field. If it is our dummy // dummy transaction's mTransaction field. If it is our dummy
@ -444,6 +444,19 @@ nsTransactionManager::GetNumberOfRedoItems(PRInt32 *aNumItems)
return result; 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 NS_IMETHODIMP
nsTransactionManager::SetMaxTransactionCount(PRInt32 aMaxCount) nsTransactionManager::SetMaxTransactionCount(PRInt32 aMaxCount)
{ {
@ -454,9 +467,10 @@ nsTransactionManager::SetMaxTransactionCount(PRInt32 aMaxCount)
LOCK_TX_MANAGER(this); LOCK_TX_MANAGER(this);
// It is illegal to call SetMaxTransactionCount() while the transaction // It is illegal to call SetMaxTransactionCount() while the transaction
// manager is executing a transaction's Do() method because the undo and // manager is executing a transaction's DoTransaction() method because
// redo stacks might get pruned! If this happens, the SetMaxTransactionCount() // the undo and redo stacks might get pruned! If this happens, the
// request is ignored, and we return NS_ERROR_FAILURE. // SetMaxTransactionCount() request is ignored, and we return
// NS_ERROR_FAILURE.
result = mDoStack.Peek(&tx); result = mDoStack.Peek(&tx);
@ -570,6 +584,8 @@ nsTransactionManager::PeekUndoStack(nsITransaction **aTransaction)
UNLOCK_TX_MANAGER(this); UNLOCK_TX_MANAGER(this);
NS_IF_ADDREF(*aTransaction);
return result; return result;
} }
@ -597,24 +613,35 @@ nsTransactionManager::PeekRedoStack(nsITransaction **aTransaction)
UNLOCK_TX_MANAGER(this); UNLOCK_TX_MANAGER(this);
NS_IF_ADDREF(*aTransaction);
return result; return result;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsTransactionManager::Write(nsIOutputStream *aOutputStream) nsTransactionManager::GetUndoList(nsITransactionList **aTransactionList)
{ {
PRUint32 len; if (!aTransactionList)
if (!aOutputStream)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
aOutputStream->Write("UndoStack:\n\n", 12, &len); *aTransactionList = (nsITransactionList *)new nsTransactionList(this, &mUndoStack);
mUndoStack.Write(aOutputStream);
aOutputStream->Write("\nRedoStack:\n\n", 13, &len); NS_IF_ADDREF(*aTransactionList);
mRedoStack.Write(aOutputStream);
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 NS_IMETHODIMP
@ -1030,7 +1057,7 @@ nsTransactionManager::BeginTransaction(nsITransaction *aTransaction)
return result; return result;
} }
result = tx->Do(); result = tx->DoTransaction();
if (NS_FAILED(result)) { if (NS_FAILED(result)) {
mDoStack.Pop(&tx); mDoStack.Pop(&tx);
@ -1137,7 +1164,7 @@ nsTransactionManager::EndTransaction()
return result; return result;
if (!doInterrupt) { if (!doInterrupt) {
result = topTransaction->Merge(&didMerge, tint); result = topTransaction->Merge(tint, &didMerge);
nsresult result2 = DidMergeNotify(topTransaction, tint, didMerge, result); nsresult result2 = DidMergeNotify(topTransaction, tint, didMerge, result);

Просмотреть файл

@ -24,9 +24,10 @@
#define nsTransactionManager_h__ #define nsTransactionManager_h__
#include "prmon.h" #include "prmon.h"
#include "nsWeakReference.h"
#include "nsITransactionManager.h"
class nsITransaction; class nsITransaction;
class nsITransactionManager;
class nsITransactionListener; class nsITransactionListener;
class nsTransactionItem; class nsTransactionItem;
class nsTransactionStack; class nsTransactionStack;
@ -37,6 +38,7 @@ class nsVoidArray;
* *
*/ */
class nsTransactionManager : public nsITransactionManager class nsTransactionManager : public nsITransactionManager
, public nsSupportsWeakReference
{ {
private: private:
@ -62,27 +64,14 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
/* nsITransactionManager method implementations. */ /* nsITransactionManager method implementations. */
NS_IMETHOD Do(nsITransaction *aTransaction); NS_DECL_NSITRANSACTIONMANAGER
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);
/* nsTransactionManager specific methods. */ /* nsTransactionManager specific methods. */
virtual nsresult ClearUndoStack(void); virtual nsresult ClearUndoStack(void);
virtual nsresult ClearRedoStack(void); virtual nsresult ClearRedoStack(void);
virtual nsresult WillDoNotify(nsITransaction *aTransaction, PRBool *aInterrupt); 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 WillUndoNotify(nsITransaction *aTransaction, PRBool *aInterrupt);
virtual nsresult DidUndoNotify(nsITransaction *aTransaction, nsresult aUndoResult); virtual nsresult DidUndoNotify(nsITransaction *aTransaction, nsresult aUndoResult);
virtual nsresult WillRedoNotify(nsITransaction *aTransaction, PRBool *aInterrupt); virtual nsresult WillRedoNotify(nsITransaction *aTransaction, PRBool *aInterrupt);

Просмотреть файл

@ -23,7 +23,6 @@
#include "nsIGenericFactory.h" #include "nsIGenericFactory.h"
#include "nsTransactionManagerCID.h" #include "nsTransactionManagerCID.h"
#include "nsITransactionManager.h"
#include "nsTransactionStack.h" #include "nsTransactionStack.h"
#include "nsTransactionManager.h" #include "nsTransactionManager.h"
@ -40,7 +39,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransactionManager)
// class name. // class name.
// //
static nsModuleComponentInfo components[] = { static nsModuleComponentInfo components[] = {
{ NULL, NS_TRANSACTIONMANAGER_CID, NULL, nsTransactionManagerConstructor }, { "nsTransactionManager", NS_TRANSACTIONMANAGER_CID, NS_TRANSACTIONMANAGER_CONTRACTID, nsTransactionManagerConstructor },
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -94,6 +94,20 @@ nsTransactionStack::Peek(nsTransactionItem **aTransaction)
return NS_OK; 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 nsresult
nsTransactionStack::Clear(void) nsTransactionStack::Clear(void)
{ {
@ -130,24 +144,6 @@ nsTransactionStack::GetSize(PRInt32 *aStackSize)
return NS_OK; 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() nsTransactionRedoStack::~nsTransactionRedoStack()
{ {
Clear(); Clear();

Просмотреть файл

@ -49,9 +49,9 @@ public:
virtual nsresult Pop(nsTransactionItem **aTransactionItem); virtual nsresult Pop(nsTransactionItem **aTransactionItem);
virtual nsresult PopBottom(nsTransactionItem **aTransactionItem); virtual nsresult PopBottom(nsTransactionItem **aTransactionItem);
virtual nsresult Peek(nsTransactionItem **aTransactionItem); virtual nsresult Peek(nsTransactionItem **aTransactionItem);
virtual nsresult GetItem(PRInt32 aIndex, nsTransactionItem **aTransactionItem);
virtual nsresult Clear(void); virtual nsresult Clear(void);
virtual nsresult GetSize(PRInt32 *aStackSize); virtual nsresult GetSize(PRInt32 *aStackSize);
virtual nsresult Write(nsIOutputStream *aOutputStream);
}; };
class nsTransactionRedoStack: public nsTransactionStack class nsTransactionRedoStack: public nsTransactionStack

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -385,3 +385,69 @@ function EditorTableize()
window._content.focus(); 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("<!-- Bottom of Stack -->\n");
PrintTxnList(txmgr.getUndoList(), "");
dump("<!-- Top of Stack -->\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("<!-- Bottom of Stack -->\n");
PrintTxnList(txmgr.getRedoList(), "");
dump("<!-- Top of Stack -->\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 + "| ");
}
}

Просмотреть файл

@ -836,6 +836,11 @@
<menuitem value="&runUnitTestsCmd.label;" <menuitem value="&runUnitTestsCmd.label;"
oncommand="EditorUnitTests()"/> oncommand="EditorUnitTests()"/>
<menuseparator /> <menuseparator />
<menuitem value="&dumpUndoStack.label;"
oncommand="DumpUndoStack()"/>
<menuitem value="&dumpRedoStack.label;"
oncommand="DumpRedoStack()"/>
<menuseparator />
<menuitem value="&startLogCmd.label;" <menuitem value="&startLogCmd.label;"
oncommand="EditorStartLog()"/> oncommand="EditorStartLog()"/>
<menuitem value="&stopLogCmd.label;" <menuitem value="&stopLogCmd.label;"

Просмотреть файл

@ -539,6 +539,8 @@
<!ENTITY showEmbeddedCmd.label "Show Embedded Objects"> <!ENTITY showEmbeddedCmd.label "Show Embedded Objects">
<!ENTITY dumpContentCmd.label "Dump Content Tree"> <!ENTITY dumpContentCmd.label "Dump Content Tree">
<!ENTITY runUnitTestsCmd.label "Run Unit Tests"> <!ENTITY runUnitTestsCmd.label "Run Unit Tests">
<!ENTITY dumpUndoStack.label "Dump Undo Stack">
<!ENTITY dumpRedoStack.label "Dump Redo Stack">
<!ENTITY startLogCmd.label "Start Log"> <!ENTITY startLogCmd.label "Start Log">
<!ENTITY stopLogCmd.label "Stop Log"> <!ENTITY stopLogCmd.label "Stop Log">
<!ENTITY runLogCmd.label "Run Log"> <!ENTITY runLogCmd.label "Run Log">

Просмотреть файл

@ -1204,9 +1204,8 @@ NS_IMETHODIMP nsMessenger::GetUndoTransactionType(PRUint32 *txnType)
if (!txnType || !mTxnMgr) if (!txnType || !mTxnMgr)
return rv; return rv;
*txnType = nsMessenger::eUnknown; *txnType = nsMessenger::eUnknown;
nsITransaction *txn = nsnull; nsCOMPtr<nsITransaction> txn;
// ** jt -- too bad PeekUndoStack not AddRef'ing rv = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));
rv = mTxnMgr->PeekUndoStack(&txn);
if (NS_SUCCEEDED(rv) && txn) if (NS_SUCCEEDED(rv) && txn)
{ {
nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv); nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv);
@ -1235,9 +1234,8 @@ NS_IMETHODIMP nsMessenger::GetRedoTransactionType(PRUint32 *txnType)
if (!txnType || !mTxnMgr) if (!txnType || !mTxnMgr)
return rv; return rv;
*txnType = nsMessenger::eUnknown; *txnType = nsMessenger::eUnknown;
nsITransaction *txn = nsnull; nsCOMPtr<nsITransaction> txn;
// ** jt - too bad PeekRedoStack not AddRef'ing rv = mTxnMgr->PeekRedoStack(getter_AddRefs(txn));
rv = mTxnMgr->PeekRedoStack(&txn);
if (NS_SUCCEEDED(rv) && txn) if (NS_SUCCEEDED(rv) && txn)
{ {
nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv); nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv);
@ -1270,16 +1268,15 @@ nsMessenger::Undo(nsIMsgWindow *msgWindow)
rv = mTxnMgr->GetNumberOfUndoItems(&numTxn); rv = mTxnMgr->GetNumberOfUndoItems(&numTxn);
if (NS_SUCCEEDED(rv) && numTxn > 0) if (NS_SUCCEEDED(rv) && numTxn > 0)
{ {
nsITransaction *txn = nsnull; nsCOMPtr<nsITransaction> txn;
// ** jt -- PeekUndoStack not AddRef'ing rv = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));
rv = mTxnMgr->PeekUndoStack(&txn);
if (NS_SUCCEEDED(rv) && txn) if (NS_SUCCEEDED(rv) && txn)
{ {
nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv); nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv);
if (NS_SUCCEEDED(rv) && msgTxn) if (NS_SUCCEEDED(rv) && msgTxn)
msgTxn->SetMsgWindow(msgWindow); msgTxn->SetMsgWindow(msgWindow);
} }
mTxnMgr->Undo(); mTxnMgr->UndoTransaction();
} }
} }
return rv; return rv;
@ -1295,16 +1292,15 @@ nsMessenger::Redo(nsIMsgWindow *msgWindow)
rv = mTxnMgr->GetNumberOfRedoItems(&numTxn); rv = mTxnMgr->GetNumberOfRedoItems(&numTxn);
if (NS_SUCCEEDED(rv) && numTxn > 0) if (NS_SUCCEEDED(rv) && numTxn > 0)
{ {
nsITransaction *txn = nsnull; nsCOMPtr<nsITransaction> txn;
// jt -- PeekRedoStack not AddRef'ing rv = mTxnMgr->PeekRedoStack(getter_AddRefs(txn));
rv = mTxnMgr->PeekRedoStack(&txn);
if (NS_SUCCEEDED(rv) && txn) if (NS_SUCCEEDED(rv) && txn)
{ {
nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv); nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv);
if (NS_SUCCEEDED(rv) && msgTxn) if (NS_SUCCEEDED(rv) && msgTxn)
msgTxn->SetMsgWindow(msgWindow); msgTxn->SetMsgWindow(msgWindow);
} }
mTxnMgr->Redo(); mTxnMgr->RedoTransaction();
} }
} }
return rv; return rv;

Просмотреть файл

@ -32,15 +32,13 @@ nsMsgTxn::nsMsgTxn()
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
m_txnType = 0; m_txnType = 0;
m_undoString.AssignWithConversion("Undo");
m_redoString.AssignWithConversion("Redo");
} }
nsMsgTxn::~nsMsgTxn() nsMsgTxn::~nsMsgTxn()
{ {
} }
NS_IMETHODIMP nsMsgTxn::Do(void) NS_IMETHODIMP nsMsgTxn::DoTransaction(void)
{ {
return NS_OK; return NS_OK;
} }
@ -54,12 +52,7 @@ NS_IMETHODIMP nsMsgTxn::GetIsTransient(PRBool *aIsTransient)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsMsgTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction) NS_IMETHODIMP nsMsgTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgTxn::Write(nsIOutputStream *aOutputStream)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -80,39 +73,6 @@ NS_IMETHODIMP nsMsgTxn::SetMsgWindow(nsIMsgWindow *msgWindow)
return NS_OK; 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 NS_IMETHODIMP
nsMsgTxn::GetTransactionType(PRUint32 *txnType) nsMsgTxn::GetTransactionType(PRUint32 *txnType)
{ {

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше