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