Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/HTMLHeadElementBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM HTMLHeadElement.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "HTMLElementBinding.h"
4
#include "HTMLHeadElementBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/DOMJSClass.h"
9
#include "mozilla/dom/HTMLSharedElement.h"
10
#include "mozilla/dom/NonRefcountedDOMObject.h"
11
#include "mozilla/dom/XrayExpandoClass.h"
12
13
namespace mozilla {
14
namespace dom {
15
16
namespace binding_detail {}; // Just to make sure it's known as a namespace
17
using namespace mozilla::dom::binding_detail;
18
19
20
namespace HTMLHeadElement_Binding {
21
22
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElement_Binding::NativeType>::value,
23
              "Can't inherit from an interface with a different ownership model.");
24
25
static bool
26
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
27
0
{
28
0
  mozilla::dom::HTMLSharedElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedElement>(obj);
29
0
  // We don't want to preserve if we don't have a wrapper, and we
30
0
  // obviously can't preserve if we're not initialized.
31
0
  if (self && self->GetWrapperPreserveColor()) {
32
0
    PreserveWrapper(self);
33
0
  }
34
0
  return true;
35
0
}
36
37
static void
38
_finalize(js::FreeOp* fop, JSObject* obj)
39
0
{
40
0
  mozilla::dom::HTMLSharedElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedElement>(obj);
41
0
  if (self) {
42
0
    ClearWrapper(self, self, obj);
43
0
    AddForDeferredFinalization<mozilla::dom::HTMLSharedElement>(self);
44
0
  }
45
0
}
46
47
static size_t
48
_objectMoved(JSObject* obj, JSObject* old)
49
0
{
50
0
  mozilla::dom::HTMLSharedElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedElement>(obj);
51
0
  if (self) {
52
0
    UpdateWrapper(self, self, obj, old);
53
0
  }
54
0
55
0
  return 0;
56
0
}
57
58
static bool
59
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
60
0
{
61
0
  AUTO_PROFILER_LABEL_FAST("HTMLHeadElement constructor", DOM, cx);
62
0
63
0
  return HTMLConstructor(cx, argc, vp,
64
0
                         constructors::id::HTMLHeadElement,
65
0
                         prototypes::id::HTMLHeadElement,
66
0
                         CreateInterfaceObjects);
67
0
}
68
69
static const js::ClassOps sInterfaceObjectClassOps = {
70
    nullptr,               /* addProperty */
71
    nullptr,               /* delProperty */
72
    nullptr,               /* enumerate */
73
    nullptr,               /* newEnumerate */
74
    nullptr,               /* resolve */
75
    nullptr,               /* mayResolve */
76
    nullptr,               /* finalize */
77
    _constructor, /* call */
78
    nullptr,               /* hasInstance */
79
    _constructor, /* construct */
80
    nullptr,               /* trace */
81
};
82
83
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
84
  {
85
    "Function",
86
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
87
    &sInterfaceObjectClassOps,
88
    JS_NULL_CLASS_SPEC,
89
    JS_NULL_CLASS_EXT,
90
    &sInterfaceObjectClassObjectOps
91
  },
92
  eInterface,
93
  true,
94
  prototypes::id::HTMLHeadElement,
95
  PrototypeTraits<prototypes::id::HTMLHeadElement>::Depth,
96
  sNativePropertyHooks,
97
  "function HTMLHeadElement() {\n    [native code]\n}",
98
  HTMLElement_Binding::GetConstructorObject
99
};
100
101
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
102
  {
103
    "HTMLHeadElementPrototype",
104
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
105
    JS_NULL_CLASS_OPS,
106
    JS_NULL_CLASS_SPEC,
107
    JS_NULL_CLASS_EXT,
108
    JS_NULL_OBJECT_OPS
109
  },
110
  eInterfacePrototype,
111
  false,
112
  prototypes::id::HTMLHeadElement,
113
  PrototypeTraits<prototypes::id::HTMLHeadElement>::Depth,
114
  sNativePropertyHooks,
115
  "[object HTMLHeadElementPrototype]",
116
  HTMLElement_Binding::GetProtoObject
117
};
118
119
static const js::ClassOps sClassOps = {
120
  _addProperty, /* addProperty */
121
  nullptr,               /* delProperty */
122
  nullptr,               /* enumerate */
123
  nullptr, /* newEnumerate */
124
  nullptr, /* resolve */
125
  nullptr, /* mayResolve */
126
  _finalize, /* finalize */
127
  nullptr, /* call */
128
  nullptr,               /* hasInstance */
129
  nullptr,               /* construct */
130
  nullptr, /* trace */
131
};
132
133
static const js::ClassExtension sClassExtension = {
134
  nullptr, /* weakmapKeyDelegateOp */
135
  _objectMoved /* objectMovedOp */
136
};
137
138
static const DOMJSClass sClass = {
139
  { "HTMLHeadElement",
140
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
141
    &sClassOps,
142
    JS_NULL_CLASS_SPEC,
143
    &sClassExtension,
144
    JS_NULL_OBJECT_OPS
145
  },
146
  { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLHeadElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
147
  IsBaseOf<nsISupports, mozilla::dom::HTMLSharedElement >::value,
148
  sNativePropertyHooks,
149
  FindAssociatedGlobalForNative<mozilla::dom::HTMLSharedElement>::Get,
150
  GetProtoObjectHandle,
151
  GetCCParticipant<mozilla::dom::HTMLSharedElement>::Get()
152
};
153
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
154
              "Must have the right minimal number of reserved slots.");
155
static_assert(1 >= 1,
156
              "Must have enough reserved slots.");
157
158
const JSClass*
159
GetJSClass()
160
0
{
161
0
  return sClass.ToJSClass();
162
0
}
163
164
bool
165
Wrap(JSContext* aCx, mozilla::dom::HTMLSharedElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
166
0
{
167
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::HTMLSharedElement>::value,
168
0
                "Shouldn't have wrappercached things that are not refcounted.");
169
0
  MOZ_ASSERT(static_cast<mozilla::dom::HTMLSharedElement*>(aObject) ==
170
0
             reinterpret_cast<mozilla::dom::HTMLSharedElement*>(aObject),
171
0
             "Multiple inheritance for mozilla::dom::HTMLSharedElement is broken.");
172
0
  MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
173
0
             reinterpret_cast<nsGenericHTMLElement*>(aObject),
174
0
             "Multiple inheritance for nsGenericHTMLElement is broken.");
175
0
  MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
176
0
             reinterpret_cast<mozilla::dom::Element*>(aObject),
177
0
             "Multiple inheritance for mozilla::dom::Element is broken.");
178
0
  MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
179
0
             reinterpret_cast<nsINode*>(aObject),
180
0
             "Multiple inheritance for nsINode is broken.");
181
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
182
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
183
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
184
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
185
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
186
0
  MOZ_ASSERT(!aCache->GetWrapper(),
187
0
             "You should probably not be using Wrap() directly; use "
188
0
             "GetOrCreateDOMReflector instead");
189
0
190
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
191
0
             "nsISupports must be on our primary inheritance chain");
192
0
193
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
194
0
  if (!global) {
195
0
    return false;
196
0
  }
197
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
198
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
199
0
200
0
  // That might have ended up wrapping us already, due to the wonders
201
0
  // of XBL.  Check for that, and bail out as needed.
202
0
  aReflector.set(aCache->GetWrapper());
203
0
  if (aReflector) {
204
#ifdef DEBUG
205
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
206
#endif // DEBUG
207
    return true;
208
0
  }
209
0
210
0
  JSAutoRealm ar(aCx, global);
211
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
212
0
  if (!canonicalProto) {
213
0
    return false;
214
0
  }
215
0
  JS::Rooted<JSObject*> proto(aCx);
216
0
  if (aGivenProto) {
217
0
    proto = aGivenProto;
218
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
219
0
    // coming in, we changed compartments to that of "parent" so may need
220
0
    // to wrap the proto here.
221
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
222
0
      if (!JS_WrapObject(aCx, &proto)) {
223
0
        return false;
224
0
      }
225
0
    }
226
0
  } else {
227
0
    proto = canonicalProto;
228
0
  }
229
0
230
0
  BindingJSObjectCreator<mozilla::dom::HTMLSharedElement> creator(aCx);
231
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
232
0
  if (!aReflector) {
233
0
    return false;
234
0
  }
235
0
236
0
  aCache->SetWrapper(aReflector);
237
0
  creator.InitializationSucceeded();
238
0
239
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
240
0
             aCache->GetWrapperPreserveColor() == aReflector);
241
0
  // If proto != canonicalProto, we have to preserve our wrapper;
242
0
  // otherwise we won't be able to properly recreate it later, since
243
0
  // we won't know what proto to use.  Note that we don't check
244
0
  // aGivenProto here, since it's entirely possible (and even
245
0
  // somewhat common) to have a non-null aGivenProto which is the
246
0
  // same as canonicalProto.
247
0
  if (proto != canonicalProto) {
248
0
    PreserveWrapper(aObject);
249
0
  }
250
0
251
0
  return true;
252
0
}
253
254
const NativePropertyHooks sNativePropertyHooks[] = { {
255
  nullptr,
256
  nullptr,
257
  nullptr,
258
  { nullptr, nullptr },
259
  prototypes::id::HTMLHeadElement,
260
  constructors::id::HTMLHeadElement,
261
  HTMLElement_Binding::sNativePropertyHooks,
262
  &DefaultXrayExpandoObjectClass
263
} };
264
265
void
266
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
267
0
{
268
0
  JS::Handle<JSObject*> parentProto(HTMLElement_Binding::GetProtoObjectHandle(aCx));
269
0
  if (!parentProto) {
270
0
    return;
271
0
  }
272
0
273
0
  JS::Handle<JSObject*> constructorProto(HTMLElement_Binding::GetConstructorObjectHandle(aCx));
274
0
  if (!constructorProto) {
275
0
    return;
276
0
  }
277
0
278
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLHeadElement);
279
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLHeadElement);
280
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
281
0
                              &sPrototypeClass.mBase, protoCache,
282
0
                              nullptr,
283
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
284
0
                              interfaceCache,
285
0
                              nullptr,
286
0
                              nullptr,
287
0
                              "HTMLHeadElement", aDefineOnGlobal,
288
0
                              nullptr,
289
0
                              false);
290
0
}
291
292
JSObject*
293
GetConstructorObject(JSContext* aCx)
294
0
{
295
0
  return GetConstructorObjectHandle(aCx);
296
0
}
297
298
} // namespace HTMLHeadElement_Binding
299
300
301
302
} // namespace dom
303
} // namespace mozilla