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