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