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