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