/work/obj-fuzz/dom/bindings/GetUserMediaRequestBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM GetUserMediaRequest.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "GetUserMediaRequestBinding.h" |
4 | | #include "MediaStreamBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/BindingUtils.h" |
8 | | #include "mozilla/dom/DOMJSClass.h" |
9 | | #include "mozilla/dom/GetUserMediaRequest.h" |
10 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
11 | | #include "mozilla/dom/PrimitiveConversions.h" |
12 | | #include "mozilla/dom/XrayExpandoClass.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace dom { |
16 | | |
17 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
18 | | using namespace mozilla::dom::binding_detail; |
19 | | |
20 | | |
21 | | namespace GetUserMediaRequest_Binding { |
22 | | |
23 | | MOZ_CAN_RUN_SCRIPT static bool |
24 | | get_windowID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args) |
25 | 0 | { |
26 | 0 | AUTO_PROFILER_LABEL_FAST("get GetUserMediaRequest.windowID", DOM, cx); |
27 | 0 |
|
28 | 0 | uint64_t result(self->WindowID()); |
29 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
30 | 0 | args.rval().set(JS_NumberValue(double(result))); |
31 | 0 | return true; |
32 | 0 | } |
33 | | |
34 | | static const JSJitInfo windowID_getterinfo = { |
35 | | { (JSJitGetterOp)get_windowID }, |
36 | | { prototypes::id::GetUserMediaRequest }, |
37 | | { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth }, |
38 | | JSJitInfo::Getter, |
39 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
40 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
41 | | true, /* isInfallible. False in setters. */ |
42 | | false, /* isMovable. Not relevant for setters. */ |
43 | | false, /* isEliminatable. Not relevant for setters. */ |
44 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
45 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
46 | | false, /* isTypedMethod. Only relevant for methods. */ |
47 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
48 | | }; |
49 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
50 | | static_assert(0 < 1, "There is no slot for us"); |
51 | | |
52 | | MOZ_CAN_RUN_SCRIPT static bool |
53 | | get_innerWindowID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args) |
54 | 0 | { |
55 | 0 | AUTO_PROFILER_LABEL_FAST("get GetUserMediaRequest.innerWindowID", DOM, cx); |
56 | 0 |
|
57 | 0 | uint64_t result(self->InnerWindowID()); |
58 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
59 | 0 | args.rval().set(JS_NumberValue(double(result))); |
60 | 0 | return true; |
61 | 0 | } |
62 | | |
63 | | static const JSJitInfo innerWindowID_getterinfo = { |
64 | | { (JSJitGetterOp)get_innerWindowID }, |
65 | | { prototypes::id::GetUserMediaRequest }, |
66 | | { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth }, |
67 | | JSJitInfo::Getter, |
68 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
69 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
70 | | true, /* isInfallible. False in setters. */ |
71 | | false, /* isMovable. Not relevant for setters. */ |
72 | | false, /* isEliminatable. Not relevant for setters. */ |
73 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
74 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
75 | | false, /* isTypedMethod. Only relevant for methods. */ |
76 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
77 | | }; |
78 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
79 | | static_assert(0 < 1, "There is no slot for us"); |
80 | | |
81 | | MOZ_CAN_RUN_SCRIPT static bool |
82 | | get_callID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args) |
83 | 0 | { |
84 | 0 | AUTO_PROFILER_LABEL_FAST("get GetUserMediaRequest.callID", DOM, cx); |
85 | 0 |
|
86 | 0 | DOMString result; |
87 | 0 | self->GetCallID(result); |
88 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
89 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
90 | 0 | return false; |
91 | 0 | } |
92 | 0 | return true; |
93 | 0 | } |
94 | | |
95 | | static const JSJitInfo callID_getterinfo = { |
96 | | { (JSJitGetterOp)get_callID }, |
97 | | { prototypes::id::GetUserMediaRequest }, |
98 | | { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth }, |
99 | | JSJitInfo::Getter, |
100 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
101 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
102 | | false, /* isInfallible. False in setters. */ |
103 | | false, /* isMovable. Not relevant for setters. */ |
104 | | false, /* isEliminatable. Not relevant for setters. */ |
105 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
106 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
107 | | false, /* isTypedMethod. Only relevant for methods. */ |
108 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
109 | | }; |
110 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
111 | | static_assert(0 < 1, "There is no slot for us"); |
112 | | |
113 | | MOZ_CAN_RUN_SCRIPT static bool |
114 | | get_rawID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args) |
115 | 0 | { |
116 | 0 | AUTO_PROFILER_LABEL_FAST("get GetUserMediaRequest.rawID", DOM, cx); |
117 | 0 |
|
118 | 0 | DOMString result; |
119 | 0 | self->GetRawID(result); |
120 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
121 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
122 | 0 | return false; |
123 | 0 | } |
124 | 0 | return true; |
125 | 0 | } |
126 | | |
127 | | static const JSJitInfo rawID_getterinfo = { |
128 | | { (JSJitGetterOp)get_rawID }, |
129 | | { prototypes::id::GetUserMediaRequest }, |
130 | | { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth }, |
131 | | JSJitInfo::Getter, |
132 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
133 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
134 | | false, /* isInfallible. False in setters. */ |
135 | | false, /* isMovable. Not relevant for setters. */ |
136 | | false, /* isEliminatable. Not relevant for setters. */ |
137 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
138 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
139 | | false, /* isTypedMethod. Only relevant for methods. */ |
140 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
141 | | }; |
142 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
143 | | static_assert(0 < 1, "There is no slot for us"); |
144 | | |
145 | | MOZ_CAN_RUN_SCRIPT static bool |
146 | | get_mediaSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args) |
147 | 0 | { |
148 | 0 | AUTO_PROFILER_LABEL_FAST("get GetUserMediaRequest.mediaSource", DOM, cx); |
149 | 0 |
|
150 | 0 | DOMString result; |
151 | 0 | self->GetMediaSource(result); |
152 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
153 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
154 | 0 | return false; |
155 | 0 | } |
156 | 0 | return true; |
157 | 0 | } |
158 | | |
159 | | static const JSJitInfo mediaSource_getterinfo = { |
160 | | { (JSJitGetterOp)get_mediaSource }, |
161 | | { prototypes::id::GetUserMediaRequest }, |
162 | | { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth }, |
163 | | JSJitInfo::Getter, |
164 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
165 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
166 | | false, /* isInfallible. False in setters. */ |
167 | | false, /* isMovable. Not relevant for setters. */ |
168 | | false, /* isEliminatable. Not relevant for setters. */ |
169 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
170 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
171 | | false, /* isTypedMethod. Only relevant for methods. */ |
172 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
173 | | }; |
174 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
175 | | static_assert(0 < 1, "There is no slot for us"); |
176 | | |
177 | | MOZ_CAN_RUN_SCRIPT static bool |
178 | | getConstraints(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, const JSJitMethodCallArgs& args) |
179 | 0 | { |
180 | 0 | AUTO_PROFILER_LABEL_FAST("GetUserMediaRequest.getConstraints", DOM, cx); |
181 | 0 |
|
182 | 0 | MediaStreamConstraints result; |
183 | 0 | self->GetConstraints(result); |
184 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
185 | 0 | if (!result.ToObjectInternal(cx, args.rval())) { |
186 | 0 | return false; |
187 | 0 | } |
188 | 0 | return true; |
189 | 0 | } |
190 | | |
191 | | static const JSJitInfo getConstraints_methodinfo = { |
192 | | { (JSJitGetterOp)getConstraints }, |
193 | | { prototypes::id::GetUserMediaRequest }, |
194 | | { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth }, |
195 | | JSJitInfo::Method, |
196 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
197 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
198 | | false, /* isInfallible. False in setters. */ |
199 | | false, /* isMovable. Not relevant for setters. */ |
200 | | false, /* isEliminatable. Not relevant for setters. */ |
201 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
202 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
203 | | false, /* isTypedMethod. Only relevant for methods. */ |
204 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
205 | | }; |
206 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
207 | | static_assert(0 < 1, "There is no slot for us"); |
208 | | |
209 | | MOZ_CAN_RUN_SCRIPT static bool |
210 | | get_isSecure(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args) |
211 | 0 | { |
212 | 0 | AUTO_PROFILER_LABEL_FAST("get GetUserMediaRequest.isSecure", DOM, cx); |
213 | 0 |
|
214 | 0 | bool result(self->IsSecure()); |
215 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
216 | 0 | args.rval().setBoolean(result); |
217 | 0 | return true; |
218 | 0 | } |
219 | | |
220 | | static const JSJitInfo isSecure_getterinfo = { |
221 | | { (JSJitGetterOp)get_isSecure }, |
222 | | { prototypes::id::GetUserMediaRequest }, |
223 | | { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth }, |
224 | | JSJitInfo::Getter, |
225 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
226 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
227 | | true, /* isInfallible. False in setters. */ |
228 | | false, /* isMovable. Not relevant for setters. */ |
229 | | false, /* isEliminatable. Not relevant for setters. */ |
230 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
231 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
232 | | false, /* isTypedMethod. Only relevant for methods. */ |
233 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
234 | | }; |
235 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
236 | | static_assert(0 < 1, "There is no slot for us"); |
237 | | |
238 | | MOZ_CAN_RUN_SCRIPT static bool |
239 | | get_isHandlingUserInput(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args) |
240 | 0 | { |
241 | 0 | AUTO_PROFILER_LABEL_FAST("get GetUserMediaRequest.isHandlingUserInput", DOM, cx); |
242 | 0 |
|
243 | 0 | bool result(self->IsHandlingUserInput()); |
244 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
245 | 0 | args.rval().setBoolean(result); |
246 | 0 | return true; |
247 | 0 | } |
248 | | |
249 | | static const JSJitInfo isHandlingUserInput_getterinfo = { |
250 | | { (JSJitGetterOp)get_isHandlingUserInput }, |
251 | | { prototypes::id::GetUserMediaRequest }, |
252 | | { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth }, |
253 | | JSJitInfo::Getter, |
254 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
255 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
256 | | true, /* isInfallible. False in setters. */ |
257 | | false, /* isMovable. Not relevant for setters. */ |
258 | | false, /* isEliminatable. Not relevant for setters. */ |
259 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
260 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
261 | | false, /* isTypedMethod. Only relevant for methods. */ |
262 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
263 | | }; |
264 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
265 | | static_assert(0 < 1, "There is no slot for us"); |
266 | | |
267 | | static bool |
268 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
269 | 0 | { |
270 | 0 | mozilla::dom::GetUserMediaRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GetUserMediaRequest>(obj); |
271 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
272 | 0 | // obviously can't preserve if we're not initialized. |
273 | 0 | if (self && self->GetWrapperPreserveColor()) { |
274 | 0 | PreserveWrapper(self); |
275 | 0 | } |
276 | 0 | return true; |
277 | 0 | } |
278 | | |
279 | | static void |
280 | | _finalize(js::FreeOp* fop, JSObject* obj) |
281 | 0 | { |
282 | 0 | mozilla::dom::GetUserMediaRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GetUserMediaRequest>(obj); |
283 | 0 | if (self) { |
284 | 0 | ClearWrapper(self, self, obj); |
285 | 0 | AddForDeferredFinalization<mozilla::dom::GetUserMediaRequest>(self); |
286 | 0 | } |
287 | 0 | } |
288 | | |
289 | | static size_t |
290 | | _objectMoved(JSObject* obj, JSObject* old) |
291 | 0 | { |
292 | 0 | mozilla::dom::GetUserMediaRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GetUserMediaRequest>(obj); |
293 | 0 | if (self) { |
294 | 0 | UpdateWrapper(self, self, obj, old); |
295 | 0 | } |
296 | 0 |
|
297 | 0 | return 0; |
298 | 0 | } |
299 | | |
300 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
301 | | #if defined(__clang__) |
302 | | #pragma clang diagnostic push |
303 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
304 | | #endif |
305 | | static const JSFunctionSpec sMethods_specs[] = { |
306 | | JS_FNSPEC("getConstraints", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getConstraints_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
307 | | JS_FS_END |
308 | | }; |
309 | | #if defined(__clang__) |
310 | | #pragma clang diagnostic pop |
311 | | #endif |
312 | | |
313 | | |
314 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
315 | | { nullptr, &sMethods_specs[0] }, |
316 | | { nullptr, nullptr } |
317 | | }; |
318 | | |
319 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
320 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
321 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
322 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
323 | | |
324 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
325 | | #if defined(__clang__) |
326 | | #pragma clang diagnostic push |
327 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
328 | | #endif |
329 | | static const JSPropertySpec sAttributes_specs[] = { |
330 | | { "windowID", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &windowID_getterinfo, nullptr, nullptr }, |
331 | | { "innerWindowID", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &innerWindowID_getterinfo, nullptr, nullptr }, |
332 | | { "callID", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &callID_getterinfo, nullptr, nullptr }, |
333 | | { "rawID", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rawID_getterinfo, nullptr, nullptr }, |
334 | | { "mediaSource", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mediaSource_getterinfo, nullptr, nullptr }, |
335 | | { "isSecure", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isSecure_getterinfo, nullptr, nullptr }, |
336 | | { "isHandlingUserInput", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isHandlingUserInput_getterinfo, nullptr, nullptr }, |
337 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
338 | | }; |
339 | | #if defined(__clang__) |
340 | | #pragma clang diagnostic pop |
341 | | #endif |
342 | | |
343 | | |
344 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
345 | | { nullptr, &sAttributes_specs[0] }, |
346 | | { nullptr, nullptr } |
347 | | }; |
348 | | |
349 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
350 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
351 | | static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
352 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
353 | | |
354 | | |
355 | | static uint16_t sNativeProperties_sortedPropertyIndices[8]; |
356 | | static PropertyInfo sNativeProperties_propertyInfos[8]; |
357 | | |
358 | | static const NativePropertiesN<2> sNativeProperties = { |
359 | | false, 0, |
360 | | false, 0, |
361 | | true, 0 /* sMethods */, |
362 | | true, 1 /* sAttributes */, |
363 | | false, 0, |
364 | | false, 0, |
365 | | false, 0, |
366 | | -1, |
367 | | 8, |
368 | | sNativeProperties_sortedPropertyIndices, |
369 | | { |
370 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
371 | | { sAttributes, &sNativeProperties_propertyInfos[1] } |
372 | | } |
373 | | }; |
374 | | static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
375 | | "We have a property info count that is oversized"); |
376 | | |
377 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
378 | | { |
379 | | "GetUserMediaRequestPrototype", |
380 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
381 | | JS_NULL_CLASS_OPS, |
382 | | JS_NULL_CLASS_SPEC, |
383 | | JS_NULL_CLASS_EXT, |
384 | | JS_NULL_OBJECT_OPS |
385 | | }, |
386 | | eInterfacePrototype, |
387 | | false, |
388 | | prototypes::id::GetUserMediaRequest, |
389 | | PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth, |
390 | | sNativePropertyHooks, |
391 | | "[object GetUserMediaRequestPrototype]", |
392 | | JS::GetRealmObjectPrototype |
393 | | }; |
394 | | |
395 | | static const js::ClassOps sClassOps = { |
396 | | _addProperty, /* addProperty */ |
397 | | nullptr, /* delProperty */ |
398 | | nullptr, /* enumerate */ |
399 | | nullptr, /* newEnumerate */ |
400 | | nullptr, /* resolve */ |
401 | | nullptr, /* mayResolve */ |
402 | | _finalize, /* finalize */ |
403 | | nullptr, /* call */ |
404 | | nullptr, /* hasInstance */ |
405 | | nullptr, /* construct */ |
406 | | nullptr, /* trace */ |
407 | | }; |
408 | | |
409 | | static const js::ClassExtension sClassExtension = { |
410 | | nullptr, /* weakmapKeyDelegateOp */ |
411 | | _objectMoved /* objectMovedOp */ |
412 | | }; |
413 | | |
414 | | static const DOMJSClass sClass = { |
415 | | { "GetUserMediaRequest", |
416 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
417 | | &sClassOps, |
418 | | JS_NULL_CLASS_SPEC, |
419 | | &sClassExtension, |
420 | | JS_NULL_OBJECT_OPS |
421 | | }, |
422 | | { prototypes::id::GetUserMediaRequest, 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 }, |
423 | | IsBaseOf<nsISupports, mozilla::dom::GetUserMediaRequest >::value, |
424 | | sNativePropertyHooks, |
425 | | FindAssociatedGlobalForNative<mozilla::dom::GetUserMediaRequest>::Get, |
426 | | GetProtoObjectHandle, |
427 | | GetCCParticipant<mozilla::dom::GetUserMediaRequest>::Get() |
428 | | }; |
429 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
430 | | "Must have the right minimal number of reserved slots."); |
431 | | static_assert(1 >= 1, |
432 | | "Must have enough reserved slots."); |
433 | | |
434 | | const JSClass* |
435 | | GetJSClass() |
436 | 0 | { |
437 | 0 | return sClass.ToJSClass(); |
438 | 0 | } |
439 | | |
440 | | bool |
441 | | Wrap(JSContext* aCx, mozilla::dom::GetUserMediaRequest* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
442 | 0 | { |
443 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::GetUserMediaRequest>::value, |
444 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
445 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::GetUserMediaRequest*>(aObject) == |
446 | 0 | reinterpret_cast<mozilla::dom::GetUserMediaRequest*>(aObject), |
447 | 0 | "Multiple inheritance for mozilla::dom::GetUserMediaRequest is broken."); |
448 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
449 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
450 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
451 | 0 | "You should probably not be using Wrap() directly; use " |
452 | 0 | "GetOrCreateDOMReflector instead"); |
453 | 0 |
|
454 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
455 | 0 | "nsISupports must be on our primary inheritance chain"); |
456 | 0 |
|
457 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
458 | 0 | if (!global) { |
459 | 0 | return false; |
460 | 0 | } |
461 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
462 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
463 | 0 |
|
464 | 0 | // That might have ended up wrapping us already, due to the wonders |
465 | 0 | // of XBL. Check for that, and bail out as needed. |
466 | 0 | aReflector.set(aCache->GetWrapper()); |
467 | 0 | if (aReflector) { |
468 | | #ifdef DEBUG |
469 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
470 | | #endif // DEBUG |
471 | | return true; |
472 | 0 | } |
473 | 0 |
|
474 | 0 | JSAutoRealm ar(aCx, global); |
475 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
476 | 0 | if (!canonicalProto) { |
477 | 0 | return false; |
478 | 0 | } |
479 | 0 | JS::Rooted<JSObject*> proto(aCx); |
480 | 0 | if (aGivenProto) { |
481 | 0 | proto = aGivenProto; |
482 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
483 | 0 | // coming in, we changed compartments to that of "parent" so may need |
484 | 0 | // to wrap the proto here. |
485 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
486 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
487 | 0 | return false; |
488 | 0 | } |
489 | 0 | } |
490 | 0 | } else { |
491 | 0 | proto = canonicalProto; |
492 | 0 | } |
493 | 0 |
|
494 | 0 | BindingJSObjectCreator<mozilla::dom::GetUserMediaRequest> creator(aCx); |
495 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
496 | 0 | if (!aReflector) { |
497 | 0 | return false; |
498 | 0 | } |
499 | 0 | |
500 | 0 | aCache->SetWrapper(aReflector); |
501 | 0 | creator.InitializationSucceeded(); |
502 | 0 |
|
503 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
504 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
505 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
506 | 0 | // otherwise we won't be able to properly recreate it later, since |
507 | 0 | // we won't know what proto to use. Note that we don't check |
508 | 0 | // aGivenProto here, since it's entirely possible (and even |
509 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
510 | 0 | // same as canonicalProto. |
511 | 0 | if (proto != canonicalProto) { |
512 | 0 | PreserveWrapper(aObject); |
513 | 0 | } |
514 | 0 |
|
515 | 0 | return true; |
516 | 0 | } |
517 | | |
518 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
519 | | nullptr, |
520 | | nullptr, |
521 | | nullptr, |
522 | | { sNativeProperties.Upcast(), nullptr }, |
523 | | prototypes::id::GetUserMediaRequest, |
524 | | constructors::id::_ID_Count, |
525 | | nullptr, |
526 | | &DefaultXrayExpandoObjectClass |
527 | | } }; |
528 | | |
529 | | void |
530 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
531 | 0 | { |
532 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
533 | 0 | if (!parentProto) { |
534 | 0 | return; |
535 | 0 | } |
536 | 0 | |
537 | 0 | static bool sIdsInited = false; |
538 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
539 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
540 | 0 | return; |
541 | 0 | } |
542 | 0 | sIdsInited = true; |
543 | 0 | } |
544 | 0 |
|
545 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GetUserMediaRequest); |
546 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
547 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
548 | 0 | &sPrototypeClass.mBase, protoCache, |
549 | 0 | nullptr, |
550 | 0 | nullptr, nullptr, 0, nullptr, |
551 | 0 | interfaceCache, |
552 | 0 | sNativeProperties.Upcast(), |
553 | 0 | nullptr, |
554 | 0 | nullptr, aDefineOnGlobal, |
555 | 0 | nullptr, |
556 | 0 | false); |
557 | 0 | } |
558 | | |
559 | | } // namespace GetUserMediaRequest_Binding |
560 | | |
561 | | |
562 | | |
563 | | } // namespace dom |
564 | | } // namespace mozilla |