author Ryan VanderMeulen <ryanvm@gmail.com>
Sat, 30 Aug 2014 21:27:11 -0400
changeset 202636 b87f8e6760d9693c2204a9ec97b7a80015539e4a
parent 190971 1f9ddc6738f63865f02dd7823df817ae51e29f7e
child 266617 91d4539e00cecb658604e021675a923c60ef3235
permissions -rw-r--r--
Backed out changeset cd821c1ef789 (bug 1037235) for blowing up B2G.

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */

#ifndef nsTransactionStack_h__
#define nsTransactionStack_h__

#include <deque>
#include "nsAutoPtr.h"

class nsCycleCollectionTraversalCallback;
class nsTransactionItem;

class nsTransactionStack
  enum Type { FOR_UNDO, FOR_REDO };

  explicit nsTransactionStack(Type aType);

  void Push(nsTransactionItem *aTransactionItem);
  already_AddRefed<nsTransactionItem> Pop();
  already_AddRefed<nsTransactionItem> PopBottom();
  already_AddRefed<nsTransactionItem> Peek();
  already_AddRefed<nsTransactionItem> GetItem(int32_t aIndex);
  void Clear();
  int32_t GetSize() { return mDeque.size(); }

  void DoUnlink() { Clear(); }
  void DoTraverse(nsCycleCollectionTraversalCallback &cb);

  std::deque<nsRefPtr<nsTransactionItem> > mDeque;
  const Type mType;

#endif // nsTransactionStack_h__