|
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 mozilla_dom_HTMLAllCollection_h |
|
8 #define mozilla_dom_HTMLAllCollection_h |
|
9 |
|
10 #include "js/RootingAPI.h" |
|
11 #include "nsAutoPtr.h" |
|
12 #include "nsCycleCollectionParticipant.h" |
|
13 #include "nsISupportsImpl.h" |
|
14 #include "nsRefPtrHashtable.h" |
|
15 |
|
16 #include <stdint.h> |
|
17 |
|
18 class nsContentList; |
|
19 class nsHTMLDocument; |
|
20 class nsIContent; |
|
21 class nsWrapperCache; |
|
22 |
|
23 namespace mozilla { |
|
24 class ErrorResult; |
|
25 |
|
26 namespace dom { |
|
27 |
|
28 class HTMLAllCollection |
|
29 { |
|
30 public: |
|
31 HTMLAllCollection(nsHTMLDocument* aDocument); |
|
32 ~HTMLAllCollection(); |
|
33 |
|
34 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(HTMLAllCollection) |
|
35 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(HTMLAllCollection) |
|
36 |
|
37 uint32_t Length(); |
|
38 nsIContent* Item(uint32_t aIndex); |
|
39 |
|
40 JSObject* GetObject(JSContext* aCx, ErrorResult& aRv); |
|
41 |
|
42 nsISupports* GetNamedItem(const nsAString& aID, nsWrapperCache** aCache); |
|
43 |
|
44 private: |
|
45 nsContentList* Collection(); |
|
46 |
|
47 /** |
|
48 * Returns the NodeList for document.all[aID], or null if there isn't one. |
|
49 */ |
|
50 nsContentList* GetDocumentAllList(const nsAString& aID); |
|
51 |
|
52 JS::Heap<JSObject*> mObject; |
|
53 nsRefPtr<nsHTMLDocument> mDocument; |
|
54 nsRefPtr<nsContentList> mCollection; |
|
55 nsRefPtrHashtable<nsStringHashKey, nsContentList> mNamedMap; |
|
56 }; |
|
57 |
|
58 } // namespace dom |
|
59 } // namespace mozilla |
|
60 |
|
61 #endif // mozilla_dom_HTMLAllCollection_h |