|
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 nsTransactionManager_h__ |
|
7 #define nsTransactionManager_h__ |
|
8 |
|
9 #include "nsCOMArray.h" |
|
10 #include "nsCOMPtr.h" |
|
11 #include "nsCycleCollectionParticipant.h" |
|
12 #include "nsTransactionStack.h" |
|
13 #include "nsISupportsImpl.h" |
|
14 #include "nsITransactionManager.h" |
|
15 #include "nsTransactionStack.h" |
|
16 #include "nsWeakReference.h" |
|
17 #include "nscore.h" |
|
18 |
|
19 class nsITransaction; |
|
20 class nsITransactionListener; |
|
21 class nsTransactionItem; |
|
22 |
|
23 /** implementation of a transaction manager object. |
|
24 * |
|
25 */ |
|
26 class nsTransactionManager : public nsITransactionManager |
|
27 , public nsSupportsWeakReference |
|
28 { |
|
29 private: |
|
30 |
|
31 int32_t mMaxTransactionCount; |
|
32 nsTransactionStack mDoStack; |
|
33 nsTransactionStack mUndoStack; |
|
34 nsTransactionStack mRedoStack; |
|
35 nsCOMArray<nsITransactionListener> mListeners; |
|
36 |
|
37 public: |
|
38 |
|
39 /** The default constructor. |
|
40 */ |
|
41 nsTransactionManager(int32_t aMaxTransactionCount=-1); |
|
42 |
|
43 /** The default destructor. |
|
44 */ |
|
45 virtual ~nsTransactionManager(); |
|
46 |
|
47 /* Macro for AddRef(), Release(), and QueryInterface() */ |
|
48 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
49 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTransactionManager, |
|
50 nsITransactionManager) |
|
51 |
|
52 /* nsITransactionManager method implementations. */ |
|
53 NS_DECL_NSITRANSACTIONMANAGER |
|
54 |
|
55 already_AddRefed<nsITransaction> PeekUndoStack(); |
|
56 already_AddRefed<nsITransaction> PeekRedoStack(); |
|
57 |
|
58 virtual nsresult WillDoNotify(nsITransaction *aTransaction, bool *aInterrupt); |
|
59 virtual nsresult DidDoNotify(nsITransaction *aTransaction, nsresult aExecuteResult); |
|
60 virtual nsresult WillUndoNotify(nsITransaction *aTransaction, bool *aInterrupt); |
|
61 virtual nsresult DidUndoNotify(nsITransaction *aTransaction, nsresult aUndoResult); |
|
62 virtual nsresult WillRedoNotify(nsITransaction *aTransaction, bool *aInterrupt); |
|
63 virtual nsresult DidRedoNotify(nsITransaction *aTransaction, nsresult aRedoResult); |
|
64 virtual nsresult WillBeginBatchNotify(bool *aInterrupt); |
|
65 virtual nsresult DidBeginBatchNotify(nsresult aResult); |
|
66 virtual nsresult WillEndBatchNotify(bool *aInterrupt); |
|
67 virtual nsresult DidEndBatchNotify(nsresult aResult); |
|
68 virtual nsresult WillMergeNotify(nsITransaction *aTop, |
|
69 nsITransaction *aTransaction, |
|
70 bool *aInterrupt); |
|
71 virtual nsresult DidMergeNotify(nsITransaction *aTop, |
|
72 nsITransaction *aTransaction, |
|
73 bool aDidMerge, |
|
74 nsresult aMergeResult); |
|
75 |
|
76 private: |
|
77 |
|
78 /* nsTransactionManager specific private methods. */ |
|
79 virtual nsresult BeginTransaction(nsITransaction *aTransaction, |
|
80 nsISupports *aData); |
|
81 virtual nsresult EndTransaction(bool aAllowEmpty); |
|
82 }; |
|
83 |
|
84 #endif // nsTransactionManager_h__ |