Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#ifndef TransactionItem_h
7
#define TransactionItem_h
8
9
#include "nsCOMPtr.h"
10
#include "nsCOMArray.h"
11
#include "nsCycleCollectionParticipant.h"
12
#include "nsISupportsImpl.h"
13
#include "nscore.h"
14
15
class nsITransaction;
16
17
namespace mozilla {
18
19
class TransactionManager;
20
class TransactionStack;
21
22
class TransactionItem final {
23
public:
24
explicit TransactionItem(nsITransaction* aTransaction);
25
NS_METHOD_(MozExternalRefCountType) AddRef();
26
NS_METHOD_(MozExternalRefCountType) Release();
27
28
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(TransactionItem)
29
30
nsresult AddChild(TransactionItem* aTransactionItem);
31
already_AddRefed<nsITransaction> GetTransaction();
32
nsresult GetIsBatch(bool* aIsBatch);
33
nsresult GetNumberOfChildren(int32_t* aNumChildren);
34
nsresult GetChild(int32_t aIndex, TransactionItem** aChild);
35
36
nsresult DoTransaction();
37
nsresult UndoTransaction(TransactionManager* aTransactionManager);
38
nsresult RedoTransaction(TransactionManager* aTransactionManager);
39
40
nsCOMArray<nsISupports>& GetData() { return mData; }
41
42
private:
43
nsresult UndoChildren(TransactionManager* aTransactionManager);
44
nsresult RedoChildren(TransactionManager* aTransactionManager);
45
46
nsresult RecoverFromUndoError(TransactionManager* aTransactionManager);
47
nsresult RecoverFromRedoError(TransactionManager* aTransactionManager);
48
49
nsresult GetNumberOfUndoItems(int32_t* aNumItems);
50
nsresult GetNumberOfRedoItems(int32_t* aNumItems);
51
52
void CleanUp();
53
54
~TransactionItem();
55
56
nsCycleCollectingAutoRefCnt mRefCnt;
57
NS_DECL_OWNINGTHREAD
58
59
nsCOMArray<nsISupports> mData;
60
nsCOMPtr<nsITransaction> mTransaction;
61
TransactionStack* mUndoStack;
62
TransactionStack* mRedoStack;
63
};
64
65
} // namespace mozilla
66
67
#endif // #ifndef TransactionItem_h