Line data Source code
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 :
6 : #ifndef nsTransactionStack_h__
7 : #define nsTransactionStack_h__
8 :
9 : #include "nsDeque.h"
10 :
11 : class nsCycleCollectionTraversalCallback;
12 : class nsTransactionItem;
13 :
14 : class nsTransactionStack : private nsDeque
15 : {
16 : public:
17 : enum Type { FOR_UNDO, FOR_REDO };
18 :
19 : explicit nsTransactionStack(Type aType);
20 : ~nsTransactionStack();
21 :
22 : void Push(nsTransactionItem *aTransactionItem);
23 : void Push(already_AddRefed<nsTransactionItem> aTransactionItem);
24 : already_AddRefed<nsTransactionItem> Pop();
25 : already_AddRefed<nsTransactionItem> PopBottom();
26 : already_AddRefed<nsTransactionItem> Peek();
27 : already_AddRefed<nsTransactionItem> GetItem(int32_t aIndex);
28 : void Clear();
29 22 : int32_t GetSize() const { return static_cast<int32_t>(nsDeque::GetSize()); }
30 6 : bool IsEmpty() const { return GetSize() == 0; }
31 :
32 0 : void DoUnlink() { Clear(); }
33 : void DoTraverse(nsCycleCollectionTraversalCallback &cb);
34 :
35 : private:
36 : const Type mType;
37 : };
38 :
39 : #endif // nsTransactionStack_h__
|