2001-09-25 22:53:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-11-24 00:43:31 +00:00
|
|
|
|
|
|
|
#ifndef nsTransactionStack_h__
|
|
|
|
#define nsTransactionStack_h__
|
|
|
|
|
2013-04-28 11:33:45 +00:00
|
|
|
#include <deque>
|
|
|
|
#include "nsAutoPtr.h"
|
1998-11-24 00:43:31 +00:00
|
|
|
|
2012-07-13 06:33:42 +00:00
|
|
|
class nsCycleCollectionTraversalCallback;
|
1998-12-01 18:38:52 +00:00
|
|
|
class nsTransactionItem;
|
|
|
|
|
1998-11-24 00:43:31 +00:00
|
|
|
class nsTransactionStack
|
|
|
|
{
|
|
|
|
public:
|
2012-03-02 20:08:40 +00:00
|
|
|
enum Type { FOR_UNDO, FOR_REDO };
|
1998-11-24 00:43:31 +00:00
|
|
|
|
2012-03-02 20:08:40 +00:00
|
|
|
explicit nsTransactionStack(Type aType);
|
|
|
|
~nsTransactionStack();
|
1998-11-24 00:43:31 +00:00
|
|
|
|
2012-03-02 20:08:40 +00:00
|
|
|
void Push(nsTransactionItem *aTransactionItem);
|
|
|
|
already_AddRefed<nsTransactionItem> Pop();
|
|
|
|
already_AddRefed<nsTransactionItem> PopBottom();
|
|
|
|
already_AddRefed<nsTransactionItem> Peek();
|
2012-08-22 15:56:38 +00:00
|
|
|
already_AddRefed<nsTransactionItem> GetItem(int32_t aIndex);
|
2012-03-02 20:08:40 +00:00
|
|
|
void Clear();
|
2013-04-28 11:33:45 +00:00
|
|
|
int32_t GetSize() { return mDeque.size(); }
|
2009-05-09 04:59:25 +00:00
|
|
|
|
|
|
|
void DoUnlink() { Clear(); }
|
|
|
|
void DoTraverse(nsCycleCollectionTraversalCallback &cb);
|
1998-11-24 00:43:31 +00:00
|
|
|
|
2012-03-02 20:08:40 +00:00
|
|
|
private:
|
2013-04-28 11:33:45 +00:00
|
|
|
std::deque<nsRefPtr<nsTransactionItem> > mDeque;
|
2012-03-02 20:08:40 +00:00
|
|
|
const Type mType;
|
1998-11-24 00:43:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsTransactionStack_h__
|