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