content/base/public/nsINodeList.h

branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
equal deleted inserted replaced
-1:000000000000 0:83d5ee10b946
1 /* -*- Mode: C++; tab-width: 2; 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 nsINodeList_h___
7 #define nsINodeList_h___
8
9 #include "nsIDOMNodeList.h"
10 #include "nsWrapperCache.h"
11 #include "nsIContent.h"
12
13 // IID for the nsINodeList interface
14 #define NS_INODELIST_IID \
15 { 0xadb5e54c, 0x6e96, 0x4102, \
16 { 0x8d, 0x40, 0xe0, 0x12, 0x3d, 0xcf, 0x48, 0x7a } }
17
18 /**
19 * An internal interface for a reasonably fast indexOf.
20 */
21 class nsINodeList : public nsIDOMNodeList,
22 public nsWrapperCache
23 {
24 public:
25 NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODELIST_IID)
26
27 /**
28 * Get the index of the given node in the list. Will return -1 if the node
29 * is not in the list.
30 */
31 virtual int32_t IndexOf(nsIContent* aContent) = 0;
32
33 /**
34 * Get the root node for this nodelist.
35 */
36 virtual nsINode* GetParentObject() = 0;
37
38 using nsIDOMNodeList::Item;
39
40 uint32_t Length()
41 {
42 uint32_t length;
43 GetLength(&length);
44 return length;
45 }
46 virtual nsIContent* Item(uint32_t aIndex) = 0;
47 nsIContent* IndexedGetter(uint32_t aIndex, bool& aFound)
48 {
49 nsIContent* item = Item(aIndex);
50 aFound = !!item;
51 return item;
52 }
53 };
54
55 #define NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \
56 NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINodeList)
57
58 NS_DEFINE_STATIC_IID_ACCESSOR(nsINodeList, NS_INODELIST_IID)
59
60 #endif /* nsINodeList_h___ */

mercurial