Source code

Revision control

Other Tools

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