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