nsTransactionManager.h 3.0 KB

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