2001-09-25 22:53:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-12-01 18:35:49 +00:00
|
|
|
|
2012-07-13 06:33:42 +00:00
|
|
|
#include "mozilla/mozalloc.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDebug.h"
|
|
|
|
#include "nsError.h"
|
2014-02-26 21:36:35 +00:00
|
|
|
#include "nsISupportsImpl.h"
|
1999-05-26 21:16:25 +00:00
|
|
|
#include "nsITransaction.h"
|
1998-12-01 18:35:49 +00:00
|
|
|
#include "nsTransactionItem.h"
|
2012-07-13 06:33:42 +00:00
|
|
|
#include "nsTransactionManager.h"
|
|
|
|
#include "nsTransactionStack.h"
|
1998-12-01 18:35:49 +00:00
|
|
|
|
|
|
|
nsTransactionItem::nsTransactionItem(nsITransaction *aTransaction)
|
|
|
|
: mTransaction(aTransaction), mUndoStack(0), mRedoStack(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTransactionItem::~nsTransactionItem()
|
|
|
|
{
|
2011-05-17 14:01:36 +00:00
|
|
|
delete mRedoStack;
|
1998-12-01 18:35:49 +00:00
|
|
|
|
2011-05-17 14:01:36 +00:00
|
|
|
delete mUndoStack;
|
2008-12-10 16:46:36 +00:00
|
|
|
}
|
1998-12-01 18:35:49 +00:00
|
|
|
|
2013-07-09 17:30:58 +00:00
|
|
|
void
|
|
|
|
nsTransactionItem::CleanUp()
|
|
|
|
{
|
|
|
|
mData.Clear();
|
|
|
|
mTransaction = nullptr;
|
|
|
|
if (mRedoStack) {
|
|
|
|
mRedoStack->DoUnlink();
|
|
|
|
}
|
|
|
|
if (mUndoStack) {
|
|
|
|
mUndoStack->DoUnlink();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-24 16:50:06 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_NATIVE_ADDREF(nsTransactionItem)
|
2013-07-09 17:30:58 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE_WITH_LAST_RELEASE(nsTransactionItem,
|
|
|
|
CleanUp())
|
1998-12-01 18:35:49 +00:00
|
|
|
|
2013-08-02 01:29:05 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsTransactionItem)
|
|
|
|
|
2012-11-22 17:15:38 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsTransactionItem)
|
2013-07-09 17:30:58 +00:00
|
|
|
tmp->CleanUp();
|
2009-05-09 04:59:25 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2012-11-22 17:15:38 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsTransactionItem)
|
2013-01-04 06:54:26 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mData)
|
2012-11-15 07:32:40 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTransaction)
|
2009-05-09 04:59:25 +00:00
|
|
|
if (tmp->mRedoStack) {
|
|
|
|
tmp->mRedoStack->DoTraverse(cb);
|
|
|
|
}
|
|
|
|
if (tmp->mUndoStack) {
|
|
|
|
tmp->mUndoStack->DoTraverse(cb);
|
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsTransactionItem, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsTransactionItem, Release)
|
|
|
|
|
1998-12-01 18:35:49 +00:00
|
|
|
nsresult
|
|
|
|
nsTransactionItem::AddChild(nsTransactionItem *aTransactionItem)
|
|
|
|
{
|
2010-06-17 20:40:48 +00:00
|
|
|
NS_ENSURE_TRUE(aTransactionItem, NS_ERROR_NULL_POINTER);
|
1998-12-01 18:35:49 +00:00
|
|
|
|
|
|
|
if (!mUndoStack) {
|
2012-03-02 20:08:40 +00:00
|
|
|
mUndoStack = new nsTransactionStack(nsTransactionStack::FOR_UNDO);
|
1998-12-01 18:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mUndoStack->Push(aTransactionItem);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-19 13:23:36 +00:00
|
|
|
already_AddRefed<nsITransaction>
|
|
|
|
nsTransactionItem::GetTransaction()
|
1998-12-02 17:40:56 +00:00
|
|
|
{
|
2012-06-19 13:23:36 +00:00
|
|
|
nsCOMPtr<nsITransaction> txn = mTransaction;
|
|
|
|
return txn.forget();
|
1998-12-02 17:40:56 +00:00
|
|
|
}
|
|
|
|
|
2001-03-09 14:23:59 +00:00
|
|
|
nsresult
|
2011-09-29 06:19:26 +00:00
|
|
|
nsTransactionItem::GetIsBatch(bool *aIsBatch)
|
2001-03-09 14:23:59 +00:00
|
|
|
{
|
2010-06-17 20:40:48 +00:00
|
|
|
NS_ENSURE_TRUE(aIsBatch, NS_ERROR_NULL_POINTER);
|
2001-03-09 14:23:59 +00:00
|
|
|
|
|
|
|
*aIsBatch = !mTransaction;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-08 17:27:42 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsTransactionItem::GetNumberOfChildren(int32_t *aNumChildren)
|
1999-02-08 17:27:42 +00:00
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
|
2010-06-17 20:40:48 +00:00
|
|
|
NS_ENSURE_TRUE(aNumChildren, NS_ERROR_NULL_POINTER);
|
1999-02-08 17:27:42 +00:00
|
|
|
|
|
|
|
*aNumChildren = 0;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t ui = 0;
|
|
|
|
int32_t ri = 0;
|
1999-02-08 17:27:42 +00:00
|
|
|
|
|
|
|
result = GetNumberOfUndoItems(&ui);
|
|
|
|
|
2010-06-17 20:44:35 +00:00
|
|
|
NS_ENSURE_SUCCESS(result, result);
|
1999-02-08 17:27:42 +00:00
|
|
|
|
|
|
|
result = GetNumberOfRedoItems(&ri);
|
|
|
|
|
2010-06-17 20:44:35 +00:00
|
|
|
NS_ENSURE_SUCCESS(result, result);
|
1999-02-08 17:27:42 +00:00
|
|
|
|
|
|
|
*aNumChildren = ui + ri;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-01 18:35:49 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsTransactionItem::GetChild(int32_t aIndex, nsTransactionItem **aChild)
|
2001-03-09 14:23:59 +00:00
|
|
|
{
|
2010-06-17 20:40:48 +00:00
|
|
|
NS_ENSURE_TRUE(aChild, NS_ERROR_NULL_POINTER);
|
2001-03-09 14:23:59 +00:00
|
|
|
|
|
|
|
*aChild = 0;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numItems = 0;
|
2001-03-09 14:23:59 +00:00
|
|
|
nsresult result = GetNumberOfChildren(&numItems);
|
|
|
|
|
2010-06-17 20:44:35 +00:00
|
|
|
NS_ENSURE_SUCCESS(result, result);
|
2001-03-09 14:23:59 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2010-06-17 20:44:35 +00:00
|
|
|
NS_ENSURE_SUCCESS(result, result);
|
2001-03-09 14:23:59 +00:00
|
|
|
|
|
|
|
if (numItems > 0 && aIndex < numItems) {
|
2010-06-17 20:40:48 +00:00
|
|
|
NS_ENSURE_TRUE(mUndoStack, NS_ERROR_FAILURE);
|
2001-03-09 14:23:59 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsTransactionItem> child = mUndoStack->GetItem(aIndex);
|
2012-03-02 20:08:40 +00:00
|
|
|
child.forget(aChild);
|
|
|
|
return *aChild ? NS_OK : NS_ERROR_FAILURE;
|
2001-03-09 14:23:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Adjust the index for the redo stack:
|
|
|
|
|
|
|
|
aIndex -= numItems;
|
|
|
|
|
|
|
|
result = GetNumberOfRedoItems(&numItems);
|
|
|
|
|
2010-06-17 20:44:35 +00:00
|
|
|
NS_ENSURE_SUCCESS(result, result);
|
2001-03-09 14:23:59 +00:00
|
|
|
|
2010-06-17 20:40:48 +00:00
|
|
|
NS_ENSURE_TRUE(mRedoStack && numItems != 0 && aIndex < numItems, NS_ERROR_FAILURE);
|
2001-03-09 14:23:59 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsTransactionItem> child = mRedoStack->GetItem(aIndex);
|
2012-03-02 20:08:40 +00:00
|
|
|
child.forget(aChild);
|
|
|
|
return *aChild ? NS_OK : NS_ERROR_FAILURE;
|
2001-03-09 14:23:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsTransactionItem::DoTransaction()
|
1998-12-01 18:35:49 +00:00
|
|
|
{
|
|
|
|
if (mTransaction)
|
2001-03-09 14:23:59 +00:00
|
|
|
return mTransaction->DoTransaction();
|
1998-12-01 18:35:49 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2001-03-09 14:23:59 +00:00
|
|
|
nsTransactionItem::UndoTransaction(nsTransactionManager *aTxMgr)
|
1998-12-04 21:50:09 +00:00
|
|
|
{
|
1999-05-26 21:16:25 +00:00
|
|
|
nsresult result = UndoChildren(aTxMgr);
|
1998-12-04 21:50:09 +00:00
|
|
|
|
1999-02-08 17:27:42 +00:00
|
|
|
if (NS_FAILED(result)) {
|
1999-05-26 21:16:25 +00:00
|
|
|
RecoverFromUndoError(aTxMgr);
|
1998-12-04 21:50:09 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-07-31 17:58:35 +00:00
|
|
|
if (!mTransaction)
|
|
|
|
return NS_OK;
|
1998-12-04 21:50:09 +00:00
|
|
|
|
2001-03-09 14:23:59 +00:00
|
|
|
result = mTransaction->UndoTransaction();
|
1998-12-04 21:50:09 +00:00
|
|
|
|
1999-02-08 17:27:42 +00:00
|
|
|
if (NS_FAILED(result)) {
|
1999-05-26 21:16:25 +00:00
|
|
|
RecoverFromUndoError(aTxMgr);
|
1998-12-04 21:50:09 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-05-26 21:16:25 +00:00
|
|
|
nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr)
|
1998-12-01 18:35:49 +00:00
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsTransactionItem> item;
|
1999-05-26 21:16:25 +00:00
|
|
|
nsresult result = NS_OK;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t sz = 0;
|
1998-12-01 18:35:49 +00:00
|
|
|
|
|
|
|
if (mUndoStack) {
|
|
|
|
if (!mRedoStack && mUndoStack) {
|
2012-03-02 20:08:40 +00:00
|
|
|
mRedoStack = new nsTransactionStack(nsTransactionStack::FOR_REDO);
|
1998-12-01 18:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Undo all of the transaction items children! */
|
2012-03-02 20:08:40 +00:00
|
|
|
sz = mUndoStack->GetSize();
|
1998-12-01 18:35:49 +00:00
|
|
|
|
|
|
|
while (sz-- > 0) {
|
2012-03-02 20:08:40 +00:00
|
|
|
item = mUndoStack->Peek();
|
1998-12-01 18:35:49 +00:00
|
|
|
|
2012-03-02 20:08:40 +00:00
|
|
|
if (!item) {
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-12-01 18:35:49 +00:00
|
|
|
}
|
|
|
|
|
2012-06-19 13:23:36 +00:00
|
|
|
nsCOMPtr<nsITransaction> t = item->GetTransaction();
|
1998-12-01 18:35:49 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool doInterrupt = false;
|
1999-11-11 19:35:40 +00:00
|
|
|
|
|
|
|
result = aTxMgr->WillUndoNotify(t, &doInterrupt);
|
1998-12-01 18:35:49 +00:00
|
|
|
|
1999-02-08 17:27:42 +00:00
|
|
|
if (NS_FAILED(result)) {
|
1998-12-01 18:35:49 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-11-11 19:35:40 +00:00
|
|
|
if (doInterrupt) {
|
1999-05-26 21:16:25 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-12-01 18:35:49 +00:00
|
|
|
|
2001-03-09 14:23:59 +00:00
|
|
|
result = item->UndoTransaction(aTxMgr);
|
1999-05-26 21:16:25 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
2012-03-02 20:08:40 +00:00
|
|
|
item = mUndoStack->Pop();
|
|
|
|
mRedoStack->Push(item);
|
1999-05-26 21:16:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult result2 = aTxMgr->DidUndoNotify(t, result);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
result = result2;
|
1998-12-01 18:35:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-26 21:16:25 +00:00
|
|
|
return result;
|
1998-12-01 18:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2001-03-09 14:23:59 +00:00
|
|
|
nsTransactionItem::RedoTransaction(nsTransactionManager *aTxMgr)
|
1998-12-01 18:35:49 +00:00
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
|
2008-12-10 16:46:36 +00:00
|
|
|
nsCOMPtr<nsITransaction> kungfuDeathGrip(mTransaction);
|
1999-02-04 17:39:21 +00:00
|
|
|
if (mTransaction) {
|
2001-03-09 14:23:59 +00:00
|
|
|
result = mTransaction->RedoTransaction();
|
1998-12-01 18:35:49 +00:00
|
|
|
|
2010-06-17 20:44:35 +00:00
|
|
|
NS_ENSURE_SUCCESS(result, result);
|
1999-02-04 17:39:21 +00:00
|
|
|
}
|
1998-12-01 18:35:49 +00:00
|
|
|
|
1999-05-26 21:16:25 +00:00
|
|
|
result = RedoChildren(aTxMgr);
|
1998-12-01 18:35:49 +00:00
|
|
|
|
1999-02-08 17:27:42 +00:00
|
|
|
if (NS_FAILED(result)) {
|
1999-05-26 21:16:25 +00:00
|
|
|
RecoverFromRedoError(aTxMgr);
|
1998-12-01 18:35:49 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-12-04 21:50:09 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-05-26 21:16:25 +00:00
|
|
|
nsTransactionItem::RedoChildren(nsTransactionManager *aTxMgr)
|
1998-12-04 21:50:09 +00:00
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsTransactionItem> item;
|
1999-05-26 21:16:25 +00:00
|
|
|
nsresult result = NS_OK;
|
1998-12-04 21:50:09 +00:00
|
|
|
|
2010-06-18 23:29:16 +00:00
|
|
|
if (!mRedoStack)
|
|
|
|
return NS_OK;
|
1998-12-08 22:05:23 +00:00
|
|
|
|
|
|
|
/* Redo all of the transaction items children! */
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t sz = mRedoStack->GetSize();
|
1998-12-08 22:05:23 +00:00
|
|
|
|
1998-12-01 18:35:49 +00:00
|
|
|
while (sz-- > 0) {
|
2012-03-02 20:08:40 +00:00
|
|
|
item = mRedoStack->Peek();
|
1998-12-01 18:35:49 +00:00
|
|
|
|
2012-03-02 20:08:40 +00:00
|
|
|
if (!item) {
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-12-01 18:35:49 +00:00
|
|
|
}
|
|
|
|
|
2012-06-19 13:23:36 +00:00
|
|
|
nsCOMPtr<nsITransaction> t = item->GetTransaction();
|
1998-12-01 18:35:49 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool doInterrupt = false;
|
1999-11-11 19:35:40 +00:00
|
|
|
|
|
|
|
result = aTxMgr->WillRedoNotify(t, &doInterrupt);
|
1998-12-01 18:35:49 +00:00
|
|
|
|
1999-02-08 17:27:42 +00:00
|
|
|
if (NS_FAILED(result)) {
|
1998-12-01 18:35:49 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-11-11 19:35:40 +00:00
|
|
|
if (doInterrupt) {
|
1999-05-26 21:16:25 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-12-01 18:35:49 +00:00
|
|
|
|
2001-03-09 14:23:59 +00:00
|
|
|
result = item->RedoTransaction(aTxMgr);
|
1999-05-26 21:16:25 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
2012-03-02 20:08:40 +00:00
|
|
|
item = mRedoStack->Pop();
|
|
|
|
mUndoStack->Push(item);
|
1999-05-26 21:16:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult result2 = aTxMgr->DidUndoNotify(t, result);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
result = result2;
|
1998-12-01 18:35:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-26 21:16:25 +00:00
|
|
|
return result;
|
1998-12-01 18:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsTransactionItem::GetNumberOfUndoItems(int32_t *aNumItems)
|
1998-12-01 18:35:49 +00:00
|
|
|
{
|
2010-06-17 20:40:48 +00:00
|
|
|
NS_ENSURE_TRUE(aNumItems, NS_ERROR_NULL_POINTER);
|
1999-02-08 17:27:42 +00:00
|
|
|
|
|
|
|
if (!mUndoStack) {
|
|
|
|
*aNumItems = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-02 20:08:40 +00:00
|
|
|
*aNumItems = mUndoStack->GetSize();
|
|
|
|
return *aNumItems ? NS_OK : NS_ERROR_FAILURE;
|
1998-12-01 18:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsTransactionItem::GetNumberOfRedoItems(int32_t *aNumItems)
|
1998-12-01 18:35:49 +00:00
|
|
|
{
|
2010-06-17 20:40:48 +00:00
|
|
|
NS_ENSURE_TRUE(aNumItems, NS_ERROR_NULL_POINTER);
|
1999-02-08 17:27:42 +00:00
|
|
|
|
|
|
|
if (!mRedoStack) {
|
|
|
|
*aNumItems = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-02 20:08:40 +00:00
|
|
|
*aNumItems = mRedoStack->GetSize();
|
|
|
|
return *aNumItems ? NS_OK : NS_ERROR_FAILURE;
|
1998-12-01 18:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-05-26 21:16:25 +00:00
|
|
|
nsTransactionItem::RecoverFromUndoError(nsTransactionManager *aTxMgr)
|
1998-12-01 18:35:49 +00:00
|
|
|
{
|
1998-12-04 21:50:09 +00:00
|
|
|
//
|
|
|
|
// If this method gets called, we never got to the point where we
|
2001-03-09 14:23:59 +00:00
|
|
|
// successfully called UndoTransaction() for the transaction item itself.
|
1998-12-04 21:50:09 +00:00
|
|
|
// Just redo any children that successfully called undo!
|
|
|
|
//
|
1999-05-26 21:16:25 +00:00
|
|
|
return RedoChildren(aTxMgr);
|
1998-12-01 18:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-05-26 21:16:25 +00:00
|
|
|
nsTransactionItem::RecoverFromRedoError(nsTransactionManager *aTxMgr)
|
1998-12-01 18:35:49 +00:00
|
|
|
{
|
1998-12-04 21:50:09 +00:00
|
|
|
//
|
2001-03-09 14:23:59 +00:00
|
|
|
// 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.
|
1998-12-04 21:50:09 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
nsresult result;
|
1998-12-01 18:35:49 +00:00
|
|
|
|
1999-05-26 21:16:25 +00:00
|
|
|
result = UndoChildren(aTxMgr);
|
1998-12-04 21:50:09 +00:00
|
|
|
|
1999-02-08 17:27:42 +00:00
|
|
|
if (NS_FAILED(result)) {
|
1998-12-04 21:50:09 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-08-06 02:13:07 +00:00
|
|
|
if (!mTransaction)
|
|
|
|
return NS_OK;
|
1998-12-04 21:50:09 +00:00
|
|
|
|
2001-03-09 14:23:59 +00:00
|
|
|
return mTransaction->UndoTransaction();
|
1998-12-04 21:50:09 +00:00
|
|
|
}
|
1998-12-01 18:35:49 +00:00
|
|
|
|