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