michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsINodeList_h___ michael@0: #define nsINodeList_h___ michael@0: michael@0: #include "nsIDOMNodeList.h" michael@0: #include "nsWrapperCache.h" michael@0: #include "nsIContent.h" michael@0: michael@0: // IID for the nsINodeList interface michael@0: #define NS_INODELIST_IID \ michael@0: { 0xadb5e54c, 0x6e96, 0x4102, \ michael@0: { 0x8d, 0x40, 0xe0, 0x12, 0x3d, 0xcf, 0x48, 0x7a } } michael@0: michael@0: /** michael@0: * An internal interface for a reasonably fast indexOf. michael@0: */ michael@0: class nsINodeList : public nsIDOMNodeList, michael@0: public nsWrapperCache michael@0: { michael@0: public: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODELIST_IID) michael@0: michael@0: /** michael@0: * Get the index of the given node in the list. Will return -1 if the node michael@0: * is not in the list. michael@0: */ michael@0: virtual int32_t IndexOf(nsIContent* aContent) = 0; michael@0: michael@0: /** michael@0: * Get the root node for this nodelist. michael@0: */ michael@0: virtual nsINode* GetParentObject() = 0; michael@0: michael@0: using nsIDOMNodeList::Item; michael@0: michael@0: uint32_t Length() michael@0: { michael@0: uint32_t length; michael@0: GetLength(&length); michael@0: return length; michael@0: } michael@0: virtual nsIContent* Item(uint32_t aIndex) = 0; michael@0: nsIContent* IndexedGetter(uint32_t aIndex, bool& aFound) michael@0: { michael@0: nsIContent* item = Item(aIndex); michael@0: aFound = !!item; michael@0: return item; michael@0: } michael@0: }; michael@0: michael@0: #define NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \ michael@0: NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINodeList) michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsINodeList, NS_INODELIST_IID) michael@0: michael@0: #endif /* nsINodeList_h___ */