Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/ScriptProcessorNodeBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM ScriptProcessorNode.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AudioNodeBinding.h"
4
#include "EventHandlerBinding.h"
5
#include "ScriptProcessorNodeBinding.h"
6
#include "WrapperFactory.h"
7
#include "mozilla/OwningNonNull.h"
8
#include "mozilla/Preferences.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/NonRefcountedDOMObject.h"
12
#include "mozilla/dom/Nullable.h"
13
#include "mozilla/dom/PrimitiveConversions.h"
14
#include "mozilla/dom/ScriptProcessorNode.h"
15
#include "mozilla/dom/XrayExpandoClass.h"
16
#include "nsContentUtils.h"
17
18
namespace mozilla {
19
namespace dom {
20
21
namespace binding_detail {}; // Just to make sure it's known as a namespace
22
using namespace mozilla::dom::binding_detail;
23
24
25
namespace ScriptProcessorNode_Binding {
26
27
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<AudioNode_Binding::NativeType>::value,
28
              "Can't inherit from an interface with a different ownership model.");
29
30
MOZ_CAN_RUN_SCRIPT static bool
31
get_onaudioprocess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScriptProcessorNode* self, JSJitGetterCallArgs args)
32
0
{
33
0
  AUTO_PROFILER_LABEL_FAST("get ScriptProcessorNode.onaudioprocess", DOM, cx);
34
0
35
0
  RefPtr<EventHandlerNonNull> result(self->GetOnaudioprocess());
36
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
37
0
  if (result) {
38
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
39
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
40
0
      return false;
41
0
    }
42
0
    return true;
43
0
  } else {
44
0
    args.rval().setNull();
45
0
    return true;
46
0
  }
47
0
}
48
49
MOZ_CAN_RUN_SCRIPT static bool
50
set_onaudioprocess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScriptProcessorNode* self, JSJitSetterCallArgs args)
51
0
{
52
0
  AUTO_PROFILER_LABEL_FAST("set ScriptProcessorNode.onaudioprocess", DOM, cx);
53
0
54
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
55
0
  if (args[0].isObject()) {
56
0
    { // scope for tempRoot and tempGlobalRoot if needed
57
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
58
0
    }
59
0
  } else {
60
0
    arg0 = nullptr;
61
0
  }
62
0
  self->SetOnaudioprocess(Constify(arg0));
63
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
64
0
65
0
  return true;
66
0
}
67
68
static const JSJitInfo onaudioprocess_getterinfo = {
69
  { (JSJitGetterOp)get_onaudioprocess },
70
  { prototypes::id::ScriptProcessorNode },
71
  { PrototypeTraits<prototypes::id::ScriptProcessorNode>::Depth },
72
  JSJitInfo::Getter,
73
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
74
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
75
  false,  /* isInfallible. False in setters. */
76
  false,  /* isMovable.  Not relevant for setters. */
77
  false, /* isEliminatable.  Not relevant for setters. */
78
  false, /* isAlwaysInSlot.  Only relevant for getters. */
79
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
80
  false,  /* isTypedMethod.  Only relevant for methods. */
81
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
82
};
83
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
84
static_assert(0 < 1, "There is no slot for us");
85
static const JSJitInfo onaudioprocess_setterinfo = {
86
  { (JSJitGetterOp)set_onaudioprocess },
87
  { prototypes::id::ScriptProcessorNode },
88
  { PrototypeTraits<prototypes::id::ScriptProcessorNode>::Depth },
89
  JSJitInfo::Setter,
90
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
91
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
92
  false,  /* isInfallible. False in setters. */
93
  false,  /* isMovable.  Not relevant for setters. */
94
  false, /* isEliminatable.  Not relevant for setters. */
95
  false, /* isAlwaysInSlot.  Only relevant for getters. */
96
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
97
  false,  /* isTypedMethod.  Only relevant for methods. */
98
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
99
};
100
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
101
static_assert(0 < 1, "There is no slot for us");
102
103
MOZ_CAN_RUN_SCRIPT static bool
104
get_bufferSize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScriptProcessorNode* self, JSJitGetterCallArgs args)
105
0
{
106
0
  AUTO_PROFILER_LABEL_FAST("get ScriptProcessorNode.bufferSize", DOM, cx);
107
0
108
0
  int32_t result(self->BufferSize());
109
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
110
0
  args.rval().setInt32(int32_t(result));
111
0
  return true;
112
0
}
113
114
static const JSJitInfo bufferSize_getterinfo = {
115
  { (JSJitGetterOp)get_bufferSize },
116
  { prototypes::id::ScriptProcessorNode },
117
  { PrototypeTraits<prototypes::id::ScriptProcessorNode>::Depth },
118
  JSJitInfo::Getter,
119
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
120
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
121
  true,  /* isInfallible. False in setters. */
122
  false,  /* isMovable.  Not relevant for setters. */
123
  false, /* isEliminatable.  Not relevant for setters. */
124
  false, /* isAlwaysInSlot.  Only relevant for getters. */
125
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
126
  false,  /* isTypedMethod.  Only relevant for methods. */
127
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
128
};
129
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
130
static_assert(0 < 1, "There is no slot for us");
131
132
MOZ_CAN_RUN_SCRIPT static bool
133
get_passThrough(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScriptProcessorNode* self, JSJitGetterCallArgs args)
134
0
{
135
0
  AUTO_PROFILER_LABEL_FAST("get ScriptProcessorNode.passThrough", DOM, cx);
136
0
137
0
  bool result(self->PassThrough());
138
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
139
0
  args.rval().setBoolean(result);
140
0
  return true;
141
0
}
142
143
MOZ_CAN_RUN_SCRIPT static bool
144
set_passThrough(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScriptProcessorNode* self, JSJitSetterCallArgs args)
145
0
{
146
0
  AUTO_PROFILER_LABEL_FAST("set ScriptProcessorNode.passThrough", DOM, cx);
147
0
148
0
  bool arg0;
149
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
150
0
    return false;
151
0
  }
152
0
  self->SetPassThrough(arg0);
153
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
154
0
155
0
  return true;
156
0
}
157
158
static const JSJitInfo passThrough_getterinfo = {
159
  { (JSJitGetterOp)get_passThrough },
160
  { prototypes::id::ScriptProcessorNode },
161
  { PrototypeTraits<prototypes::id::ScriptProcessorNode>::Depth },
162
  JSJitInfo::Getter,
163
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
164
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
165
  true,  /* isInfallible. False in setters. */
166
  false,  /* isMovable.  Not relevant for setters. */
167
  false, /* isEliminatable.  Not relevant for setters. */
168
  false, /* isAlwaysInSlot.  Only relevant for getters. */
169
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
170
  false,  /* isTypedMethod.  Only relevant for methods. */
171
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
172
};
173
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
174
static_assert(0 < 1, "There is no slot for us");
175
static const JSJitInfo passThrough_setterinfo = {
176
  { (JSJitGetterOp)set_passThrough },
177
  { prototypes::id::ScriptProcessorNode },
178
  { PrototypeTraits<prototypes::id::ScriptProcessorNode>::Depth },
179
  JSJitInfo::Setter,
180
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
181
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
182
  false,  /* isInfallible. False in setters. */
183
  false,  /* isMovable.  Not relevant for setters. */
184
  false, /* isEliminatable.  Not relevant for setters. */
185
  false, /* isAlwaysInSlot.  Only relevant for getters. */
186
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
187
  false,  /* isTypedMethod.  Only relevant for methods. */
188
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
189
};
190
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
191
static_assert(0 < 1, "There is no slot for us");
192
193
static bool
194
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
195
0
{
196
0
  mozilla::dom::ScriptProcessorNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ScriptProcessorNode>(obj);
197
0
  // We don't want to preserve if we don't have a wrapper, and we
198
0
  // obviously can't preserve if we're not initialized.
199
0
  if (self && self->GetWrapperPreserveColor()) {
200
0
    PreserveWrapper(self);
201
0
  }
202
0
  return true;
203
0
}
204
205
static void
206
_finalize(js::FreeOp* fop, JSObject* obj)
207
0
{
208
0
  mozilla::dom::ScriptProcessorNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ScriptProcessorNode>(obj);
209
0
  if (self) {
210
0
    ClearWrapper(self, self, obj);
211
0
    AddForDeferredFinalization<mozilla::dom::ScriptProcessorNode>(self);
212
0
  }
213
0
}
214
215
static size_t
216
_objectMoved(JSObject* obj, JSObject* old)
217
0
{
218
0
  mozilla::dom::ScriptProcessorNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ScriptProcessorNode>(obj);
219
0
  if (self) {
220
0
    UpdateWrapper(self, self, obj, old);
221
0
  }
222
0
223
0
  return 0;
224
0
}
225
226
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
227
#if defined(__clang__)
228
#pragma clang diagnostic push
229
#pragma clang diagnostic ignored "-Wmissing-braces"
230
#endif
231
static const JSPropertySpec sAttributes_specs[] = {
232
  { "onaudioprocess", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onaudioprocess_getterinfo, GenericSetter<NormalThisPolicy>, &onaudioprocess_setterinfo },
233
  { "bufferSize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &bufferSize_getterinfo, nullptr, nullptr },
234
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
235
};
236
#if defined(__clang__)
237
#pragma clang diagnostic pop
238
#endif
239
240
241
static const Prefable<const JSPropertySpec> sAttributes[] = {
242
  { nullptr, &sAttributes_specs[0] },
243
  { nullptr, nullptr }
244
};
245
246
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
247
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
248
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
249
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
250
251
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
252
#if defined(__clang__)
253
#pragma clang diagnostic push
254
#pragma clang diagnostic ignored "-Wmissing-braces"
255
#endif
256
static const JSPropertySpec sChromeAttributes_specs[] = {
257
  { "passThrough", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &passThrough_getterinfo, GenericSetter<NormalThisPolicy>, &passThrough_setterinfo },
258
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
259
};
260
#if defined(__clang__)
261
#pragma clang diagnostic pop
262
#endif
263
264
265
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
266
  { nullptr, &sChromeAttributes_specs[0] },
267
  { nullptr, nullptr }
268
};
269
270
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
271
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
272
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
273
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
274
275
276
static uint16_t sNativeProperties_sortedPropertyIndices[2];
277
static PropertyInfo sNativeProperties_propertyInfos[2];
278
279
static const NativePropertiesN<1> sNativeProperties = {
280
  false, 0,
281
  false, 0,
282
  false, 0,
283
  true,  0 /* sAttributes */,
284
  false, 0,
285
  false, 0,
286
  false, 0,
287
  -1,
288
  2,
289
  sNativeProperties_sortedPropertyIndices,
290
  {
291
    { sAttributes, &sNativeProperties_propertyInfos[0] }
292
  }
293
};
294
static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
295
    "We have a property info count that is oversized");
296
297
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
298
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
299
300
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
301
  false, 0,
302
  false, 0,
303
  false, 0,
304
  true,  0 /* sChromeAttributes */,
305
  false, 0,
306
  false, 0,
307
  false, 0,
308
  -1,
309
  1,
310
  sChromeOnlyNativeProperties_sortedPropertyIndices,
311
  {
312
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
313
  }
314
};
315
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
316
    "We have a property info count that is oversized");
317
318
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
319
  {
320
    "Function",
321
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
322
    &sBoringInterfaceObjectClassClassOps,
323
    JS_NULL_CLASS_SPEC,
324
    JS_NULL_CLASS_EXT,
325
    &sInterfaceObjectClassObjectOps
326
  },
327
  eInterface,
328
  true,
329
  prototypes::id::ScriptProcessorNode,
330
  PrototypeTraits<prototypes::id::ScriptProcessorNode>::Depth,
331
  sNativePropertyHooks,
332
  "function ScriptProcessorNode() {\n    [native code]\n}",
333
  AudioNode_Binding::GetConstructorObject
334
};
335
336
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
337
  {
338
    "ScriptProcessorNodePrototype",
339
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
340
    JS_NULL_CLASS_OPS,
341
    JS_NULL_CLASS_SPEC,
342
    JS_NULL_CLASS_EXT,
343
    JS_NULL_OBJECT_OPS
344
  },
345
  eInterfacePrototype,
346
  false,
347
  prototypes::id::ScriptProcessorNode,
348
  PrototypeTraits<prototypes::id::ScriptProcessorNode>::Depth,
349
  sNativePropertyHooks,
350
  "[object ScriptProcessorNodePrototype]",
351
  AudioNode_Binding::GetProtoObject
352
};
353
354
bool
355
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
356
0
{
357
0
  static bool sPrefValue;
358
0
  static bool sPrefCacheSetUp = false;
359
0
  if (!sPrefCacheSetUp) {
360
0
    sPrefCacheSetUp = true;
361
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.webaudio.enabled");
362
0
  }
363
0
364
0
  return sPrefValue;
365
0
}
366
367
static const js::ClassOps sClassOps = {
368
  _addProperty, /* addProperty */
369
  nullptr,               /* delProperty */
370
  nullptr,               /* enumerate */
371
  nullptr, /* newEnumerate */
372
  nullptr, /* resolve */
373
  nullptr, /* mayResolve */
374
  _finalize, /* finalize */
375
  nullptr, /* call */
376
  nullptr,               /* hasInstance */
377
  nullptr,               /* construct */
378
  nullptr, /* trace */
379
};
380
381
static const js::ClassExtension sClassExtension = {
382
  nullptr, /* weakmapKeyDelegateOp */
383
  _objectMoved /* objectMovedOp */
384
};
385
386
static const DOMJSClass sClass = {
387
  { "ScriptProcessorNode",
388
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
389
    &sClassOps,
390
    JS_NULL_CLASS_SPEC,
391
    &sClassExtension,
392
    JS_NULL_OBJECT_OPS
393
  },
394
  { prototypes::id::EventTarget, prototypes::id::AudioNode, prototypes::id::ScriptProcessorNode, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
395
  IsBaseOf<nsISupports, mozilla::dom::ScriptProcessorNode >::value,
396
  sNativePropertyHooks,
397
  FindAssociatedGlobalForNative<mozilla::dom::ScriptProcessorNode>::Get,
398
  GetProtoObjectHandle,
399
  GetCCParticipant<mozilla::dom::ScriptProcessorNode>::Get()
400
};
401
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
402
              "Must have the right minimal number of reserved slots.");
403
static_assert(1 >= 1,
404
              "Must have enough reserved slots.");
405
406
const JSClass*
407
GetJSClass()
408
0
{
409
0
  return sClass.ToJSClass();
410
0
}
411
412
bool
413
Wrap(JSContext* aCx, mozilla::dom::ScriptProcessorNode* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
414
0
{
415
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::ScriptProcessorNode>::value,
416
0
                "Shouldn't have wrappercached things that are not refcounted.");
417
0
  MOZ_ASSERT(static_cast<mozilla::dom::ScriptProcessorNode*>(aObject) ==
418
0
             reinterpret_cast<mozilla::dom::ScriptProcessorNode*>(aObject),
419
0
             "Multiple inheritance for mozilla::dom::ScriptProcessorNode is broken.");
420
0
  MOZ_ASSERT(static_cast<mozilla::dom::AudioNode*>(aObject) ==
421
0
             reinterpret_cast<mozilla::dom::AudioNode*>(aObject),
422
0
             "Multiple inheritance for mozilla::dom::AudioNode is broken.");
423
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
424
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
425
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
426
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
427
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
428
0
  MOZ_ASSERT(!aCache->GetWrapper(),
429
0
             "You should probably not be using Wrap() directly; use "
430
0
             "GetOrCreateDOMReflector instead");
431
0
432
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
433
0
             "nsISupports must be on our primary inheritance chain");
434
0
435
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
436
0
  if (!global) {
437
0
    return false;
438
0
  }
439
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
440
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
441
0
442
0
  // That might have ended up wrapping us already, due to the wonders
443
0
  // of XBL.  Check for that, and bail out as needed.
444
0
  aReflector.set(aCache->GetWrapper());
445
0
  if (aReflector) {
446
#ifdef DEBUG
447
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
448
#endif // DEBUG
449
    return true;
450
0
  }
451
0
452
0
  JSAutoRealm ar(aCx, global);
453
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
454
0
  if (!canonicalProto) {
455
0
    return false;
456
0
  }
457
0
  JS::Rooted<JSObject*> proto(aCx);
458
0
  if (aGivenProto) {
459
0
    proto = aGivenProto;
460
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
461
0
    // coming in, we changed compartments to that of "parent" so may need
462
0
    // to wrap the proto here.
463
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
464
0
      if (!JS_WrapObject(aCx, &proto)) {
465
0
        return false;
466
0
      }
467
0
    }
468
0
  } else {
469
0
    proto = canonicalProto;
470
0
  }
471
0
472
0
  BindingJSObjectCreator<mozilla::dom::ScriptProcessorNode> creator(aCx);
473
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
474
0
  if (!aReflector) {
475
0
    return false;
476
0
  }
477
0
478
0
  aCache->SetWrapper(aReflector);
479
0
  creator.InitializationSucceeded();
480
0
481
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
482
0
             aCache->GetWrapperPreserveColor() == aReflector);
483
0
  // If proto != canonicalProto, we have to preserve our wrapper;
484
0
  // otherwise we won't be able to properly recreate it later, since
485
0
  // we won't know what proto to use.  Note that we don't check
486
0
  // aGivenProto here, since it's entirely possible (and even
487
0
  // somewhat common) to have a non-null aGivenProto which is the
488
0
  // same as canonicalProto.
489
0
  if (proto != canonicalProto) {
490
0
    PreserveWrapper(aObject);
491
0
  }
492
0
493
0
  return true;
494
0
}
495
496
const NativePropertyHooks sNativePropertyHooks[] = { {
497
  nullptr,
498
  nullptr,
499
  nullptr,
500
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
501
  prototypes::id::ScriptProcessorNode,
502
  constructors::id::ScriptProcessorNode,
503
  AudioNode_Binding::sNativePropertyHooks,
504
  &DefaultXrayExpandoObjectClass
505
} };
506
507
void
508
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
509
0
{
510
0
  JS::Handle<JSObject*> parentProto(AudioNode_Binding::GetProtoObjectHandle(aCx));
511
0
  if (!parentProto) {
512
0
    return;
513
0
  }
514
0
515
0
  JS::Handle<JSObject*> constructorProto(AudioNode_Binding::GetConstructorObjectHandle(aCx));
516
0
  if (!constructorProto) {
517
0
    return;
518
0
  }
519
0
520
0
  static bool sIdsInited = false;
521
0
  if (!sIdsInited && NS_IsMainThread()) {
522
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
523
0
      return;
524
0
    }
525
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
526
0
      return;
527
0
    }
528
0
    sIdsInited = true;
529
0
  }
530
0
531
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ScriptProcessorNode);
532
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ScriptProcessorNode);
533
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
534
0
                              &sPrototypeClass.mBase, protoCache,
535
0
                              nullptr,
536
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
537
0
                              interfaceCache,
538
0
                              sNativeProperties.Upcast(),
539
0
                              sChromeOnlyNativeProperties.Upcast(),
540
0
                              "ScriptProcessorNode", aDefineOnGlobal,
541
0
                              nullptr,
542
0
                              false);
543
0
}
544
545
JSObject*
546
GetConstructorObject(JSContext* aCx)
547
0
{
548
0
  return GetConstructorObjectHandle(aCx);
549
0
}
550
551
} // namespace ScriptProcessorNode_Binding
552
553
554
555
} // namespace dom
556
} // namespace mozilla