1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/txmgr/src/nsTransactionManager.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,84 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsTransactionManager_h__ 1.10 +#define nsTransactionManager_h__ 1.11 + 1.12 +#include "nsCOMArray.h" 1.13 +#include "nsCOMPtr.h" 1.14 +#include "nsCycleCollectionParticipant.h" 1.15 +#include "nsTransactionStack.h" 1.16 +#include "nsISupportsImpl.h" 1.17 +#include "nsITransactionManager.h" 1.18 +#include "nsTransactionStack.h" 1.19 +#include "nsWeakReference.h" 1.20 +#include "nscore.h" 1.21 + 1.22 +class nsITransaction; 1.23 +class nsITransactionListener; 1.24 +class nsTransactionItem; 1.25 + 1.26 +/** implementation of a transaction manager object. 1.27 + * 1.28 + */ 1.29 +class nsTransactionManager : public nsITransactionManager 1.30 + , public nsSupportsWeakReference 1.31 +{ 1.32 +private: 1.33 + 1.34 + int32_t mMaxTransactionCount; 1.35 + nsTransactionStack mDoStack; 1.36 + nsTransactionStack mUndoStack; 1.37 + nsTransactionStack mRedoStack; 1.38 + nsCOMArray<nsITransactionListener> mListeners; 1.39 + 1.40 +public: 1.41 + 1.42 + /** The default constructor. 1.43 + */ 1.44 + nsTransactionManager(int32_t aMaxTransactionCount=-1); 1.45 + 1.46 + /** The default destructor. 1.47 + */ 1.48 + virtual ~nsTransactionManager(); 1.49 + 1.50 + /* Macro for AddRef(), Release(), and QueryInterface() */ 1.51 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.52 + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTransactionManager, 1.53 + nsITransactionManager) 1.54 + 1.55 + /* nsITransactionManager method implementations. */ 1.56 + NS_DECL_NSITRANSACTIONMANAGER 1.57 + 1.58 + already_AddRefed<nsITransaction> PeekUndoStack(); 1.59 + already_AddRefed<nsITransaction> PeekRedoStack(); 1.60 + 1.61 + virtual nsresult WillDoNotify(nsITransaction *aTransaction, bool *aInterrupt); 1.62 + virtual nsresult DidDoNotify(nsITransaction *aTransaction, nsresult aExecuteResult); 1.63 + virtual nsresult WillUndoNotify(nsITransaction *aTransaction, bool *aInterrupt); 1.64 + virtual nsresult DidUndoNotify(nsITransaction *aTransaction, nsresult aUndoResult); 1.65 + virtual nsresult WillRedoNotify(nsITransaction *aTransaction, bool *aInterrupt); 1.66 + virtual nsresult DidRedoNotify(nsITransaction *aTransaction, nsresult aRedoResult); 1.67 + virtual nsresult WillBeginBatchNotify(bool *aInterrupt); 1.68 + virtual nsresult DidBeginBatchNotify(nsresult aResult); 1.69 + virtual nsresult WillEndBatchNotify(bool *aInterrupt); 1.70 + virtual nsresult DidEndBatchNotify(nsresult aResult); 1.71 + virtual nsresult WillMergeNotify(nsITransaction *aTop, 1.72 + nsITransaction *aTransaction, 1.73 + bool *aInterrupt); 1.74 + virtual nsresult DidMergeNotify(nsITransaction *aTop, 1.75 + nsITransaction *aTransaction, 1.76 + bool aDidMerge, 1.77 + nsresult aMergeResult); 1.78 + 1.79 +private: 1.80 + 1.81 + /* nsTransactionManager specific private methods. */ 1.82 + virtual nsresult BeginTransaction(nsITransaction *aTransaction, 1.83 + nsISupports *aData); 1.84 + virtual nsresult EndTransaction(bool aAllowEmpty); 1.85 +}; 1.86 + 1.87 +#endif // nsTransactionManager_h__