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