Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / html / nsIHTMLCollection.h
blob17d0c1fbcf17018b0773edbc33a42b6e87d7e6ff
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/. */
7 #ifndef nsIHTMLCollection_h___
8 #define nsIHTMLCollection_h___
10 #include "nsISupports.h"
11 #include "nsStringFwd.h"
12 #include "nsTArrayForwardDeclare.h"
13 #include "nsWrapperCache.h"
14 #include "js/TypeDecls.h"
16 class nsINode;
18 namespace mozilla::dom {
19 class Element;
20 } // namespace mozilla::dom
22 // IID for the nsIHTMLCollection interface
23 #define NS_IHTMLCOLLECTION_IID \
24 { \
25 0x4e169191, 0x5196, 0x4e17, { \
26 0xa4, 0x79, 0xd5, 0x35, 0x0b, 0x5b, 0x0a, 0xcd \
27 } \
30 /**
31 * An internal interface
33 class nsIHTMLCollection : public nsISupports {
34 public:
35 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTMLCOLLECTION_IID)
37 /**
38 * Get the root node for this HTML collection.
40 virtual nsINode* GetParentObject() = 0;
42 virtual uint32_t Length() = 0;
43 virtual mozilla::dom::Element* GetElementAt(uint32_t index) = 0;
44 mozilla::dom::Element* Item(uint32_t index) { return GetElementAt(index); }
45 mozilla::dom::Element* IndexedGetter(uint32_t index, bool& aFound) {
46 mozilla::dom::Element* item = Item(index);
47 aFound = !!item;
48 return item;
50 mozilla::dom::Element* NamedItem(const nsAString& aName) {
51 bool dummy;
52 return NamedGetter(aName, dummy);
54 mozilla::dom::Element* NamedGetter(const nsAString& aName, bool& aFound) {
55 return GetFirstNamedElement(aName, aFound);
57 virtual mozilla::dom::Element* GetFirstNamedElement(const nsAString& aName,
58 bool& aFound) = 0;
60 virtual void GetSupportedNames(nsTArray<nsString>& aNames) = 0;
62 JSObject* GetWrapperPreserveColor() {
63 return GetWrapperPreserveColorInternal();
65 JSObject* GetWrapper() {
66 JSObject* obj = GetWrapperPreserveColor();
67 if (obj) {
68 JS::ExposeObjectToActiveJS(obj);
70 return obj;
72 void PreserveWrapper(nsISupports* aScriptObjectHolder) {
73 PreserveWrapperInternal(aScriptObjectHolder);
75 virtual JSObject* WrapObject(JSContext* aCx,
76 JS::Handle<JSObject*> aGivenProto) = 0;
78 protected:
79 // Hook for calling nsWrapperCache::GetWrapperPreserveColor.
80 virtual JSObject* GetWrapperPreserveColorInternal() = 0;
81 // Hook for calling nsWrapperCache::PreserveWrapper.
82 virtual void PreserveWrapperInternal(nsISupports* aScriptObjectHolder) = 0;
85 NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLCollection, NS_IHTMLCOLLECTION_IID)
87 #endif /* nsIHTMLCollection_h___ */