/work/obj-fuzz/dom/bindings/SpeechSynthesisUtteranceBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM SpeechSynthesisUtterance.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "EventHandlerBinding.h" |
4 | | #include "EventTargetBinding.h" |
5 | | #include "SpeechSynthesisUtteranceBinding.h" |
6 | | #include "WrapperFactory.h" |
7 | | #include "mozilla/FloatingPoint.h" |
8 | | #include "mozilla/OwningNonNull.h" |
9 | | #include "mozilla/Preferences.h" |
10 | | #include "mozilla/dom/BindingUtils.h" |
11 | | #include "mozilla/dom/DOMJSClass.h" |
12 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "mozilla/dom/PrimitiveConversions.h" |
15 | | #include "mozilla/dom/SpeechSynthesisUtterance.h" |
16 | | #include "mozilla/dom/SpeechSynthesisVoice.h" |
17 | | #include "mozilla/dom/XrayExpandoClass.h" |
18 | | #include "nsContentUtils.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 SpeechSynthesisUtterance_Binding { |
28 | | |
29 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_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_text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
34 | 0 | { |
35 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.text", DOM, cx); |
36 | 0 |
|
37 | 0 | DOMString result; |
38 | 0 | self->GetText(result); |
39 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
40 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
41 | 0 | return false; |
42 | 0 | } |
43 | 0 | return true; |
44 | 0 | } |
45 | | |
46 | | MOZ_CAN_RUN_SCRIPT static bool |
47 | | set_text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
48 | 0 | { |
49 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.text", DOM, cx); |
50 | 0 |
|
51 | 0 | binding_detail::FakeString arg0; |
52 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
53 | 0 | return false; |
54 | 0 | } |
55 | 0 | self->SetText(NonNullHelper(Constify(arg0))); |
56 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
57 | 0 |
|
58 | 0 | return true; |
59 | 0 | } |
60 | | |
61 | | static const JSJitInfo text_getterinfo = { |
62 | | { (JSJitGetterOp)get_text }, |
63 | | { prototypes::id::SpeechSynthesisUtterance }, |
64 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::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 | | static const JSJitInfo text_setterinfo = { |
79 | | { (JSJitGetterOp)set_text }, |
80 | | { prototypes::id::SpeechSynthesisUtterance }, |
81 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
82 | | JSJitInfo::Setter, |
83 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
84 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
85 | | false, /* isInfallible. False in setters. */ |
86 | | false, /* isMovable. Not relevant for setters. */ |
87 | | false, /* isEliminatable. Not relevant for setters. */ |
88 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
89 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
90 | | false, /* isTypedMethod. Only relevant for methods. */ |
91 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
92 | | }; |
93 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
94 | | static_assert(0 < 1, "There is no slot for us"); |
95 | | |
96 | | MOZ_CAN_RUN_SCRIPT static bool |
97 | | get_lang(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
98 | 0 | { |
99 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.lang", DOM, cx); |
100 | 0 |
|
101 | 0 | DOMString result; |
102 | 0 | self->GetLang(result); |
103 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
104 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
105 | 0 | return false; |
106 | 0 | } |
107 | 0 | return true; |
108 | 0 | } |
109 | | |
110 | | MOZ_CAN_RUN_SCRIPT static bool |
111 | | set_lang(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
112 | 0 | { |
113 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.lang", DOM, cx); |
114 | 0 |
|
115 | 0 | binding_detail::FakeString arg0; |
116 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
117 | 0 | return false; |
118 | 0 | } |
119 | 0 | self->SetLang(NonNullHelper(Constify(arg0))); |
120 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
121 | 0 |
|
122 | 0 | return true; |
123 | 0 | } |
124 | | |
125 | | static const JSJitInfo lang_getterinfo = { |
126 | | { (JSJitGetterOp)get_lang }, |
127 | | { prototypes::id::SpeechSynthesisUtterance }, |
128 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
129 | | JSJitInfo::Getter, |
130 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
131 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
132 | | false, /* isInfallible. False in setters. */ |
133 | | false, /* isMovable. Not relevant for setters. */ |
134 | | false, /* isEliminatable. Not relevant for setters. */ |
135 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
136 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
137 | | false, /* isTypedMethod. Only relevant for methods. */ |
138 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
139 | | }; |
140 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
141 | | static_assert(0 < 1, "There is no slot for us"); |
142 | | static const JSJitInfo lang_setterinfo = { |
143 | | { (JSJitGetterOp)set_lang }, |
144 | | { prototypes::id::SpeechSynthesisUtterance }, |
145 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
146 | | JSJitInfo::Setter, |
147 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
148 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
149 | | false, /* isInfallible. False in setters. */ |
150 | | false, /* isMovable. Not relevant for setters. */ |
151 | | false, /* isEliminatable. Not relevant for setters. */ |
152 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
153 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
154 | | false, /* isTypedMethod. Only relevant for methods. */ |
155 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
156 | | }; |
157 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
158 | | static_assert(0 < 1, "There is no slot for us"); |
159 | | |
160 | | MOZ_CAN_RUN_SCRIPT static bool |
161 | | get_voice(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
162 | 0 | { |
163 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.voice", DOM, cx); |
164 | 0 |
|
165 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SpeechSynthesisVoice>(self->GetVoice())); |
166 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
167 | 0 | if (!result) { |
168 | 0 | args.rval().setNull(); |
169 | 0 | return true; |
170 | 0 | } |
171 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
172 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
173 | 0 | return false; |
174 | 0 | } |
175 | 0 | return true; |
176 | 0 | } |
177 | | |
178 | | MOZ_CAN_RUN_SCRIPT static bool |
179 | | set_voice(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
180 | 0 | { |
181 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.voice", DOM, cx); |
182 | 0 |
|
183 | 0 | mozilla::dom::SpeechSynthesisVoice* arg0; |
184 | 0 | if (args[0].isObject()) { |
185 | 0 | { |
186 | 0 | nsresult rv = UnwrapObject<prototypes::id::SpeechSynthesisVoice, mozilla::dom::SpeechSynthesisVoice>(args[0], arg0); |
187 | 0 | if (NS_FAILED(rv)) { |
188 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to SpeechSynthesisUtterance.voice", "SpeechSynthesisVoice"); |
189 | 0 | return false; |
190 | 0 | } |
191 | 0 | } |
192 | 0 | } else if (args[0].isNullOrUndefined()) { |
193 | 0 | arg0 = nullptr; |
194 | 0 | } else { |
195 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to SpeechSynthesisUtterance.voice"); |
196 | 0 | return false; |
197 | 0 | } |
198 | 0 | self->SetVoice(MOZ_KnownLive(Constify(arg0))); |
199 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
200 | 0 |
|
201 | 0 | return true; |
202 | 0 | } |
203 | | |
204 | | static const JSJitInfo voice_getterinfo = { |
205 | | { (JSJitGetterOp)get_voice }, |
206 | | { prototypes::id::SpeechSynthesisUtterance }, |
207 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
208 | | JSJitInfo::Getter, |
209 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
210 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
211 | | false, /* isInfallible. False in setters. */ |
212 | | false, /* isMovable. Not relevant for setters. */ |
213 | | false, /* isEliminatable. Not relevant for setters. */ |
214 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
215 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
216 | | false, /* isTypedMethod. Only relevant for methods. */ |
217 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
218 | | }; |
219 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
220 | | static_assert(0 < 1, "There is no slot for us"); |
221 | | static const JSJitInfo voice_setterinfo = { |
222 | | { (JSJitGetterOp)set_voice }, |
223 | | { prototypes::id::SpeechSynthesisUtterance }, |
224 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
225 | | JSJitInfo::Setter, |
226 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
227 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
228 | | false, /* isInfallible. False in setters. */ |
229 | | false, /* isMovable. Not relevant for setters. */ |
230 | | false, /* isEliminatable. Not relevant for setters. */ |
231 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
232 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
233 | | false, /* isTypedMethod. Only relevant for methods. */ |
234 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
235 | | }; |
236 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
237 | | static_assert(0 < 1, "There is no slot for us"); |
238 | | |
239 | | MOZ_CAN_RUN_SCRIPT static bool |
240 | | get_volume(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
241 | 0 | { |
242 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.volume", DOM, cx); |
243 | 0 |
|
244 | 0 | float result(self->Volume()); |
245 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
246 | 0 | args.rval().set(JS_NumberValue(double(result))); |
247 | 0 | return true; |
248 | 0 | } |
249 | | |
250 | | MOZ_CAN_RUN_SCRIPT static bool |
251 | | set_volume(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
252 | 0 | { |
253 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.volume", DOM, cx); |
254 | 0 |
|
255 | 0 | float arg0; |
256 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
257 | 0 | return false; |
258 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
259 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SpeechSynthesisUtterance.volume"); |
260 | 0 | return false; |
261 | 0 | } |
262 | 0 | self->SetVolume(arg0); |
263 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
264 | 0 |
|
265 | 0 | return true; |
266 | 0 | } |
267 | | |
268 | | static const JSJitInfo volume_getterinfo = { |
269 | | { (JSJitGetterOp)get_volume }, |
270 | | { prototypes::id::SpeechSynthesisUtterance }, |
271 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
272 | | JSJitInfo::Getter, |
273 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
274 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
275 | | true, /* isInfallible. False in setters. */ |
276 | | false, /* isMovable. Not relevant for setters. */ |
277 | | false, /* isEliminatable. Not relevant for setters. */ |
278 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
279 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
280 | | false, /* isTypedMethod. Only relevant for methods. */ |
281 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
282 | | }; |
283 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
284 | | static_assert(0 < 1, "There is no slot for us"); |
285 | | static const JSJitInfo volume_setterinfo = { |
286 | | { (JSJitGetterOp)set_volume }, |
287 | | { prototypes::id::SpeechSynthesisUtterance }, |
288 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
289 | | JSJitInfo::Setter, |
290 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
291 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
292 | | false, /* isInfallible. False in setters. */ |
293 | | false, /* isMovable. Not relevant for setters. */ |
294 | | false, /* isEliminatable. Not relevant for setters. */ |
295 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
296 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
297 | | false, /* isTypedMethod. Only relevant for methods. */ |
298 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
299 | | }; |
300 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
301 | | static_assert(0 < 1, "There is no slot for us"); |
302 | | |
303 | | MOZ_CAN_RUN_SCRIPT static bool |
304 | | get_rate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
305 | 0 | { |
306 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.rate", DOM, cx); |
307 | 0 |
|
308 | 0 | float result(self->Rate()); |
309 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
310 | 0 | args.rval().set(JS_NumberValue(double(result))); |
311 | 0 | return true; |
312 | 0 | } |
313 | | |
314 | | MOZ_CAN_RUN_SCRIPT static bool |
315 | | set_rate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
316 | 0 | { |
317 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.rate", DOM, cx); |
318 | 0 |
|
319 | 0 | float arg0; |
320 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
321 | 0 | return false; |
322 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
323 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SpeechSynthesisUtterance.rate"); |
324 | 0 | return false; |
325 | 0 | } |
326 | 0 | self->SetRate(arg0); |
327 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
328 | 0 |
|
329 | 0 | return true; |
330 | 0 | } |
331 | | |
332 | | static const JSJitInfo rate_getterinfo = { |
333 | | { (JSJitGetterOp)get_rate }, |
334 | | { prototypes::id::SpeechSynthesisUtterance }, |
335 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
336 | | JSJitInfo::Getter, |
337 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
338 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
339 | | true, /* isInfallible. False in setters. */ |
340 | | false, /* isMovable. Not relevant for setters. */ |
341 | | false, /* isEliminatable. Not relevant for setters. */ |
342 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
343 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
344 | | false, /* isTypedMethod. Only relevant for methods. */ |
345 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
346 | | }; |
347 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
348 | | static_assert(0 < 1, "There is no slot for us"); |
349 | | static const JSJitInfo rate_setterinfo = { |
350 | | { (JSJitGetterOp)set_rate }, |
351 | | { prototypes::id::SpeechSynthesisUtterance }, |
352 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
353 | | JSJitInfo::Setter, |
354 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
355 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
356 | | false, /* 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_pitch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
369 | 0 | { |
370 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.pitch", DOM, cx); |
371 | 0 |
|
372 | 0 | float result(self->Pitch()); |
373 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
374 | 0 | args.rval().set(JS_NumberValue(double(result))); |
375 | 0 | return true; |
376 | 0 | } |
377 | | |
378 | | MOZ_CAN_RUN_SCRIPT static bool |
379 | | set_pitch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
380 | 0 | { |
381 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.pitch", DOM, cx); |
382 | 0 |
|
383 | 0 | float arg0; |
384 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
385 | 0 | return false; |
386 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
387 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SpeechSynthesisUtterance.pitch"); |
388 | 0 | return false; |
389 | 0 | } |
390 | 0 | self->SetPitch(arg0); |
391 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
392 | 0 |
|
393 | 0 | return true; |
394 | 0 | } |
395 | | |
396 | | static const JSJitInfo pitch_getterinfo = { |
397 | | { (JSJitGetterOp)get_pitch }, |
398 | | { prototypes::id::SpeechSynthesisUtterance }, |
399 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
400 | | JSJitInfo::Getter, |
401 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
402 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
403 | | true, /* isInfallible. False in setters. */ |
404 | | false, /* isMovable. Not relevant for setters. */ |
405 | | false, /* isEliminatable. Not relevant for setters. */ |
406 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
407 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
408 | | false, /* isTypedMethod. Only relevant for methods. */ |
409 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
410 | | }; |
411 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
412 | | static_assert(0 < 1, "There is no slot for us"); |
413 | | static const JSJitInfo pitch_setterinfo = { |
414 | | { (JSJitGetterOp)set_pitch }, |
415 | | { prototypes::id::SpeechSynthesisUtterance }, |
416 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
417 | | JSJitInfo::Setter, |
418 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
419 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
420 | | false, /* isInfallible. False in setters. */ |
421 | | false, /* isMovable. Not relevant for setters. */ |
422 | | false, /* isEliminatable. Not relevant for setters. */ |
423 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
424 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
425 | | false, /* isTypedMethod. Only relevant for methods. */ |
426 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
427 | | }; |
428 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
429 | | static_assert(0 < 1, "There is no slot for us"); |
430 | | |
431 | | MOZ_CAN_RUN_SCRIPT static bool |
432 | | get_onstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
433 | 0 | { |
434 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.onstart", DOM, cx); |
435 | 0 |
|
436 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnstart()); |
437 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
438 | 0 | if (result) { |
439 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
440 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
441 | 0 | return false; |
442 | 0 | } |
443 | 0 | return true; |
444 | 0 | } else { |
445 | 0 | args.rval().setNull(); |
446 | 0 | return true; |
447 | 0 | } |
448 | 0 | } |
449 | | |
450 | | MOZ_CAN_RUN_SCRIPT static bool |
451 | | set_onstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
452 | 0 | { |
453 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.onstart", DOM, cx); |
454 | 0 |
|
455 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
456 | 0 | if (args[0].isObject()) { |
457 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
458 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
459 | 0 | } |
460 | 0 | } else { |
461 | 0 | arg0 = nullptr; |
462 | 0 | } |
463 | 0 | self->SetOnstart(Constify(arg0)); |
464 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
465 | 0 |
|
466 | 0 | return true; |
467 | 0 | } |
468 | | |
469 | | static const JSJitInfo onstart_getterinfo = { |
470 | | { (JSJitGetterOp)get_onstart }, |
471 | | { prototypes::id::SpeechSynthesisUtterance }, |
472 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
473 | | JSJitInfo::Getter, |
474 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
475 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
476 | | false, /* isInfallible. False in setters. */ |
477 | | false, /* isMovable. Not relevant for setters. */ |
478 | | false, /* isEliminatable. Not relevant for setters. */ |
479 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
480 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
481 | | false, /* isTypedMethod. Only relevant for methods. */ |
482 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
483 | | }; |
484 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
485 | | static_assert(0 < 1, "There is no slot for us"); |
486 | | static const JSJitInfo onstart_setterinfo = { |
487 | | { (JSJitGetterOp)set_onstart }, |
488 | | { prototypes::id::SpeechSynthesisUtterance }, |
489 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
490 | | JSJitInfo::Setter, |
491 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
492 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
493 | | false, /* isInfallible. False in setters. */ |
494 | | false, /* isMovable. Not relevant for setters. */ |
495 | | false, /* isEliminatable. Not relevant for setters. */ |
496 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
497 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
498 | | false, /* isTypedMethod. Only relevant for methods. */ |
499 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
500 | | }; |
501 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
502 | | static_assert(0 < 1, "There is no slot for us"); |
503 | | |
504 | | MOZ_CAN_RUN_SCRIPT static bool |
505 | | get_onend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
506 | 0 | { |
507 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.onend", DOM, cx); |
508 | 0 |
|
509 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnend()); |
510 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
511 | 0 | if (result) { |
512 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
513 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
514 | 0 | return false; |
515 | 0 | } |
516 | 0 | return true; |
517 | 0 | } else { |
518 | 0 | args.rval().setNull(); |
519 | 0 | return true; |
520 | 0 | } |
521 | 0 | } |
522 | | |
523 | | MOZ_CAN_RUN_SCRIPT static bool |
524 | | set_onend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
525 | 0 | { |
526 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.onend", DOM, cx); |
527 | 0 |
|
528 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
529 | 0 | if (args[0].isObject()) { |
530 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
531 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
532 | 0 | } |
533 | 0 | } else { |
534 | 0 | arg0 = nullptr; |
535 | 0 | } |
536 | 0 | self->SetOnend(Constify(arg0)); |
537 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
538 | 0 |
|
539 | 0 | return true; |
540 | 0 | } |
541 | | |
542 | | static const JSJitInfo onend_getterinfo = { |
543 | | { (JSJitGetterOp)get_onend }, |
544 | | { prototypes::id::SpeechSynthesisUtterance }, |
545 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
546 | | JSJitInfo::Getter, |
547 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
548 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
549 | | false, /* isInfallible. False in setters. */ |
550 | | false, /* isMovable. Not relevant for setters. */ |
551 | | false, /* isEliminatable. Not relevant for setters. */ |
552 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
553 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
554 | | false, /* isTypedMethod. Only relevant for methods. */ |
555 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
556 | | }; |
557 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
558 | | static_assert(0 < 1, "There is no slot for us"); |
559 | | static const JSJitInfo onend_setterinfo = { |
560 | | { (JSJitGetterOp)set_onend }, |
561 | | { prototypes::id::SpeechSynthesisUtterance }, |
562 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
563 | | JSJitInfo::Setter, |
564 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
565 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
566 | | false, /* isInfallible. False in setters. */ |
567 | | false, /* isMovable. Not relevant for setters. */ |
568 | | false, /* isEliminatable. Not relevant for setters. */ |
569 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
570 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
571 | | false, /* isTypedMethod. Only relevant for methods. */ |
572 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
573 | | }; |
574 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
575 | | static_assert(0 < 1, "There is no slot for us"); |
576 | | |
577 | | MOZ_CAN_RUN_SCRIPT static bool |
578 | | get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
579 | 0 | { |
580 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.onerror", DOM, cx); |
581 | 0 |
|
582 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnerror()); |
583 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
584 | 0 | if (result) { |
585 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
586 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
587 | 0 | return false; |
588 | 0 | } |
589 | 0 | return true; |
590 | 0 | } else { |
591 | 0 | args.rval().setNull(); |
592 | 0 | return true; |
593 | 0 | } |
594 | 0 | } |
595 | | |
596 | | MOZ_CAN_RUN_SCRIPT static bool |
597 | | set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
598 | 0 | { |
599 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.onerror", DOM, cx); |
600 | 0 |
|
601 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
602 | 0 | if (args[0].isObject()) { |
603 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
604 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
605 | 0 | } |
606 | 0 | } else { |
607 | 0 | arg0 = nullptr; |
608 | 0 | } |
609 | 0 | self->SetOnerror(Constify(arg0)); |
610 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
611 | 0 |
|
612 | 0 | return true; |
613 | 0 | } |
614 | | |
615 | | static const JSJitInfo onerror_getterinfo = { |
616 | | { (JSJitGetterOp)get_onerror }, |
617 | | { prototypes::id::SpeechSynthesisUtterance }, |
618 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
619 | | JSJitInfo::Getter, |
620 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
621 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
622 | | false, /* isInfallible. False in setters. */ |
623 | | false, /* isMovable. Not relevant for setters. */ |
624 | | false, /* isEliminatable. Not relevant for setters. */ |
625 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
626 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
627 | | false, /* isTypedMethod. Only relevant for methods. */ |
628 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
629 | | }; |
630 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
631 | | static_assert(0 < 1, "There is no slot for us"); |
632 | | static const JSJitInfo onerror_setterinfo = { |
633 | | { (JSJitGetterOp)set_onerror }, |
634 | | { prototypes::id::SpeechSynthesisUtterance }, |
635 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
636 | | JSJitInfo::Setter, |
637 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
638 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
639 | | false, /* isInfallible. False in setters. */ |
640 | | false, /* isMovable. Not relevant for setters. */ |
641 | | false, /* isEliminatable. Not relevant for setters. */ |
642 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
643 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
644 | | false, /* isTypedMethod. Only relevant for methods. */ |
645 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
646 | | }; |
647 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
648 | | static_assert(0 < 1, "There is no slot for us"); |
649 | | |
650 | | MOZ_CAN_RUN_SCRIPT static bool |
651 | | get_onpause(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
652 | 0 | { |
653 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.onpause", DOM, cx); |
654 | 0 |
|
655 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnpause()); |
656 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
657 | 0 | if (result) { |
658 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
659 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
660 | 0 | return false; |
661 | 0 | } |
662 | 0 | return true; |
663 | 0 | } else { |
664 | 0 | args.rval().setNull(); |
665 | 0 | return true; |
666 | 0 | } |
667 | 0 | } |
668 | | |
669 | | MOZ_CAN_RUN_SCRIPT static bool |
670 | | set_onpause(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
671 | 0 | { |
672 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.onpause", DOM, cx); |
673 | 0 |
|
674 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
675 | 0 | if (args[0].isObject()) { |
676 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
677 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
678 | 0 | } |
679 | 0 | } else { |
680 | 0 | arg0 = nullptr; |
681 | 0 | } |
682 | 0 | self->SetOnpause(Constify(arg0)); |
683 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
684 | 0 |
|
685 | 0 | return true; |
686 | 0 | } |
687 | | |
688 | | static const JSJitInfo onpause_getterinfo = { |
689 | | { (JSJitGetterOp)get_onpause }, |
690 | | { prototypes::id::SpeechSynthesisUtterance }, |
691 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
692 | | JSJitInfo::Getter, |
693 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
694 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
695 | | false, /* isInfallible. False in setters. */ |
696 | | false, /* isMovable. Not relevant for setters. */ |
697 | | false, /* isEliminatable. Not relevant for setters. */ |
698 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
699 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
700 | | false, /* isTypedMethod. Only relevant for methods. */ |
701 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
702 | | }; |
703 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
704 | | static_assert(0 < 1, "There is no slot for us"); |
705 | | static const JSJitInfo onpause_setterinfo = { |
706 | | { (JSJitGetterOp)set_onpause }, |
707 | | { prototypes::id::SpeechSynthesisUtterance }, |
708 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
709 | | JSJitInfo::Setter, |
710 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
711 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
712 | | false, /* isInfallible. False in setters. */ |
713 | | false, /* isMovable. Not relevant for setters. */ |
714 | | false, /* isEliminatable. Not relevant for setters. */ |
715 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
716 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
717 | | false, /* isTypedMethod. Only relevant for methods. */ |
718 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
719 | | }; |
720 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
721 | | static_assert(0 < 1, "There is no slot for us"); |
722 | | |
723 | | MOZ_CAN_RUN_SCRIPT static bool |
724 | | get_onresume(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
725 | 0 | { |
726 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.onresume", DOM, cx); |
727 | 0 |
|
728 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnresume()); |
729 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
730 | 0 | if (result) { |
731 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
732 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
733 | 0 | return false; |
734 | 0 | } |
735 | 0 | return true; |
736 | 0 | } else { |
737 | 0 | args.rval().setNull(); |
738 | 0 | return true; |
739 | 0 | } |
740 | 0 | } |
741 | | |
742 | | MOZ_CAN_RUN_SCRIPT static bool |
743 | | set_onresume(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
744 | 0 | { |
745 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.onresume", DOM, cx); |
746 | 0 |
|
747 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
748 | 0 | if (args[0].isObject()) { |
749 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
750 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
751 | 0 | } |
752 | 0 | } else { |
753 | 0 | arg0 = nullptr; |
754 | 0 | } |
755 | 0 | self->SetOnresume(Constify(arg0)); |
756 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
757 | 0 |
|
758 | 0 | return true; |
759 | 0 | } |
760 | | |
761 | | static const JSJitInfo onresume_getterinfo = { |
762 | | { (JSJitGetterOp)get_onresume }, |
763 | | { prototypes::id::SpeechSynthesisUtterance }, |
764 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
765 | | JSJitInfo::Getter, |
766 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
767 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
768 | | false, /* isInfallible. False in setters. */ |
769 | | false, /* isMovable. Not relevant for setters. */ |
770 | | false, /* isEliminatable. Not relevant for setters. */ |
771 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
772 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
773 | | false, /* isTypedMethod. Only relevant for methods. */ |
774 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
775 | | }; |
776 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
777 | | static_assert(0 < 1, "There is no slot for us"); |
778 | | static const JSJitInfo onresume_setterinfo = { |
779 | | { (JSJitGetterOp)set_onresume }, |
780 | | { prototypes::id::SpeechSynthesisUtterance }, |
781 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
782 | | JSJitInfo::Setter, |
783 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
784 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
785 | | false, /* isInfallible. False in setters. */ |
786 | | false, /* isMovable. Not relevant for setters. */ |
787 | | false, /* isEliminatable. Not relevant for setters. */ |
788 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
789 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
790 | | false, /* isTypedMethod. Only relevant for methods. */ |
791 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
792 | | }; |
793 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
794 | | static_assert(0 < 1, "There is no slot for us"); |
795 | | |
796 | | MOZ_CAN_RUN_SCRIPT static bool |
797 | | get_onmark(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
798 | 0 | { |
799 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.onmark", DOM, cx); |
800 | 0 |
|
801 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnmark()); |
802 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
803 | 0 | if (result) { |
804 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
805 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
806 | 0 | return false; |
807 | 0 | } |
808 | 0 | return true; |
809 | 0 | } else { |
810 | 0 | args.rval().setNull(); |
811 | 0 | return true; |
812 | 0 | } |
813 | 0 | } |
814 | | |
815 | | MOZ_CAN_RUN_SCRIPT static bool |
816 | | set_onmark(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
817 | 0 | { |
818 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.onmark", DOM, cx); |
819 | 0 |
|
820 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
821 | 0 | if (args[0].isObject()) { |
822 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
823 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
824 | 0 | } |
825 | 0 | } else { |
826 | 0 | arg0 = nullptr; |
827 | 0 | } |
828 | 0 | self->SetOnmark(Constify(arg0)); |
829 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
830 | 0 |
|
831 | 0 | return true; |
832 | 0 | } |
833 | | |
834 | | static const JSJitInfo onmark_getterinfo = { |
835 | | { (JSJitGetterOp)get_onmark }, |
836 | | { prototypes::id::SpeechSynthesisUtterance }, |
837 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
838 | | JSJitInfo::Getter, |
839 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
840 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
841 | | false, /* isInfallible. False in setters. */ |
842 | | false, /* isMovable. Not relevant for setters. */ |
843 | | false, /* isEliminatable. Not relevant for setters. */ |
844 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
845 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
846 | | false, /* isTypedMethod. Only relevant for methods. */ |
847 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
848 | | }; |
849 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
850 | | static_assert(0 < 1, "There is no slot for us"); |
851 | | static const JSJitInfo onmark_setterinfo = { |
852 | | { (JSJitGetterOp)set_onmark }, |
853 | | { prototypes::id::SpeechSynthesisUtterance }, |
854 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
855 | | JSJitInfo::Setter, |
856 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
857 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
858 | | false, /* isInfallible. False in setters. */ |
859 | | false, /* isMovable. Not relevant for setters. */ |
860 | | false, /* isEliminatable. Not relevant for setters. */ |
861 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
862 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
863 | | false, /* isTypedMethod. Only relevant for methods. */ |
864 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
865 | | }; |
866 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
867 | | static_assert(0 < 1, "There is no slot for us"); |
868 | | |
869 | | MOZ_CAN_RUN_SCRIPT static bool |
870 | | get_onboundary(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
871 | 0 | { |
872 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.onboundary", DOM, cx); |
873 | 0 |
|
874 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnboundary()); |
875 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
876 | 0 | if (result) { |
877 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
878 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
879 | 0 | return false; |
880 | 0 | } |
881 | 0 | return true; |
882 | 0 | } else { |
883 | 0 | args.rval().setNull(); |
884 | 0 | return true; |
885 | 0 | } |
886 | 0 | } |
887 | | |
888 | | MOZ_CAN_RUN_SCRIPT static bool |
889 | | set_onboundary(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitSetterCallArgs args) |
890 | 0 | { |
891 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechSynthesisUtterance.onboundary", DOM, cx); |
892 | 0 |
|
893 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
894 | 0 | if (args[0].isObject()) { |
895 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
896 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
897 | 0 | } |
898 | 0 | } else { |
899 | 0 | arg0 = nullptr; |
900 | 0 | } |
901 | 0 | self->SetOnboundary(Constify(arg0)); |
902 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
903 | 0 |
|
904 | 0 | return true; |
905 | 0 | } |
906 | | |
907 | | static const JSJitInfo onboundary_getterinfo = { |
908 | | { (JSJitGetterOp)get_onboundary }, |
909 | | { prototypes::id::SpeechSynthesisUtterance }, |
910 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
911 | | JSJitInfo::Getter, |
912 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
913 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
914 | | false, /* isInfallible. False in setters. */ |
915 | | false, /* isMovable. Not relevant for setters. */ |
916 | | false, /* isEliminatable. Not relevant for setters. */ |
917 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
918 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
919 | | false, /* isTypedMethod. Only relevant for methods. */ |
920 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
921 | | }; |
922 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
923 | | static_assert(0 < 1, "There is no slot for us"); |
924 | | static const JSJitInfo onboundary_setterinfo = { |
925 | | { (JSJitGetterOp)set_onboundary }, |
926 | | { prototypes::id::SpeechSynthesisUtterance }, |
927 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
928 | | JSJitInfo::Setter, |
929 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
930 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
931 | | false, /* isInfallible. False in setters. */ |
932 | | false, /* isMovable. Not relevant for setters. */ |
933 | | false, /* isEliminatable. Not relevant for setters. */ |
934 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
935 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
936 | | false, /* isTypedMethod. Only relevant for methods. */ |
937 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
938 | | }; |
939 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
940 | | static_assert(0 < 1, "There is no slot for us"); |
941 | | |
942 | | MOZ_CAN_RUN_SCRIPT static bool |
943 | | get_chosenVoiceURI(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechSynthesisUtterance* self, JSJitGetterCallArgs args) |
944 | 0 | { |
945 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechSynthesisUtterance.chosenVoiceURI", DOM, cx); |
946 | 0 |
|
947 | 0 | DOMString result; |
948 | 0 | self->GetChosenVoiceURI(result); |
949 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
950 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
951 | 0 | return false; |
952 | 0 | } |
953 | 0 | return true; |
954 | 0 | } |
955 | | |
956 | | static const JSJitInfo chosenVoiceURI_getterinfo = { |
957 | | { (JSJitGetterOp)get_chosenVoiceURI }, |
958 | | { prototypes::id::SpeechSynthesisUtterance }, |
959 | | { PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth }, |
960 | | JSJitInfo::Getter, |
961 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
962 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
963 | | false, /* isInfallible. False in setters. */ |
964 | | false, /* isMovable. Not relevant for setters. */ |
965 | | false, /* isEliminatable. Not relevant for setters. */ |
966 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
967 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
968 | | false, /* isTypedMethod. Only relevant for methods. */ |
969 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
970 | | }; |
971 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
972 | | static_assert(0 < 1, "There is no slot for us"); |
973 | | |
974 | | static bool |
975 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
976 | 0 | { |
977 | 0 | mozilla::dom::SpeechSynthesisUtterance* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechSynthesisUtterance>(obj); |
978 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
979 | 0 | // obviously can't preserve if we're not initialized. |
980 | 0 | if (self && self->GetWrapperPreserveColor()) { |
981 | 0 | PreserveWrapper(self); |
982 | 0 | } |
983 | 0 | return true; |
984 | 0 | } |
985 | | |
986 | | static void |
987 | | _finalize(js::FreeOp* fop, JSObject* obj) |
988 | 0 | { |
989 | 0 | mozilla::dom::SpeechSynthesisUtterance* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechSynthesisUtterance>(obj); |
990 | 0 | if (self) { |
991 | 0 | ClearWrapper(self, self, obj); |
992 | 0 | AddForDeferredFinalization<mozilla::dom::SpeechSynthesisUtterance>(self); |
993 | 0 | } |
994 | 0 | } |
995 | | |
996 | | static size_t |
997 | | _objectMoved(JSObject* obj, JSObject* old) |
998 | 0 | { |
999 | 0 | mozilla::dom::SpeechSynthesisUtterance* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechSynthesisUtterance>(obj); |
1000 | 0 | if (self) { |
1001 | 0 | UpdateWrapper(self, self, obj, old); |
1002 | 0 | } |
1003 | 0 |
|
1004 | 0 | return 0; |
1005 | 0 | } |
1006 | | |
1007 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1008 | | #if defined(__clang__) |
1009 | | #pragma clang diagnostic push |
1010 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1011 | | #endif |
1012 | | static const JSPropertySpec sAttributes_specs[] = { |
1013 | | { "text", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &text_getterinfo, GenericSetter<NormalThisPolicy>, &text_setterinfo }, |
1014 | | { "lang", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lang_getterinfo, GenericSetter<NormalThisPolicy>, &lang_setterinfo }, |
1015 | | { "voice", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &voice_getterinfo, GenericSetter<NormalThisPolicy>, &voice_setterinfo }, |
1016 | | { "volume", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &volume_getterinfo, GenericSetter<NormalThisPolicy>, &volume_setterinfo }, |
1017 | | { "rate", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rate_getterinfo, GenericSetter<NormalThisPolicy>, &rate_setterinfo }, |
1018 | | { "pitch", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pitch_getterinfo, GenericSetter<NormalThisPolicy>, &pitch_setterinfo }, |
1019 | | { "onstart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onstart_getterinfo, GenericSetter<NormalThisPolicy>, &onstart_setterinfo }, |
1020 | | { "onend", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onend_getterinfo, GenericSetter<NormalThisPolicy>, &onend_setterinfo }, |
1021 | | { "onerror", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onerror_getterinfo, GenericSetter<NormalThisPolicy>, &onerror_setterinfo }, |
1022 | | { "onpause", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onpause_getterinfo, GenericSetter<NormalThisPolicy>, &onpause_setterinfo }, |
1023 | | { "onresume", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onresume_getterinfo, GenericSetter<NormalThisPolicy>, &onresume_setterinfo }, |
1024 | | { "onmark", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onmark_getterinfo, GenericSetter<NormalThisPolicy>, &onmark_setterinfo }, |
1025 | | { "onboundary", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onboundary_getterinfo, GenericSetter<NormalThisPolicy>, &onboundary_setterinfo }, |
1026 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1027 | | }; |
1028 | | #if defined(__clang__) |
1029 | | #pragma clang diagnostic pop |
1030 | | #endif |
1031 | | |
1032 | | |
1033 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
1034 | | { nullptr, &sAttributes_specs[0] }, |
1035 | | { nullptr, nullptr } |
1036 | | }; |
1037 | | |
1038 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1039 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1040 | | static_assert(13 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1041 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1042 | | |
1043 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1044 | | #if defined(__clang__) |
1045 | | #pragma clang diagnostic push |
1046 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1047 | | #endif |
1048 | | static const JSPropertySpec sChromeAttributes_specs[] = { |
1049 | | { "chosenVoiceURI", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &chosenVoiceURI_getterinfo, nullptr, nullptr }, |
1050 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1051 | | }; |
1052 | | #if defined(__clang__) |
1053 | | #pragma clang diagnostic pop |
1054 | | #endif |
1055 | | |
1056 | | |
1057 | | static const Prefable<const JSPropertySpec> sChromeAttributes[] = { |
1058 | | { nullptr, &sChromeAttributes_specs[0] }, |
1059 | | { nullptr, nullptr } |
1060 | | }; |
1061 | | |
1062 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1063 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1064 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1065 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1066 | | |
1067 | | |
1068 | | static uint16_t sNativeProperties_sortedPropertyIndices[13]; |
1069 | | static PropertyInfo sNativeProperties_propertyInfos[13]; |
1070 | | |
1071 | | static const NativePropertiesN<1> sNativeProperties = { |
1072 | | false, 0, |
1073 | | false, 0, |
1074 | | false, 0, |
1075 | | true, 0 /* sAttributes */, |
1076 | | false, 0, |
1077 | | false, 0, |
1078 | | false, 0, |
1079 | | -1, |
1080 | | 13, |
1081 | | sNativeProperties_sortedPropertyIndices, |
1082 | | { |
1083 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
1084 | | } |
1085 | | }; |
1086 | | static_assert(13 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1087 | | "We have a property info count that is oversized"); |
1088 | | |
1089 | | static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1]; |
1090 | | static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1]; |
1091 | | |
1092 | | static const NativePropertiesN<1> sChromeOnlyNativeProperties = { |
1093 | | false, 0, |
1094 | | false, 0, |
1095 | | false, 0, |
1096 | | true, 0 /* sChromeAttributes */, |
1097 | | false, 0, |
1098 | | false, 0, |
1099 | | false, 0, |
1100 | | -1, |
1101 | | 1, |
1102 | | sChromeOnlyNativeProperties_sortedPropertyIndices, |
1103 | | { |
1104 | | { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] } |
1105 | | } |
1106 | | }; |
1107 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount), |
1108 | | "We have a property info count that is oversized"); |
1109 | | |
1110 | | static bool |
1111 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
1112 | 0 | { |
1113 | 0 | AUTO_PROFILER_LABEL_FAST("SpeechSynthesisUtterance constructor", DOM, cx); |
1114 | 0 |
|
1115 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
1116 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
1117 | 0 | if (!args.isConstructing()) { |
1118 | 0 | // XXXbz wish I could get the name from the callee instead of |
1119 | 0 | // Adding more relocations |
1120 | 0 | return ThrowConstructorWithoutNew(cx, "SpeechSynthesisUtterance"); |
1121 | 0 | } |
1122 | 0 | |
1123 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
1124 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
1125 | 0 | return false; |
1126 | 0 | } |
1127 | 0 | |
1128 | 0 | unsigned argcount = std::min(args.length(), 1u); |
1129 | 0 | switch (argcount) { |
1130 | 0 | case 0: { |
1131 | 0 | GlobalObject global(cx, obj); |
1132 | 0 | if (global.Failed()) { |
1133 | 0 | return false; |
1134 | 0 | } |
1135 | 0 | |
1136 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1137 | 0 | Maybe<JSAutoRealm> ar; |
1138 | 0 | if (objIsXray) { |
1139 | 0 | obj = js::CheckedUnwrap(obj); |
1140 | 0 | if (!obj) { |
1141 | 0 | return false; |
1142 | 0 | } |
1143 | 0 | ar.emplace(cx, obj); |
1144 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
1145 | 0 | return false; |
1146 | 0 | } |
1147 | 0 | } |
1148 | 0 | FastErrorResult rv; |
1149 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SpeechSynthesisUtterance>(mozilla::dom::SpeechSynthesisUtterance::Constructor(global, rv))); |
1150 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1151 | 0 | return false; |
1152 | 0 | } |
1153 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1154 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
1155 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
1156 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
1157 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1158 | 0 | return false; |
1159 | 0 | } |
1160 | 0 | return true; |
1161 | 0 | break; |
1162 | 0 | } |
1163 | 0 | case 1: { |
1164 | 0 | GlobalObject global(cx, obj); |
1165 | 0 | if (global.Failed()) { |
1166 | 0 | return false; |
1167 | 0 | } |
1168 | 0 | |
1169 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1170 | 0 | binding_detail::FakeString arg0; |
1171 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1172 | 0 | return false; |
1173 | 0 | } |
1174 | 0 | Maybe<JSAutoRealm> ar; |
1175 | 0 | if (objIsXray) { |
1176 | 0 | obj = js::CheckedUnwrap(obj); |
1177 | 0 | if (!obj) { |
1178 | 0 | return false; |
1179 | 0 | } |
1180 | 0 | ar.emplace(cx, obj); |
1181 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
1182 | 0 | return false; |
1183 | 0 | } |
1184 | 0 | } |
1185 | 0 | FastErrorResult rv; |
1186 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SpeechSynthesisUtterance>(mozilla::dom::SpeechSynthesisUtterance::Constructor(global, NonNullHelper(Constify(arg0)), rv))); |
1187 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1188 | 0 | return false; |
1189 | 0 | } |
1190 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1191 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
1192 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
1193 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
1194 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1195 | 0 | return false; |
1196 | 0 | } |
1197 | 0 | return true; |
1198 | 0 | break; |
1199 | 0 | } |
1200 | 0 | default: { |
1201 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SpeechSynthesisUtterance"); |
1202 | 0 | break; |
1203 | 0 | } |
1204 | 0 | } |
1205 | 0 | MOZ_CRASH("We have an always-returning default case"); |
1206 | 0 | return false; |
1207 | 0 | } |
1208 | | |
1209 | | static const js::ClassOps sInterfaceObjectClassOps = { |
1210 | | nullptr, /* addProperty */ |
1211 | | nullptr, /* delProperty */ |
1212 | | nullptr, /* enumerate */ |
1213 | | nullptr, /* newEnumerate */ |
1214 | | nullptr, /* resolve */ |
1215 | | nullptr, /* mayResolve */ |
1216 | | nullptr, /* finalize */ |
1217 | | _constructor, /* call */ |
1218 | | nullptr, /* hasInstance */ |
1219 | | _constructor, /* construct */ |
1220 | | nullptr, /* trace */ |
1221 | | }; |
1222 | | |
1223 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
1224 | | { |
1225 | | "Function", |
1226 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
1227 | | &sInterfaceObjectClassOps, |
1228 | | JS_NULL_CLASS_SPEC, |
1229 | | JS_NULL_CLASS_EXT, |
1230 | | &sInterfaceObjectClassObjectOps |
1231 | | }, |
1232 | | eInterface, |
1233 | | true, |
1234 | | prototypes::id::SpeechSynthesisUtterance, |
1235 | | PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth, |
1236 | | sNativePropertyHooks, |
1237 | | "function SpeechSynthesisUtterance() {\n [native code]\n}", |
1238 | | EventTarget_Binding::GetConstructorObject |
1239 | | }; |
1240 | | |
1241 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1242 | | { |
1243 | | "SpeechSynthesisUtterancePrototype", |
1244 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1245 | | JS_NULL_CLASS_OPS, |
1246 | | JS_NULL_CLASS_SPEC, |
1247 | | JS_NULL_CLASS_EXT, |
1248 | | JS_NULL_OBJECT_OPS |
1249 | | }, |
1250 | | eInterfacePrototype, |
1251 | | false, |
1252 | | prototypes::id::SpeechSynthesisUtterance, |
1253 | | PrototypeTraits<prototypes::id::SpeechSynthesisUtterance>::Depth, |
1254 | | sNativePropertyHooks, |
1255 | | "[object SpeechSynthesisUtterancePrototype]", |
1256 | | EventTarget_Binding::GetProtoObject |
1257 | | }; |
1258 | | |
1259 | | bool |
1260 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
1261 | 0 | { |
1262 | 0 | static bool sPrefValue; |
1263 | 0 | static bool sPrefCacheSetUp = false; |
1264 | 0 | if (!sPrefCacheSetUp) { |
1265 | 0 | sPrefCacheSetUp = true; |
1266 | 0 | Preferences::AddBoolVarCache(&sPrefValue, "media.webspeech.synth.enabled"); |
1267 | 0 | } |
1268 | 0 |
|
1269 | 0 | return sPrefValue; |
1270 | 0 | } |
1271 | | |
1272 | | static const js::ClassOps sClassOps = { |
1273 | | _addProperty, /* addProperty */ |
1274 | | nullptr, /* delProperty */ |
1275 | | nullptr, /* enumerate */ |
1276 | | nullptr, /* newEnumerate */ |
1277 | | nullptr, /* resolve */ |
1278 | | nullptr, /* mayResolve */ |
1279 | | _finalize, /* finalize */ |
1280 | | nullptr, /* call */ |
1281 | | nullptr, /* hasInstance */ |
1282 | | nullptr, /* construct */ |
1283 | | nullptr, /* trace */ |
1284 | | }; |
1285 | | |
1286 | | static const js::ClassExtension sClassExtension = { |
1287 | | nullptr, /* weakmapKeyDelegateOp */ |
1288 | | _objectMoved /* objectMovedOp */ |
1289 | | }; |
1290 | | |
1291 | | static const DOMJSClass sClass = { |
1292 | | { "SpeechSynthesisUtterance", |
1293 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1294 | | &sClassOps, |
1295 | | JS_NULL_CLASS_SPEC, |
1296 | | &sClassExtension, |
1297 | | JS_NULL_OBJECT_OPS |
1298 | | }, |
1299 | | { prototypes::id::EventTarget, prototypes::id::SpeechSynthesisUtterance, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
1300 | | IsBaseOf<nsISupports, mozilla::dom::SpeechSynthesisUtterance >::value, |
1301 | | sNativePropertyHooks, |
1302 | | FindAssociatedGlobalForNative<mozilla::dom::SpeechSynthesisUtterance>::Get, |
1303 | | GetProtoObjectHandle, |
1304 | | GetCCParticipant<mozilla::dom::SpeechSynthesisUtterance>::Get() |
1305 | | }; |
1306 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1307 | | "Must have the right minimal number of reserved slots."); |
1308 | | static_assert(1 >= 1, |
1309 | | "Must have enough reserved slots."); |
1310 | | |
1311 | | const JSClass* |
1312 | | GetJSClass() |
1313 | 0 | { |
1314 | 0 | return sClass.ToJSClass(); |
1315 | 0 | } |
1316 | | |
1317 | | bool |
1318 | | Wrap(JSContext* aCx, mozilla::dom::SpeechSynthesisUtterance* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1319 | 0 | { |
1320 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SpeechSynthesisUtterance>::value, |
1321 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1322 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::SpeechSynthesisUtterance*>(aObject) == |
1323 | 0 | reinterpret_cast<mozilla::dom::SpeechSynthesisUtterance*>(aObject), |
1324 | 0 | "Multiple inheritance for mozilla::dom::SpeechSynthesisUtterance is broken."); |
1325 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
1326 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
1327 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
1328 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1329 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1330 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1331 | 0 | "You should probably not be using Wrap() directly; use " |
1332 | 0 | "GetOrCreateDOMReflector instead"); |
1333 | 0 |
|
1334 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1335 | 0 | "nsISupports must be on our primary inheritance chain"); |
1336 | 0 |
|
1337 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1338 | 0 | if (!global) { |
1339 | 0 | return false; |
1340 | 0 | } |
1341 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1342 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1343 | 0 |
|
1344 | 0 | // That might have ended up wrapping us already, due to the wonders |
1345 | 0 | // of XBL. Check for that, and bail out as needed. |
1346 | 0 | aReflector.set(aCache->GetWrapper()); |
1347 | 0 | if (aReflector) { |
1348 | | #ifdef DEBUG |
1349 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1350 | | #endif // DEBUG |
1351 | | return true; |
1352 | 0 | } |
1353 | 0 |
|
1354 | 0 | JSAutoRealm ar(aCx, global); |
1355 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1356 | 0 | if (!canonicalProto) { |
1357 | 0 | return false; |
1358 | 0 | } |
1359 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1360 | 0 | if (aGivenProto) { |
1361 | 0 | proto = aGivenProto; |
1362 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1363 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1364 | 0 | // to wrap the proto here. |
1365 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1366 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1367 | 0 | return false; |
1368 | 0 | } |
1369 | 0 | } |
1370 | 0 | } else { |
1371 | 0 | proto = canonicalProto; |
1372 | 0 | } |
1373 | 0 |
|
1374 | 0 | BindingJSObjectCreator<mozilla::dom::SpeechSynthesisUtterance> creator(aCx); |
1375 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1376 | 0 | if (!aReflector) { |
1377 | 0 | return false; |
1378 | 0 | } |
1379 | 0 | |
1380 | 0 | aCache->SetWrapper(aReflector); |
1381 | 0 | creator.InitializationSucceeded(); |
1382 | 0 |
|
1383 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1384 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1385 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1386 | 0 | // otherwise we won't be able to properly recreate it later, since |
1387 | 0 | // we won't know what proto to use. Note that we don't check |
1388 | 0 | // aGivenProto here, since it's entirely possible (and even |
1389 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1390 | 0 | // same as canonicalProto. |
1391 | 0 | if (proto != canonicalProto) { |
1392 | 0 | PreserveWrapper(aObject); |
1393 | 0 | } |
1394 | 0 |
|
1395 | 0 | return true; |
1396 | 0 | } |
1397 | | |
1398 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1399 | | nullptr, |
1400 | | nullptr, |
1401 | | nullptr, |
1402 | | { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() }, |
1403 | | prototypes::id::SpeechSynthesisUtterance, |
1404 | | constructors::id::SpeechSynthesisUtterance, |
1405 | | EventTarget_Binding::sNativePropertyHooks, |
1406 | | &DefaultXrayExpandoObjectClass |
1407 | | } }; |
1408 | | |
1409 | | void |
1410 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1411 | 0 | { |
1412 | 0 | JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx)); |
1413 | 0 | if (!parentProto) { |
1414 | 0 | return; |
1415 | 0 | } |
1416 | 0 | |
1417 | 0 | JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx)); |
1418 | 0 | if (!constructorProto) { |
1419 | 0 | return; |
1420 | 0 | } |
1421 | 0 | |
1422 | 0 | static bool sIdsInited = false; |
1423 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1424 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1425 | 0 | return; |
1426 | 0 | } |
1427 | 0 | if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) { |
1428 | 0 | return; |
1429 | 0 | } |
1430 | 0 | sIdsInited = true; |
1431 | 0 | } |
1432 | 0 |
|
1433 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SpeechSynthesisUtterance); |
1434 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SpeechSynthesisUtterance); |
1435 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1436 | 0 | &sPrototypeClass.mBase, protoCache, |
1437 | 0 | nullptr, |
1438 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
1439 | 0 | interfaceCache, |
1440 | 0 | sNativeProperties.Upcast(), |
1441 | 0 | sChromeOnlyNativeProperties.Upcast(), |
1442 | 0 | "SpeechSynthesisUtterance", aDefineOnGlobal, |
1443 | 0 | nullptr, |
1444 | 0 | false); |
1445 | 0 | } |
1446 | | |
1447 | | JSObject* |
1448 | | GetConstructorObject(JSContext* aCx) |
1449 | 0 | { |
1450 | 0 | return GetConstructorObjectHandle(aCx); |
1451 | 0 | } |
1452 | | |
1453 | | } // namespace SpeechSynthesisUtterance_Binding |
1454 | | |
1455 | | |
1456 | | |
1457 | | } // namespace dom |
1458 | | } // namespace mozilla |