Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/HTMLAllCollection.h
Line
Count
Source (jump to first uncovered line)
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 "nsCycleCollectionParticipant.h"
11
#include "nsISupportsImpl.h"
12
#include "nsRefPtrHashtable.h"
13
#include "nsWrapperCache.h"
14
15
#include <stdint.h>
16
17
class nsContentList;
18
class nsHTMLDocument;
19
class nsIContent;
20
class nsINode;
21
22
namespace mozilla {
23
namespace dom {
24
25
class OwningNodeOrHTMLCollection;
26
template<typename> struct Nullable;
27
28
class HTMLAllCollection final : public nsISupports
29
                              , public nsWrapperCache
30
{
31
  ~HTMLAllCollection();
32
33
public:
34
  explicit HTMLAllCollection(nsHTMLDocument* aDocument);
35
36
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
37
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(HTMLAllCollection)
38
39
  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
40
  nsINode* GetParentObject() const;
41
42
  uint32_t Length();
43
  nsIContent* Item(uint32_t aIndex);
44
  void Item(const nsAString& aName, Nullable<OwningNodeOrHTMLCollection>& aResult)
45
0
  {
46
0
    NamedItem(aName, aResult);
47
0
  }
48
  nsIContent* IndexedGetter(uint32_t aIndex, bool& aFound)
49
0
  {
50
0
    nsIContent* result = Item(aIndex);
51
0
    aFound = !!result;
52
0
    return result;
53
0
  }
54
55
  void NamedItem(const nsAString& aName,
56
                 Nullable<OwningNodeOrHTMLCollection>& aResult)
57
0
  {
58
0
    bool found = false;
59
0
    NamedGetter(aName, found, aResult);
60
0
  }
61
  void NamedGetter(const nsAString& aName,
62
                   bool& aFound,
63
                   Nullable<OwningNodeOrHTMLCollection>& aResult);
64
  void GetSupportedNames(nsTArray<nsString>& aNames);
65
  void LegacyCall(JS::Handle<JS::Value>, const nsAString& aName,
66
                  Nullable<OwningNodeOrHTMLCollection>& aResult)
67
0
  {
68
0
    NamedItem(aName, aResult);
69
0
  }
70
71
private:
72
  nsContentList* Collection();
73
74
  /**
75
   * Returns the HTMLCollection for document.all[aID], or null if there isn't one.
76
   */
77
  nsContentList* GetDocumentAllList(const nsAString& aID);
78
79
  RefPtr<nsHTMLDocument> mDocument;
80
  RefPtr<nsContentList> mCollection;
81
  nsRefPtrHashtable<nsStringHashKey, nsContentList> mNamedMap;
82
};
83
84
} // namespace dom
85
} // namespace mozilla
86
87
#endif // mozilla_dom_HTMLAllCollection_h