Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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/. */
6 :
7 : #ifndef __nsIContentIterator_h___
8 : #define __nsIContentIterator_h___
9 :
10 : #include "nsISupports.h"
11 : #include "nsCOMPtr.h"
12 :
13 : class nsINode;
14 : class nsIDOMRange;
15 :
16 : #define NS_ICONTENTITERATOR_IID \
17 : { 0x2550078e, 0xae87, 0x4914, \
18 : { 0xb3, 0x04, 0xe4, 0xd1, 0x46, 0x19, 0x3d, 0x5f } }
19 :
20 0 : class nsIContentIterator : public nsISupports
21 : {
22 : public:
23 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTITERATOR_IID)
24 :
25 : /* Initializes an iterator for the subtree rooted by the node aRoot
26 : */
27 : virtual nsresult Init(nsINode* aRoot) = 0;
28 :
29 : /* Initializes an iterator for the subtree defined by the range aRange
30 : Subclasses should make sure they implement both of these!
31 : */
32 : virtual nsresult Init(nsIDOMRange* aRange) = 0;
33 :
34 : /** First will reset the list.
35 : */
36 : virtual void First() = 0;
37 :
38 : /** Last will reset the list to the end.
39 : */
40 : virtual void Last() = 0;
41 :
42 : /** Next will advance the list.
43 : */
44 : virtual void Next() = 0;
45 :
46 : /** Prev will decrement the list.
47 : */
48 : virtual void Prev() = 0;
49 :
50 : /** CurrentItem will return the current item, or null if the list is empty
51 : * @return the current node
52 : */
53 : virtual nsINode *GetCurrentNode() = 0;
54 :
55 : /** return if the collection is at the end. that is the beginning following a call to Prev
56 : * and it is the end of the list following a call to next
57 : * @return if the iterator is done.
58 : */
59 : virtual bool IsDone() = 0;
60 :
61 : /** PositionAt will position the iterator to the supplied node
62 : */
63 : virtual nsresult PositionAt(nsINode* aCurNode) = 0;
64 : };
65 :
66 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentIterator, NS_ICONTENTITERATOR_IID)
67 :
68 : already_AddRefed<nsIContentIterator> NS_NewContentIterator();
69 : already_AddRefed<nsIContentIterator> NS_NewPreContentIterator();
70 : already_AddRefed<nsIContentIterator> NS_NewContentSubtreeIterator();
71 :
72 : #endif // __nsIContentIterator_h___
|