docshell/base/nsDocShellEnumerator.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     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;
    16 /*
    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"
    30 */
    32 class nsDocShellEnumerator : public nsISimpleEnumerator
    33 {
    34 protected:
    36   enum {
    37     enumerateForwards,
    38     enumerateBackwards
    39   };
    41 public:
    43                               nsDocShellEnumerator(int32_t inEnumerationDirection);
    44   virtual                     ~nsDocShellEnumerator();
    46   // nsISupports
    47   NS_DECL_ISUPPORTS
    49   // nsISimpleEnumerator
    50   NS_DECL_NSISIMPLEENUMERATOR
    52 public:
    54   nsresult                    GetEnumerationRootItem(nsIDocShellTreeItem * *aEnumerationRootItem);
    55   nsresult                    SetEnumerationRootItem(nsIDocShellTreeItem * aEnumerationRootItem);
    57   nsresult                    GetEnumDocShellType(int32_t *aEnumerationItemType);
    58   nsresult                    SetEnumDocShellType(int32_t aEnumerationItemType);
    60   nsresult                    First();
    62 protected:
    64   nsresult                    EnsureDocShellArray();
    65   nsresult                    ClearState();
    67   nsresult                    BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray);
    68   virtual nsresult            BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray) = 0;
    70 protected:
    72   nsWeakPtr                   mRootItem;      // weak ref!
    74   nsTArray<nsWeakPtr>         mItemArray;     // flattened list of items with matching type
    75   uint32_t                    mCurIndex;
    77   int32_t                     mDocShellType;  // only want shells of this type
    78   bool                        mArrayValid;    // is mItemArray up to date?
    80   const int8_t                mEnumerationDirection;
    81 };
    84 class nsDocShellForwardsEnumerator : public nsDocShellEnumerator
    85 {
    86 public:
    88                               nsDocShellForwardsEnumerator()
    89                               : nsDocShellEnumerator(enumerateForwards)
    90                               {                              
    91                               }
    93 protected:
    95   virtual nsresult            BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
    97 };
    99 class nsDocShellBackwardsEnumerator : public nsDocShellEnumerator
   100 {
   101 public:
   103                               nsDocShellBackwardsEnumerator()
   104                               : nsDocShellEnumerator(enumerateBackwards)
   105                               {                              
   106                               }
   107 protected:
   109   virtual nsresult            BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
   110 };
   112 #endif // nsDocShellEnumerator_h___

mercurial