Line data Source code
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 nsTransactionItem_h__
7 : #define nsTransactionItem_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 : class nsTransactionManager;
17 : class nsTransactionStack;
18 :
19 : class nsTransactionItem final
20 : {
21 : nsCOMArray<nsISupports> mData;
22 : nsCOMPtr<nsITransaction> mTransaction;
23 : nsTransactionStack *mUndoStack;
24 : nsTransactionStack *mRedoStack;
25 :
26 : public:
27 :
28 : explicit nsTransactionItem(nsITransaction *aTransaction);
29 : NS_METHOD_(MozExternalRefCountType) AddRef();
30 : NS_METHOD_(MozExternalRefCountType) Release();
31 :
32 24 : NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsTransactionItem)
33 :
34 : virtual nsresult AddChild(nsTransactionItem *aTransactionItem);
35 : already_AddRefed<nsITransaction> GetTransaction();
36 : virtual nsresult GetIsBatch(bool *aIsBatch);
37 : virtual nsresult GetNumberOfChildren(int32_t *aNumChildren);
38 : virtual nsresult GetChild(int32_t aIndex, nsTransactionItem **aChild);
39 :
40 : virtual nsresult DoTransaction(void);
41 : virtual nsresult UndoTransaction(nsTransactionManager *aTxMgr);
42 : virtual nsresult RedoTransaction(nsTransactionManager *aTxMgr);
43 :
44 0 : nsCOMArray<nsISupports>& GetData()
45 : {
46 0 : return mData;
47 : }
48 :
49 : private:
50 :
51 : virtual nsresult UndoChildren(nsTransactionManager *aTxMgr);
52 : virtual nsresult RedoChildren(nsTransactionManager *aTxMgr);
53 :
54 : virtual nsresult RecoverFromUndoError(nsTransactionManager *aTxMgr);
55 : virtual nsresult RecoverFromRedoError(nsTransactionManager *aTxMgr);
56 :
57 : virtual nsresult GetNumberOfUndoItems(int32_t *aNumItems);
58 : virtual nsresult GetNumberOfRedoItems(int32_t *aNumItems);
59 :
60 : void CleanUp();
61 : protected:
62 : virtual ~nsTransactionItem();
63 :
64 : nsCycleCollectingAutoRefCnt mRefCnt;
65 : NS_DECL_OWNINGTHREAD
66 : };
67 :
68 : #endif // nsTransactionItem_h__
|