Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / editor / txmgr / TransactionStack.h
blob74e8aebec8a425efda2fed21af90f40847a21863
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 mozilla_TransactionStack_h
7 #define mozilla_TransactionStack_h
9 #include "mozilla/AlreadyAddRefed.h"
10 #include "nsDeque.h"
12 class nsCycleCollectionTraversalCallback;
14 namespace mozilla {
16 class TransactionItem;
18 class TransactionStack : private nsRefPtrDeque<TransactionItem> {
19 public:
20 enum Type { FOR_UNDO, FOR_REDO };
22 explicit TransactionStack(Type aType);
23 ~TransactionStack();
25 void Push(TransactionItem* aTransactionItem);
26 void Push(already_AddRefed<TransactionItem> aTransactionItem);
27 already_AddRefed<TransactionItem> Pop();
28 already_AddRefed<TransactionItem> PopBottom();
29 already_AddRefed<TransactionItem> Peek() const;
30 already_AddRefed<TransactionItem> GetItemAt(size_t aIndex) const;
31 void Clear();
32 size_t GetSize() const { return nsRefPtrDeque<TransactionItem>::GetSize(); }
33 bool IsEmpty() const { return GetSize() == 0; }
35 void DoUnlink() { Clear(); }
36 void DoTraverse(nsCycleCollectionTraversalCallback& cb);
38 private:
39 const Type mType;
42 } // namespace mozilla
44 #endif // mozilla_TransactionStack_h