Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM MediaKeyStatusMap.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "MediaKeyStatusMapBinding.h"
4 : #include "WrapperFactory.h"
5 : #include "jsapi.h"
6 : #include "jsfriendapi.h"
7 : #include "mozilla/OwningNonNull.h"
8 : #include "mozilla/dom/BindingUtils.h"
9 : #include "mozilla/dom/DOMJSClass.h"
10 : #include "mozilla/dom/IterableIterator.h"
11 : #include "mozilla/dom/MediaKeyStatusMap.h"
12 : #include "mozilla/dom/NonRefcountedDOMObject.h"
13 : #include "mozilla/dom/PrimitiveConversions.h"
14 : #include "mozilla/dom/ToJSValue.h"
15 : #include "mozilla/dom/TypedArray.h"
16 : #include "mozilla/dom/UnionConversions.h"
17 : #include "mozilla/dom/UnionTypes.h"
18 : #include "mozilla/dom/XrayExpandoClass.h"
19 :
20 : namespace mozilla {
21 : namespace dom {
22 :
23 : namespace MediaKeyStatusValues {
24 : extern const EnumEntry strings[8] = {
25 : {"usable", 6},
26 : {"expired", 7},
27 : {"released", 8},
28 : {"output-restricted", 17},
29 : {"output-downscaled", 17},
30 : {"status-pending", 14},
31 : {"internal-error", 14},
32 : { nullptr, 0 }
33 : };
34 : } // namespace MediaKeyStatusValues
35 :
36 : bool
37 0 : ToJSValue(JSContext* aCx, MediaKeyStatus aArgument, JS::MutableHandle<JS::Value> aValue)
38 : {
39 0 : MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(MediaKeyStatusValues::strings));
40 : JSString* resultStr =
41 0 : JS_NewStringCopyN(aCx, MediaKeyStatusValues::strings[uint32_t(aArgument)].value,
42 0 : MediaKeyStatusValues::strings[uint32_t(aArgument)].length);
43 0 : if (!resultStr) {
44 0 : return false;
45 : }
46 0 : aValue.setString(resultStr);
47 0 : return true;
48 : }
49 :
50 :
51 : namespace MediaKeyStatusMapBinding {
52 :
53 : static bool
54 0 : get_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, JSJitGetterCallArgs args)
55 : {
56 0 : uint32_t result(self->Size());
57 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
58 0 : args.rval().setNumber(result);
59 0 : return true;
60 : }
61 :
62 : static const JSJitInfo size_getterinfo = {
63 : { (JSJitGetterOp)get_size },
64 : { prototypes::id::MediaKeyStatusMap },
65 : { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth },
66 : JSJitInfo::Getter,
67 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
68 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
69 : true, /* isInfallible. False in setters. */
70 : false, /* isMovable. Not relevant for setters. */
71 : false, /* isEliminatable. Not relevant for setters. */
72 : false, /* isAlwaysInSlot. Only relevant for getters. */
73 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
74 : false, /* isTypedMethod. Only relevant for methods. */
75 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
76 : };
77 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
78 : static_assert(0 < 1, "There is no slot for us");
79 :
80 : static bool
81 0 : has(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args)
82 : {
83 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
84 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaKeyStatusMap.has");
85 : }
86 0 : ArrayBufferViewOrArrayBuffer arg0;
87 0 : ArrayBufferViewOrArrayBufferArgument arg0_holder(arg0);
88 : {
89 0 : bool done = false, failed = false, tryNext;
90 0 : if (args[0].isObject()) {
91 0 : done = (failed = !arg0_holder.TrySetToArrayBufferView(cx, args[0], tryNext, false)) || !tryNext ||
92 0 : (failed = !arg0_holder.TrySetToArrayBuffer(cx, args[0], tryNext, false)) || !tryNext;
93 :
94 : }
95 0 : if (failed) {
96 0 : return false;
97 : }
98 0 : if (!done) {
99 0 : ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of MediaKeyStatusMap.has", "ArrayBufferView, ArrayBuffer");
100 0 : return false;
101 : }
102 : }
103 0 : bool result(self->Has(Constify(arg0)));
104 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
105 0 : args.rval().setBoolean(result);
106 0 : return true;
107 : }
108 :
109 : static const JSJitInfo has_methodinfo = {
110 : { (JSJitGetterOp)has },
111 : { prototypes::id::MediaKeyStatusMap },
112 : { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth },
113 : JSJitInfo::Method,
114 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
115 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
116 : false, /* isInfallible. False in setters. */
117 : false, /* isMovable. Not relevant for setters. */
118 : false, /* isEliminatable. Not relevant for setters. */
119 : false, /* isAlwaysInSlot. Only relevant for getters. */
120 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
121 : false, /* isTypedMethod. Only relevant for methods. */
122 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
123 : };
124 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
125 : static_assert(0 < 1, "There is no slot for us");
126 :
127 : static bool
128 0 : get(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args)
129 : {
130 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
131 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaKeyStatusMap.get");
132 : }
133 0 : ArrayBufferViewOrArrayBuffer arg0;
134 0 : ArrayBufferViewOrArrayBufferArgument arg0_holder(arg0);
135 : {
136 0 : bool done = false, failed = false, tryNext;
137 0 : if (args[0].isObject()) {
138 0 : done = (failed = !arg0_holder.TrySetToArrayBufferView(cx, args[0], tryNext, false)) || !tryNext ||
139 0 : (failed = !arg0_holder.TrySetToArrayBuffer(cx, args[0], tryNext, false)) || !tryNext;
140 :
141 : }
142 0 : if (failed) {
143 0 : return false;
144 : }
145 0 : if (!done) {
146 0 : ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of MediaKeyStatusMap.get", "ArrayBufferView, ArrayBuffer");
147 0 : return false;
148 : }
149 : }
150 0 : binding_detail::FastErrorResult rv;
151 0 : JS::Rooted<JS::Value> result(cx);
152 0 : self->Get(cx, Constify(arg0), &result, rv);
153 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
154 0 : return false;
155 : }
156 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
157 0 : JS::ExposeValueToActiveJS(result);
158 0 : args.rval().set(result);
159 0 : if (!MaybeWrapValue(cx, args.rval())) {
160 0 : return false;
161 : }
162 0 : return true;
163 : }
164 :
165 : static const JSJitInfo get_methodinfo = {
166 : { (JSJitGetterOp)get },
167 : { prototypes::id::MediaKeyStatusMap },
168 : { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth },
169 : JSJitInfo::Method,
170 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
171 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
172 : false, /* isInfallible. False in setters. */
173 : false, /* isMovable. Not relevant for setters. */
174 : false, /* isEliminatable. Not relevant for setters. */
175 : false, /* isAlwaysInSlot. Only relevant for getters. */
176 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
177 : false, /* isTypedMethod. Only relevant for methods. */
178 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
179 : };
180 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
181 : static_assert(0 < 1, "There is no slot for us");
182 :
183 : static bool
184 0 : entries(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args)
185 : {
186 : typedef mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap> itrType;
187 : RefPtr<itrType> result(new itrType(self,
188 : itrType::IterableIteratorType::Entries,
189 0 : &MediaKeyStatusMapIteratorBinding::Wrap));
190 : static_assert(!IsPointer<decltype(result)>::value,
191 : "NewObject implies that we need to keep the object alive with a strong reference.");
192 0 : if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
193 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
194 0 : return false;
195 : }
196 0 : return true;
197 : }
198 :
199 : static const JSJitInfo::ArgType entries_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd };
200 : static const JSTypedMethodJitInfo entries_methodinfo = {
201 : {
202 : { (JSJitGetterOp)entries },
203 : { prototypes::id::MediaKeyStatusMap },
204 : { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth },
205 : JSJitInfo::Method,
206 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
207 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
208 : false, /* isInfallible. False in setters. */
209 : false, /* isMovable. Not relevant for setters. */
210 : false, /* isEliminatable. Not relevant for setters. */
211 : false, /* isAlwaysInSlot. Only relevant for getters. */
212 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
213 : true, /* isTypedMethod. Only relevant for methods. */
214 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
215 : },
216 : entries_methodinfo_argTypes
217 : };
218 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
219 : static_assert(0 < 1, "There is no slot for us");
220 :
221 : static bool
222 0 : keys(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args)
223 : {
224 : typedef mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap> itrType;
225 : RefPtr<itrType> result(new itrType(self,
226 : itrType::IterableIteratorType::Keys,
227 0 : &MediaKeyStatusMapIteratorBinding::Wrap));
228 : static_assert(!IsPointer<decltype(result)>::value,
229 : "NewObject implies that we need to keep the object alive with a strong reference.");
230 0 : if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
231 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
232 0 : return false;
233 : }
234 0 : return true;
235 : }
236 :
237 : static const JSJitInfo::ArgType keys_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd };
238 : static const JSTypedMethodJitInfo keys_methodinfo = {
239 : {
240 : { (JSJitGetterOp)keys },
241 : { prototypes::id::MediaKeyStatusMap },
242 : { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth },
243 : JSJitInfo::Method,
244 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
245 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
246 : false, /* isInfallible. False in setters. */
247 : false, /* isMovable. Not relevant for setters. */
248 : false, /* isEliminatable. Not relevant for setters. */
249 : false, /* isAlwaysInSlot. Only relevant for getters. */
250 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
251 : true, /* isTypedMethod. Only relevant for methods. */
252 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
253 : },
254 : keys_methodinfo_argTypes
255 : };
256 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
257 : static_assert(0 < 1, "There is no slot for us");
258 :
259 : static bool
260 0 : values(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args)
261 : {
262 : typedef mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap> itrType;
263 : RefPtr<itrType> result(new itrType(self,
264 : itrType::IterableIteratorType::Values,
265 0 : &MediaKeyStatusMapIteratorBinding::Wrap));
266 : static_assert(!IsPointer<decltype(result)>::value,
267 : "NewObject implies that we need to keep the object alive with a strong reference.");
268 0 : if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
269 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
270 0 : return false;
271 : }
272 0 : return true;
273 : }
274 :
275 : static const JSJitInfo::ArgType values_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd };
276 : static const JSTypedMethodJitInfo values_methodinfo = {
277 : {
278 : { (JSJitGetterOp)values },
279 : { prototypes::id::MediaKeyStatusMap },
280 : { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth },
281 : JSJitInfo::Method,
282 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
283 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
284 : false, /* isInfallible. False in setters. */
285 : false, /* isMovable. Not relevant for setters. */
286 : false, /* isEliminatable. Not relevant for setters. */
287 : false, /* isAlwaysInSlot. Only relevant for getters. */
288 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
289 : true, /* isTypedMethod. Only relevant for methods. */
290 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
291 : },
292 : values_methodinfo_argTypes
293 : };
294 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
295 : static_assert(0 < 1, "There is no slot for us");
296 :
297 : static bool
298 0 : forEach(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args)
299 : {
300 0 : JS::Rooted<JSObject*> arg0(cx);
301 0 : if (args.get(0).isObject()) {
302 0 : arg0 = &args.get(0).toObject();
303 : } else {
304 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of MediaKeyStatusMap.forEach");
305 0 : return false;
306 : }
307 0 : JS::Rooted<JS::Value> arg1(cx);
308 0 : if (args.hasDefined(1)) {
309 0 : arg1 = args.get(1);
310 : } else {
311 0 : arg1 = JS::UndefinedValue();
312 : }
313 0 : if (!JS::IsCallable(arg0)) {
314 0 : ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 1 of MediaKeyStatusMap.forEach");
315 0 : return false;
316 : }
317 0 : JS::AutoValueArray<3> callArgs(cx);
318 0 : callArgs[2].setObject(*obj);
319 0 : JS::Rooted<JS::Value> ignoredReturnVal(cx);
320 0 : for (size_t i = 0; i < self->GetIterableLength(); ++i) {
321 0 : if (!ToJSValue(cx, self->GetValueAtIndex(i), callArgs[0])) {
322 0 : return false;
323 : }
324 0 : if (!ToJSValue(cx, self->GetKeyAtIndex(i), callArgs[1])) {
325 0 : return false;
326 : }
327 0 : if (!JS::Call(cx, arg1, arg0, JS::HandleValueArray(callArgs),
328 : &ignoredReturnVal)) {
329 0 : return false;
330 : }
331 : }
332 0 : args.rval().setUndefined();
333 0 : return true;
334 : }
335 :
336 : static const JSJitInfo forEach_methodinfo = {
337 : { (JSJitGetterOp)forEach },
338 : { prototypes::id::MediaKeyStatusMap },
339 : { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth },
340 : JSJitInfo::Method,
341 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
342 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
343 : false, /* isInfallible. False in setters. */
344 : false, /* isMovable. Not relevant for setters. */
345 : false, /* isEliminatable. Not relevant for setters. */
346 : false, /* isAlwaysInSlot. Only relevant for getters. */
347 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
348 : false, /* isTypedMethod. Only relevant for methods. */
349 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
350 : };
351 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
352 : static_assert(0 < 1, "There is no slot for us");
353 :
354 : static bool
355 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
356 : {
357 0 : mozilla::dom::MediaKeyStatusMap* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeyStatusMap>(obj);
358 : // We don't want to preserve if we don't have a wrapper, and we
359 : // obviously can't preserve if we're not initialized.
360 0 : if (self && self->GetWrapperPreserveColor()) {
361 0 : PreserveWrapper(self);
362 : }
363 0 : return true;
364 : }
365 :
366 : static void
367 0 : _finalize(js::FreeOp* fop, JSObject* obj)
368 : {
369 0 : mozilla::dom::MediaKeyStatusMap* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeyStatusMap>(obj);
370 0 : if (self) {
371 0 : ClearWrapper(self, self, obj);
372 0 : AddForDeferredFinalization<mozilla::dom::MediaKeyStatusMap>(self);
373 : }
374 0 : }
375 :
376 : static void
377 0 : _objectMoved(JSObject* obj, const JSObject* old)
378 : {
379 0 : mozilla::dom::MediaKeyStatusMap* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeyStatusMap>(obj);
380 0 : if (self) {
381 0 : UpdateWrapper(self, self, obj, old);
382 : }
383 0 : }
384 :
385 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
386 : #if defined(__clang__)
387 : #pragma clang diagnostic push
388 : #pragma clang diagnostic ignored "-Wmissing-braces"
389 : #endif
390 : static const JSFunctionSpec sMethods_specs[] = {
391 : JS_FNSPEC("has", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&has_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
392 : JS_FNSPEC("get", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&get_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
393 : JS_FNSPEC("entries", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&entries_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
394 : JS_FNSPEC("keys", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&keys_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
395 : JS_FNSPEC("values", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&values_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
396 : JS_FNSPEC("forEach", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&forEach_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
397 : JS_FS_END
398 : };
399 : #if defined(__clang__)
400 : #pragma clang diagnostic pop
401 : #endif
402 :
403 :
404 : // Can't be const because the pref-enabled boolean needs to be writable
405 : static Prefable<const JSFunctionSpec> sMethods[] = {
406 : { nullptr, &sMethods_specs[0] },
407 : { nullptr, nullptr }
408 : };
409 :
410 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
411 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
412 : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
413 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
414 :
415 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
416 : #if defined(__clang__)
417 : #pragma clang diagnostic push
418 : #pragma clang diagnostic ignored "-Wmissing-braces"
419 : #endif
420 : static const JSPropertySpec sAttributes_specs[] = {
421 : { "size", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &size_getterinfo, nullptr, nullptr },
422 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
423 : };
424 : #if defined(__clang__)
425 : #pragma clang diagnostic pop
426 : #endif
427 :
428 :
429 : // Can't be const because the pref-enabled boolean needs to be writable
430 : static Prefable<const JSPropertySpec> sAttributes[] = {
431 : { nullptr, &sAttributes_specs[0] },
432 : { nullptr, nullptr }
433 : };
434 :
435 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
436 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
437 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
438 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
439 :
440 :
441 : static uint16_t sNativeProperties_sortedPropertyIndices[7];
442 : static PropertyInfo sNativeProperties_propertyInfos[7];
443 :
444 : static const NativePropertiesN<2> sNativeProperties = {
445 : false, 0,
446 : false, 0,
447 : true, 0 /* sMethods */,
448 : true, 1 /* sAttributes */,
449 : false, 0,
450 : false, 0,
451 : false, 0,
452 : 2,
453 : 7,
454 : sNativeProperties_sortedPropertyIndices,
455 : {
456 : { sMethods, &sNativeProperties_propertyInfos[0] },
457 : { sAttributes, &sNativeProperties_propertyInfos[6] }
458 : }
459 : };
460 : static_assert(2 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.iteratorAliasMethodIndex) - 1),
461 : "We have an iterator alias index that is oversized");
462 : static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
463 : "We have a property info count that is oversized");
464 :
465 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
466 : {
467 : "Function",
468 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
469 : &sBoringInterfaceObjectClassClassOps,
470 : JS_NULL_CLASS_SPEC,
471 : JS_NULL_CLASS_EXT,
472 : &sInterfaceObjectClassObjectOps
473 : },
474 : eInterface,
475 : true,
476 : prototypes::id::MediaKeyStatusMap,
477 : PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth,
478 : sNativePropertyHooks,
479 : "function MediaKeyStatusMap() {\n [native code]\n}",
480 : JS::GetRealmFunctionPrototype
481 : };
482 :
483 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
484 : {
485 : "MediaKeyStatusMapPrototype",
486 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
487 : JS_NULL_CLASS_OPS,
488 : JS_NULL_CLASS_SPEC,
489 : JS_NULL_CLASS_EXT,
490 : JS_NULL_OBJECT_OPS
491 : },
492 : eInterfacePrototype,
493 : false,
494 : prototypes::id::MediaKeyStatusMap,
495 : PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth,
496 : sNativePropertyHooks,
497 : "[object MediaKeyStatusMapPrototype]",
498 : JS::GetRealmObjectPrototype
499 : };
500 :
501 : JSObject*
502 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
503 : {
504 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
505 : }
506 :
507 : static const js::ClassOps sClassOps = {
508 : _addProperty, /* addProperty */
509 : nullptr, /* delProperty */
510 : nullptr, /* getProperty */
511 : nullptr, /* setProperty */
512 : nullptr, /* enumerate */
513 : nullptr, /* newEnumerate */
514 : nullptr, /* resolve */
515 : nullptr, /* mayResolve */
516 : _finalize, /* finalize */
517 : nullptr, /* call */
518 : nullptr, /* hasInstance */
519 : nullptr, /* construct */
520 : nullptr, /* trace */
521 : };
522 :
523 : static const js::ClassExtension sClassExtension = {
524 : nullptr, /* weakmapKeyDelegateOp */
525 : _objectMoved /* objectMovedOp */
526 : };
527 :
528 : static const DOMJSClass sClass = {
529 : { "MediaKeyStatusMap",
530 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
531 : &sClassOps,
532 : JS_NULL_CLASS_SPEC,
533 : &sClassExtension,
534 : JS_NULL_OBJECT_OPS
535 : },
536 : { prototypes::id::MediaKeyStatusMap, 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 },
537 : IsBaseOf<nsISupports, mozilla::dom::MediaKeyStatusMap >::value,
538 : sNativePropertyHooks,
539 : FindAssociatedGlobalForNative<mozilla::dom::MediaKeyStatusMap>::Get,
540 : GetProtoObjectHandle,
541 : GetCCParticipant<mozilla::dom::MediaKeyStatusMap>::Get()
542 : };
543 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
544 : "Must have the right minimal number of reserved slots.");
545 : static_assert(1 >= 1,
546 : "Must have enough reserved slots.");
547 :
548 : const JSClass*
549 0 : GetJSClass()
550 : {
551 0 : return sClass.ToJSClass();
552 : }
553 :
554 : bool
555 0 : Wrap(JSContext* aCx, mozilla::dom::MediaKeyStatusMap* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
556 : {
557 : MOZ_ASSERT(static_cast<mozilla::dom::MediaKeyStatusMap*>(aObject) ==
558 : reinterpret_cast<mozilla::dom::MediaKeyStatusMap*>(aObject),
559 : "Multiple inheritance for mozilla::dom::MediaKeyStatusMap is broken.");
560 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
561 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
562 0 : MOZ_ASSERT(!aCache->GetWrapper(),
563 : "You should probably not be using Wrap() directly; use "
564 : "GetOrCreateDOMReflector instead");
565 :
566 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
567 : "nsISupports must be on our primary inheritance chain");
568 :
569 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
570 0 : if (!global) {
571 0 : return false;
572 : }
573 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
574 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
575 :
576 : // That might have ended up wrapping us already, due to the wonders
577 : // of XBL. Check for that, and bail out as needed.
578 0 : aReflector.set(aCache->GetWrapper());
579 0 : if (aReflector) {
580 : #ifdef DEBUG
581 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
582 : #endif // DEBUG
583 0 : return true;
584 : }
585 :
586 0 : JSAutoCompartment ac(aCx, global);
587 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
588 0 : if (!canonicalProto) {
589 0 : return false;
590 : }
591 0 : JS::Rooted<JSObject*> proto(aCx);
592 0 : if (aGivenProto) {
593 0 : proto = aGivenProto;
594 : // Unfortunately, while aGivenProto was in the compartment of aCx
595 : // coming in, we changed compartments to that of "parent" so may need
596 : // to wrap the proto here.
597 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
598 0 : if (!JS_WrapObject(aCx, &proto)) {
599 0 : return false;
600 : }
601 : }
602 : } else {
603 0 : proto = canonicalProto;
604 : }
605 :
606 0 : BindingJSObjectCreator<mozilla::dom::MediaKeyStatusMap> creator(aCx);
607 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
608 0 : if (!aReflector) {
609 0 : return false;
610 : }
611 :
612 0 : aCache->SetWrapper(aReflector);
613 0 : creator.InitializationSucceeded();
614 :
615 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
616 : aCache->GetWrapperPreserveColor() == aReflector);
617 : // If proto != canonicalProto, we have to preserve our wrapper;
618 : // otherwise we won't be able to properly recreate it later, since
619 : // we won't know what proto to use. Note that we don't check
620 : // aGivenProto here, since it's entirely possible (and even
621 : // somewhat common) to have a non-null aGivenProto which is the
622 : // same as canonicalProto.
623 0 : if (proto != canonicalProto) {
624 0 : PreserveWrapper(aObject);
625 : }
626 :
627 0 : return true;
628 : }
629 :
630 : const NativePropertyHooks sNativePropertyHooks[] = { {
631 : nullptr,
632 : nullptr,
633 : nullptr,
634 : { sNativeProperties.Upcast(), nullptr },
635 : prototypes::id::MediaKeyStatusMap,
636 : constructors::id::MediaKeyStatusMap,
637 : nullptr,
638 : &DefaultXrayExpandoObjectClass
639 : } };
640 :
641 : void
642 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
643 : {
644 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
645 0 : if (!parentProto) {
646 0 : return;
647 : }
648 :
649 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
650 0 : if (!constructorProto) {
651 0 : return;
652 : }
653 :
654 : static bool sIdsInited = false;
655 0 : if (!sIdsInited && NS_IsMainThread()) {
656 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
657 0 : return;
658 : }
659 0 : sIdsInited = true;
660 : }
661 :
662 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaKeyStatusMap);
663 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MediaKeyStatusMap);
664 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
665 : &sPrototypeClass.mBase, protoCache,
666 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
667 : interfaceCache,
668 : sNativeProperties.Upcast(),
669 : nullptr,
670 : "MediaKeyStatusMap", aDefineOnGlobal,
671 : nullptr,
672 0 : false);
673 :
674 : // Set up aliases on the interface prototype object we just created.
675 0 : JS::Handle<JSObject*> proto = GetProtoObjectHandle(aCx);
676 0 : if (!proto) {
677 0 : *protoCache = nullptr;
678 0 : if (interfaceCache) {
679 0 : *interfaceCache = nullptr;
680 : }
681 0 : return;
682 : }
683 :
684 0 : JS::Rooted<JS::Value> aliasedVal(aCx);
685 :
686 0 : if (!JS_GetProperty(aCx, proto, "entries", &aliasedVal)) {
687 0 : *protoCache = nullptr;
688 0 : if (interfaceCache) {
689 0 : *interfaceCache = nullptr;
690 : }
691 0 : return;
692 : }
693 0 : JS::Rooted<jsid> iteratorId(aCx, SYMBOL_TO_JSID(JS::GetWellKnownSymbol(aCx, JS::SymbolCode::iterator)));
694 0 : if (!JS_DefinePropertyById(aCx, proto, iteratorId, aliasedVal, 0)) {
695 0 : *protoCache = nullptr;
696 0 : if (interfaceCache) {
697 0 : *interfaceCache = nullptr;
698 : }
699 0 : return;
700 : }
701 : }
702 :
703 : JS::Handle<JSObject*>
704 0 : GetProtoObjectHandle(JSContext* aCx)
705 : {
706 : /* Get the interface prototype object for this class. This will create the
707 : object as needed. */
708 0 : bool aDefineOnGlobal = true;
709 :
710 : /* Make sure our global is sane. Hopefully we can remove this sometime */
711 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
712 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
713 0 : return nullptr;
714 : }
715 :
716 : /* Check to see whether the interface objects are already installed */
717 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
718 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::MediaKeyStatusMap)) {
719 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
720 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
721 : }
722 :
723 : /*
724 : * The object might _still_ be null, but that's OK.
725 : *
726 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
727 : * traced by TraceProtoAndIfaceCache() and its contents are never
728 : * changed after they have been set.
729 : *
730 : * Calling address() avoids the read read barrier that does gray
731 : * unmarking, but it's not possible for the object to be gray here.
732 : */
733 :
734 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::MediaKeyStatusMap);
735 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
736 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
737 : }
738 :
739 : JS::Handle<JSObject*>
740 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
741 : {
742 : /* Get the interface object for this class. This will create the object as
743 : needed. */
744 :
745 : /* Make sure our global is sane. Hopefully we can remove this sometime */
746 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
747 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
748 0 : return nullptr;
749 : }
750 :
751 : /* Check to see whether the interface objects are already installed */
752 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
753 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::MediaKeyStatusMap)) {
754 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
755 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
756 : }
757 :
758 : /*
759 : * The object might _still_ be null, but that's OK.
760 : *
761 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
762 : * traced by TraceProtoAndIfaceCache() and its contents are never
763 : * changed after they have been set.
764 : *
765 : * Calling address() avoids the read read barrier that does gray
766 : * unmarking, but it's not possible for the object to be gray here.
767 : */
768 :
769 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::MediaKeyStatusMap);
770 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
771 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
772 : }
773 :
774 : JSObject*
775 0 : GetConstructorObject(JSContext* aCx)
776 : {
777 0 : return GetConstructorObjectHandle(aCx);
778 : }
779 :
780 : } // namespace MediaKeyStatusMapBinding
781 :
782 :
783 :
784 : namespace MediaKeyStatusMapIteratorBinding {
785 :
786 : static bool
787 0 : next(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>* self, const JSJitMethodCallArgs& args)
788 : {
789 0 : binding_detail::FastErrorResult rv;
790 0 : JS::Rooted<JSObject*> result(cx);
791 0 : self->Next(cx, &result, rv);
792 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
793 0 : return false;
794 : }
795 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
796 0 : JS::ExposeObjectToActiveJS(result);
797 0 : args.rval().setObject(*result);
798 0 : if (!MaybeWrapObjectValue(cx, args.rval())) {
799 0 : return false;
800 : }
801 0 : return true;
802 : }
803 :
804 : static const JSJitInfo next_methodinfo = {
805 : { (JSJitGetterOp)next },
806 : { prototypes::id::MediaKeyStatusMapIterator },
807 : { PrototypeTraits<prototypes::id::MediaKeyStatusMapIterator>::Depth },
808 : JSJitInfo::Method,
809 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
810 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
811 : false, /* isInfallible. False in setters. */
812 : false, /* isMovable. Not relevant for setters. */
813 : false, /* isEliminatable. Not relevant for setters. */
814 : false, /* isAlwaysInSlot. Only relevant for getters. */
815 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
816 : false, /* isTypedMethod. Only relevant for methods. */
817 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
818 : };
819 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
820 : static_assert(0 < 1, "There is no slot for us");
821 :
822 : static void
823 0 : _finalize(js::FreeOp* fop, JSObject* obj)
824 : {
825 0 : mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>>(obj);
826 0 : if (self) {
827 0 : AddForDeferredFinalization<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>>(self);
828 : }
829 0 : }
830 :
831 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
832 : #if defined(__clang__)
833 : #pragma clang diagnostic push
834 : #pragma clang diagnostic ignored "-Wmissing-braces"
835 : #endif
836 : static const JSFunctionSpec sMethods_specs[] = {
837 : JS_FNSPEC("next", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&next_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
838 : JS_FS_END
839 : };
840 : #if defined(__clang__)
841 : #pragma clang diagnostic pop
842 : #endif
843 :
844 :
845 : // Can't be const because the pref-enabled boolean needs to be writable
846 : static Prefable<const JSFunctionSpec> sMethods[] = {
847 : { nullptr, &sMethods_specs[0] },
848 : { nullptr, nullptr }
849 : };
850 :
851 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
852 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
853 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
854 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
855 :
856 :
857 : static uint16_t sNativeProperties_sortedPropertyIndices[1];
858 : static PropertyInfo sNativeProperties_propertyInfos[1];
859 :
860 : static const NativePropertiesN<1> sNativeProperties = {
861 : false, 0,
862 : false, 0,
863 : true, 0 /* sMethods */,
864 : false, 0,
865 : false, 0,
866 : false, 0,
867 : false, 0,
868 : -1,
869 : 1,
870 : sNativeProperties_sortedPropertyIndices,
871 : {
872 : { sMethods, &sNativeProperties_propertyInfos[0] }
873 : }
874 : };
875 : static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
876 : "We have a property info count that is oversized");
877 :
878 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
879 : {
880 : "MediaKeyStatusMapIteratorPrototype",
881 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
882 : JS_NULL_CLASS_OPS,
883 : JS_NULL_CLASS_SPEC,
884 : JS_NULL_CLASS_EXT,
885 : JS_NULL_OBJECT_OPS
886 : },
887 : eInterfacePrototype,
888 : false,
889 : prototypes::id::MediaKeyStatusMapIterator,
890 : PrototypeTraits<prototypes::id::MediaKeyStatusMapIterator>::Depth,
891 : sNativePropertyHooks,
892 : "[object MediaKeyStatusMapIteratorPrototype]",
893 : JS::GetRealmIteratorPrototype
894 : };
895 :
896 : static const js::ClassOps sClassOps = {
897 : nullptr, /* addProperty */
898 : nullptr, /* delProperty */
899 : nullptr, /* getProperty */
900 : nullptr, /* setProperty */
901 : nullptr, /* enumerate */
902 : nullptr, /* newEnumerate */
903 : nullptr, /* resolve */
904 : nullptr, /* mayResolve */
905 : _finalize, /* finalize */
906 : nullptr, /* call */
907 : nullptr, /* hasInstance */
908 : nullptr, /* construct */
909 : nullptr, /* trace */
910 : };
911 :
912 : static const js::ClassExtension sClassExtension = {
913 : nullptr, /* weakmapKeyDelegateOp */
914 : nullptr /* objectMovedOp */
915 : };
916 :
917 : static const DOMJSClass sClass = {
918 : { "MediaKeyStatusMapIterator",
919 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
920 : &sClassOps,
921 : JS_NULL_CLASS_SPEC,
922 : &sClassExtension,
923 : JS_NULL_OBJECT_OPS
924 : },
925 : { prototypes::id::MediaKeyStatusMapIterator, 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 },
926 : IsBaseOf<nsISupports, mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap> >::value,
927 : sNativePropertyHooks,
928 : FindAssociatedGlobalForNative<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>>::Get,
929 : GetProtoObjectHandle,
930 : GetCCParticipant<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>>::Get()
931 : };
932 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
933 : "Must have the right minimal number of reserved slots.");
934 : static_assert(1 >= 1,
935 : "Must have enough reserved slots.");
936 :
937 : const JSClass*
938 0 : GetJSClass()
939 : {
940 0 : return sClass.ToJSClass();
941 : }
942 :
943 : bool
944 0 : Wrap(JSContext* aCx, mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
945 : {
946 : MOZ_ASSERT(static_cast<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>*>(aObject) ==
947 : reinterpret_cast<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>*>(aObject),
948 : "Multiple inheritance for mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap> is broken.");
949 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
950 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
951 :
952 0 : JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
953 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
954 0 : if (!canonicalProto) {
955 0 : return false;
956 : }
957 0 : JS::Rooted<JSObject*> proto(aCx);
958 0 : if (aGivenProto) {
959 0 : proto = aGivenProto;
960 : // Unfortunately, while aGivenProto was in the compartment of aCx
961 : // coming in, we changed compartments to that of "parent" so may need
962 : // to wrap the proto here.
963 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
964 0 : if (!JS_WrapObject(aCx, &proto)) {
965 0 : return false;
966 : }
967 : }
968 : } else {
969 0 : proto = canonicalProto;
970 : }
971 :
972 0 : BindingJSObjectCreator<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>> creator(aCx);
973 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
974 0 : if (!aReflector) {
975 0 : return false;
976 : }
977 :
978 :
979 :
980 0 : creator.InitializationSucceeded();
981 0 : return true;
982 : }
983 :
984 : const NativePropertyHooks sNativePropertyHooks[] = { {
985 : nullptr,
986 : nullptr,
987 : nullptr,
988 : { sNativeProperties.Upcast(), nullptr },
989 : prototypes::id::MediaKeyStatusMapIterator,
990 : constructors::id::_ID_Count,
991 : nullptr,
992 : &DefaultXrayExpandoObjectClass
993 : } };
994 :
995 : void
996 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
997 : {
998 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmIteratorPrototype(aCx));
999 0 : if (!parentProto) {
1000 0 : return;
1001 : }
1002 :
1003 : static bool sIdsInited = false;
1004 0 : if (!sIdsInited && NS_IsMainThread()) {
1005 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1006 0 : return;
1007 : }
1008 0 : sIdsInited = true;
1009 : }
1010 :
1011 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaKeyStatusMapIterator);
1012 0 : JS::Heap<JSObject*>* interfaceCache = nullptr;
1013 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1014 : &sPrototypeClass.mBase, protoCache,
1015 : nullptr, nullptr, 0, nullptr,
1016 : interfaceCache,
1017 : sNativeProperties.Upcast(),
1018 : nullptr,
1019 : nullptr, aDefineOnGlobal,
1020 : nullptr,
1021 0 : false);
1022 : }
1023 :
1024 : JS::Handle<JSObject*>
1025 0 : GetProtoObjectHandle(JSContext* aCx)
1026 : {
1027 : /* Get the interface prototype object for this class. This will create the
1028 : object as needed. */
1029 0 : bool aDefineOnGlobal = true;
1030 :
1031 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1032 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1033 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1034 0 : return nullptr;
1035 : }
1036 :
1037 : /* Check to see whether the interface objects are already installed */
1038 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1039 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::MediaKeyStatusMapIterator)) {
1040 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1041 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1042 : }
1043 :
1044 : /*
1045 : * The object might _still_ be null, but that's OK.
1046 : *
1047 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1048 : * traced by TraceProtoAndIfaceCache() and its contents are never
1049 : * changed after they have been set.
1050 : *
1051 : * Calling address() avoids the read read barrier that does gray
1052 : * unmarking, but it's not possible for the object to be gray here.
1053 : */
1054 :
1055 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::MediaKeyStatusMapIterator);
1056 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1057 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1058 : }
1059 :
1060 : } // namespace MediaKeyStatusMapIteratorBinding
1061 :
1062 :
1063 :
1064 : } // namespace dom
1065 : } // namespace mozilla
|