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"
12 class nsCycleCollectionTraversalCallback
;
16 class TransactionItem
;
18 class TransactionStack
: private nsRefPtrDeque
<TransactionItem
> {
20 enum Type
{ FOR_UNDO
, FOR_REDO
};
22 explicit TransactionStack(Type aType
);
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;
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
);
42 } // namespace mozilla
44 #endif // mozilla_TransactionStack_h