Bumping manifests a=b2g-bump
[gecko.git] / editor / txmgr / nsTransactionManager.h
blob4399f493a367bf5fc9e51e7b5f9f1d1e88fcffcc
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/. */
6 #ifndef nsTransactionManager_h__
7 #define nsTransactionManager_h__
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"
19 class nsITransaction;
20 class nsITransactionListener;
21 class nsTransactionItem;
23 /** implementation of a transaction manager object.
26 class nsTransactionManager MOZ_FINAL : public nsITransactionManager
27 , public nsSupportsWeakReference
29 private:
31 int32_t mMaxTransactionCount;
32 nsTransactionStack mDoStack;
33 nsTransactionStack mUndoStack;
34 nsTransactionStack mRedoStack;
35 nsCOMArray<nsITransactionListener> mListeners;
37 /** The default destructor.
39 virtual ~nsTransactionManager();
41 public:
43 /** The default constructor.
45 explicit nsTransactionManager(int32_t aMaxTransactionCount=-1);
47 /* Macro for AddRef(), Release(), and QueryInterface() */
48 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
49 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTransactionManager,
50 nsITransactionManager)
52 /* nsITransactionManager method implementations. */
53 NS_DECL_NSITRANSACTIONMANAGER
55 already_AddRefed<nsITransaction> PeekUndoStack();
56 already_AddRefed<nsITransaction> PeekRedoStack();
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);
76 private:
78 /* nsTransactionManager specific private methods. */
79 virtual nsresult BeginTransaction(nsITransaction *aTransaction,
80 nsISupports *aData);
81 virtual nsresult EndTransaction(bool aAllowEmpty);
84 #endif // nsTransactionManager_h__