Bumping manifests a=b2g-bump
[gecko.git] / docshell / base / nsDocShellEnumerator.h
blobb885e47ac26f566e3b60fe69f29df9f9ec08dece
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsDocShellEnumerator_h___
8 #define nsDocShellEnumerator_h___
10 #include "nsISimpleEnumerator.h"
11 #include "nsTArray.h"
12 #include "nsIWeakReferenceUtils.h"
14 class nsIDocShellTreeItem;
17 // {13cbc281-35ae-11d5-be5b-bde0edece43c}
18 #define NS_DOCSHELL_FORWARDS_ENUMERATOR_CID \
19 { 0x13cbc281, 0x35ae, 0x11d5, { 0xbe, 0x5b, 0xbd, 0xe0, 0xed, 0xec, 0xe4, 0x3c } }
21 #define NS_DOCSHELL_FORWARDS_ENUMERATOR_CONTRACTID \
22 "@mozilla.org/docshell/enumerator-forwards;1"
24 // {13cbc282-35ae-11d5-be5b-bde0edece43c}
25 #define NS_DOCSHELL_BACKWARDS_ENUMERATOR_CID \
26 { 0x13cbc282, 0x35ae, 0x11d5, { 0xbe, 0x5b, 0xbd, 0xe0, 0xed, 0xec, 0xe4, 0x3c } }
28 #define NS_DOCSHELL_BACKWARDS_ENUMERATOR_CONTRACTID \
29 "@mozilla.org/docshell/enumerator-backwards;1"
32 class nsDocShellEnumerator : public nsISimpleEnumerator
34 protected:
36 enum {
37 enumerateForwards,
38 enumerateBackwards
41 virtual ~nsDocShellEnumerator();
43 public:
45 explicit nsDocShellEnumerator(int32_t inEnumerationDirection);
47 // nsISupports
48 NS_DECL_ISUPPORTS
50 // nsISimpleEnumerator
51 NS_DECL_NSISIMPLEENUMERATOR
53 public:
55 nsresult GetEnumerationRootItem(nsIDocShellTreeItem * *aEnumerationRootItem);
56 nsresult SetEnumerationRootItem(nsIDocShellTreeItem * aEnumerationRootItem);
58 nsresult GetEnumDocShellType(int32_t *aEnumerationItemType);
59 nsresult SetEnumDocShellType(int32_t aEnumerationItemType);
61 nsresult First();
63 protected:
65 nsresult EnsureDocShellArray();
66 nsresult ClearState();
68 nsresult BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray);
69 virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray) = 0;
71 protected:
73 nsWeakPtr mRootItem; // weak ref!
75 nsTArray<nsWeakPtr> mItemArray; // flattened list of items with matching type
76 uint32_t mCurIndex;
78 int32_t mDocShellType; // only want shells of this type
79 bool mArrayValid; // is mItemArray up to date?
81 const int8_t mEnumerationDirection;
85 class nsDocShellForwardsEnumerator : public nsDocShellEnumerator
87 public:
89 nsDocShellForwardsEnumerator()
90 : nsDocShellEnumerator(enumerateForwards)
94 protected:
96 virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
100 class nsDocShellBackwardsEnumerator : public nsDocShellEnumerator
102 public:
104 nsDocShellBackwardsEnumerator()
105 : nsDocShellEnumerator(enumerateBackwards)
108 protected:
110 virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
113 #endif // nsDocShellEnumerator_h___