1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/public/nsINodeList.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsINodeList_h___ 1.10 +#define nsINodeList_h___ 1.11 + 1.12 +#include "nsIDOMNodeList.h" 1.13 +#include "nsWrapperCache.h" 1.14 +#include "nsIContent.h" 1.15 + 1.16 +// IID for the nsINodeList interface 1.17 +#define NS_INODELIST_IID \ 1.18 +{ 0xadb5e54c, 0x6e96, 0x4102, \ 1.19 + { 0x8d, 0x40, 0xe0, 0x12, 0x3d, 0xcf, 0x48, 0x7a } } 1.20 + 1.21 +/** 1.22 + * An internal interface for a reasonably fast indexOf. 1.23 + */ 1.24 +class nsINodeList : public nsIDOMNodeList, 1.25 + public nsWrapperCache 1.26 +{ 1.27 +public: 1.28 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODELIST_IID) 1.29 + 1.30 + /** 1.31 + * Get the index of the given node in the list. Will return -1 if the node 1.32 + * is not in the list. 1.33 + */ 1.34 + virtual int32_t IndexOf(nsIContent* aContent) = 0; 1.35 + 1.36 + /** 1.37 + * Get the root node for this nodelist. 1.38 + */ 1.39 + virtual nsINode* GetParentObject() = 0; 1.40 + 1.41 + using nsIDOMNodeList::Item; 1.42 + 1.43 + uint32_t Length() 1.44 + { 1.45 + uint32_t length; 1.46 + GetLength(&length); 1.47 + return length; 1.48 + } 1.49 + virtual nsIContent* Item(uint32_t aIndex) = 0; 1.50 + nsIContent* IndexedGetter(uint32_t aIndex, bool& aFound) 1.51 + { 1.52 + nsIContent* item = Item(aIndex); 1.53 + aFound = !!item; 1.54 + return item; 1.55 + } 1.56 +}; 1.57 + 1.58 +#define NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \ 1.59 + NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINodeList) 1.60 + 1.61 +NS_DEFINE_STATIC_IID_ACCESSOR(nsINodeList, NS_INODELIST_IID) 1.62 + 1.63 +#endif /* nsINodeList_h___ */