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