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 nsIHTMLCollection_h___
8 : #define nsIHTMLCollection_h___
9 :
10 : #include "nsIDOMHTMLCollection.h"
11 : #include "nsTArrayForwardDeclare.h"
12 : #include "nsWrapperCache.h"
13 : #include "js/GCAPI.h"
14 : #include "js/TypeDecls.h"
15 :
16 : class nsINode;
17 : class nsString;
18 :
19 : namespace mozilla {
20 : namespace dom {
21 : class Element;
22 : } // namespace dom
23 : } // namespace mozilla
24 :
25 : // IID for the nsIHTMLCollection interface
26 : #define NS_IHTMLCOLLECTION_IID \
27 : { 0x4e169191, 0x5196, 0x4e17, \
28 : { 0xa4, 0x79, 0xd5, 0x35, 0x0b, 0x5b, 0x0a, 0xcd } }
29 :
30 : /**
31 : * An internal interface
32 : */
33 10 : class nsIHTMLCollection : public nsIDOMHTMLCollection
34 : {
35 : public:
36 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTMLCOLLECTION_IID)
37 :
38 : /**
39 : * Get the root node for this HTML collection.
40 : */
41 : virtual nsINode* GetParentObject() = 0;
42 :
43 : using nsIDOMHTMLCollection::Item;
44 : using nsIDOMHTMLCollection::NamedItem;
45 :
46 42 : uint32_t Length()
47 : {
48 : uint32_t length;
49 42 : GetLength(&length);
50 42 : return length;
51 : }
52 : virtual mozilla::dom::Element* GetElementAt(uint32_t index) = 0;
53 40 : mozilla::dom::Element* Item(uint32_t index)
54 : {
55 40 : return GetElementAt(index);
56 : }
57 37 : mozilla::dom::Element* IndexedGetter(uint32_t index, bool& aFound)
58 : {
59 37 : mozilla::dom::Element* item = Item(index);
60 37 : aFound = !!item;
61 37 : return item;
62 : }
63 0 : mozilla::dom::Element* NamedItem(const nsAString& aName)
64 : {
65 : bool dummy;
66 0 : return NamedGetter(aName, dummy);
67 : }
68 0 : mozilla::dom::Element* NamedGetter(const nsAString& aName, bool& aFound)
69 : {
70 0 : return GetFirstNamedElement(aName, aFound);
71 : }
72 : virtual mozilla::dom::Element*
73 : GetFirstNamedElement(const nsAString& aName, bool& aFound) = 0;
74 :
75 : virtual void GetSupportedNames(nsTArray<nsString>& aNames) = 0;
76 :
77 7 : JSObject* GetWrapperPreserveColor()
78 : {
79 7 : return GetWrapperPreserveColorInternal();
80 : }
81 7 : JSObject* GetWrapper()
82 : {
83 7 : JSObject* obj = GetWrapperPreserveColor();
84 7 : if (obj) {
85 0 : JS::ExposeObjectToActiveJS(obj);
86 : }
87 7 : return obj;
88 : }
89 0 : void PreserveWrapper(nsISupports* aScriptObjectHolder)
90 : {
91 0 : PreserveWrapperInternal(aScriptObjectHolder);
92 0 : }
93 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) = 0;
94 : protected:
95 : // Hook for calling nsWrapperCache::GetWrapperPreserveColor.
96 : virtual JSObject* GetWrapperPreserveColorInternal() = 0;
97 : // Hook for calling nsWrapperCache::PreserveWrapper.
98 : virtual void PreserveWrapperInternal(nsISupports* aScriptObjectHolder) = 0;
99 : };
100 :
101 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLCollection, NS_IHTMLCOLLECTION_IID)
102 :
103 : #endif /* nsIHTMLCollection_h___ */
|