Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/html/nsIHTMLCollection.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 nsIHTMLCollection_h___
8
#define nsIHTMLCollection_h___
9
10
#include "nsISupports.h"
11
#include "nsStringFwd.h"
12
#include "nsTArrayForwardDeclare.h"
13
#include "nsWrapperCache.h"
14
#include "js/RootingAPI.h"
15
#include "js/TypeDecls.h"
16
17
class nsINode;
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
class nsIHTMLCollection : public nsISupports
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
  virtual uint32_t Length() = 0;
44
  virtual mozilla::dom::Element* GetElementAt(uint32_t index) = 0;
45
  mozilla::dom::Element* Item(uint32_t index)
46
0
  {
47
0
    return GetElementAt(index);
48
0
  }
49
  mozilla::dom::Element* IndexedGetter(uint32_t index, bool& aFound)
50
0
  {
51
0
    mozilla::dom::Element* item = Item(index);
52
0
    aFound = !!item;
53
0
    return item;
54
0
  }
55
  mozilla::dom::Element* NamedItem(const nsAString& aName)
56
0
  {
57
0
    bool dummy;
58
0
    return NamedGetter(aName, dummy);
59
0
  }
60
  mozilla::dom::Element* NamedGetter(const nsAString& aName, bool& aFound)
61
0
  {
62
0
    return GetFirstNamedElement(aName, aFound);
63
0
  }
64
  virtual mozilla::dom::Element*
65
  GetFirstNamedElement(const nsAString& aName, bool& aFound) = 0;
66
67
  virtual void GetSupportedNames(nsTArray<nsString>& aNames) = 0;
68
69
  JSObject* GetWrapperPreserveColor()
70
0
  {
71
0
    return GetWrapperPreserveColorInternal();
72
0
  }
73
  JSObject* GetWrapper()
74
0
  {
75
0
    JSObject* obj = GetWrapperPreserveColor();
76
0
    if (obj) {
77
0
      JS::ExposeObjectToActiveJS(obj);
78
0
    }
79
0
    return obj;
80
0
  }
81
  void PreserveWrapper(nsISupports* aScriptObjectHolder)
82
0
  {
83
0
    PreserveWrapperInternal(aScriptObjectHolder);
84
0
  }
85
  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) = 0;
86
protected:
87
  // Hook for calling nsWrapperCache::GetWrapperPreserveColor.
88
  virtual JSObject* GetWrapperPreserveColorInternal() = 0;
89
  // Hook for calling nsWrapperCache::PreserveWrapper.
90
  virtual void PreserveWrapperInternal(nsISupports* aScriptObjectHolder) = 0;
91
};
92
93
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLCollection, NS_IHTMLCOLLECTION_IID)
94
95
#endif /* nsIHTMLCollection_h___ */