author Andrew McCreight <continuation@gmail.com>
Thu, 13 Aug 2015 14:24:59 -0700
changeset 257735 9b16a669ddc717870613ef78fd39fd8257b76834
parent 191040 1f9ddc6738f63865f02dd7823df817ae51e29f7e
child 266353 91d4539e00cecb658604e021675a923c60ef3235
permissions -rw-r--r--
Bug 1193572, part 2 - nsXULPrototypeElement::Deserialize should use fallible SetCapacity. r=baku I think this prevents a crash if we end up with a bogus cache value.

/* -*- 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__