зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
c4120e0590
Коммит
11f8ac97cd
|
@ -26,7 +26,7 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public idl base txmgr txtsvc
|
||||
DIRS = txmgr public idl base txtsvc
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
ChangeAttributeTxn::ChangeAttributeTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
ChangeAttributeTxn::~ChangeAttributeTxn()
|
||||
|
@ -54,7 +52,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Do(void)
|
||||
NS_IMETHODIMP ChangeAttributeTxn::DoTransaction(void)
|
||||
{
|
||||
NS_ASSERTION(mEditor && mElement, "bad state");
|
||||
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
|
@ -75,7 +73,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Undo(void)
|
||||
NS_IMETHODIMP ChangeAttributeTxn::UndoTransaction(void)
|
||||
{
|
||||
NS_ASSERTION(mEditor && mElement, "bad state");
|
||||
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
|
@ -89,7 +87,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Redo(void)
|
||||
NS_IMETHODIMP ChangeAttributeTxn::RedoTransaction(void)
|
||||
{
|
||||
NS_ASSERTION(mEditor && mElement, "bad state");
|
||||
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
|
@ -104,40 +102,21 @@ NS_IMETHODIMP ChangeAttributeTxn::Redo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP ChangeAttributeTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("ChangeAttributeTxn: "));
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
if (PR_FALSE==mRemoveAttribute)
|
||||
aString->AssignWithConversion("Change Attribute: ");
|
||||
aString += NS_LITERAL_STRING("[mRemoveAttribute == false] ");
|
||||
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;
|
||||
}
|
||||
aString += NS_LITERAL_STRING("[mRemoveAttribute == true] ");
|
||||
aString += mAttribute;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -63,21 +63,15 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11180 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
CreateElementTxn::CreateElementTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor,
|
||||
|
@ -72,7 +70,7 @@ CreateElementTxn::~CreateElementTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Do(void)
|
||||
NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy)
|
||||
{
|
||||
|
@ -170,7 +168,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Undo(void)
|
||||
NS_IMETHODIMP CreateElementTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Undo Create Element, mParent = %p, node = %p\n",
|
||||
mParent.get(), mNewNode.get()); }
|
||||
|
@ -182,7 +180,7 @@ NS_IMETHODIMP CreateElementTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Redo(void)
|
||||
NS_IMETHODIMP CreateElementTxn::RedoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Redo Create Element\n"); }
|
||||
NS_ASSERTION(mEditor && mParent, "bad state");
|
||||
|
@ -203,35 +201,17 @@ NS_IMETHODIMP CreateElementTxn::Redo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP CreateElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP CreateElementTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Element: ");
|
||||
*aString += mTag;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Create Element: ");
|
||||
*aString += mTag;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("CreateElementTxn: "));
|
||||
aString += mTag;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,24 +63,18 @@ public:
|
|||
|
||||
virtual ~CreateElementTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
|
||||
|
||||
enum { kTransactionID = 11140 };
|
||||
|
||||
protected:
|
||||
|
||||
/** the document into which the new node will be inserted */
|
||||
|
|
|
@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
DeleteElementTxn::DeleteElementTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Init(nsIDOMNode *aElement)
|
||||
|
@ -54,7 +52,7 @@ DeleteElementTxn::~DeleteElementTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Do(void)
|
||||
NS_IMETHODIMP DeleteElementTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Do Delete Element element = %p\n", this, mElement.get()); }
|
||||
if (!mElement) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -96,7 +94,7 @@ NS_IMETHODIMP DeleteElementTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Undo(void)
|
||||
NS_IMETHODIMP DeleteElementTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Undo Delete Element element = %p, parent = %p\n", this, mElement.get(), mParent.get()); }
|
||||
if (!mParent) { return NS_OK; } // this is a legal state, the txn is a no-op
|
||||
|
@ -132,7 +130,7 @@ NS_IMETHODIMP DeleteElementTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Redo(void)
|
||||
NS_IMETHODIMP DeleteElementTxn::RedoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Redo Delete Element element = %p, parent = %p\n", this, mElement.get(), mParent.get()); }
|
||||
if (!mParent) { return NS_OK; } // this is a legal state, the txn is a no-op
|
||||
|
@ -144,32 +142,15 @@ NS_IMETHODIMP DeleteElementTxn::Redo(void)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP DeleteElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP DeleteElementTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Element: ");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Element: ");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("DeleteElementTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -53,21 +53,15 @@ public:
|
|||
|
||||
virtual ~DeleteElementTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11160 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -47,8 +47,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
DeleteRangeTxn::DeleteRangeTxn()
|
||||
: EditAggregateTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Init(nsIEditor *aEditor, nsIDOMRange *aRange)
|
||||
|
@ -112,7 +110,7 @@ DeleteRangeTxn::~DeleteRangeTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Do(void)
|
||||
NS_IMETHODIMP DeleteRangeTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Do Delete Range\n"); }
|
||||
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor)
|
||||
|
@ -143,7 +141,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
|
|||
|
||||
// if we've successfully built this aggregate transaction, then do it.
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = EditAggregateTxn::Do();
|
||||
result = EditAggregateTxn::DoTransaction();
|
||||
}
|
||||
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
@ -167,53 +165,36 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Undo(void)
|
||||
NS_IMETHODIMP DeleteRangeTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Undo Delete Range\n"); }
|
||||
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult result = EditAggregateTxn::Undo();
|
||||
nsresult result = EditAggregateTxn::UndoTransaction();
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Redo(void)
|
||||
NS_IMETHODIMP DeleteRangeTxn::RedoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Redo Delete Range\n"); }
|
||||
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult result = EditAggregateTxn::Redo();
|
||||
nsresult result = EditAggregateTxn::RedoTransaction();
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP DeleteRangeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP DeleteRangeTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Range: ");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Range: ");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("DeleteRangeTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,21 +61,15 @@ public:
|
|||
|
||||
virtual ~DeleteRangeTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11170 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
DeleteTextTxn::DeleteTextTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
DeleteTextTxn::~DeleteTextTxn()
|
||||
|
@ -62,7 +60,7 @@ NS_IMETHODIMP DeleteTextTxn::Init(nsIEditor *aEditor,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteTextTxn::Do(void)
|
||||
NS_IMETHODIMP DeleteTextTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Do Delete Text\n"); }
|
||||
NS_ASSERTION(mEditor && mElement, "bad state");
|
||||
|
@ -94,7 +92,7 @@ NS_IMETHODIMP DeleteTextTxn::Do(void)
|
|||
|
||||
//XXX: we may want to store the selection state and restore it properly
|
||||
// was it an insertion point or an extended selection?
|
||||
NS_IMETHODIMP DeleteTextTxn::Undo(void)
|
||||
NS_IMETHODIMP DeleteTextTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Undo Delete Text\n"); }
|
||||
NS_ASSERTION(mEditor && mElement, "bad state");
|
||||
|
@ -105,34 +103,16 @@ NS_IMETHODIMP DeleteTextTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP DeleteTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteTextTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP DeleteTextTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteTextTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Text: ");
|
||||
*aString += mDeletedText;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteTextTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Text: ");
|
||||
*aString += mDeletedText;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("DeleteTextTxn: "));
|
||||
aString += mDeletedText;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -59,19 +59,13 @@ private:
|
|||
public:
|
||||
virtual ~DeleteTextTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11130 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@ EditAggregateTxn::EditAggregateTxn()
|
|||
// base class does this: NS_INIT_REFCNT();
|
||||
nsresult res = NS_NewISupportsArray(getter_AddRefs(mChildren));
|
||||
NS_POSTCONDITION(NS_SUCCEEDED(res), "EditAggregateTxn failed in constructor");
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
EditAggregateTxn::~EditAggregateTxn()
|
||||
|
@ -40,7 +38,7 @@ EditAggregateTxn::~EditAggregateTxn()
|
|||
// nsISupportsArray cleans up array for us at destruct time
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::Do(void)
|
||||
NS_IMETHODIMP EditAggregateTxn::DoTransaction(void)
|
||||
{
|
||||
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
|
||||
if (mChildren)
|
||||
|
@ -53,7 +51,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void)
|
|||
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
|
||||
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
|
||||
if (!txn) { return NS_ERROR_NULL_POINTER; }
|
||||
result = txn->Do();
|
||||
result = txn->DoTransaction();
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
|
@ -61,7 +59,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::Undo(void)
|
||||
NS_IMETHODIMP EditAggregateTxn::UndoTransaction(void)
|
||||
{
|
||||
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
|
||||
if (mChildren)
|
||||
|
@ -75,7 +73,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void)
|
|||
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
|
||||
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
|
||||
if (!txn) { return NS_ERROR_NULL_POINTER; }
|
||||
result = txn->Undo();
|
||||
result = txn->UndoTransaction();
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
|
@ -83,7 +81,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::Redo(void)
|
||||
NS_IMETHODIMP EditAggregateTxn::RedoTransaction(void)
|
||||
{
|
||||
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
|
||||
if (mChildren)
|
||||
|
@ -96,7 +94,7 @@ NS_IMETHODIMP EditAggregateTxn::Redo(void)
|
|||
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
|
||||
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
|
||||
if (!txn) { return NS_ERROR_NULL_POINTER; }
|
||||
result = txn->Redo();
|
||||
result = txn->RedoTransaction();
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
|
@ -111,7 +109,7 @@ NS_IMETHODIMP EditAggregateTxn::GetIsTransient(PRBool *aIsTransient)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP EditAggregateTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
|
||||
if (nsnull!=aDidMerge)
|
||||
|
@ -127,29 +125,24 @@ NS_IMETHODIMP EditAggregateTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransa
|
|||
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
|
||||
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
|
||||
if (!txn) { return NS_ERROR_NULL_POINTER; }
|
||||
result = txn->Merge(aDidMerge, aTransaction);
|
||||
result = txn->Merge(aTransaction, aDidMerge);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP EditAggregateTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("EditAggregateTxn: "));
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
aString->SetLength(0);
|
||||
return NS_OK;
|
||||
}
|
||||
if (mName)
|
||||
{
|
||||
nsAutoString name;
|
||||
mName->ToString(name);
|
||||
aString += name;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
aString->SetLength(0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,21 +50,17 @@ public:
|
|||
|
||||
virtual ~EditAggregateTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD GetIsTransient(PRBool *aIsTransient);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
/** append a transaction to this aggregate */
|
||||
NS_IMETHOD AppendChild(EditTxn *aTxn);
|
||||
|
@ -85,8 +81,6 @@ public:
|
|||
/** get the name assigned to this txn */
|
||||
NS_IMETHOD GetName(nsIAtom **aName);
|
||||
|
||||
enum { kTransactionID = 11210 };
|
||||
|
||||
protected:
|
||||
|
||||
nsCOMPtr<nsISupportsArray> mChildren;
|
||||
|
|
|
@ -34,7 +34,6 @@ NS_IMPL_RELEASE(EditTxn)
|
|||
|
||||
// note that aEditor is not refcounted
|
||||
EditTxn::EditTxn()
|
||||
: mTransactionID(-1)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -43,19 +42,19 @@ EditTxn::~EditTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::Do(void)
|
||||
NS_IMETHODIMP EditTxn::DoTransaction(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::Undo(void)
|
||||
NS_IMETHODIMP EditTxn::UndoTransaction(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::Redo(void)
|
||||
NS_IMETHODIMP EditTxn::RedoTransaction(void)
|
||||
{
|
||||
return Do();
|
||||
return DoTransaction();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient)
|
||||
|
@ -65,53 +64,14 @@ NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP EditTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP EditTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
aString->SetLength(0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
aString->SetLength(0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::GetLogDescription(PRUnichar * *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
*aString = mLogDescription.ToNewUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::SetLogDescription(const PRUnichar *aString)
|
||||
{
|
||||
mLogDescription = (PRUnichar *)aString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::GetTransactionDescriptionID(int *aID)
|
||||
{
|
||||
if (nsnull!=aID)
|
||||
*aID = mTransactionID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::SetTransactionDescriptionID(int aID)
|
||||
{
|
||||
mTransactionID = aID;
|
||||
aString.Assign(NS_LITERAL_STRING("EditTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -133,12 +93,13 @@ EditTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsITransactionDescription))) {
|
||||
*aInstancePtr = (void*)(nsITransactionDescription*)this;
|
||||
if (aIID.Equals(NS_GET_IID(nsPIEditorTransaction))) {
|
||||
*aInstancePtr = (void*)(nsPIEditorTransaction*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
*aInstancePtr = 0;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,10 @@
|
|||
#define EditTxn_h__
|
||||
|
||||
#include "nsITransaction.h"
|
||||
#include "nsITransactionDescription.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsPIEditorTransaction.h"
|
||||
|
||||
#define EDIT_TXN_CID \
|
||||
{/* c5ea31b0-ac48-11d2-86d8-000064657374 */ \
|
||||
|
@ -39,7 +41,7 @@
|
|||
* it is never seen by the user or by any external entity.
|
||||
*/
|
||||
class EditTxn : public nsITransaction
|
||||
, public nsITransactionDescription
|
||||
, public nsPIEditorTransaction
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -51,27 +53,17 @@ public:
|
|||
virtual ~EditTxn();
|
||||
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD GetIsTransient(PRBool *aIsTransient);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11100 };
|
||||
|
||||
NS_DECL_NSITRANSACTIONDESCRIPTION
|
||||
nsString mLogDescription;
|
||||
int mTransactionID;
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,8 +42,6 @@ nsresult IMECommitTxn::ClassShutdown()
|
|||
IMECommitTxn::IMECommitTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
IMECommitTxn::~IMECommitTxn()
|
||||
|
@ -55,7 +53,7 @@ NS_IMETHODIMP IMECommitTxn::Init(void)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMECommitTxn::Do(void)
|
||||
NS_IMETHODIMP IMECommitTxn::DoTransaction(void)
|
||||
{
|
||||
#ifdef DEBUG_IME
|
||||
printf("Do IME Commit");
|
||||
|
@ -64,7 +62,7 @@ NS_IMETHODIMP IMECommitTxn::Do(void)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMECommitTxn::Undo(void)
|
||||
NS_IMETHODIMP IMECommitTxn::UndoTransaction(void)
|
||||
{
|
||||
#ifdef DEBUG_IME
|
||||
printf("Undo IME Commit");
|
||||
|
@ -73,7 +71,7 @@ NS_IMETHODIMP IMECommitTxn::Undo(void)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMECommitTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP IMECommitTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
#ifdef DEBUG_IME
|
||||
printf("Merge IME Commit");
|
||||
|
@ -88,37 +86,12 @@ NS_IMETHODIMP IMECommitTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransactio
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMECommitTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP IMECommitTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
NS_ASSERTION(aOutputStream, "null ptr- aOutputStream");
|
||||
if(nsnull == aOutputStream)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
else
|
||||
aString.Assign(NS_LITERAL_STRING("IMECommitTxn"));
|
||||
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
|
||||
|
|
|
@ -55,17 +55,13 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
// nsISupports declarations
|
||||
|
||||
|
@ -78,8 +74,6 @@ public:
|
|||
/** must be called once we are guaranteed all IMECommitTxn have completed */
|
||||
static nsresult ClassShutdown();
|
||||
|
||||
enum { kTransactionID = 11230 };
|
||||
|
||||
protected:
|
||||
|
||||
friend class TransactionFactory;
|
||||
|
|
|
@ -54,8 +54,6 @@ nsresult IMETextTxn::ClassShutdown()
|
|||
IMETextTxn::IMETextTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
IMETextTxn::~IMETextTxn()
|
||||
|
@ -84,7 +82,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::Do(void)
|
||||
NS_IMETHODIMP IMETextTxn::DoTransaction(void)
|
||||
{
|
||||
|
||||
#ifdef DEBUG_IMETXN
|
||||
|
@ -108,7 +106,7 @@ NS_IMETHODIMP IMETextTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::Undo(void)
|
||||
NS_IMETHODIMP IMETextTxn::UndoTransaction(void)
|
||||
{
|
||||
#ifdef DEBUG_IMETXN
|
||||
printf("Undo IME Text element = %p\n", mElement.get());
|
||||
|
@ -132,7 +130,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP IMETextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
NS_ASSERTION(aDidMerge, "illegal vaule- null ptr- aDidMerge");
|
||||
NS_ASSERTION(aTransaction, "illegal vaule- null ptr- aTransaction");
|
||||
|
@ -185,45 +183,16 @@ NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::Write(nsIOutputStream *aOutputStream)
|
||||
{
|
||||
NS_ASSERTION(aOutputStream, "illegal value- null ptr- aOutputStream");
|
||||
if(nsnull == aOutputStream)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::MarkFixed(void)
|
||||
{
|
||||
mFixed = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::GetUndoString(nsString *aString)
|
||||
NS_IMETHODIMP IMETextTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
NS_ASSERTION(aString, "illegal value- null ptr- aString");
|
||||
if(nsnull == aString)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Text: ");
|
||||
*aString += mStringToInsert;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
NS_ASSERTION(aString, "illegal value- null ptr- aString");
|
||||
if(nsnull == aString)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Text: ");
|
||||
*aString += mStringToInsert;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("IMETextTxn: "));
|
||||
aString += mStringToInsert;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,17 +74,13 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
NS_IMETHOD MarkFixed(void);
|
||||
|
||||
|
@ -102,8 +98,6 @@ public:
|
|||
/** must be called once we are guaranteed all IMETextTxn have completed */
|
||||
static nsresult ClassShutdown();
|
||||
|
||||
enum { kTransactionID = 11220 };
|
||||
|
||||
protected:
|
||||
|
||||
NS_IMETHOD CollapseTextSelection(void);
|
||||
|
|
|
@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
InsertElementTxn::InsertElementTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::Init(nsIDOMNode *aNode,
|
||||
|
@ -62,7 +60,7 @@ InsertElementTxn::~InsertElementTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::Do(void)
|
||||
NS_IMETHODIMP InsertElementTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy)
|
||||
{
|
||||
|
@ -119,7 +117,7 @@ NS_IMETHODIMP InsertElementTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::Undo(void)
|
||||
NS_IMETHODIMP InsertElementTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Undo Insert Element of %p into parent %p at offset %d\n",
|
||||
this, mNode.get(), mParent.get(), mOffset); }
|
||||
|
@ -130,32 +128,15 @@ NS_IMETHODIMP InsertElementTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP InsertElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP InsertElementTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Element: ");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Element: ");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("InsertElementTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -59,19 +59,13 @@ public:
|
|||
|
||||
virtual ~InsertElementTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11150 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -52,8 +52,6 @@ nsresult InsertTextTxn::ClassShutdown()
|
|||
InsertTextTxn::InsertTextTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
InsertTextTxn::~InsertTextTxn()
|
||||
|
@ -83,7 +81,7 @@ NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::Do(void)
|
||||
NS_IMETHODIMP InsertTextTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Do Insert Text element = %p\n", mElement.get()); }
|
||||
NS_ASSERTION(mElement && mEditor, "bad state");
|
||||
|
@ -112,7 +110,7 @@ NS_IMETHODIMP InsertTextTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::Undo(void)
|
||||
NS_IMETHODIMP InsertTextTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Undo Insert Text element = %p\n", mElement.get()); }
|
||||
NS_ASSERTION(mElement && mEditor, "bad state");
|
||||
|
@ -124,7 +122,7 @@ NS_IMETHODIMP InsertTextTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP InsertTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
// set out param default value
|
||||
if (nsnull!=aDidMerge)
|
||||
|
@ -192,28 +190,10 @@ NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransacti
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP InsertTextTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Text: ");
|
||||
*aString += mStringToInsert;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Text: ");
|
||||
*aString += mStringToInsert;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("InsertTextTxn: "));
|
||||
aString += mStringToInsert;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,17 +68,13 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
// nsISupports declarations
|
||||
|
||||
|
@ -94,8 +90,6 @@ public:
|
|||
/** must be called once we are guaranteed all InsertTextTxn have completed */
|
||||
static nsresult ClassShutdown();
|
||||
|
||||
enum { kTransactionID = 11120 };
|
||||
|
||||
protected:
|
||||
|
||||
/** return PR_TRUE if aOtherTxn immediately follows this txn */
|
||||
|
|
|
@ -34,8 +34,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
JoinElementTxn::JoinElementTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinElementTxn::Init(nsEditor *aEditor,
|
||||
|
@ -55,8 +53,8 @@ JoinElementTxn::~JoinElementTxn()
|
|||
{
|
||||
}
|
||||
|
||||
// After Do() and Redo(), the left node is removed from the content tree and right node remains.
|
||||
NS_IMETHODIMP JoinElementTxn::Do(void)
|
||||
// After DoTransaction() and RedoTransaction(), the left node is removed from the content tree and right node remains.
|
||||
NS_IMETHODIMP JoinElementTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Do Join of %p and %p\n", this, mLeftNode.get(), mRightNode.get()); }
|
||||
NS_PRECONDITION((mEditor && mLeftNode && mRightNode), "null arg");
|
||||
|
@ -110,7 +108,7 @@ NS_IMETHODIMP JoinElementTxn::Do(void)
|
|||
|
||||
//XXX: what if instead of split, we just deleted the unneeded children of mRight
|
||||
// and re-inserted mLeft?
|
||||
NS_IMETHODIMP JoinElementTxn::Undo(void)
|
||||
NS_IMETHODIMP JoinElementTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Undo Join, right node = %p\n", this, mRightNode.get()); }
|
||||
NS_ASSERTION(mRightNode && mLeftNode && mParent, "bad state");
|
||||
|
@ -152,32 +150,15 @@ NS_IMETHODIMP JoinElementTxn::GetIsTransient(PRBool *aIsTransient)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult JoinElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
nsresult JoinElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinElementTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP JoinElementTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinElementTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Join Element");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinElementTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Split Element");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("JoinElementTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ class nsEditor;
|
|||
* A transaction that joins two elements E1 (left node) and E2 (right node)
|
||||
* into a single node E.
|
||||
* The children of E are the children of E1 followed by the children of E2.
|
||||
* After Do() and Redo(), E1 is removed from the content tree and E2 remains.
|
||||
* After DoTransaction() and RedoTransaction(), E1 is removed from the content
|
||||
* tree and E2 remains.
|
||||
*/
|
||||
class JoinElementTxn : public EditTxn
|
||||
{
|
||||
|
@ -62,23 +63,17 @@ public:
|
|||
|
||||
virtual ~JoinElementTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
// NS_IMETHOD Redo(void);
|
||||
// NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD GetIsTransient(PRBool *aIsTransient);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11200 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ CPPSRCS = \
|
|||
DeleteTextTxn.cpp \
|
||||
EditAggregateTxn.cpp \
|
||||
EditTxn.cpp \
|
||||
IMECommitTxn.cpp \
|
||||
IMETextTxn.cpp \
|
||||
InsertElementTxn.cpp \
|
||||
InsertTextTxn.cpp \
|
||||
|
|
|
@ -43,8 +43,6 @@ PlaceholderTxn::PlaceholderTxn() : EditAggregateTxn(),
|
|||
mEndSel(),
|
||||
mEditor(nsnull)
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,16 +82,16 @@ NS_IMETHODIMP PlaceholderTxn::Init(nsIAtom *aName, nsSelectionState *aSelState,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::Do(void)
|
||||
NS_IMETHODIMP PlaceholderTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("PlaceholderTxn Do\n"); }
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::Undo(void)
|
||||
NS_IMETHODIMP PlaceholderTxn::UndoTransaction(void)
|
||||
{
|
||||
// undo txns
|
||||
nsresult res = EditAggregateTxn::Undo();
|
||||
nsresult res = EditAggregateTxn::UndoTransaction();
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// now restore selection
|
||||
|
@ -107,10 +105,10 @@ NS_IMETHODIMP PlaceholderTxn::Undo(void)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::Redo(void)
|
||||
NS_IMETHODIMP PlaceholderTxn::RedoTransaction(void)
|
||||
{
|
||||
// redo txns
|
||||
nsresult res = EditAggregateTxn::Redo();
|
||||
nsresult res = EditAggregateTxn::RedoTransaction();
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// now restore selection
|
||||
|
@ -123,7 +121,7 @@ NS_IMETHODIMP PlaceholderTxn::Redo(void)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP PlaceholderTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (!aDidMerge || !aTransaction) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
|
@ -155,7 +153,7 @@ NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransact
|
|||
else
|
||||
{
|
||||
PRBool didMerge;
|
||||
mIMETextTxn->Merge(&didMerge, otherTxn);
|
||||
mIMETextTxn->Merge(otherTxn, &didMerge);
|
||||
if (!didMerge)
|
||||
{
|
||||
// it wouldn't merge. Earlier IME txn is already commited and will
|
||||
|
@ -218,6 +216,20 @@ NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransact
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
aString.Assign(NS_LITERAL_STRING("PlaceholderTxn: "));
|
||||
|
||||
if (mName)
|
||||
{
|
||||
nsAutoString name;
|
||||
mName->ToString(name);
|
||||
aString += name;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::GetTxnName(nsIAtom **aName)
|
||||
{
|
||||
return GetName(aName);
|
||||
|
|
|
@ -65,13 +65,15 @@ public:
|
|||
|
||||
// ------------ EditAggregateTxn -----------------------
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
// ------------ nsIAbsorbingTransaction -----------------------
|
||||
|
||||
|
@ -91,8 +93,6 @@ public:
|
|||
|
||||
friend class TransactionFactory;
|
||||
|
||||
enum { kTransactionID = 11260 };
|
||||
|
||||
protected:
|
||||
|
||||
/** the presentation shell, which we'll need to get the selection */
|
||||
|
@ -103,7 +103,8 @@ protected:
|
|||
PRBool mCommitted; // do we stop auto absorbing any matching placeholder txns?
|
||||
// these next two members store the state of the selection in a safe way.
|
||||
// selection at the start of the txn is stored, as is the selection at the end.
|
||||
// This is so that Undo() and Redo() can restore the selection properly.
|
||||
// This is so that UndoTransaction() and RedoTransaction() can restore the
|
||||
// selection properly.
|
||||
nsSelectionState *mStartSel; // use a pointer because this is constructed before we exist
|
||||
nsSelectionState mEndSel;
|
||||
nsIEditor* mEditor; /** the editor for this transaction */
|
||||
|
|
|
@ -36,8 +36,6 @@ SetDocTitleTxn::SetDocTitleTxn()
|
|||
: EditTxn()
|
||||
, mIsTransient(PR_FALSE)
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor,
|
||||
|
@ -57,7 +55,7 @@ SetDocTitleTxn::~SetDocTitleTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Do(void)
|
||||
NS_IMETHODIMP SetDocTitleTxn::DoTransaction(void)
|
||||
{
|
||||
nsresult res = SetDomTitle(mValue);
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
@ -65,12 +63,12 @@ NS_IMETHODIMP SetDocTitleTxn::Do(void)
|
|||
return SetDocTitle(mValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Undo(void)
|
||||
NS_IMETHODIMP SetDocTitleTxn::UndoTransaction(void)
|
||||
{
|
||||
return SetDocTitle(mUndoValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Redo(void)
|
||||
NS_IMETHODIMP SetDocTitleTxn::RedoTransaction(void)
|
||||
{
|
||||
return SetDocTitle(mValue);
|
||||
}
|
||||
|
@ -208,35 +206,17 @@ nsresult SetDocTitleTxn::SetDomTitle(nsString& aTitle)
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP SetDocTitleTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP SetDocTitleTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Restore Document Title: ");
|
||||
*aString += mUndoValue;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Set Document Title: ");
|
||||
*aString += mValue;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("SetDocTitleTxn: "));
|
||||
aString += mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
#include "nsITransaction.h"
|
||||
#include "nsITransactionDescription.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define SET_DOC_TITLE_TXN_CID \
|
||||
|
@ -61,23 +60,17 @@ private:
|
|||
nsresult SetDomTitle(nsString& aTitle);
|
||||
|
||||
public:
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD GetIsTransient(PRBool *aIsTransient);
|
||||
|
||||
enum { kTransactionID = 11270 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -37,8 +37,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
SplitElementTxn::SplitElementTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::Init(nsEditor *aEditor,
|
||||
|
@ -58,7 +56,7 @@ SplitElementTxn::~SplitElementTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::Do(void)
|
||||
NS_IMETHODIMP SplitElementTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Do Split of node %p offset %d\n", this, mExistingRightNode.get(), mOffset); }
|
||||
NS_ASSERTION(mExistingRightNode && mEditor, "bad state");
|
||||
|
@ -94,7 +92,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::Undo(void)
|
||||
NS_IMETHODIMP SplitElementTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) {
|
||||
printf("%p Undo Split of existing node %p and new node %p offset %d\n",
|
||||
|
@ -122,7 +120,7 @@ NS_IMETHODIMP SplitElementTxn::Undo(void)
|
|||
/* redo cannot simply resplit the right node, because subsequent transactions
|
||||
* on the redo stack may depend on the left node existing in its previous state.
|
||||
*/
|
||||
NS_IMETHODIMP SplitElementTxn::Redo(void)
|
||||
NS_IMETHODIMP SplitElementTxn::RedoTransaction(void)
|
||||
{
|
||||
NS_ASSERTION(mEditor && mExistingRightNode && mNewLeftNode && mParent, "bad state");
|
||||
if (!mEditor || !mExistingRightNode || !mNewLeftNode || !mParent) {
|
||||
|
@ -182,33 +180,16 @@ NS_IMETHODIMP SplitElementTxn::Redo(void)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP SplitElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP SplitElementTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Join Element");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Split Element");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("SplitElementTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,24 +61,18 @@ protected:
|
|||
public:
|
||||
virtual ~SplitElementTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
|
||||
|
||||
enum { kTransactionID = 11190 };
|
||||
|
||||
protected:
|
||||
|
||||
/** the element to operate upon */
|
||||
|
|
|
@ -39,7 +39,6 @@ CPPSRCS = \
|
|||
DeleteTextTxn.cpp \
|
||||
EditAggregateTxn.cpp \
|
||||
EditTxn.cpp \
|
||||
IMECommitTxn.cpp \
|
||||
IMETextTxn.cpp \
|
||||
InsertElementTxn.cpp \
|
||||
InsertTextTxn.cpp \
|
||||
|
@ -70,7 +69,6 @@ CPP_OBJS = \
|
|||
.\$(OBJDIR)\DeleteTextTxn.obj \
|
||||
.\$(OBJDIR)\EditAggregateTxn.obj \
|
||||
.\$(OBJDIR)\EditTxn.obj \
|
||||
.\$(OBJDIR)\IMECommitTxn.obj \
|
||||
.\$(OBJDIR)\IMETextTxn.obj \
|
||||
.\$(OBJDIR)\InsertElementTxn.obj \
|
||||
.\$(OBJDIR)\InsertTextTxn.obj \
|
||||
|
|
|
@ -423,10 +423,10 @@ nsEditor::Do(nsITransaction *aTxn)
|
|||
|
||||
selPrivate->StartBatchChanges();
|
||||
if (mTxnMgr) {
|
||||
result = mTxnMgr->Do(aTxn);
|
||||
result = mTxnMgr->DoTransaction(aTxn);
|
||||
}
|
||||
else {
|
||||
result = aTxn->Do();
|
||||
result = aTxn->DoTransaction();
|
||||
}
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = DoAfterDoTransaction(aTxn);
|
||||
|
@ -500,7 +500,7 @@ nsEditor::Undo(PRUint32 aCount)
|
|||
PRUint32 i=0;
|
||||
for ( ; i<aCount; i++)
|
||||
{
|
||||
result = mTxnMgr->Undo();
|
||||
result = mTxnMgr->UndoTransaction();
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
result = DoAfterUndoTransaction();
|
||||
|
@ -544,7 +544,7 @@ nsEditor::Redo(PRUint32 aCount)
|
|||
PRUint32 i=0;
|
||||
for ( ; i<aCount; i++)
|
||||
{
|
||||
result = mTxnMgr->Redo();
|
||||
result = mTxnMgr->RedoTransaction();
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
result = DoAfterRedoTransaction();
|
||||
|
@ -1015,7 +1015,7 @@ NS_IMETHODIMP nsEditor::CreateNode(const nsString& aTag,
|
|||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
result = txn->GetNewNode(aNewNode);
|
||||
NS_ASSERTION((NS_SUCCEEDED(result)), "GetNewNode can't fail if txn::Do succeeded.");
|
||||
NS_ASSERTION((NS_SUCCEEDED(result)), "GetNewNode can't fail if txn::DoTransaction succeeded.");
|
||||
}
|
||||
}
|
||||
// The transaction system (if any) has taken ownwership of txn
|
||||
|
@ -1771,9 +1771,8 @@ nsEditor::EndComposition(void)
|
|||
// Note that this means IME won't work without an undo stack!
|
||||
if (mTxnMgr)
|
||||
{
|
||||
nsITransaction *txn;
|
||||
result = mTxnMgr->PeekUndoStack(&txn);
|
||||
// PeekUndoStack does not addref
|
||||
nsCOMPtr<nsITransaction> txn;
|
||||
result = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));
|
||||
nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryInterface(txn);
|
||||
if (plcTxn)
|
||||
{
|
||||
|
|
|
@ -2299,6 +2299,17 @@ nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval)
|
|||
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
|
||||
nsEditorShell::Undo()
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <stdio.h>
|
||||
#include "nsHTMLEditorLog.h"
|
||||
#include "nsEditorTxnLog.h"
|
||||
#include "nsPIEditorTransaction.h"
|
||||
|
||||
#define LOCK_LOG(doc)
|
||||
#define UNLOCK_LOG(doc)
|
||||
|
@ -361,7 +362,12 @@ nsEditorTxnLog::GetString(nsITransaction *aTransaction, char *aBuffer, PRInt32 a
|
|||
|
||||
nsString str;
|
||||
|
||||
aTransaction->GetRedoString(&str);
|
||||
nsCOMPtr<nsPIEditorTransaction> txn = do_QueryInterface(aTransaction);
|
||||
|
||||
if (!txn)
|
||||
return aBuffer;
|
||||
|
||||
txn->GetTxnDescription(str);
|
||||
|
||||
if (str.Length() == 0)
|
||||
str.AssignWithConversion("<NULL>");
|
||||
|
|
|
@ -38,8 +38,6 @@ AddStyleSheetTxn::AddStyleSheetTxn()
|
|||
: EditTxn()
|
||||
, mEditor(NULL)
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
AddStyleSheetTxn::~AddStyleSheetTxn()
|
||||
|
@ -63,7 +61,7 @@ AddStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::Do()
|
||||
AddStyleSheetTxn::DoTransaction()
|
||||
{
|
||||
if (!mEditor || !mSheet)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -100,7 +98,7 @@ AddStyleSheetTxn::Do()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::Undo()
|
||||
AddStyleSheetTxn::UndoTransaction()
|
||||
{
|
||||
if (!mEditor || !mSheet)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -136,13 +134,13 @@ AddStyleSheetTxn::Undo()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::Redo()
|
||||
AddStyleSheetTxn::RedoTransaction()
|
||||
{
|
||||
return Do();
|
||||
return DoTransaction();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
AddStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
// set out param default value
|
||||
if (!aDidMerge)
|
||||
|
@ -153,28 +151,9 @@ AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::Write(nsIOutputStream *aOutputStream)
|
||||
AddStyleSheetTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Style Sheet");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (aString)
|
||||
{
|
||||
aString->AssignWithConversion("Add Style Sheet");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("AddStyleSheetTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -187,7 +166,6 @@ RemoveStyleSheetTxn::RemoveStyleSheetTxn()
|
|||
: EditTxn()
|
||||
, mEditor(NULL)
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
}
|
||||
|
||||
RemoveStyleSheetTxn::~RemoveStyleSheetTxn()
|
||||
|
@ -211,7 +189,7 @@ RemoveStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::Do()
|
||||
RemoveStyleSheetTxn::DoTransaction()
|
||||
{
|
||||
if (!mEditor || !mSheet)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -247,7 +225,7 @@ RemoveStyleSheetTxn::Do()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::Undo()
|
||||
RemoveStyleSheetTxn::UndoTransaction()
|
||||
{
|
||||
if (!mEditor || !mSheet)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -283,13 +261,13 @@ RemoveStyleSheetTxn::Undo()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::Redo()
|
||||
RemoveStyleSheetTxn::RedoTransaction()
|
||||
{
|
||||
return Do();
|
||||
return DoTransaction();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
RemoveStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
// set out param default value
|
||||
if (!aDidMerge)
|
||||
|
@ -300,27 +278,8 @@ RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::Write(nsIOutputStream *aOutputStream)
|
||||
RemoveStyleSheetTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (aString)
|
||||
{
|
||||
aString->AssignWithConversion("Add Style Sheet");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Style Sheet");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("RemoveStyleSheetTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -59,21 +59,15 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11240 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -105,21 +99,15 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11250 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -2299,6 +2299,17 @@ nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval)
|
|||
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
|
||||
nsEditorShell::Undo()
|
||||
{
|
||||
|
|
|
@ -26,3 +26,4 @@ nsIEditorSpellCheck.idl
|
|||
nsIDocumentStateListener.idl
|
||||
nsIEditorService.idl
|
||||
nsIEditorController.idl
|
||||
nsPIEditorTransaction.idl
|
||||
|
|
|
@ -35,6 +35,7 @@ XPIDLSRCS = \
|
|||
nsIDocumentStateListener.idl \
|
||||
nsIEditorService.idl \
|
||||
nsIEditorController.idl \
|
||||
nsPIEditorTransaction.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
DEPTH=..\..
|
||||
|
||||
|
||||
MODULE=editor
|
||||
XPIDL_MODULE=editor
|
||||
|
||||
|
@ -33,6 +32,7 @@ XPIDLSRCS = .\nsIEditorShell.idl \
|
|||
.\nsIDocumentStateListener.idl \
|
||||
.\nsIEditorService.idl \
|
||||
.\nsIEditorController.idl \
|
||||
.\nsPIEditorTransaction.idl \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "nsISupportsArray.idl"
|
||||
#include "nsIDocumentStateListener.idl"
|
||||
#include "nsISelectionController.idl"
|
||||
#include "nsITransactionManager.idl"
|
||||
|
||||
%{C++
|
||||
|
||||
|
@ -45,6 +46,7 @@ interface nsIEditorShell : nsISupports
|
|||
readonly attribute nsIDOMDocument editorDocument;
|
||||
readonly attribute nsISelection editorSelection;
|
||||
readonly attribute nsISelectionController selectionController;
|
||||
readonly attribute nsITransactionManager transactionManager;
|
||||
|
||||
attribute nsIDOMWindowInternal webShellWindow;
|
||||
attribute nsIDOMWindowInternal contentWindow;
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
ChangeAttributeTxn::ChangeAttributeTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
ChangeAttributeTxn::~ChangeAttributeTxn()
|
||||
|
@ -54,7 +52,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Do(void)
|
||||
NS_IMETHODIMP ChangeAttributeTxn::DoTransaction(void)
|
||||
{
|
||||
NS_ASSERTION(mEditor && mElement, "bad state");
|
||||
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
|
@ -75,7 +73,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Undo(void)
|
||||
NS_IMETHODIMP ChangeAttributeTxn::UndoTransaction(void)
|
||||
{
|
||||
NS_ASSERTION(mEditor && mElement, "bad state");
|
||||
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
|
@ -89,7 +87,7 @@ NS_IMETHODIMP ChangeAttributeTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Redo(void)
|
||||
NS_IMETHODIMP ChangeAttributeTxn::RedoTransaction(void)
|
||||
{
|
||||
NS_ASSERTION(mEditor && mElement, "bad state");
|
||||
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
|
@ -104,40 +102,21 @@ NS_IMETHODIMP ChangeAttributeTxn::Redo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP ChangeAttributeTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("ChangeAttributeTxn: "));
|
||||
|
||||
NS_IMETHODIMP ChangeAttributeTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
if (PR_FALSE==mRemoveAttribute)
|
||||
aString->AssignWithConversion("Change Attribute: ");
|
||||
aString += NS_LITERAL_STRING("[mRemoveAttribute == false] ");
|
||||
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;
|
||||
}
|
||||
aString += NS_LITERAL_STRING("[mRemoveAttribute == true] ");
|
||||
aString += mAttribute;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -63,21 +63,15 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11180 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
CreateElementTxn::CreateElementTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor,
|
||||
|
@ -72,7 +70,7 @@ CreateElementTxn::~CreateElementTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Do(void)
|
||||
NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy)
|
||||
{
|
||||
|
@ -170,7 +168,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Undo(void)
|
||||
NS_IMETHODIMP CreateElementTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Undo Create Element, mParent = %p, node = %p\n",
|
||||
mParent.get(), mNewNode.get()); }
|
||||
|
@ -182,7 +180,7 @@ NS_IMETHODIMP CreateElementTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Redo(void)
|
||||
NS_IMETHODIMP CreateElementTxn::RedoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Redo Create Element\n"); }
|
||||
NS_ASSERTION(mEditor && mParent, "bad state");
|
||||
|
@ -203,35 +201,17 @@ NS_IMETHODIMP CreateElementTxn::Redo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP CreateElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP CreateElementTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Element: ");
|
||||
*aString += mTag;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CreateElementTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Create Element: ");
|
||||
*aString += mTag;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("CreateElementTxn: "));
|
||||
aString += mTag;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,24 +63,18 @@ public:
|
|||
|
||||
virtual ~CreateElementTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
|
||||
|
||||
enum { kTransactionID = 11140 };
|
||||
|
||||
protected:
|
||||
|
||||
/** the document into which the new node will be inserted */
|
||||
|
|
|
@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
DeleteElementTxn::DeleteElementTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Init(nsIDOMNode *aElement)
|
||||
|
@ -54,7 +52,7 @@ DeleteElementTxn::~DeleteElementTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Do(void)
|
||||
NS_IMETHODIMP DeleteElementTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Do Delete Element element = %p\n", this, mElement.get()); }
|
||||
if (!mElement) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -96,7 +94,7 @@ NS_IMETHODIMP DeleteElementTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Undo(void)
|
||||
NS_IMETHODIMP DeleteElementTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Undo Delete Element element = %p, parent = %p\n", this, mElement.get(), mParent.get()); }
|
||||
if (!mParent) { return NS_OK; } // this is a legal state, the txn is a no-op
|
||||
|
@ -132,7 +130,7 @@ NS_IMETHODIMP DeleteElementTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Redo(void)
|
||||
NS_IMETHODIMP DeleteElementTxn::RedoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Redo Delete Element element = %p, parent = %p\n", this, mElement.get(), mParent.get()); }
|
||||
if (!mParent) { return NS_OK; } // this is a legal state, the txn is a no-op
|
||||
|
@ -144,32 +142,15 @@ NS_IMETHODIMP DeleteElementTxn::Redo(void)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP DeleteElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP DeleteElementTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Element: ");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteElementTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Element: ");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("DeleteElementTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -53,21 +53,15 @@ public:
|
|||
|
||||
virtual ~DeleteElementTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11160 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -47,8 +47,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
DeleteRangeTxn::DeleteRangeTxn()
|
||||
: EditAggregateTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Init(nsIEditor *aEditor, nsIDOMRange *aRange)
|
||||
|
@ -112,7 +110,7 @@ DeleteRangeTxn::~DeleteRangeTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Do(void)
|
||||
NS_IMETHODIMP DeleteRangeTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Do Delete Range\n"); }
|
||||
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor)
|
||||
|
@ -143,7 +141,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
|
|||
|
||||
// if we've successfully built this aggregate transaction, then do it.
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = EditAggregateTxn::Do();
|
||||
result = EditAggregateTxn::DoTransaction();
|
||||
}
|
||||
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
@ -167,53 +165,36 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Undo(void)
|
||||
NS_IMETHODIMP DeleteRangeTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Undo Delete Range\n"); }
|
||||
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult result = EditAggregateTxn::Undo();
|
||||
nsresult result = EditAggregateTxn::UndoTransaction();
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Redo(void)
|
||||
NS_IMETHODIMP DeleteRangeTxn::RedoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Redo Delete Range\n"); }
|
||||
if (!mStartParent || !mEndParent || !mCommonParent || !mEditor)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult result = EditAggregateTxn::Redo();
|
||||
nsresult result = EditAggregateTxn::RedoTransaction();
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP DeleteRangeTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP DeleteRangeTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Range: ");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteRangeTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Range: ");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("DeleteRangeTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,21 +61,15 @@ public:
|
|||
|
||||
virtual ~DeleteRangeTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11170 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
DeleteTextTxn::DeleteTextTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
DeleteTextTxn::~DeleteTextTxn()
|
||||
|
@ -62,7 +60,7 @@ NS_IMETHODIMP DeleteTextTxn::Init(nsIEditor *aEditor,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteTextTxn::Do(void)
|
||||
NS_IMETHODIMP DeleteTextTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Do Delete Text\n"); }
|
||||
NS_ASSERTION(mEditor && mElement, "bad state");
|
||||
|
@ -94,7 +92,7 @@ NS_IMETHODIMP DeleteTextTxn::Do(void)
|
|||
|
||||
//XXX: we may want to store the selection state and restore it properly
|
||||
// was it an insertion point or an extended selection?
|
||||
NS_IMETHODIMP DeleteTextTxn::Undo(void)
|
||||
NS_IMETHODIMP DeleteTextTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Undo Delete Text\n"); }
|
||||
NS_ASSERTION(mEditor && mElement, "bad state");
|
||||
|
@ -105,34 +103,16 @@ NS_IMETHODIMP DeleteTextTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP DeleteTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteTextTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP DeleteTextTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteTextTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Text: ");
|
||||
*aString += mDeletedText;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeleteTextTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Text: ");
|
||||
*aString += mDeletedText;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("DeleteTextTxn: "));
|
||||
aString += mDeletedText;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -59,19 +59,13 @@ private:
|
|||
public:
|
||||
virtual ~DeleteTextTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11130 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@ EditAggregateTxn::EditAggregateTxn()
|
|||
// base class does this: NS_INIT_REFCNT();
|
||||
nsresult res = NS_NewISupportsArray(getter_AddRefs(mChildren));
|
||||
NS_POSTCONDITION(NS_SUCCEEDED(res), "EditAggregateTxn failed in constructor");
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
EditAggregateTxn::~EditAggregateTxn()
|
||||
|
@ -40,7 +38,7 @@ EditAggregateTxn::~EditAggregateTxn()
|
|||
// nsISupportsArray cleans up array for us at destruct time
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::Do(void)
|
||||
NS_IMETHODIMP EditAggregateTxn::DoTransaction(void)
|
||||
{
|
||||
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
|
||||
if (mChildren)
|
||||
|
@ -53,7 +51,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void)
|
|||
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
|
||||
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
|
||||
if (!txn) { return NS_ERROR_NULL_POINTER; }
|
||||
result = txn->Do();
|
||||
result = txn->DoTransaction();
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
|
@ -61,7 +59,7 @@ NS_IMETHODIMP EditAggregateTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::Undo(void)
|
||||
NS_IMETHODIMP EditAggregateTxn::UndoTransaction(void)
|
||||
{
|
||||
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
|
||||
if (mChildren)
|
||||
|
@ -75,7 +73,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void)
|
|||
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
|
||||
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
|
||||
if (!txn) { return NS_ERROR_NULL_POINTER; }
|
||||
result = txn->Undo();
|
||||
result = txn->UndoTransaction();
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
|
@ -83,7 +81,7 @@ NS_IMETHODIMP EditAggregateTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::Redo(void)
|
||||
NS_IMETHODIMP EditAggregateTxn::RedoTransaction(void)
|
||||
{
|
||||
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
|
||||
if (mChildren)
|
||||
|
@ -96,7 +94,7 @@ NS_IMETHODIMP EditAggregateTxn::Redo(void)
|
|||
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
|
||||
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
|
||||
if (!txn) { return NS_ERROR_NULL_POINTER; }
|
||||
result = txn->Redo();
|
||||
result = txn->RedoTransaction();
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
|
@ -111,7 +109,7 @@ NS_IMETHODIMP EditAggregateTxn::GetIsTransient(PRBool *aIsTransient)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP EditAggregateTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
nsresult result=NS_OK; // it's legal (but not very useful) to have an empty child list
|
||||
if (nsnull!=aDidMerge)
|
||||
|
@ -127,29 +125,24 @@ NS_IMETHODIMP EditAggregateTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransa
|
|||
nsCOMPtr<nsISupports> isupports = dont_AddRef(mChildren->ElementAt(i));
|
||||
nsCOMPtr<nsITransaction> txn ( do_QueryInterface(isupports) );
|
||||
if (!txn) { return NS_ERROR_NULL_POINTER; }
|
||||
result = txn->Merge(aDidMerge, aTransaction);
|
||||
result = txn->Merge(aTransaction, aDidMerge);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP EditAggregateTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("EditAggregateTxn: "));
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
aString->SetLength(0);
|
||||
return NS_OK;
|
||||
}
|
||||
if (mName)
|
||||
{
|
||||
nsAutoString name;
|
||||
mName->ToString(name);
|
||||
aString += name;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
aString->SetLength(0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,21 +50,17 @@ public:
|
|||
|
||||
virtual ~EditAggregateTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD GetIsTransient(PRBool *aIsTransient);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
/** append a transaction to this aggregate */
|
||||
NS_IMETHOD AppendChild(EditTxn *aTxn);
|
||||
|
@ -85,8 +81,6 @@ public:
|
|||
/** get the name assigned to this txn */
|
||||
NS_IMETHOD GetName(nsIAtom **aName);
|
||||
|
||||
enum { kTransactionID = 11210 };
|
||||
|
||||
protected:
|
||||
|
||||
nsCOMPtr<nsISupportsArray> mChildren;
|
||||
|
|
|
@ -34,7 +34,6 @@ NS_IMPL_RELEASE(EditTxn)
|
|||
|
||||
// note that aEditor is not refcounted
|
||||
EditTxn::EditTxn()
|
||||
: mTransactionID(-1)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -43,19 +42,19 @@ EditTxn::~EditTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::Do(void)
|
||||
NS_IMETHODIMP EditTxn::DoTransaction(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::Undo(void)
|
||||
NS_IMETHODIMP EditTxn::UndoTransaction(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::Redo(void)
|
||||
NS_IMETHODIMP EditTxn::RedoTransaction(void)
|
||||
{
|
||||
return Do();
|
||||
return DoTransaction();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient)
|
||||
|
@ -65,53 +64,14 @@ NS_IMETHODIMP EditTxn::GetIsTransient(PRBool *aIsTransient)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP EditTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP EditTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
aString->SetLength(0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
aString->SetLength(0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::GetLogDescription(PRUnichar * *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
*aString = mLogDescription.ToNewUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::SetLogDescription(const PRUnichar *aString)
|
||||
{
|
||||
mLogDescription = (PRUnichar *)aString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::GetTransactionDescriptionID(int *aID)
|
||||
{
|
||||
if (nsnull!=aID)
|
||||
*aID = mTransactionID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EditTxn::SetTransactionDescriptionID(int aID)
|
||||
{
|
||||
mTransactionID = aID;
|
||||
aString.Assign(NS_LITERAL_STRING("EditTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -133,12 +93,13 @@ EditTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsITransactionDescription))) {
|
||||
*aInstancePtr = (void*)(nsITransactionDescription*)this;
|
||||
if (aIID.Equals(NS_GET_IID(nsPIEditorTransaction))) {
|
||||
*aInstancePtr = (void*)(nsPIEditorTransaction*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
*aInstancePtr = 0;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,10 @@
|
|||
#define EditTxn_h__
|
||||
|
||||
#include "nsITransaction.h"
|
||||
#include "nsITransactionDescription.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsPIEditorTransaction.h"
|
||||
|
||||
#define EDIT_TXN_CID \
|
||||
{/* c5ea31b0-ac48-11d2-86d8-000064657374 */ \
|
||||
|
@ -39,7 +41,7 @@
|
|||
* it is never seen by the user or by any external entity.
|
||||
*/
|
||||
class EditTxn : public nsITransaction
|
||||
, public nsITransactionDescription
|
||||
, public nsPIEditorTransaction
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -51,27 +53,17 @@ public:
|
|||
virtual ~EditTxn();
|
||||
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD GetIsTransient(PRBool *aIsTransient);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11100 };
|
||||
|
||||
NS_DECL_NSITRANSACTIONDESCRIPTION
|
||||
nsString mLogDescription;
|
||||
int mTransactionID;
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -54,8 +54,6 @@ nsresult IMETextTxn::ClassShutdown()
|
|||
IMETextTxn::IMETextTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
IMETextTxn::~IMETextTxn()
|
||||
|
@ -84,7 +82,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::Do(void)
|
||||
NS_IMETHODIMP IMETextTxn::DoTransaction(void)
|
||||
{
|
||||
|
||||
#ifdef DEBUG_IMETXN
|
||||
|
@ -108,7 +106,7 @@ NS_IMETHODIMP IMETextTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::Undo(void)
|
||||
NS_IMETHODIMP IMETextTxn::UndoTransaction(void)
|
||||
{
|
||||
#ifdef DEBUG_IMETXN
|
||||
printf("Undo IME Text element = %p\n", mElement.get());
|
||||
|
@ -132,7 +130,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP IMETextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
NS_ASSERTION(aDidMerge, "illegal vaule- null ptr- aDidMerge");
|
||||
NS_ASSERTION(aTransaction, "illegal vaule- null ptr- aTransaction");
|
||||
|
@ -185,45 +183,16 @@ NS_IMETHODIMP IMETextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::Write(nsIOutputStream *aOutputStream)
|
||||
{
|
||||
NS_ASSERTION(aOutputStream, "illegal value- null ptr- aOutputStream");
|
||||
if(nsnull == aOutputStream)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::MarkFixed(void)
|
||||
{
|
||||
mFixed = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::GetUndoString(nsString *aString)
|
||||
NS_IMETHODIMP IMETextTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
NS_ASSERTION(aString, "illegal value- null ptr- aString");
|
||||
if(nsnull == aString)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Text: ");
|
||||
*aString += mStringToInsert;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
NS_ASSERTION(aString, "illegal value- null ptr- aString");
|
||||
if(nsnull == aString)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Text: ");
|
||||
*aString += mStringToInsert;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("IMETextTxn: "));
|
||||
aString += mStringToInsert;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,17 +74,13 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
NS_IMETHOD MarkFixed(void);
|
||||
|
||||
|
@ -102,8 +98,6 @@ public:
|
|||
/** must be called once we are guaranteed all IMETextTxn have completed */
|
||||
static nsresult ClassShutdown();
|
||||
|
||||
enum { kTransactionID = 11220 };
|
||||
|
||||
protected:
|
||||
|
||||
NS_IMETHOD CollapseTextSelection(void);
|
||||
|
|
|
@ -35,8 +35,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
InsertElementTxn::InsertElementTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::Init(nsIDOMNode *aNode,
|
||||
|
@ -62,7 +60,7 @@ InsertElementTxn::~InsertElementTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::Do(void)
|
||||
NS_IMETHODIMP InsertElementTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy)
|
||||
{
|
||||
|
@ -119,7 +117,7 @@ NS_IMETHODIMP InsertElementTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::Undo(void)
|
||||
NS_IMETHODIMP InsertElementTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Undo Insert Element of %p into parent %p at offset %d\n",
|
||||
this, mNode.get(), mParent.get(), mOffset); }
|
||||
|
@ -130,32 +128,15 @@ NS_IMETHODIMP InsertElementTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP InsertElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP InsertElementTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Element: ");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertElementTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Element: ");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("InsertElementTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -59,19 +59,13 @@ public:
|
|||
|
||||
virtual ~InsertElementTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11150 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -52,8 +52,6 @@ nsresult InsertTextTxn::ClassShutdown()
|
|||
InsertTextTxn::InsertTextTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
InsertTextTxn::~InsertTextTxn()
|
||||
|
@ -83,7 +81,7 @@ NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::Do(void)
|
||||
NS_IMETHODIMP InsertTextTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Do Insert Text element = %p\n", mElement.get()); }
|
||||
NS_ASSERTION(mElement && mEditor, "bad state");
|
||||
|
@ -112,7 +110,7 @@ NS_IMETHODIMP InsertTextTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::Undo(void)
|
||||
NS_IMETHODIMP InsertTextTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("Undo Insert Text element = %p\n", mElement.get()); }
|
||||
NS_ASSERTION(mElement && mEditor, "bad state");
|
||||
|
@ -124,7 +122,7 @@ NS_IMETHODIMP InsertTextTxn::Undo(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP InsertTextTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
// set out param default value
|
||||
if (nsnull!=aDidMerge)
|
||||
|
@ -192,28 +190,10 @@ NS_IMETHODIMP InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransacti
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP InsertTextTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Text: ");
|
||||
*aString += mStringToInsert;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Insert Text: ");
|
||||
*aString += mStringToInsert;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("InsertTextTxn: "));
|
||||
aString += mStringToInsert;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,17 +68,13 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
// nsISupports declarations
|
||||
|
||||
|
@ -94,8 +90,6 @@ public:
|
|||
/** must be called once we are guaranteed all InsertTextTxn have completed */
|
||||
static nsresult ClassShutdown();
|
||||
|
||||
enum { kTransactionID = 11120 };
|
||||
|
||||
protected:
|
||||
|
||||
/** return PR_TRUE if aOtherTxn immediately follows this txn */
|
||||
|
|
|
@ -34,8 +34,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
JoinElementTxn::JoinElementTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinElementTxn::Init(nsEditor *aEditor,
|
||||
|
@ -55,8 +53,8 @@ JoinElementTxn::~JoinElementTxn()
|
|||
{
|
||||
}
|
||||
|
||||
// After Do() and Redo(), the left node is removed from the content tree and right node remains.
|
||||
NS_IMETHODIMP JoinElementTxn::Do(void)
|
||||
// After DoTransaction() and RedoTransaction(), the left node is removed from the content tree and right node remains.
|
||||
NS_IMETHODIMP JoinElementTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Do Join of %p and %p\n", this, mLeftNode.get(), mRightNode.get()); }
|
||||
NS_PRECONDITION((mEditor && mLeftNode && mRightNode), "null arg");
|
||||
|
@ -110,7 +108,7 @@ NS_IMETHODIMP JoinElementTxn::Do(void)
|
|||
|
||||
//XXX: what if instead of split, we just deleted the unneeded children of mRight
|
||||
// and re-inserted mLeft?
|
||||
NS_IMETHODIMP JoinElementTxn::Undo(void)
|
||||
NS_IMETHODIMP JoinElementTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Undo Join, right node = %p\n", this, mRightNode.get()); }
|
||||
NS_ASSERTION(mRightNode && mLeftNode && mParent, "bad state");
|
||||
|
@ -152,32 +150,15 @@ NS_IMETHODIMP JoinElementTxn::GetIsTransient(PRBool *aIsTransient)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult JoinElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
nsresult JoinElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinElementTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP JoinElementTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinElementTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Join Element");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinElementTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Split Element");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("JoinElementTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ class nsEditor;
|
|||
* A transaction that joins two elements E1 (left node) and E2 (right node)
|
||||
* into a single node E.
|
||||
* The children of E are the children of E1 followed by the children of E2.
|
||||
* After Do() and Redo(), E1 is removed from the content tree and E2 remains.
|
||||
* After DoTransaction() and RedoTransaction(), E1 is removed from the content
|
||||
* tree and E2 remains.
|
||||
*/
|
||||
class JoinElementTxn : public EditTxn
|
||||
{
|
||||
|
@ -62,23 +63,17 @@ public:
|
|||
|
||||
virtual ~JoinElementTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
// NS_IMETHOD Redo(void);
|
||||
// NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD GetIsTransient(PRBool *aIsTransient);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11200 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -43,8 +43,6 @@ PlaceholderTxn::PlaceholderTxn() : EditAggregateTxn(),
|
|||
mEndSel(),
|
||||
mEditor(nsnull)
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,16 +82,16 @@ NS_IMETHODIMP PlaceholderTxn::Init(nsIAtom *aName, nsSelectionState *aSelState,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::Do(void)
|
||||
NS_IMETHODIMP PlaceholderTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("PlaceholderTxn Do\n"); }
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::Undo(void)
|
||||
NS_IMETHODIMP PlaceholderTxn::UndoTransaction(void)
|
||||
{
|
||||
// undo txns
|
||||
nsresult res = EditAggregateTxn::Undo();
|
||||
nsresult res = EditAggregateTxn::UndoTransaction();
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// now restore selection
|
||||
|
@ -107,10 +105,10 @@ NS_IMETHODIMP PlaceholderTxn::Undo(void)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::Redo(void)
|
||||
NS_IMETHODIMP PlaceholderTxn::RedoTransaction(void)
|
||||
{
|
||||
// redo txns
|
||||
nsresult res = EditAggregateTxn::Redo();
|
||||
nsresult res = EditAggregateTxn::RedoTransaction();
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// now restore selection
|
||||
|
@ -123,7 +121,7 @@ NS_IMETHODIMP PlaceholderTxn::Redo(void)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP PlaceholderTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (!aDidMerge || !aTransaction) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
|
@ -155,7 +153,7 @@ NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransact
|
|||
else
|
||||
{
|
||||
PRBool didMerge;
|
||||
mIMETextTxn->Merge(&didMerge, otherTxn);
|
||||
mIMETextTxn->Merge(otherTxn, &didMerge);
|
||||
if (!didMerge)
|
||||
{
|
||||
// it wouldn't merge. Earlier IME txn is already commited and will
|
||||
|
@ -218,6 +216,20 @@ NS_IMETHODIMP PlaceholderTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransact
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
aString.Assign(NS_LITERAL_STRING("PlaceholderTxn: "));
|
||||
|
||||
if (mName)
|
||||
{
|
||||
nsAutoString name;
|
||||
mName->ToString(name);
|
||||
aString += name;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::GetTxnName(nsIAtom **aName)
|
||||
{
|
||||
return GetName(aName);
|
||||
|
|
|
@ -65,13 +65,15 @@ public:
|
|||
|
||||
// ------------ EditAggregateTxn -----------------------
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
// ------------ nsIAbsorbingTransaction -----------------------
|
||||
|
||||
|
@ -91,8 +93,6 @@ public:
|
|||
|
||||
friend class TransactionFactory;
|
||||
|
||||
enum { kTransactionID = 11260 };
|
||||
|
||||
protected:
|
||||
|
||||
/** the presentation shell, which we'll need to get the selection */
|
||||
|
@ -103,7 +103,8 @@ protected:
|
|||
PRBool mCommitted; // do we stop auto absorbing any matching placeholder txns?
|
||||
// these next two members store the state of the selection in a safe way.
|
||||
// selection at the start of the txn is stored, as is the selection at the end.
|
||||
// This is so that Undo() and Redo() can restore the selection properly.
|
||||
// This is so that UndoTransaction() and RedoTransaction() can restore the
|
||||
// selection properly.
|
||||
nsSelectionState *mStartSel; // use a pointer because this is constructed before we exist
|
||||
nsSelectionState mEndSel;
|
||||
nsIEditor* mEditor; /** the editor for this transaction */
|
||||
|
|
|
@ -36,8 +36,6 @@ SetDocTitleTxn::SetDocTitleTxn()
|
|||
: EditTxn()
|
||||
, mIsTransient(PR_FALSE)
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor,
|
||||
|
@ -57,7 +55,7 @@ SetDocTitleTxn::~SetDocTitleTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Do(void)
|
||||
NS_IMETHODIMP SetDocTitleTxn::DoTransaction(void)
|
||||
{
|
||||
nsresult res = SetDomTitle(mValue);
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
@ -65,12 +63,12 @@ NS_IMETHODIMP SetDocTitleTxn::Do(void)
|
|||
return SetDocTitle(mValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Undo(void)
|
||||
NS_IMETHODIMP SetDocTitleTxn::UndoTransaction(void)
|
||||
{
|
||||
return SetDocTitle(mUndoValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Redo(void)
|
||||
NS_IMETHODIMP SetDocTitleTxn::RedoTransaction(void)
|
||||
{
|
||||
return SetDocTitle(mValue);
|
||||
}
|
||||
|
@ -208,35 +206,17 @@ nsresult SetDocTitleTxn::SetDomTitle(nsString& aTitle)
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP SetDocTitleTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP SetDocTitleTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Restore Document Title: ");
|
||||
*aString += mUndoValue;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Set Document Title: ");
|
||||
*aString += mValue;
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("SetDocTitleTxn: "));
|
||||
aString += mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
#include "nsITransaction.h"
|
||||
#include "nsITransactionDescription.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define SET_DOC_TITLE_TXN_CID \
|
||||
|
@ -61,23 +60,17 @@ private:
|
|||
nsresult SetDomTitle(nsString& aTitle);
|
||||
|
||||
public:
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD GetIsTransient(PRBool *aIsTransient);
|
||||
|
||||
enum { kTransactionID = 11270 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -37,8 +37,6 @@ static const PRBool gNoisy = PR_FALSE;
|
|||
SplitElementTxn::SplitElementTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::Init(nsEditor *aEditor,
|
||||
|
@ -58,7 +56,7 @@ SplitElementTxn::~SplitElementTxn()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::Do(void)
|
||||
NS_IMETHODIMP SplitElementTxn::DoTransaction(void)
|
||||
{
|
||||
if (gNoisy) { printf("%p Do Split of node %p offset %d\n", this, mExistingRightNode.get(), mOffset); }
|
||||
NS_ASSERTION(mExistingRightNode && mEditor, "bad state");
|
||||
|
@ -94,7 +92,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::Undo(void)
|
||||
NS_IMETHODIMP SplitElementTxn::UndoTransaction(void)
|
||||
{
|
||||
if (gNoisy) {
|
||||
printf("%p Undo Split of existing node %p and new node %p offset %d\n",
|
||||
|
@ -122,7 +120,7 @@ NS_IMETHODIMP SplitElementTxn::Undo(void)
|
|||
/* redo cannot simply resplit the right node, because subsequent transactions
|
||||
* on the redo stack may depend on the left node existing in its previous state.
|
||||
*/
|
||||
NS_IMETHODIMP SplitElementTxn::Redo(void)
|
||||
NS_IMETHODIMP SplitElementTxn::RedoTransaction(void)
|
||||
{
|
||||
NS_ASSERTION(mEditor && mExistingRightNode && mNewLeftNode && mParent, "bad state");
|
||||
if (!mEditor || !mExistingRightNode || !mNewLeftNode || !mParent) {
|
||||
|
@ -182,33 +180,16 @@ NS_IMETHODIMP SplitElementTxn::Redo(void)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
NS_IMETHODIMP SplitElementTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP SplitElementTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Join Element");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP SplitElementTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
aString->AssignWithConversion("Split Element");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("SplitElementTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,24 +61,18 @@ protected:
|
|||
public:
|
||||
virtual ~SplitElementTxn();
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
|
||||
|
||||
enum { kTransactionID = 11190 };
|
||||
|
||||
protected:
|
||||
|
||||
/** the element to operate upon */
|
||||
|
|
|
@ -423,10 +423,10 @@ nsEditor::Do(nsITransaction *aTxn)
|
|||
|
||||
selPrivate->StartBatchChanges();
|
||||
if (mTxnMgr) {
|
||||
result = mTxnMgr->Do(aTxn);
|
||||
result = mTxnMgr->DoTransaction(aTxn);
|
||||
}
|
||||
else {
|
||||
result = aTxn->Do();
|
||||
result = aTxn->DoTransaction();
|
||||
}
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = DoAfterDoTransaction(aTxn);
|
||||
|
@ -500,7 +500,7 @@ nsEditor::Undo(PRUint32 aCount)
|
|||
PRUint32 i=0;
|
||||
for ( ; i<aCount; i++)
|
||||
{
|
||||
result = mTxnMgr->Undo();
|
||||
result = mTxnMgr->UndoTransaction();
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
result = DoAfterUndoTransaction();
|
||||
|
@ -544,7 +544,7 @@ nsEditor::Redo(PRUint32 aCount)
|
|||
PRUint32 i=0;
|
||||
for ( ; i<aCount; i++)
|
||||
{
|
||||
result = mTxnMgr->Redo();
|
||||
result = mTxnMgr->RedoTransaction();
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
result = DoAfterRedoTransaction();
|
||||
|
@ -1015,7 +1015,7 @@ NS_IMETHODIMP nsEditor::CreateNode(const nsString& aTag,
|
|||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
result = txn->GetNewNode(aNewNode);
|
||||
NS_ASSERTION((NS_SUCCEEDED(result)), "GetNewNode can't fail if txn::Do succeeded.");
|
||||
NS_ASSERTION((NS_SUCCEEDED(result)), "GetNewNode can't fail if txn::DoTransaction succeeded.");
|
||||
}
|
||||
}
|
||||
// The transaction system (if any) has taken ownwership of txn
|
||||
|
@ -1771,9 +1771,8 @@ nsEditor::EndComposition(void)
|
|||
// Note that this means IME won't work without an undo stack!
|
||||
if (mTxnMgr)
|
||||
{
|
||||
nsITransaction *txn;
|
||||
result = mTxnMgr->PeekUndoStack(&txn);
|
||||
// PeekUndoStack does not addref
|
||||
nsCOMPtr<nsITransaction> txn;
|
||||
result = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));
|
||||
nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryInterface(txn);
|
||||
if (plcTxn)
|
||||
{
|
||||
|
|
|
@ -38,8 +38,6 @@ AddStyleSheetTxn::AddStyleSheetTxn()
|
|||
: EditTxn()
|
||||
, mEditor(NULL)
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
/* log description initialized in parent constructor */
|
||||
}
|
||||
|
||||
AddStyleSheetTxn::~AddStyleSheetTxn()
|
||||
|
@ -63,7 +61,7 @@ AddStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::Do()
|
||||
AddStyleSheetTxn::DoTransaction()
|
||||
{
|
||||
if (!mEditor || !mSheet)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -100,7 +98,7 @@ AddStyleSheetTxn::Do()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::Undo()
|
||||
AddStyleSheetTxn::UndoTransaction()
|
||||
{
|
||||
if (!mEditor || !mSheet)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -136,13 +134,13 @@ AddStyleSheetTxn::Undo()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::Redo()
|
||||
AddStyleSheetTxn::RedoTransaction()
|
||||
{
|
||||
return Do();
|
||||
return DoTransaction();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
AddStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
// set out param default value
|
||||
if (!aDidMerge)
|
||||
|
@ -153,28 +151,9 @@ AddStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::Write(nsIOutputStream *aOutputStream)
|
||||
AddStyleSheetTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Style Sheet");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (aString)
|
||||
{
|
||||
aString->AssignWithConversion("Add Style Sheet");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("AddStyleSheetTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -187,7 +166,6 @@ RemoveStyleSheetTxn::RemoveStyleSheetTxn()
|
|||
: EditTxn()
|
||||
, mEditor(NULL)
|
||||
{
|
||||
SetTransactionDescriptionID( kTransactionID );
|
||||
}
|
||||
|
||||
RemoveStyleSheetTxn::~RemoveStyleSheetTxn()
|
||||
|
@ -211,7 +189,7 @@ RemoveStyleSheetTxn::Init(nsIEditor *aEditor, nsICSSStyleSheet *aSheet)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::Do()
|
||||
RemoveStyleSheetTxn::DoTransaction()
|
||||
{
|
||||
if (!mEditor || !mSheet)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -247,7 +225,7 @@ RemoveStyleSheetTxn::Do()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::Undo()
|
||||
RemoveStyleSheetTxn::UndoTransaction()
|
||||
{
|
||||
if (!mEditor || !mSheet)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -283,13 +261,13 @@ RemoveStyleSheetTxn::Undo()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::Redo()
|
||||
RemoveStyleSheetTxn::RedoTransaction()
|
||||
{
|
||||
return Do();
|
||||
return DoTransaction();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
RemoveStyleSheetTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
// set out param default value
|
||||
if (!aDidMerge)
|
||||
|
@ -300,27 +278,8 @@ RemoveStyleSheetTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::Write(nsIOutputStream *aOutputStream)
|
||||
RemoveStyleSheetTxn::GetTxnDescription(nsAWritableString& aString)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (aString)
|
||||
{
|
||||
aString->AssignWithConversion("Add Style Sheet");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (aString)
|
||||
{
|
||||
aString->AssignWithConversion("Remove Style Sheet");
|
||||
}
|
||||
aString.Assign(NS_LITERAL_STRING("RemoveStyleSheetTxn"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -59,21 +59,15 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11240 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -105,21 +99,15 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
NS_IMETHOD DoTransaction(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD UndoTransaction(void);
|
||||
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD RedoTransaction(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
enum { kTransactionID = 11250 };
|
||||
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <stdio.h>
|
||||
#include "nsHTMLEditorLog.h"
|
||||
#include "nsEditorTxnLog.h"
|
||||
#include "nsPIEditorTransaction.h"
|
||||
|
||||
#define LOCK_LOG(doc)
|
||||
#define UNLOCK_LOG(doc)
|
||||
|
@ -361,7 +362,12 @@ nsEditorTxnLog::GetString(nsITransaction *aTransaction, char *aBuffer, PRInt32 a
|
|||
|
||||
nsString str;
|
||||
|
||||
aTransaction->GetRedoString(&str);
|
||||
nsCOMPtr<nsPIEditorTransaction> txn = do_QueryInterface(aTransaction);
|
||||
|
||||
if (!txn)
|
||||
return aBuffer;
|
||||
|
||||
txn->GetTxnDescription(str);
|
||||
|
||||
if (str.Length() == 0)
|
||||
str.AssignWithConversion("<NULL>");
|
||||
|
|
|
@ -25,7 +25,7 @@ DEPTH=..
|
|||
!if defined(DISABLE_EDITOR)
|
||||
DIRS= public idl
|
||||
!else
|
||||
DIRS= public idl base txmgr ui txtsvc
|
||||
DIRS= txmgr public idl base ui txtsvc
|
||||
!endif
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -20,4 +20,7 @@
|
|||
# Contributor(s):
|
||||
#
|
||||
|
||||
nsITransactionDescription.idl
|
||||
nsITransaction.idl
|
||||
nsITransactionList.idl
|
||||
nsITransactionListener.idl
|
||||
nsITransactionManager.idl
|
||||
|
|
|
@ -30,7 +30,10 @@ include $(DEPTH)/config/autoconf.mk
|
|||
MODULE = txmgr
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsITransactionDescription.idl \
|
||||
nsITransaction.idl \
|
||||
nsITransactionList.idl \
|
||||
nsITransactionListener.idl \
|
||||
nsITransactionManager.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -26,7 +26,10 @@ MODULE=txmgr
|
|||
XPIDL_MODULE=txmgr
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsITransactionDescription.idl \
|
||||
.\nsITransaction.idl \
|
||||
.\nsITransactionList.idl \
|
||||
.\nsITransactionListener.idl \
|
||||
.\nsITransactionManager.idl \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "nsITransaction.idl"
|
||||
#include "nsITransactionList.idl"
|
||||
#include "nsITransactionListener.idl"
|
||||
#include "nsIOutputStream.idl"
|
||||
|
||||
%{ C++
|
||||
|
||||
|
@ -138,14 +137,6 @@ interface nsITransactionManager : nsISupports
|
|||
*/
|
||||
nsITransactionList getRedoList();
|
||||
|
||||
/**
|
||||
* Writes a stream representation of the transaction manager and it's
|
||||
* execution stacks. Calls the Write() method of each transaction on the
|
||||
* execution stacks.
|
||||
* @param aOutputStream the stream to write to.
|
||||
*/
|
||||
void Write(in nsIOutputStream aOutputStream);
|
||||
|
||||
/**
|
||||
* Adds a listener to the transaction manager's notification list. Listeners
|
||||
* are notified whenever a transaction is done, undone, or redone.
|
||||
|
|
|
@ -2,7 +2,4 @@
|
|||
# This is a list of local files which get copied to the mozilla:dist:editor directory
|
||||
#
|
||||
|
||||
nsITransaction.h
|
||||
nsITransactionListener.h
|
||||
nsITransactionManager.h
|
||||
nsTransactionManagerCID.h
|
||||
|
|
|
@ -29,9 +29,6 @@ include $(DEPTH)/config/autoconf.mk
|
|||
MODULE = txmgr
|
||||
|
||||
EXPORTS = \
|
||||
nsITransaction.h \
|
||||
nsITransactionListener.h \
|
||||
nsITransactionManager.h \
|
||||
nsTransactionManagerCID.h \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -23,9 +23,6 @@ DEPTH=..\..\..
|
|||
|
||||
|
||||
EXPORTS = \
|
||||
nsITransaction.h \
|
||||
nsITransactionListener.h \
|
||||
nsITransactionManager.h \
|
||||
nsTransactionManagerCID.h \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ REQUIRES = xpcom string editor
|
|||
|
||||
CPPSRCS = \
|
||||
nsTransactionItem.cpp \
|
||||
nsTransactionList.cpp \
|
||||
nsTransactionManager.cpp \
|
||||
nsTransactionManagerFactory.cpp \
|
||||
nsTransactionStack.cpp \
|
||||
|
|
|
@ -26,6 +26,7 @@ LIBRARY_NAME=txmgr
|
|||
|
||||
CPPSRCS = \
|
||||
nsTransactionItem.cpp \
|
||||
nsTransactionList.cpp \
|
||||
nsTransactionManager.cpp \
|
||||
nsTransactionManagerFactory.cpp \
|
||||
nsTransactionStack.cpp \
|
||||
|
@ -33,6 +34,7 @@ CPPSRCS = \
|
|||
|
||||
CPP_OBJS = \
|
||||
.\$(OBJDIR)\nsTransactionItem.obj \
|
||||
.\$(OBJDIR)\nsTransactionList.obj \
|
||||
.\$(OBJDIR)\nsTransactionManager.obj \
|
||||
.\$(OBJDIR)\nsTransactionStack.obj \
|
||||
.\$(OBJDIR)\nsTransactionManagerFactory.obj \
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
*/
|
||||
|
||||
#include "nsITransaction.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsTransactionStack.h"
|
||||
#include "nsTransactionManager.h"
|
||||
#include "nsTransactionItem.h"
|
||||
|
@ -71,6 +70,17 @@ nsTransactionItem::GetTransaction(nsITransaction **aTransaction)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionItem::GetIsBatch(PRBool *aIsBatch)
|
||||
{
|
||||
if (!aIsBatch)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aIsBatch = !mTransaction;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionItem::GetNumberOfChildren(PRInt32 *aNumChildren)
|
||||
{
|
||||
|
@ -100,15 +110,64 @@ nsTransactionItem::GetNumberOfChildren(PRInt32 *aNumChildren)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionItem::Do()
|
||||
nsTransactionItem::GetChild(PRInt32 aIndex, nsTransactionItem **aChild)
|
||||
{
|
||||
if (!aChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aChild = 0;
|
||||
|
||||
PRInt32 numItems = 0;
|
||||
nsresult result = GetNumberOfChildren(&numItems);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
if (aIndex < 0 || aIndex >= numItems)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Children are expected to be in the order they were added,
|
||||
// so the child first added would be at the bottom of the undo
|
||||
// stack, or if there are no items on the undo stack, it would
|
||||
// be at the top of the redo stack.
|
||||
|
||||
result = GetNumberOfUndoItems(&numItems);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
if (numItems > 0 && aIndex < numItems) {
|
||||
if (!mUndoStack)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return mUndoStack->GetItem(aIndex, aChild);
|
||||
}
|
||||
|
||||
// Adjust the index for the redo stack:
|
||||
|
||||
aIndex -= numItems;
|
||||
|
||||
result = GetNumberOfRedoItems(&numItems);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
if (!mRedoStack || numItems == 0 || aIndex >= numItems)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return mRedoStack->GetItem(numItems - aIndex - 1, aChild);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionItem::DoTransaction()
|
||||
{
|
||||
if (mTransaction)
|
||||
return mTransaction->Do();
|
||||
return mTransaction->DoTransaction();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionItem::Undo(nsTransactionManager *aTxMgr)
|
||||
nsTransactionItem::UndoTransaction(nsTransactionManager *aTxMgr)
|
||||
{
|
||||
nsresult result = UndoChildren(aTxMgr);
|
||||
|
||||
|
@ -120,7 +179,7 @@ nsTransactionItem::Undo(nsTransactionManager *aTxMgr)
|
|||
if (!mTransaction)
|
||||
return NS_OK;
|
||||
|
||||
result = mTransaction->Undo();
|
||||
result = mTransaction->UndoTransaction();
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
RecoverFromUndoError(aTxMgr);
|
||||
|
@ -177,7 +236,7 @@ nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
result = item->Undo(aTxMgr);
|
||||
result = item->UndoTransaction(aTxMgr);
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = mUndoStack->Pop(&item);
|
||||
|
@ -203,12 +262,12 @@ nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionItem::Redo(nsTransactionManager *aTxMgr)
|
||||
nsTransactionItem::RedoTransaction(nsTransactionManager *aTxMgr)
|
||||
{
|
||||
nsresult result;
|
||||
|
||||
if (mTransaction) {
|
||||
result = mTransaction->Redo();
|
||||
result = mTransaction->RedoTransaction();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
@ -268,7 +327,7 @@ nsTransactionItem::RedoChildren(nsTransactionManager *aTxMgr)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
result = item->Redo(aTxMgr);
|
||||
result = item->RedoTransaction(aTxMgr);
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = mRedoStack->Pop(&item);
|
||||
|
@ -319,34 +378,12 @@ nsTransactionItem::GetNumberOfRedoItems(PRInt32 *aNumItems)
|
|||
return mRedoStack->GetSize(aNumItems);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionItem::Write(nsIOutputStream *aOutputStream)
|
||||
{
|
||||
PRUint32 len;
|
||||
|
||||
if (mTransaction)
|
||||
mTransaction->Write(aOutputStream);
|
||||
|
||||
aOutputStream->Write(" ItemUndoStack:\n", 19, &len);
|
||||
if (mUndoStack) {
|
||||
mUndoStack->Write(aOutputStream);
|
||||
}
|
||||
|
||||
aOutputStream->Write("\n ItemRedoStack:\n", 20, &len);
|
||||
if (mRedoStack) {
|
||||
mRedoStack->Write(aOutputStream);
|
||||
}
|
||||
aOutputStream->Write("\n", 1, &len);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionItem::RecoverFromUndoError(nsTransactionManager *aTxMgr)
|
||||
{
|
||||
//
|
||||
// If this method gets called, we never got to the point where we
|
||||
// successfully called Undo() for the transaction item itself.
|
||||
// successfully called UndoTransaction() for the transaction item itself.
|
||||
// Just redo any children that successfully called undo!
|
||||
//
|
||||
return RedoChildren(aTxMgr);
|
||||
|
@ -356,9 +393,10 @@ nsresult
|
|||
nsTransactionItem::RecoverFromRedoError(nsTransactionManager *aTxMgr)
|
||||
{
|
||||
//
|
||||
// If this method gets called, we already successfully called Redo()
|
||||
// for the transaction item itself. Undo all the children that successfully
|
||||
// called Redo(), then undo the transaction item itself.
|
||||
// If this method gets called, we already successfully called
|
||||
// RedoTransaction() for the transaction item itself. Undo all
|
||||
// the children that successfully called RedoTransaction(),
|
||||
// then undo the transaction item itself.
|
||||
//
|
||||
|
||||
nsresult result;
|
||||
|
@ -372,6 +410,6 @@ nsTransactionItem::RecoverFromRedoError(nsTransactionManager *aTxMgr)
|
|||
if (!mTransaction)
|
||||
return NS_OK;
|
||||
|
||||
return mTransaction->Undo();
|
||||
return mTransaction->UndoTransaction();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,12 +41,13 @@ public:
|
|||
|
||||
virtual nsresult AddChild(nsTransactionItem *aTransactionItem);
|
||||
virtual nsresult GetTransaction(nsITransaction **aTransaction);
|
||||
virtual nsresult GetIsBatch(PRBool *aIsBatch);
|
||||
virtual nsresult GetNumberOfChildren(PRInt32 *aNumChildren);
|
||||
virtual nsresult GetChild(PRInt32 aIndex, nsTransactionItem **aChild);
|
||||
|
||||
virtual nsresult Do(void);
|
||||
virtual nsresult Undo(nsTransactionManager *aTxMgr);
|
||||
virtual nsresult Redo(nsTransactionManager *aTxMgr);
|
||||
virtual nsresult Write(nsIOutputStream *aOutputStream);
|
||||
virtual nsresult DoTransaction(void);
|
||||
virtual nsresult UndoTransaction(nsTransactionManager *aTxMgr);
|
||||
virtual nsresult RedoTransaction(nsTransactionManager *aTxMgr);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsTransactionItem.h"
|
||||
#include "nsITransactionList.h"
|
||||
#include "nsTransactionList.h"
|
||||
#include "nsTransactionStack.h"
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define nsTransactionList_h__
|
||||
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsITransactionList.h"
|
||||
|
||||
class nsITransaction;
|
||||
class nsITransactionManager;
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
*/
|
||||
|
||||
#include "nsITransaction.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsITransactionListener.h"
|
||||
|
||||
#include "nsTransactionItem.h"
|
||||
#include "nsTransactionStack.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTransactionManager.h"
|
||||
#include "nsTransactionList.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
@ -86,16 +86,16 @@ nsrefcnt nsTransactionManager::Release(void)
|
|||
return mRefCnt;
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE1(nsTransactionManager, nsITransactionManager)
|
||||
NS_IMPL_QUERY_INTERFACE2(nsTransactionManager, nsITransactionManager, nsISupportsWeakReference)
|
||||
|
||||
#else
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsTransactionManager, NS_GET_IID(nsITransactionManager))
|
||||
NS_IMPL_ISUPPORTS2(nsTransactionManager, nsITransactionManager, nsISupportsWeakReference)
|
||||
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransactionManager::Do(nsITransaction *aTransaction)
|
||||
nsTransactionManager::DoTransaction(nsITransaction *aTransaction)
|
||||
{
|
||||
nsresult result;
|
||||
|
||||
|
@ -139,16 +139,16 @@ nsTransactionManager::Do(nsITransaction *aTransaction)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransactionManager::Undo()
|
||||
nsTransactionManager::UndoTransaction()
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsTransactionItem *tx = 0;
|
||||
|
||||
LOCK_TX_MANAGER(this);
|
||||
|
||||
// It is illegal to call Undo() while the transaction manager is
|
||||
// executing a transaction's Do() method! If this happens, the Undo()
|
||||
// request is ignored, and we return NS_ERROR_FAILURE.
|
||||
// It is illegal to call UndoTransaction() while the transaction manager is
|
||||
// executing a transaction's DoTransaction() method! If this happens,
|
||||
// the UndoTransaction() request is ignored, and we return NS_ERROR_FAILURE.
|
||||
|
||||
result = mDoStack.Peek(&tx);
|
||||
|
||||
|
@ -200,7 +200,7 @@ nsTransactionManager::Undo()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
result = tx->Undo(this);
|
||||
result = tx->UndoTransaction(this);
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = mUndoStack.Pop(&tx);
|
||||
|
@ -220,16 +220,16 @@ nsTransactionManager::Undo()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransactionManager::Redo()
|
||||
nsTransactionManager::RedoTransaction()
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsTransactionItem *tx = 0;
|
||||
|
||||
LOCK_TX_MANAGER(this);
|
||||
|
||||
// It is illegal to call Redo() while the transaction manager is
|
||||
// executing a transaction's Do() method! If this happens, the Redo()
|
||||
// request is ignored, and we return NS_ERROR_FAILURE.
|
||||
// It is illegal to call RedoTransaction() while the transaction manager is
|
||||
// executing a transaction's DoTransaction() method! If this happens,
|
||||
// the RedoTransaction() request is ignored, and we return NS_ERROR_FAILURE.
|
||||
|
||||
result = mDoStack.Peek(&tx);
|
||||
|
||||
|
@ -281,7 +281,7 @@ nsTransactionManager::Redo()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
result = tx->Redo(this);
|
||||
result = tx->RedoTransaction(this);
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = mRedoStack.Pop(&tx);
|
||||
|
@ -371,7 +371,7 @@ nsTransactionManager::EndBatch()
|
|||
// XXX: Need to add some mechanism to detect the case where the transaction
|
||||
// at the top of the do stack isn't the dummy transaction, so we can
|
||||
// throw an error!! This can happen if someone calls EndBatch() within
|
||||
// the Do() method of a transaction.
|
||||
// the DoTransaction() method of a transaction.
|
||||
//
|
||||
// For now, we can detect this case by checking the value of the
|
||||
// dummy transaction's mTransaction field. If it is our dummy
|
||||
|
@ -444,6 +444,19 @@ nsTransactionManager::GetNumberOfRedoItems(PRInt32 *aNumItems)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransactionManager::GetMaxTransactionCount(PRInt32 *aMaxCount)
|
||||
{
|
||||
if (!aMaxCount)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
LOCK_TX_MANAGER(this);
|
||||
*aMaxCount = mMaxTransactionCount;
|
||||
UNLOCK_TX_MANAGER(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransactionManager::SetMaxTransactionCount(PRInt32 aMaxCount)
|
||||
{
|
||||
|
@ -454,9 +467,10 @@ nsTransactionManager::SetMaxTransactionCount(PRInt32 aMaxCount)
|
|||
LOCK_TX_MANAGER(this);
|
||||
|
||||
// It is illegal to call SetMaxTransactionCount() while the transaction
|
||||
// manager is executing a transaction's Do() method because the undo and
|
||||
// redo stacks might get pruned! If this happens, the SetMaxTransactionCount()
|
||||
// request is ignored, and we return NS_ERROR_FAILURE.
|
||||
// manager is executing a transaction's DoTransaction() method because
|
||||
// the undo and redo stacks might get pruned! If this happens, the
|
||||
// SetMaxTransactionCount() request is ignored, and we return
|
||||
// NS_ERROR_FAILURE.
|
||||
|
||||
result = mDoStack.Peek(&tx);
|
||||
|
||||
|
@ -570,6 +584,8 @@ nsTransactionManager::PeekUndoStack(nsITransaction **aTransaction)
|
|||
|
||||
UNLOCK_TX_MANAGER(this);
|
||||
|
||||
NS_IF_ADDREF(*aTransaction);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -597,24 +613,35 @@ nsTransactionManager::PeekRedoStack(nsITransaction **aTransaction)
|
|||
|
||||
UNLOCK_TX_MANAGER(this);
|
||||
|
||||
NS_IF_ADDREF(*aTransaction);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransactionManager::Write(nsIOutputStream *aOutputStream)
|
||||
nsTransactionManager::GetUndoList(nsITransactionList **aTransactionList)
|
||||
{
|
||||
PRUint32 len;
|
||||
|
||||
if (!aOutputStream)
|
||||
if (!aTransactionList)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
aOutputStream->Write("UndoStack:\n\n", 12, &len);
|
||||
mUndoStack.Write(aOutputStream);
|
||||
*aTransactionList = (nsITransactionList *)new nsTransactionList(this, &mUndoStack);
|
||||
|
||||
aOutputStream->Write("\nRedoStack:\n\n", 13, &len);
|
||||
mRedoStack.Write(aOutputStream);
|
||||
NS_IF_ADDREF(*aTransactionList);
|
||||
|
||||
return NS_OK;
|
||||
return (! *aTransactionList) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransactionManager::GetRedoList(nsITransactionList **aTransactionList)
|
||||
{
|
||||
if (!aTransactionList)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aTransactionList = (nsITransactionList *)new nsTransactionList(this, &mRedoStack);
|
||||
|
||||
NS_IF_ADDREF(*aTransactionList);
|
||||
|
||||
return (! *aTransactionList) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1030,7 +1057,7 @@ nsTransactionManager::BeginTransaction(nsITransaction *aTransaction)
|
|||
return result;
|
||||
}
|
||||
|
||||
result = tx->Do();
|
||||
result = tx->DoTransaction();
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
mDoStack.Pop(&tx);
|
||||
|
@ -1137,7 +1164,7 @@ nsTransactionManager::EndTransaction()
|
|||
return result;
|
||||
|
||||
if (!doInterrupt) {
|
||||
result = topTransaction->Merge(&didMerge, tint);
|
||||
result = topTransaction->Merge(tint, &didMerge);
|
||||
|
||||
nsresult result2 = DidMergeNotify(topTransaction, tint, didMerge, result);
|
||||
|
||||
|
|
|
@ -24,9 +24,10 @@
|
|||
#define nsTransactionManager_h__
|
||||
|
||||
#include "prmon.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsITransactionManager.h"
|
||||
|
||||
class nsITransaction;
|
||||
class nsITransactionManager;
|
||||
class nsITransactionListener;
|
||||
class nsTransactionItem;
|
||||
class nsTransactionStack;
|
||||
|
@ -37,6 +38,7 @@ class nsVoidArray;
|
|||
*
|
||||
*/
|
||||
class nsTransactionManager : public nsITransactionManager
|
||||
, public nsSupportsWeakReference
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -62,27 +64,14 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* nsITransactionManager method implementations. */
|
||||
NS_IMETHOD Do(nsITransaction *aTransaction);
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD Clear(void);
|
||||
NS_IMETHOD BeginBatch(void);
|
||||
NS_IMETHOD EndBatch(void);
|
||||
NS_IMETHOD GetNumberOfUndoItems(PRInt32 *aNumItems);
|
||||
NS_IMETHOD GetNumberOfRedoItems(PRInt32 *aNumItems);
|
||||
NS_IMETHOD SetMaxTransactionCount(PRInt32 aMaxCount);
|
||||
NS_IMETHOD PeekUndoStack(nsITransaction **aTransaction);
|
||||
NS_IMETHOD PeekRedoStack(nsITransaction **aTransaction);
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
NS_IMETHOD AddListener(nsITransactionListener *aListener);
|
||||
NS_IMETHOD RemoveListener(nsITransactionListener *aListener);
|
||||
NS_DECL_NSITRANSACTIONMANAGER
|
||||
|
||||
/* nsTransactionManager specific methods. */
|
||||
virtual nsresult ClearUndoStack(void);
|
||||
virtual nsresult ClearRedoStack(void);
|
||||
|
||||
virtual nsresult WillDoNotify(nsITransaction *aTransaction, PRBool *aInterrupt);
|
||||
virtual nsresult DidDoNotify(nsITransaction *aTransaction, nsresult aDoResult);
|
||||
virtual nsresult DidDoNotify(nsITransaction *aTransaction, nsresult aExecuteResult);
|
||||
virtual nsresult WillUndoNotify(nsITransaction *aTransaction, PRBool *aInterrupt);
|
||||
virtual nsresult DidUndoNotify(nsITransaction *aTransaction, nsresult aUndoResult);
|
||||
virtual nsresult WillRedoNotify(nsITransaction *aTransaction, PRBool *aInterrupt);
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "nsIGenericFactory.h"
|
||||
|
||||
#include "nsTransactionManagerCID.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsTransactionStack.h"
|
||||
#include "nsTransactionManager.h"
|
||||
|
||||
|
@ -40,7 +39,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransactionManager)
|
|||
// class name.
|
||||
//
|
||||
static nsModuleComponentInfo components[] = {
|
||||
{ NULL, NS_TRANSACTIONMANAGER_CID, NULL, nsTransactionManagerConstructor },
|
||||
{ "nsTransactionManager", NS_TRANSACTIONMANAGER_CID, NS_TRANSACTIONMANAGER_CONTRACTID, nsTransactionManagerConstructor },
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -94,6 +94,20 @@ nsTransactionStack::Peek(nsTransactionItem **aTransaction)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionStack::GetItem(PRInt32 aIndex, nsTransactionItem **aTransaction)
|
||||
{
|
||||
if (!aTransaction)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIndex < 0 || aIndex >= mQue.GetSize())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aTransaction = (nsTransactionItem *)(mQue.ObjectAt(aIndex));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionStack::Clear(void)
|
||||
{
|
||||
|
@ -130,24 +144,6 @@ nsTransactionStack::GetSize(PRInt32 *aStackSize)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTransactionStack::Write(nsIOutputStream *aOutputStream)
|
||||
{
|
||||
/* Call Write() for every transaction on the stack. Start
|
||||
* from the top of the stack.
|
||||
*/
|
||||
|
||||
nsDequeIterator di = mQue.End();
|
||||
nsTransactionItem *tx = (nsTransactionItem *)--di;
|
||||
|
||||
while (tx) {
|
||||
tx->Write(aOutputStream);
|
||||
tx = (nsTransactionItem *)--di;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsTransactionRedoStack::~nsTransactionRedoStack()
|
||||
{
|
||||
Clear();
|
||||
|
|
|
@ -49,9 +49,9 @@ public:
|
|||
virtual nsresult Pop(nsTransactionItem **aTransactionItem);
|
||||
virtual nsresult PopBottom(nsTransactionItem **aTransactionItem);
|
||||
virtual nsresult Peek(nsTransactionItem **aTransactionItem);
|
||||
virtual nsresult GetItem(PRInt32 aIndex, nsTransactionItem **aTransactionItem);
|
||||
virtual nsresult Clear(void);
|
||||
virtual nsresult GetSize(PRInt32 *aStackSize);
|
||||
virtual nsresult Write(nsIOutputStream *aOutputStream);
|
||||
};
|
||||
|
||||
class nsTransactionRedoStack: public nsTransactionStack
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -385,3 +385,69 @@ function EditorTableize()
|
|||
window._content.focus();
|
||||
}
|
||||
|
||||
// --------------------------- TransactionManager ---------------------------
|
||||
|
||||
|
||||
function DumpUndoStack()
|
||||
{
|
||||
try {
|
||||
var txmgr = editorShell.transactionManager;
|
||||
|
||||
if (!txmgr)
|
||||
{
|
||||
dump("**** Editor has no TransactionManager!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
dump("---------------------- BEGIN UNDO STACK DUMP\n");
|
||||
dump("<!-- 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;"
|
||||
oncommand="EditorUnitTests()"/>
|
||||
<menuseparator />
|
||||
<menuitem value="&dumpUndoStack.label;"
|
||||
oncommand="DumpUndoStack()"/>
|
||||
<menuitem value="&dumpRedoStack.label;"
|
||||
oncommand="DumpRedoStack()"/>
|
||||
<menuseparator />
|
||||
<menuitem value="&startLogCmd.label;"
|
||||
oncommand="EditorStartLog()"/>
|
||||
<menuitem value="&stopLogCmd.label;"
|
||||
|
|
|
@ -539,6 +539,8 @@
|
|||
<!ENTITY showEmbeddedCmd.label "Show Embedded Objects">
|
||||
<!ENTITY dumpContentCmd.label "Dump Content Tree">
|
||||
<!ENTITY runUnitTestsCmd.label "Run Unit Tests">
|
||||
<!ENTITY dumpUndoStack.label "Dump Undo Stack">
|
||||
<!ENTITY dumpRedoStack.label "Dump Redo Stack">
|
||||
<!ENTITY startLogCmd.label "Start Log">
|
||||
<!ENTITY stopLogCmd.label "Stop Log">
|
||||
<!ENTITY runLogCmd.label "Run Log">
|
||||
|
|
|
@ -1204,9 +1204,8 @@ NS_IMETHODIMP nsMessenger::GetUndoTransactionType(PRUint32 *txnType)
|
|||
if (!txnType || !mTxnMgr)
|
||||
return rv;
|
||||
*txnType = nsMessenger::eUnknown;
|
||||
nsITransaction *txn = nsnull;
|
||||
// ** jt -- too bad PeekUndoStack not AddRef'ing
|
||||
rv = mTxnMgr->PeekUndoStack(&txn);
|
||||
nsCOMPtr<nsITransaction> txn;
|
||||
rv = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));
|
||||
if (NS_SUCCEEDED(rv) && txn)
|
||||
{
|
||||
nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv);
|
||||
|
@ -1235,9 +1234,8 @@ NS_IMETHODIMP nsMessenger::GetRedoTransactionType(PRUint32 *txnType)
|
|||
if (!txnType || !mTxnMgr)
|
||||
return rv;
|
||||
*txnType = nsMessenger::eUnknown;
|
||||
nsITransaction *txn = nsnull;
|
||||
// ** jt - too bad PeekRedoStack not AddRef'ing
|
||||
rv = mTxnMgr->PeekRedoStack(&txn);
|
||||
nsCOMPtr<nsITransaction> txn;
|
||||
rv = mTxnMgr->PeekRedoStack(getter_AddRefs(txn));
|
||||
if (NS_SUCCEEDED(rv) && txn)
|
||||
{
|
||||
nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv);
|
||||
|
@ -1270,16 +1268,15 @@ nsMessenger::Undo(nsIMsgWindow *msgWindow)
|
|||
rv = mTxnMgr->GetNumberOfUndoItems(&numTxn);
|
||||
if (NS_SUCCEEDED(rv) && numTxn > 0)
|
||||
{
|
||||
nsITransaction *txn = nsnull;
|
||||
// ** jt -- PeekUndoStack not AddRef'ing
|
||||
rv = mTxnMgr->PeekUndoStack(&txn);
|
||||
nsCOMPtr<nsITransaction> txn;
|
||||
rv = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));
|
||||
if (NS_SUCCEEDED(rv) && txn)
|
||||
{
|
||||
nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv);
|
||||
if (NS_SUCCEEDED(rv) && msgTxn)
|
||||
msgTxn->SetMsgWindow(msgWindow);
|
||||
}
|
||||
mTxnMgr->Undo();
|
||||
mTxnMgr->UndoTransaction();
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
@ -1295,16 +1292,15 @@ nsMessenger::Redo(nsIMsgWindow *msgWindow)
|
|||
rv = mTxnMgr->GetNumberOfRedoItems(&numTxn);
|
||||
if (NS_SUCCEEDED(rv) && numTxn > 0)
|
||||
{
|
||||
nsITransaction *txn = nsnull;
|
||||
// jt -- PeekRedoStack not AddRef'ing
|
||||
rv = mTxnMgr->PeekRedoStack(&txn);
|
||||
nsCOMPtr<nsITransaction> txn;
|
||||
rv = mTxnMgr->PeekRedoStack(getter_AddRefs(txn));
|
||||
if (NS_SUCCEEDED(rv) && txn)
|
||||
{
|
||||
nsCOMPtr<nsMsgTxn> msgTxn = do_QueryInterface(txn, &rv);
|
||||
if (NS_SUCCEEDED(rv) && msgTxn)
|
||||
msgTxn->SetMsgWindow(msgWindow);
|
||||
}
|
||||
mTxnMgr->Redo();
|
||||
mTxnMgr->RedoTransaction();
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
|
|
@ -32,15 +32,13 @@ nsMsgTxn::nsMsgTxn()
|
|||
{
|
||||
NS_INIT_REFCNT();
|
||||
m_txnType = 0;
|
||||
m_undoString.AssignWithConversion("Undo");
|
||||
m_redoString.AssignWithConversion("Redo");
|
||||
}
|
||||
|
||||
nsMsgTxn::~nsMsgTxn()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgTxn::Do(void)
|
||||
NS_IMETHODIMP nsMsgTxn::DoTransaction(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -54,12 +52,7 @@ NS_IMETHODIMP nsMsgTxn::GetIsTransient(PRBool *aIsTransient)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgTxn::Write(nsIOutputStream *aOutputStream)
|
||||
NS_IMETHODIMP nsMsgTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
@ -80,39 +73,6 @@ NS_IMETHODIMP nsMsgTxn::SetMsgWindow(nsIMsgWindow *msgWindow)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgTxn::SetUndoString(nsString *aString)
|
||||
{
|
||||
if (!aString) return NS_ERROR_NULL_POINTER;
|
||||
m_undoString = *aString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgTxn::SetRedoString(nsString* aString)
|
||||
{
|
||||
if (!aString) return NS_ERROR_NULL_POINTER;
|
||||
m_redoString = *aString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgTxn::GetUndoString(nsString* aString)
|
||||
{
|
||||
if (!aString) return NS_ERROR_NULL_POINTER;
|
||||
*aString = m_undoString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgTxn::GetRedoString(nsString* aString)
|
||||
{
|
||||
if (!aString) return NS_ERROR_NULL_POINTER;
|
||||
*aString = m_redoString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgTxn::GetTransactionType(PRUint32 *txnType)
|
||||
{
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче