Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef nsDocShellEnumerator_h___ |
michael@0 | 8 | #define nsDocShellEnumerator_h___ |
michael@0 | 9 | |
michael@0 | 10 | #include "nsISimpleEnumerator.h" |
michael@0 | 11 | #include "nsTArray.h" |
michael@0 | 12 | #include "nsIWeakReferenceUtils.h" |
michael@0 | 13 | |
michael@0 | 14 | class nsIDocShellTreeItem; |
michael@0 | 15 | |
michael@0 | 16 | /* |
michael@0 | 17 | // {13cbc281-35ae-11d5-be5b-bde0edece43c} |
michael@0 | 18 | #define NS_DOCSHELL_FORWARDS_ENUMERATOR_CID \ |
michael@0 | 19 | { 0x13cbc281, 0x35ae, 0x11d5, { 0xbe, 0x5b, 0xbd, 0xe0, 0xed, 0xec, 0xe4, 0x3c } } |
michael@0 | 20 | |
michael@0 | 21 | #define NS_DOCSHELL_FORWARDS_ENUMERATOR_CONTRACTID \ |
michael@0 | 22 | "@mozilla.org/docshell/enumerator-forwards;1" |
michael@0 | 23 | |
michael@0 | 24 | // {13cbc282-35ae-11d5-be5b-bde0edece43c} |
michael@0 | 25 | #define NS_DOCSHELL_BACKWARDS_ENUMERATOR_CID \ |
michael@0 | 26 | { 0x13cbc282, 0x35ae, 0x11d5, { 0xbe, 0x5b, 0xbd, 0xe0, 0xed, 0xec, 0xe4, 0x3c } } |
michael@0 | 27 | |
michael@0 | 28 | #define NS_DOCSHELL_BACKWARDS_ENUMERATOR_CONTRACTID \ |
michael@0 | 29 | "@mozilla.org/docshell/enumerator-backwards;1" |
michael@0 | 30 | */ |
michael@0 | 31 | |
michael@0 | 32 | class nsDocShellEnumerator : public nsISimpleEnumerator |
michael@0 | 33 | { |
michael@0 | 34 | protected: |
michael@0 | 35 | |
michael@0 | 36 | enum { |
michael@0 | 37 | enumerateForwards, |
michael@0 | 38 | enumerateBackwards |
michael@0 | 39 | }; |
michael@0 | 40 | |
michael@0 | 41 | public: |
michael@0 | 42 | |
michael@0 | 43 | nsDocShellEnumerator(int32_t inEnumerationDirection); |
michael@0 | 44 | virtual ~nsDocShellEnumerator(); |
michael@0 | 45 | |
michael@0 | 46 | // nsISupports |
michael@0 | 47 | NS_DECL_ISUPPORTS |
michael@0 | 48 | |
michael@0 | 49 | // nsISimpleEnumerator |
michael@0 | 50 | NS_DECL_NSISIMPLEENUMERATOR |
michael@0 | 51 | |
michael@0 | 52 | public: |
michael@0 | 53 | |
michael@0 | 54 | nsresult GetEnumerationRootItem(nsIDocShellTreeItem * *aEnumerationRootItem); |
michael@0 | 55 | nsresult SetEnumerationRootItem(nsIDocShellTreeItem * aEnumerationRootItem); |
michael@0 | 56 | |
michael@0 | 57 | nsresult GetEnumDocShellType(int32_t *aEnumerationItemType); |
michael@0 | 58 | nsresult SetEnumDocShellType(int32_t aEnumerationItemType); |
michael@0 | 59 | |
michael@0 | 60 | nsresult First(); |
michael@0 | 61 | |
michael@0 | 62 | protected: |
michael@0 | 63 | |
michael@0 | 64 | nsresult EnsureDocShellArray(); |
michael@0 | 65 | nsresult ClearState(); |
michael@0 | 66 | |
michael@0 | 67 | nsresult BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray); |
michael@0 | 68 | virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray) = 0; |
michael@0 | 69 | |
michael@0 | 70 | protected: |
michael@0 | 71 | |
michael@0 | 72 | nsWeakPtr mRootItem; // weak ref! |
michael@0 | 73 | |
michael@0 | 74 | nsTArray<nsWeakPtr> mItemArray; // flattened list of items with matching type |
michael@0 | 75 | uint32_t mCurIndex; |
michael@0 | 76 | |
michael@0 | 77 | int32_t mDocShellType; // only want shells of this type |
michael@0 | 78 | bool mArrayValid; // is mItemArray up to date? |
michael@0 | 79 | |
michael@0 | 80 | const int8_t mEnumerationDirection; |
michael@0 | 81 | }; |
michael@0 | 82 | |
michael@0 | 83 | |
michael@0 | 84 | class nsDocShellForwardsEnumerator : public nsDocShellEnumerator |
michael@0 | 85 | { |
michael@0 | 86 | public: |
michael@0 | 87 | |
michael@0 | 88 | nsDocShellForwardsEnumerator() |
michael@0 | 89 | : nsDocShellEnumerator(enumerateForwards) |
michael@0 | 90 | { |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | protected: |
michael@0 | 94 | |
michael@0 | 95 | virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray); |
michael@0 | 96 | |
michael@0 | 97 | }; |
michael@0 | 98 | |
michael@0 | 99 | class nsDocShellBackwardsEnumerator : public nsDocShellEnumerator |
michael@0 | 100 | { |
michael@0 | 101 | public: |
michael@0 | 102 | |
michael@0 | 103 | nsDocShellBackwardsEnumerator() |
michael@0 | 104 | : nsDocShellEnumerator(enumerateBackwards) |
michael@0 | 105 | { |
michael@0 | 106 | } |
michael@0 | 107 | protected: |
michael@0 | 108 | |
michael@0 | 109 | virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray); |
michael@0 | 110 | }; |
michael@0 | 111 | |
michael@0 | 112 | #endif // nsDocShellEnumerator_h___ |