/src/mozilla-central/editor/txmgr/TransactionItem.h
Line | Count | Source (jump to first uncovered line) |
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 | | { |
24 | | public: |
25 | | explicit TransactionItem(nsITransaction* aTransaction); |
26 | | NS_METHOD_(MozExternalRefCountType) AddRef(); |
27 | | NS_METHOD_(MozExternalRefCountType) Release(); |
28 | | |
29 | | NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(TransactionItem) |
30 | | |
31 | | nsresult AddChild(TransactionItem* aTransactionItem); |
32 | | already_AddRefed<nsITransaction> GetTransaction(); |
33 | | nsresult GetIsBatch(bool *aIsBatch); |
34 | | nsresult GetNumberOfChildren(int32_t *aNumChildren); |
35 | | nsresult GetChild(int32_t aIndex, TransactionItem** aChild); |
36 | | |
37 | | nsresult DoTransaction(); |
38 | | nsresult UndoTransaction(TransactionManager* aTransactionManager); |
39 | | nsresult RedoTransaction(TransactionManager* aTransactionManager); |
40 | | |
41 | | nsCOMArray<nsISupports>& GetData() |
42 | 0 | { |
43 | 0 | return mData; |
44 | 0 | } |
45 | | |
46 | | private: |
47 | | nsresult UndoChildren(TransactionManager* aTransactionManager); |
48 | | nsresult RedoChildren(TransactionManager* aTransactionManager); |
49 | | |
50 | | nsresult RecoverFromUndoError(TransactionManager* aTransactionManager); |
51 | | nsresult RecoverFromRedoError(TransactionManager* aTransactionManager); |
52 | | |
53 | | nsresult GetNumberOfUndoItems(int32_t* aNumItems); |
54 | | nsresult GetNumberOfRedoItems(int32_t* aNumItems); |
55 | | |
56 | | void CleanUp(); |
57 | | |
58 | | ~TransactionItem(); |
59 | | |
60 | | nsCycleCollectingAutoRefCnt mRefCnt; |
61 | | NS_DECL_OWNINGTHREAD |
62 | | |
63 | | nsCOMArray<nsISupports> mData; |
64 | | nsCOMPtr<nsITransaction> mTransaction; |
65 | | TransactionStack* mUndoStack; |
66 | | TransactionStack* mRedoStack; |
67 | | }; |
68 | | |
69 | | } // namespace mozilla |
70 | | |
71 | | #endif // #ifndef TransactionItem_h |