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