/work/obj-fuzz/dom/bindings/SpeechRecognitionBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM SpeechRecognition.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "DOMMediaStream.h" |
4 | | #include "EventHandlerBinding.h" |
5 | | #include "EventTargetBinding.h" |
6 | | #include "SpeechRecognition.h" |
7 | | #include "SpeechRecognitionBinding.h" |
8 | | #include "WrapperFactory.h" |
9 | | #include "mozilla/OwningNonNull.h" |
10 | | #include "mozilla/Preferences.h" |
11 | | #include "mozilla/dom/BindingUtils.h" |
12 | | #include "mozilla/dom/DOMJSClass.h" |
13 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
14 | | #include "mozilla/dom/Nullable.h" |
15 | | #include "mozilla/dom/PrimitiveConversions.h" |
16 | | #include "mozilla/dom/SpeechGrammarList.h" |
17 | | #include "mozilla/dom/SpeechRecognition.h" |
18 | | #include "mozilla/dom/XrayExpandoClass.h" |
19 | | #include "nsContentUtils.h" |
20 | | |
21 | | namespace mozilla { |
22 | | namespace dom { |
23 | | |
24 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
25 | | using namespace mozilla::dom::binding_detail; |
26 | | |
27 | | |
28 | | namespace SpeechRecognition_Binding { |
29 | | |
30 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value, |
31 | | "Can't inherit from an interface with a different ownership model."); |
32 | | |
33 | | MOZ_CAN_RUN_SCRIPT static bool |
34 | | get_grammars(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
35 | 0 | { |
36 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.grammars", DOM, cx); |
37 | 0 |
|
38 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SpeechGrammarList>(self->Grammars())); |
39 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
40 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
41 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
42 | 0 | return false; |
43 | 0 | } |
44 | 0 | return true; |
45 | 0 | } |
46 | | |
47 | | MOZ_CAN_RUN_SCRIPT static bool |
48 | | set_grammars(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
49 | 0 | { |
50 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.grammars", DOM, cx); |
51 | 0 |
|
52 | 0 | NonNull<mozilla::dom::SpeechGrammarList> arg0; |
53 | 0 | if (args[0].isObject()) { |
54 | 0 | { |
55 | 0 | nsresult rv = UnwrapObject<prototypes::id::SpeechGrammarList, mozilla::dom::SpeechGrammarList>(args[0], arg0); |
56 | 0 | if (NS_FAILED(rv)) { |
57 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to SpeechRecognition.grammars", "SpeechGrammarList"); |
58 | 0 | return false; |
59 | 0 | } |
60 | 0 | } |
61 | 0 | } else { |
62 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to SpeechRecognition.grammars"); |
63 | 0 | return false; |
64 | 0 | } |
65 | 0 | self->SetGrammars(MOZ_KnownLive(NonNullHelper(arg0))); |
66 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
67 | 0 |
|
68 | 0 | return true; |
69 | 0 | } |
70 | | |
71 | | static const JSJitInfo grammars_getterinfo = { |
72 | | { (JSJitGetterOp)get_grammars }, |
73 | | { prototypes::id::SpeechRecognition }, |
74 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
75 | | JSJitInfo::Getter, |
76 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
77 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
78 | | false, /* isInfallible. False in setters. */ |
79 | | false, /* isMovable. Not relevant for setters. */ |
80 | | false, /* isEliminatable. Not relevant for setters. */ |
81 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
82 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
83 | | false, /* isTypedMethod. Only relevant for methods. */ |
84 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
85 | | }; |
86 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
87 | | static_assert(0 < 1, "There is no slot for us"); |
88 | | static const JSJitInfo grammars_setterinfo = { |
89 | | { (JSJitGetterOp)set_grammars }, |
90 | | { prototypes::id::SpeechRecognition }, |
91 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
92 | | JSJitInfo::Setter, |
93 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
94 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
95 | | false, /* isInfallible. False in setters. */ |
96 | | false, /* isMovable. Not relevant for setters. */ |
97 | | false, /* isEliminatable. Not relevant for setters. */ |
98 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
99 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
100 | | false, /* isTypedMethod. Only relevant for methods. */ |
101 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
102 | | }; |
103 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
104 | | static_assert(0 < 1, "There is no slot for us"); |
105 | | |
106 | | MOZ_CAN_RUN_SCRIPT static bool |
107 | | get_lang(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
108 | 0 | { |
109 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.lang", DOM, cx); |
110 | 0 |
|
111 | 0 | DOMString result; |
112 | 0 | self->GetLang(result); |
113 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
114 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
115 | 0 | return false; |
116 | 0 | } |
117 | 0 | return true; |
118 | 0 | } |
119 | | |
120 | | MOZ_CAN_RUN_SCRIPT static bool |
121 | | set_lang(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
122 | 0 | { |
123 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.lang", DOM, cx); |
124 | 0 |
|
125 | 0 | binding_detail::FakeString arg0; |
126 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
127 | 0 | return false; |
128 | 0 | } |
129 | 0 | self->SetLang(NonNullHelper(Constify(arg0))); |
130 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
131 | 0 |
|
132 | 0 | return true; |
133 | 0 | } |
134 | | |
135 | | static const JSJitInfo lang_getterinfo = { |
136 | | { (JSJitGetterOp)get_lang }, |
137 | | { prototypes::id::SpeechRecognition }, |
138 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
139 | | JSJitInfo::Getter, |
140 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
141 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
142 | | false, /* isInfallible. False in setters. */ |
143 | | false, /* isMovable. Not relevant for setters. */ |
144 | | false, /* isEliminatable. Not relevant for setters. */ |
145 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
146 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
147 | | false, /* isTypedMethod. Only relevant for methods. */ |
148 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
149 | | }; |
150 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
151 | | static_assert(0 < 1, "There is no slot for us"); |
152 | | static const JSJitInfo lang_setterinfo = { |
153 | | { (JSJitGetterOp)set_lang }, |
154 | | { prototypes::id::SpeechRecognition }, |
155 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
156 | | JSJitInfo::Setter, |
157 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
158 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
159 | | false, /* isInfallible. False in setters. */ |
160 | | false, /* isMovable. Not relevant for setters. */ |
161 | | false, /* isEliminatable. Not relevant for setters. */ |
162 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
163 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
164 | | false, /* isTypedMethod. Only relevant for methods. */ |
165 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
166 | | }; |
167 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
168 | | static_assert(0 < 1, "There is no slot for us"); |
169 | | |
170 | | MOZ_CAN_RUN_SCRIPT static bool |
171 | | get_continuous(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
172 | 0 | { |
173 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.continuous", DOM, cx); |
174 | 0 |
|
175 | 0 | FastErrorResult rv; |
176 | 0 | bool result(self->GetContinuous(rv)); |
177 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
178 | 0 | return false; |
179 | 0 | } |
180 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
181 | 0 | args.rval().setBoolean(result); |
182 | 0 | return true; |
183 | 0 | } |
184 | | |
185 | | MOZ_CAN_RUN_SCRIPT static bool |
186 | | set_continuous(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
187 | 0 | { |
188 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.continuous", DOM, cx); |
189 | 0 |
|
190 | 0 | bool arg0; |
191 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
192 | 0 | return false; |
193 | 0 | } |
194 | 0 | FastErrorResult rv; |
195 | 0 | self->SetContinuous(arg0, rv); |
196 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
197 | 0 | return false; |
198 | 0 | } |
199 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
200 | 0 |
|
201 | 0 | return true; |
202 | 0 | } |
203 | | |
204 | | static const JSJitInfo continuous_getterinfo = { |
205 | | { (JSJitGetterOp)get_continuous }, |
206 | | { prototypes::id::SpeechRecognition }, |
207 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
208 | | JSJitInfo::Getter, |
209 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
210 | | JSVAL_TYPE_BOOLEAN, /* 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 continuous_setterinfo = { |
222 | | { (JSJitGetterOp)set_continuous }, |
223 | | { prototypes::id::SpeechRecognition }, |
224 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::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_interimResults(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
241 | 0 | { |
242 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.interimResults", DOM, cx); |
243 | 0 |
|
244 | 0 | bool result(self->InterimResults()); |
245 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
246 | 0 | args.rval().setBoolean(result); |
247 | 0 | return true; |
248 | 0 | } |
249 | | |
250 | | MOZ_CAN_RUN_SCRIPT static bool |
251 | | set_interimResults(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
252 | 0 | { |
253 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.interimResults", DOM, cx); |
254 | 0 |
|
255 | 0 | bool arg0; |
256 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
257 | 0 | return false; |
258 | 0 | } |
259 | 0 | self->SetInterimResults(arg0); |
260 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
261 | 0 |
|
262 | 0 | return true; |
263 | 0 | } |
264 | | |
265 | | static const JSJitInfo interimResults_getterinfo = { |
266 | | { (JSJitGetterOp)get_interimResults }, |
267 | | { prototypes::id::SpeechRecognition }, |
268 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
269 | | JSJitInfo::Getter, |
270 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
271 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
272 | | true, /* isInfallible. False in setters. */ |
273 | | false, /* isMovable. Not relevant for setters. */ |
274 | | false, /* isEliminatable. Not relevant for setters. */ |
275 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
276 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
277 | | false, /* isTypedMethod. Only relevant for methods. */ |
278 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
279 | | }; |
280 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
281 | | static_assert(0 < 1, "There is no slot for us"); |
282 | | static const JSJitInfo interimResults_setterinfo = { |
283 | | { (JSJitGetterOp)set_interimResults }, |
284 | | { prototypes::id::SpeechRecognition }, |
285 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
286 | | JSJitInfo::Setter, |
287 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
288 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
289 | | false, /* isInfallible. False in setters. */ |
290 | | false, /* isMovable. Not relevant for setters. */ |
291 | | false, /* isEliminatable. Not relevant for setters. */ |
292 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
293 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
294 | | false, /* isTypedMethod. Only relevant for methods. */ |
295 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
296 | | }; |
297 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
298 | | static_assert(0 < 1, "There is no slot for us"); |
299 | | |
300 | | MOZ_CAN_RUN_SCRIPT static bool |
301 | | get_maxAlternatives(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
302 | 0 | { |
303 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.maxAlternatives", DOM, cx); |
304 | 0 |
|
305 | 0 | uint32_t result(self->MaxAlternatives()); |
306 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
307 | 0 | args.rval().setNumber(result); |
308 | 0 | return true; |
309 | 0 | } |
310 | | |
311 | | MOZ_CAN_RUN_SCRIPT static bool |
312 | | set_maxAlternatives(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
313 | 0 | { |
314 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.maxAlternatives", DOM, cx); |
315 | 0 |
|
316 | 0 | uint32_t arg0; |
317 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
318 | 0 | return false; |
319 | 0 | } |
320 | 0 | self->SetMaxAlternatives(arg0); |
321 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
322 | 0 |
|
323 | 0 | return true; |
324 | 0 | } |
325 | | |
326 | | static const JSJitInfo maxAlternatives_getterinfo = { |
327 | | { (JSJitGetterOp)get_maxAlternatives }, |
328 | | { prototypes::id::SpeechRecognition }, |
329 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
330 | | JSJitInfo::Getter, |
331 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
332 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
333 | | true, /* isInfallible. False in setters. */ |
334 | | false, /* isMovable. Not relevant for setters. */ |
335 | | false, /* isEliminatable. Not relevant for setters. */ |
336 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
337 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
338 | | false, /* isTypedMethod. Only relevant for methods. */ |
339 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
340 | | }; |
341 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
342 | | static_assert(0 < 1, "There is no slot for us"); |
343 | | static const JSJitInfo maxAlternatives_setterinfo = { |
344 | | { (JSJitGetterOp)set_maxAlternatives }, |
345 | | { prototypes::id::SpeechRecognition }, |
346 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
347 | | JSJitInfo::Setter, |
348 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
349 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
350 | | false, /* isInfallible. False in setters. */ |
351 | | false, /* isMovable. Not relevant for setters. */ |
352 | | false, /* isEliminatable. Not relevant for setters. */ |
353 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
354 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
355 | | false, /* isTypedMethod. Only relevant for methods. */ |
356 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
357 | | }; |
358 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
359 | | static_assert(0 < 1, "There is no slot for us"); |
360 | | |
361 | | MOZ_CAN_RUN_SCRIPT static bool |
362 | | get_serviceURI(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
363 | 0 | { |
364 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.serviceURI", DOM, cx); |
365 | 0 |
|
366 | 0 | FastErrorResult rv; |
367 | 0 | DOMString result; |
368 | 0 | self->GetServiceURI(result, rv); |
369 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
370 | 0 | return false; |
371 | 0 | } |
372 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
373 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
374 | 0 | return false; |
375 | 0 | } |
376 | 0 | return true; |
377 | 0 | } |
378 | | |
379 | | MOZ_CAN_RUN_SCRIPT static bool |
380 | | set_serviceURI(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
381 | 0 | { |
382 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.serviceURI", DOM, cx); |
383 | 0 |
|
384 | 0 | binding_detail::FakeString arg0; |
385 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
386 | 0 | return false; |
387 | 0 | } |
388 | 0 | FastErrorResult rv; |
389 | 0 | self->SetServiceURI(NonNullHelper(Constify(arg0)), rv); |
390 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
391 | 0 | return false; |
392 | 0 | } |
393 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
394 | 0 |
|
395 | 0 | return true; |
396 | 0 | } |
397 | | |
398 | | static const JSJitInfo serviceURI_getterinfo = { |
399 | | { (JSJitGetterOp)get_serviceURI }, |
400 | | { prototypes::id::SpeechRecognition }, |
401 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
402 | | JSJitInfo::Getter, |
403 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
404 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
405 | | false, /* isInfallible. False in setters. */ |
406 | | false, /* isMovable. Not relevant for setters. */ |
407 | | false, /* isEliminatable. Not relevant for setters. */ |
408 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
409 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
410 | | false, /* isTypedMethod. Only relevant for methods. */ |
411 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
412 | | }; |
413 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
414 | | static_assert(0 < 1, "There is no slot for us"); |
415 | | static const JSJitInfo serviceURI_setterinfo = { |
416 | | { (JSJitGetterOp)set_serviceURI }, |
417 | | { prototypes::id::SpeechRecognition }, |
418 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
419 | | JSJitInfo::Setter, |
420 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
421 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
422 | | false, /* isInfallible. False in setters. */ |
423 | | false, /* isMovable. Not relevant for setters. */ |
424 | | false, /* isEliminatable. Not relevant for setters. */ |
425 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
426 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
427 | | false, /* isTypedMethod. Only relevant for methods. */ |
428 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
429 | | }; |
430 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
431 | | static_assert(0 < 1, "There is no slot for us"); |
432 | | |
433 | | MOZ_CAN_RUN_SCRIPT static bool |
434 | | start(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, const JSJitMethodCallArgs& args) |
435 | 0 | { |
436 | 0 | AUTO_PROFILER_LABEL_FAST("SpeechRecognition.start", DOM, cx); |
437 | 0 |
|
438 | 0 | Optional<NonNull<mozilla::DOMMediaStream>> arg0; |
439 | 0 | if (args.hasDefined(0)) { |
440 | 0 | arg0.Construct(); |
441 | 0 | if (args[0].isObject()) { |
442 | 0 | { |
443 | 0 | nsresult rv = UnwrapObject<prototypes::id::MediaStream, mozilla::DOMMediaStream>(args[0], arg0.Value()); |
444 | 0 | if (NS_FAILED(rv)) { |
445 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SpeechRecognition.start", "MediaStream"); |
446 | 0 | return false; |
447 | 0 | } |
448 | 0 | } |
449 | 0 | } else { |
450 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SpeechRecognition.start"); |
451 | 0 | return false; |
452 | 0 | } |
453 | 0 | } |
454 | 0 | FastErrorResult rv; |
455 | 0 | self->Start(MOZ_KnownLive(NonNullHelper(Constify(arg0))), nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv); |
456 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
457 | 0 | return false; |
458 | 0 | } |
459 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
460 | 0 | args.rval().setUndefined(); |
461 | 0 | return true; |
462 | 0 | } |
463 | | |
464 | | static const JSJitInfo start_methodinfo = { |
465 | | { (JSJitGetterOp)start }, |
466 | | { prototypes::id::SpeechRecognition }, |
467 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
468 | | JSJitInfo::Method, |
469 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
470 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
471 | | false, /* isInfallible. False in setters. */ |
472 | | false, /* isMovable. Not relevant for setters. */ |
473 | | false, /* isEliminatable. Not relevant for setters. */ |
474 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
475 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
476 | | false, /* isTypedMethod. Only relevant for methods. */ |
477 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
478 | | }; |
479 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
480 | | static_assert(0 < 1, "There is no slot for us"); |
481 | | |
482 | | MOZ_CAN_RUN_SCRIPT static bool |
483 | | stop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, const JSJitMethodCallArgs& args) |
484 | 0 | { |
485 | 0 | AUTO_PROFILER_LABEL_FAST("SpeechRecognition.stop", DOM, cx); |
486 | 0 |
|
487 | 0 | self->Stop(); |
488 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
489 | 0 | args.rval().setUndefined(); |
490 | 0 | return true; |
491 | 0 | } |
492 | | |
493 | | static const JSJitInfo stop_methodinfo = { |
494 | | { (JSJitGetterOp)stop }, |
495 | | { prototypes::id::SpeechRecognition }, |
496 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
497 | | JSJitInfo::Method, |
498 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
499 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
500 | | true, /* isInfallible. False in setters. */ |
501 | | false, /* isMovable. Not relevant for setters. */ |
502 | | false, /* isEliminatable. Not relevant for setters. */ |
503 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
504 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
505 | | false, /* isTypedMethod. Only relevant for methods. */ |
506 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
507 | | }; |
508 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
509 | | static_assert(0 < 1, "There is no slot for us"); |
510 | | |
511 | | MOZ_CAN_RUN_SCRIPT static bool |
512 | | abort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, const JSJitMethodCallArgs& args) |
513 | 0 | { |
514 | 0 | AUTO_PROFILER_LABEL_FAST("SpeechRecognition.abort", DOM, cx); |
515 | 0 |
|
516 | 0 | self->Abort(); |
517 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
518 | 0 | args.rval().setUndefined(); |
519 | 0 | return true; |
520 | 0 | } |
521 | | |
522 | | static const JSJitInfo abort_methodinfo = { |
523 | | { (JSJitGetterOp)abort }, |
524 | | { prototypes::id::SpeechRecognition }, |
525 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
526 | | JSJitInfo::Method, |
527 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
528 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
529 | | true, /* isInfallible. False in setters. */ |
530 | | false, /* isMovable. Not relevant for setters. */ |
531 | | false, /* isEliminatable. Not relevant for setters. */ |
532 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
533 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
534 | | false, /* isTypedMethod. Only relevant for methods. */ |
535 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
536 | | }; |
537 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
538 | | static_assert(0 < 1, "There is no slot for us"); |
539 | | |
540 | | MOZ_CAN_RUN_SCRIPT static bool |
541 | | get_onaudiostart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
542 | 0 | { |
543 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.onaudiostart", DOM, cx); |
544 | 0 |
|
545 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnaudiostart()); |
546 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
547 | 0 | if (result) { |
548 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
549 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
550 | 0 | return false; |
551 | 0 | } |
552 | 0 | return true; |
553 | 0 | } else { |
554 | 0 | args.rval().setNull(); |
555 | 0 | return true; |
556 | 0 | } |
557 | 0 | } |
558 | | |
559 | | MOZ_CAN_RUN_SCRIPT static bool |
560 | | set_onaudiostart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
561 | 0 | { |
562 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.onaudiostart", DOM, cx); |
563 | 0 |
|
564 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
565 | 0 | if (args[0].isObject()) { |
566 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
567 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
568 | 0 | } |
569 | 0 | } else { |
570 | 0 | arg0 = nullptr; |
571 | 0 | } |
572 | 0 | self->SetOnaudiostart(Constify(arg0)); |
573 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
574 | 0 |
|
575 | 0 | return true; |
576 | 0 | } |
577 | | |
578 | | static const JSJitInfo onaudiostart_getterinfo = { |
579 | | { (JSJitGetterOp)get_onaudiostart }, |
580 | | { prototypes::id::SpeechRecognition }, |
581 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
582 | | JSJitInfo::Getter, |
583 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
584 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
585 | | false, /* isInfallible. False in setters. */ |
586 | | false, /* isMovable. Not relevant for setters. */ |
587 | | false, /* isEliminatable. Not relevant for setters. */ |
588 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
589 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
590 | | false, /* isTypedMethod. Only relevant for methods. */ |
591 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
592 | | }; |
593 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
594 | | static_assert(0 < 1, "There is no slot for us"); |
595 | | static const JSJitInfo onaudiostart_setterinfo = { |
596 | | { (JSJitGetterOp)set_onaudiostart }, |
597 | | { prototypes::id::SpeechRecognition }, |
598 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
599 | | JSJitInfo::Setter, |
600 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
601 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
602 | | false, /* isInfallible. False in setters. */ |
603 | | false, /* isMovable. Not relevant for setters. */ |
604 | | false, /* isEliminatable. Not relevant for setters. */ |
605 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
606 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
607 | | false, /* isTypedMethod. Only relevant for methods. */ |
608 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
609 | | }; |
610 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
611 | | static_assert(0 < 1, "There is no slot for us"); |
612 | | |
613 | | MOZ_CAN_RUN_SCRIPT static bool |
614 | | get_onsoundstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
615 | 0 | { |
616 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.onsoundstart", DOM, cx); |
617 | 0 |
|
618 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnsoundstart()); |
619 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
620 | 0 | if (result) { |
621 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
622 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
623 | 0 | return false; |
624 | 0 | } |
625 | 0 | return true; |
626 | 0 | } else { |
627 | 0 | args.rval().setNull(); |
628 | 0 | return true; |
629 | 0 | } |
630 | 0 | } |
631 | | |
632 | | MOZ_CAN_RUN_SCRIPT static bool |
633 | | set_onsoundstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
634 | 0 | { |
635 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.onsoundstart", DOM, cx); |
636 | 0 |
|
637 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
638 | 0 | if (args[0].isObject()) { |
639 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
640 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
641 | 0 | } |
642 | 0 | } else { |
643 | 0 | arg0 = nullptr; |
644 | 0 | } |
645 | 0 | self->SetOnsoundstart(Constify(arg0)); |
646 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
647 | 0 |
|
648 | 0 | return true; |
649 | 0 | } |
650 | | |
651 | | static const JSJitInfo onsoundstart_getterinfo = { |
652 | | { (JSJitGetterOp)get_onsoundstart }, |
653 | | { prototypes::id::SpeechRecognition }, |
654 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
655 | | JSJitInfo::Getter, |
656 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
657 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
658 | | false, /* isInfallible. False in setters. */ |
659 | | false, /* isMovable. Not relevant for setters. */ |
660 | | false, /* isEliminatable. Not relevant for setters. */ |
661 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
662 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
663 | | false, /* isTypedMethod. Only relevant for methods. */ |
664 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
665 | | }; |
666 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
667 | | static_assert(0 < 1, "There is no slot for us"); |
668 | | static const JSJitInfo onsoundstart_setterinfo = { |
669 | | { (JSJitGetterOp)set_onsoundstart }, |
670 | | { prototypes::id::SpeechRecognition }, |
671 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
672 | | JSJitInfo::Setter, |
673 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
674 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
675 | | false, /* isInfallible. False in setters. */ |
676 | | false, /* isMovable. Not relevant for setters. */ |
677 | | false, /* isEliminatable. Not relevant for setters. */ |
678 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
679 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
680 | | false, /* isTypedMethod. Only relevant for methods. */ |
681 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
682 | | }; |
683 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
684 | | static_assert(0 < 1, "There is no slot for us"); |
685 | | |
686 | | MOZ_CAN_RUN_SCRIPT static bool |
687 | | get_onspeechstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
688 | 0 | { |
689 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.onspeechstart", DOM, cx); |
690 | 0 |
|
691 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnspeechstart()); |
692 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
693 | 0 | if (result) { |
694 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
695 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
696 | 0 | return false; |
697 | 0 | } |
698 | 0 | return true; |
699 | 0 | } else { |
700 | 0 | args.rval().setNull(); |
701 | 0 | return true; |
702 | 0 | } |
703 | 0 | } |
704 | | |
705 | | MOZ_CAN_RUN_SCRIPT static bool |
706 | | set_onspeechstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
707 | 0 | { |
708 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.onspeechstart", DOM, cx); |
709 | 0 |
|
710 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
711 | 0 | if (args[0].isObject()) { |
712 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
713 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
714 | 0 | } |
715 | 0 | } else { |
716 | 0 | arg0 = nullptr; |
717 | 0 | } |
718 | 0 | self->SetOnspeechstart(Constify(arg0)); |
719 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
720 | 0 |
|
721 | 0 | return true; |
722 | 0 | } |
723 | | |
724 | | static const JSJitInfo onspeechstart_getterinfo = { |
725 | | { (JSJitGetterOp)get_onspeechstart }, |
726 | | { prototypes::id::SpeechRecognition }, |
727 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
728 | | JSJitInfo::Getter, |
729 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
730 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
731 | | false, /* isInfallible. False in setters. */ |
732 | | false, /* isMovable. Not relevant for setters. */ |
733 | | false, /* isEliminatable. Not relevant for setters. */ |
734 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
735 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
736 | | false, /* isTypedMethod. Only relevant for methods. */ |
737 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
738 | | }; |
739 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
740 | | static_assert(0 < 1, "There is no slot for us"); |
741 | | static const JSJitInfo onspeechstart_setterinfo = { |
742 | | { (JSJitGetterOp)set_onspeechstart }, |
743 | | { prototypes::id::SpeechRecognition }, |
744 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
745 | | JSJitInfo::Setter, |
746 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
747 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
748 | | false, /* isInfallible. False in setters. */ |
749 | | false, /* isMovable. Not relevant for setters. */ |
750 | | false, /* isEliminatable. Not relevant for setters. */ |
751 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
752 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
753 | | false, /* isTypedMethod. Only relevant for methods. */ |
754 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
755 | | }; |
756 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
757 | | static_assert(0 < 1, "There is no slot for us"); |
758 | | |
759 | | MOZ_CAN_RUN_SCRIPT static bool |
760 | | get_onspeechend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
761 | 0 | { |
762 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.onspeechend", DOM, cx); |
763 | 0 |
|
764 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnspeechend()); |
765 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
766 | 0 | if (result) { |
767 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
768 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
769 | 0 | return false; |
770 | 0 | } |
771 | 0 | return true; |
772 | 0 | } else { |
773 | 0 | args.rval().setNull(); |
774 | 0 | return true; |
775 | 0 | } |
776 | 0 | } |
777 | | |
778 | | MOZ_CAN_RUN_SCRIPT static bool |
779 | | set_onspeechend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
780 | 0 | { |
781 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.onspeechend", DOM, cx); |
782 | 0 |
|
783 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
784 | 0 | if (args[0].isObject()) { |
785 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
786 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
787 | 0 | } |
788 | 0 | } else { |
789 | 0 | arg0 = nullptr; |
790 | 0 | } |
791 | 0 | self->SetOnspeechend(Constify(arg0)); |
792 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
793 | 0 |
|
794 | 0 | return true; |
795 | 0 | } |
796 | | |
797 | | static const JSJitInfo onspeechend_getterinfo = { |
798 | | { (JSJitGetterOp)get_onspeechend }, |
799 | | { prototypes::id::SpeechRecognition }, |
800 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
801 | | JSJitInfo::Getter, |
802 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
803 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
804 | | false, /* isInfallible. False in setters. */ |
805 | | false, /* isMovable. Not relevant for setters. */ |
806 | | false, /* isEliminatable. Not relevant for setters. */ |
807 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
808 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
809 | | false, /* isTypedMethod. Only relevant for methods. */ |
810 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
811 | | }; |
812 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
813 | | static_assert(0 < 1, "There is no slot for us"); |
814 | | static const JSJitInfo onspeechend_setterinfo = { |
815 | | { (JSJitGetterOp)set_onspeechend }, |
816 | | { prototypes::id::SpeechRecognition }, |
817 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
818 | | JSJitInfo::Setter, |
819 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
820 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
821 | | false, /* isInfallible. False in setters. */ |
822 | | false, /* isMovable. Not relevant for setters. */ |
823 | | false, /* isEliminatable. Not relevant for setters. */ |
824 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
825 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
826 | | false, /* isTypedMethod. Only relevant for methods. */ |
827 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
828 | | }; |
829 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
830 | | static_assert(0 < 1, "There is no slot for us"); |
831 | | |
832 | | MOZ_CAN_RUN_SCRIPT static bool |
833 | | get_onsoundend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
834 | 0 | { |
835 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.onsoundend", DOM, cx); |
836 | 0 |
|
837 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnsoundend()); |
838 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
839 | 0 | if (result) { |
840 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
841 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
842 | 0 | return false; |
843 | 0 | } |
844 | 0 | return true; |
845 | 0 | } else { |
846 | 0 | args.rval().setNull(); |
847 | 0 | return true; |
848 | 0 | } |
849 | 0 | } |
850 | | |
851 | | MOZ_CAN_RUN_SCRIPT static bool |
852 | | set_onsoundend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
853 | 0 | { |
854 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.onsoundend", DOM, cx); |
855 | 0 |
|
856 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
857 | 0 | if (args[0].isObject()) { |
858 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
859 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
860 | 0 | } |
861 | 0 | } else { |
862 | 0 | arg0 = nullptr; |
863 | 0 | } |
864 | 0 | self->SetOnsoundend(Constify(arg0)); |
865 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
866 | 0 |
|
867 | 0 | return true; |
868 | 0 | } |
869 | | |
870 | | static const JSJitInfo onsoundend_getterinfo = { |
871 | | { (JSJitGetterOp)get_onsoundend }, |
872 | | { prototypes::id::SpeechRecognition }, |
873 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
874 | | JSJitInfo::Getter, |
875 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
876 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
877 | | false, /* isInfallible. False in setters. */ |
878 | | false, /* isMovable. Not relevant for setters. */ |
879 | | false, /* isEliminatable. Not relevant for setters. */ |
880 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
881 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
882 | | false, /* isTypedMethod. Only relevant for methods. */ |
883 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
884 | | }; |
885 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
886 | | static_assert(0 < 1, "There is no slot for us"); |
887 | | static const JSJitInfo onsoundend_setterinfo = { |
888 | | { (JSJitGetterOp)set_onsoundend }, |
889 | | { prototypes::id::SpeechRecognition }, |
890 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
891 | | JSJitInfo::Setter, |
892 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
893 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
894 | | false, /* isInfallible. False in setters. */ |
895 | | false, /* isMovable. Not relevant for setters. */ |
896 | | false, /* isEliminatable. Not relevant for setters. */ |
897 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
898 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
899 | | false, /* isTypedMethod. Only relevant for methods. */ |
900 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
901 | | }; |
902 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
903 | | static_assert(0 < 1, "There is no slot for us"); |
904 | | |
905 | | MOZ_CAN_RUN_SCRIPT static bool |
906 | | get_onaudioend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
907 | 0 | { |
908 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.onaudioend", DOM, cx); |
909 | 0 |
|
910 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnaudioend()); |
911 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
912 | 0 | if (result) { |
913 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
914 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
915 | 0 | return false; |
916 | 0 | } |
917 | 0 | return true; |
918 | 0 | } else { |
919 | 0 | args.rval().setNull(); |
920 | 0 | return true; |
921 | 0 | } |
922 | 0 | } |
923 | | |
924 | | MOZ_CAN_RUN_SCRIPT static bool |
925 | | set_onaudioend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
926 | 0 | { |
927 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.onaudioend", DOM, cx); |
928 | 0 |
|
929 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
930 | 0 | if (args[0].isObject()) { |
931 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
932 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
933 | 0 | } |
934 | 0 | } else { |
935 | 0 | arg0 = nullptr; |
936 | 0 | } |
937 | 0 | self->SetOnaudioend(Constify(arg0)); |
938 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
939 | 0 |
|
940 | 0 | return true; |
941 | 0 | } |
942 | | |
943 | | static const JSJitInfo onaudioend_getterinfo = { |
944 | | { (JSJitGetterOp)get_onaudioend }, |
945 | | { prototypes::id::SpeechRecognition }, |
946 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
947 | | JSJitInfo::Getter, |
948 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
949 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
950 | | false, /* isInfallible. False in setters. */ |
951 | | false, /* isMovable. Not relevant for setters. */ |
952 | | false, /* isEliminatable. Not relevant for setters. */ |
953 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
954 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
955 | | false, /* isTypedMethod. Only relevant for methods. */ |
956 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
957 | | }; |
958 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
959 | | static_assert(0 < 1, "There is no slot for us"); |
960 | | static const JSJitInfo onaudioend_setterinfo = { |
961 | | { (JSJitGetterOp)set_onaudioend }, |
962 | | { prototypes::id::SpeechRecognition }, |
963 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
964 | | JSJitInfo::Setter, |
965 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
966 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
967 | | false, /* isInfallible. False in setters. */ |
968 | | false, /* isMovable. Not relevant for setters. */ |
969 | | false, /* isEliminatable. Not relevant for setters. */ |
970 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
971 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
972 | | false, /* isTypedMethod. Only relevant for methods. */ |
973 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
974 | | }; |
975 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
976 | | static_assert(0 < 1, "There is no slot for us"); |
977 | | |
978 | | MOZ_CAN_RUN_SCRIPT static bool |
979 | | get_onresult(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
980 | 0 | { |
981 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.onresult", DOM, cx); |
982 | 0 |
|
983 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnresult()); |
984 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
985 | 0 | if (result) { |
986 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
987 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
988 | 0 | return false; |
989 | 0 | } |
990 | 0 | return true; |
991 | 0 | } else { |
992 | 0 | args.rval().setNull(); |
993 | 0 | return true; |
994 | 0 | } |
995 | 0 | } |
996 | | |
997 | | MOZ_CAN_RUN_SCRIPT static bool |
998 | | set_onresult(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
999 | 0 | { |
1000 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.onresult", DOM, cx); |
1001 | 0 |
|
1002 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
1003 | 0 | if (args[0].isObject()) { |
1004 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
1005 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
1006 | 0 | } |
1007 | 0 | } else { |
1008 | 0 | arg0 = nullptr; |
1009 | 0 | } |
1010 | 0 | self->SetOnresult(Constify(arg0)); |
1011 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1012 | 0 |
|
1013 | 0 | return true; |
1014 | 0 | } |
1015 | | |
1016 | | static const JSJitInfo onresult_getterinfo = { |
1017 | | { (JSJitGetterOp)get_onresult }, |
1018 | | { prototypes::id::SpeechRecognition }, |
1019 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
1020 | | JSJitInfo::Getter, |
1021 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1022 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1023 | | false, /* isInfallible. False in setters. */ |
1024 | | false, /* isMovable. Not relevant for setters. */ |
1025 | | false, /* isEliminatable. Not relevant for setters. */ |
1026 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1027 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1028 | | false, /* isTypedMethod. Only relevant for methods. */ |
1029 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1030 | | }; |
1031 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1032 | | static_assert(0 < 1, "There is no slot for us"); |
1033 | | static const JSJitInfo onresult_setterinfo = { |
1034 | | { (JSJitGetterOp)set_onresult }, |
1035 | | { prototypes::id::SpeechRecognition }, |
1036 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
1037 | | JSJitInfo::Setter, |
1038 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1039 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1040 | | false, /* isInfallible. False in setters. */ |
1041 | | false, /* isMovable. Not relevant for setters. */ |
1042 | | false, /* isEliminatable. Not relevant for setters. */ |
1043 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1044 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1045 | | false, /* isTypedMethod. Only relevant for methods. */ |
1046 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1047 | | }; |
1048 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1049 | | static_assert(0 < 1, "There is no slot for us"); |
1050 | | |
1051 | | MOZ_CAN_RUN_SCRIPT static bool |
1052 | | get_onnomatch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
1053 | 0 | { |
1054 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.onnomatch", DOM, cx); |
1055 | 0 |
|
1056 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnnomatch()); |
1057 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1058 | 0 | if (result) { |
1059 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
1060 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
1061 | 0 | return false; |
1062 | 0 | } |
1063 | 0 | return true; |
1064 | 0 | } else { |
1065 | 0 | args.rval().setNull(); |
1066 | 0 | return true; |
1067 | 0 | } |
1068 | 0 | } |
1069 | | |
1070 | | MOZ_CAN_RUN_SCRIPT static bool |
1071 | | set_onnomatch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
1072 | 0 | { |
1073 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.onnomatch", DOM, cx); |
1074 | 0 |
|
1075 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
1076 | 0 | if (args[0].isObject()) { |
1077 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
1078 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
1079 | 0 | } |
1080 | 0 | } else { |
1081 | 0 | arg0 = nullptr; |
1082 | 0 | } |
1083 | 0 | self->SetOnnomatch(Constify(arg0)); |
1084 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1085 | 0 |
|
1086 | 0 | return true; |
1087 | 0 | } |
1088 | | |
1089 | | static const JSJitInfo onnomatch_getterinfo = { |
1090 | | { (JSJitGetterOp)get_onnomatch }, |
1091 | | { prototypes::id::SpeechRecognition }, |
1092 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
1093 | | JSJitInfo::Getter, |
1094 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1095 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1096 | | false, /* isInfallible. False in setters. */ |
1097 | | false, /* isMovable. Not relevant for setters. */ |
1098 | | false, /* isEliminatable. Not relevant for setters. */ |
1099 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1100 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1101 | | false, /* isTypedMethod. Only relevant for methods. */ |
1102 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1103 | | }; |
1104 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1105 | | static_assert(0 < 1, "There is no slot for us"); |
1106 | | static const JSJitInfo onnomatch_setterinfo = { |
1107 | | { (JSJitGetterOp)set_onnomatch }, |
1108 | | { prototypes::id::SpeechRecognition }, |
1109 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
1110 | | JSJitInfo::Setter, |
1111 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1112 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1113 | | false, /* isInfallible. False in setters. */ |
1114 | | false, /* isMovable. Not relevant for setters. */ |
1115 | | false, /* isEliminatable. Not relevant for setters. */ |
1116 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1117 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1118 | | false, /* isTypedMethod. Only relevant for methods. */ |
1119 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1120 | | }; |
1121 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1122 | | static_assert(0 < 1, "There is no slot for us"); |
1123 | | |
1124 | | MOZ_CAN_RUN_SCRIPT static bool |
1125 | | get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
1126 | 0 | { |
1127 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.onerror", DOM, cx); |
1128 | 0 |
|
1129 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnerror()); |
1130 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1131 | 0 | if (result) { |
1132 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
1133 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
1134 | 0 | return false; |
1135 | 0 | } |
1136 | 0 | return true; |
1137 | 0 | } else { |
1138 | 0 | args.rval().setNull(); |
1139 | 0 | return true; |
1140 | 0 | } |
1141 | 0 | } |
1142 | | |
1143 | | MOZ_CAN_RUN_SCRIPT static bool |
1144 | | set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
1145 | 0 | { |
1146 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.onerror", DOM, cx); |
1147 | 0 |
|
1148 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
1149 | 0 | if (args[0].isObject()) { |
1150 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
1151 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
1152 | 0 | } |
1153 | 0 | } else { |
1154 | 0 | arg0 = nullptr; |
1155 | 0 | } |
1156 | 0 | self->SetOnerror(Constify(arg0)); |
1157 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1158 | 0 |
|
1159 | 0 | return true; |
1160 | 0 | } |
1161 | | |
1162 | | static const JSJitInfo onerror_getterinfo = { |
1163 | | { (JSJitGetterOp)get_onerror }, |
1164 | | { prototypes::id::SpeechRecognition }, |
1165 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
1166 | | JSJitInfo::Getter, |
1167 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1168 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1169 | | false, /* isInfallible. False in setters. */ |
1170 | | false, /* isMovable. Not relevant for setters. */ |
1171 | | false, /* isEliminatable. Not relevant for setters. */ |
1172 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1173 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1174 | | false, /* isTypedMethod. Only relevant for methods. */ |
1175 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1176 | | }; |
1177 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1178 | | static_assert(0 < 1, "There is no slot for us"); |
1179 | | static const JSJitInfo onerror_setterinfo = { |
1180 | | { (JSJitGetterOp)set_onerror }, |
1181 | | { prototypes::id::SpeechRecognition }, |
1182 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
1183 | | JSJitInfo::Setter, |
1184 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1185 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1186 | | false, /* isInfallible. False in setters. */ |
1187 | | false, /* isMovable. Not relevant for setters. */ |
1188 | | false, /* isEliminatable. Not relevant for setters. */ |
1189 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1190 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1191 | | false, /* isTypedMethod. Only relevant for methods. */ |
1192 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1193 | | }; |
1194 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1195 | | static_assert(0 < 1, "There is no slot for us"); |
1196 | | |
1197 | | MOZ_CAN_RUN_SCRIPT static bool |
1198 | | get_onstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
1199 | 0 | { |
1200 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.onstart", DOM, cx); |
1201 | 0 |
|
1202 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnstart()); |
1203 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1204 | 0 | if (result) { |
1205 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
1206 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
1207 | 0 | return false; |
1208 | 0 | } |
1209 | 0 | return true; |
1210 | 0 | } else { |
1211 | 0 | args.rval().setNull(); |
1212 | 0 | return true; |
1213 | 0 | } |
1214 | 0 | } |
1215 | | |
1216 | | MOZ_CAN_RUN_SCRIPT static bool |
1217 | | set_onstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
1218 | 0 | { |
1219 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.onstart", DOM, cx); |
1220 | 0 |
|
1221 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
1222 | 0 | if (args[0].isObject()) { |
1223 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
1224 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
1225 | 0 | } |
1226 | 0 | } else { |
1227 | 0 | arg0 = nullptr; |
1228 | 0 | } |
1229 | 0 | self->SetOnstart(Constify(arg0)); |
1230 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1231 | 0 |
|
1232 | 0 | return true; |
1233 | 0 | } |
1234 | | |
1235 | | static const JSJitInfo onstart_getterinfo = { |
1236 | | { (JSJitGetterOp)get_onstart }, |
1237 | | { prototypes::id::SpeechRecognition }, |
1238 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
1239 | | JSJitInfo::Getter, |
1240 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1241 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1242 | | false, /* isInfallible. False in setters. */ |
1243 | | false, /* isMovable. Not relevant for setters. */ |
1244 | | false, /* isEliminatable. Not relevant for setters. */ |
1245 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1246 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1247 | | false, /* isTypedMethod. Only relevant for methods. */ |
1248 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1249 | | }; |
1250 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1251 | | static_assert(0 < 1, "There is no slot for us"); |
1252 | | static const JSJitInfo onstart_setterinfo = { |
1253 | | { (JSJitGetterOp)set_onstart }, |
1254 | | { prototypes::id::SpeechRecognition }, |
1255 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
1256 | | JSJitInfo::Setter, |
1257 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1258 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1259 | | false, /* isInfallible. False in setters. */ |
1260 | | false, /* isMovable. Not relevant for setters. */ |
1261 | | false, /* isEliminatable. Not relevant for setters. */ |
1262 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1263 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1264 | | false, /* isTypedMethod. Only relevant for methods. */ |
1265 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1266 | | }; |
1267 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1268 | | static_assert(0 < 1, "There is no slot for us"); |
1269 | | |
1270 | | MOZ_CAN_RUN_SCRIPT static bool |
1271 | | get_onend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitGetterCallArgs args) |
1272 | 0 | { |
1273 | 0 | AUTO_PROFILER_LABEL_FAST("get SpeechRecognition.onend", DOM, cx); |
1274 | 0 |
|
1275 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnend()); |
1276 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1277 | 0 | if (result) { |
1278 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
1279 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
1280 | 0 | return false; |
1281 | 0 | } |
1282 | 0 | return true; |
1283 | 0 | } else { |
1284 | 0 | args.rval().setNull(); |
1285 | 0 | return true; |
1286 | 0 | } |
1287 | 0 | } |
1288 | | |
1289 | | MOZ_CAN_RUN_SCRIPT static bool |
1290 | | set_onend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SpeechRecognition* self, JSJitSetterCallArgs args) |
1291 | 0 | { |
1292 | 0 | AUTO_PROFILER_LABEL_FAST("set SpeechRecognition.onend", DOM, cx); |
1293 | 0 |
|
1294 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
1295 | 0 | if (args[0].isObject()) { |
1296 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
1297 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
1298 | 0 | } |
1299 | 0 | } else { |
1300 | 0 | arg0 = nullptr; |
1301 | 0 | } |
1302 | 0 | self->SetOnend(Constify(arg0)); |
1303 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1304 | 0 |
|
1305 | 0 | return true; |
1306 | 0 | } |
1307 | | |
1308 | | static const JSJitInfo onend_getterinfo = { |
1309 | | { (JSJitGetterOp)get_onend }, |
1310 | | { prototypes::id::SpeechRecognition }, |
1311 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
1312 | | JSJitInfo::Getter, |
1313 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1314 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1315 | | false, /* isInfallible. False in setters. */ |
1316 | | false, /* isMovable. Not relevant for setters. */ |
1317 | | false, /* isEliminatable. Not relevant for setters. */ |
1318 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1319 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1320 | | false, /* isTypedMethod. Only relevant for methods. */ |
1321 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1322 | | }; |
1323 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1324 | | static_assert(0 < 1, "There is no slot for us"); |
1325 | | static const JSJitInfo onend_setterinfo = { |
1326 | | { (JSJitGetterOp)set_onend }, |
1327 | | { prototypes::id::SpeechRecognition }, |
1328 | | { PrototypeTraits<prototypes::id::SpeechRecognition>::Depth }, |
1329 | | JSJitInfo::Setter, |
1330 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1331 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1332 | | false, /* isInfallible. False in setters. */ |
1333 | | false, /* isMovable. Not relevant for setters. */ |
1334 | | false, /* isEliminatable. Not relevant for setters. */ |
1335 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1336 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1337 | | false, /* isTypedMethod. Only relevant for methods. */ |
1338 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1339 | | }; |
1340 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1341 | | static_assert(0 < 1, "There is no slot for us"); |
1342 | | |
1343 | | static bool |
1344 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
1345 | 0 | { |
1346 | 0 | mozilla::dom::SpeechRecognition* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechRecognition>(obj); |
1347 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
1348 | 0 | // obviously can't preserve if we're not initialized. |
1349 | 0 | if (self && self->GetWrapperPreserveColor()) { |
1350 | 0 | PreserveWrapper(self); |
1351 | 0 | } |
1352 | 0 | return true; |
1353 | 0 | } |
1354 | | |
1355 | | static void |
1356 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1357 | 0 | { |
1358 | 0 | mozilla::dom::SpeechRecognition* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechRecognition>(obj); |
1359 | 0 | if (self) { |
1360 | 0 | ClearWrapper(self, self, obj); |
1361 | 0 | AddForDeferredFinalization<mozilla::dom::SpeechRecognition>(self); |
1362 | 0 | } |
1363 | 0 | } |
1364 | | |
1365 | | static size_t |
1366 | | _objectMoved(JSObject* obj, JSObject* old) |
1367 | 0 | { |
1368 | 0 | mozilla::dom::SpeechRecognition* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SpeechRecognition>(obj); |
1369 | 0 | if (self) { |
1370 | 0 | UpdateWrapper(self, self, obj, old); |
1371 | 0 | } |
1372 | 0 |
|
1373 | 0 | return 0; |
1374 | 0 | } |
1375 | | |
1376 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1377 | | #if defined(__clang__) |
1378 | | #pragma clang diagnostic push |
1379 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1380 | | #endif |
1381 | | static const JSFunctionSpec sMethods_specs[] = { |
1382 | | JS_FNSPEC("start", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&start_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1383 | | JS_FNSPEC("stop", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&stop_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1384 | | JS_FNSPEC("abort", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&abort_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1385 | | JS_FS_END |
1386 | | }; |
1387 | | #if defined(__clang__) |
1388 | | #pragma clang diagnostic pop |
1389 | | #endif |
1390 | | |
1391 | | |
1392 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
1393 | | { nullptr, &sMethods_specs[0] }, |
1394 | | { nullptr, nullptr } |
1395 | | }; |
1396 | | |
1397 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1398 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1399 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1400 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1401 | | |
1402 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1403 | | #if defined(__clang__) |
1404 | | #pragma clang diagnostic push |
1405 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1406 | | #endif |
1407 | | static const JSPropertySpec sAttributes_specs[] = { |
1408 | | { "grammars", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &grammars_getterinfo, GenericSetter<NormalThisPolicy>, &grammars_setterinfo }, |
1409 | | { "lang", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lang_getterinfo, GenericSetter<NormalThisPolicy>, &lang_setterinfo }, |
1410 | | { "continuous", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &continuous_getterinfo, GenericSetter<NormalThisPolicy>, &continuous_setterinfo }, |
1411 | | { "interimResults", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &interimResults_getterinfo, GenericSetter<NormalThisPolicy>, &interimResults_setterinfo }, |
1412 | | { "maxAlternatives", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &maxAlternatives_getterinfo, GenericSetter<NormalThisPolicy>, &maxAlternatives_setterinfo }, |
1413 | | { "serviceURI", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &serviceURI_getterinfo, GenericSetter<NormalThisPolicy>, &serviceURI_setterinfo }, |
1414 | | { "onaudiostart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onaudiostart_getterinfo, GenericSetter<NormalThisPolicy>, &onaudiostart_setterinfo }, |
1415 | | { "onsoundstart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onsoundstart_getterinfo, GenericSetter<NormalThisPolicy>, &onsoundstart_setterinfo }, |
1416 | | { "onspeechstart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onspeechstart_getterinfo, GenericSetter<NormalThisPolicy>, &onspeechstart_setterinfo }, |
1417 | | { "onspeechend", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onspeechend_getterinfo, GenericSetter<NormalThisPolicy>, &onspeechend_setterinfo }, |
1418 | | { "onsoundend", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onsoundend_getterinfo, GenericSetter<NormalThisPolicy>, &onsoundend_setterinfo }, |
1419 | | { "onaudioend", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onaudioend_getterinfo, GenericSetter<NormalThisPolicy>, &onaudioend_setterinfo }, |
1420 | | { "onresult", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onresult_getterinfo, GenericSetter<NormalThisPolicy>, &onresult_setterinfo }, |
1421 | | { "onnomatch", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onnomatch_getterinfo, GenericSetter<NormalThisPolicy>, &onnomatch_setterinfo }, |
1422 | | { "onerror", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onerror_getterinfo, GenericSetter<NormalThisPolicy>, &onerror_setterinfo }, |
1423 | | { "onstart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onstart_getterinfo, GenericSetter<NormalThisPolicy>, &onstart_setterinfo }, |
1424 | | { "onend", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onend_getterinfo, GenericSetter<NormalThisPolicy>, &onend_setterinfo }, |
1425 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1426 | | }; |
1427 | | #if defined(__clang__) |
1428 | | #pragma clang diagnostic pop |
1429 | | #endif |
1430 | | |
1431 | | |
1432 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
1433 | | { nullptr, &sAttributes_specs[0] }, |
1434 | | { nullptr, nullptr } |
1435 | | }; |
1436 | | |
1437 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1438 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1439 | | static_assert(17 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1440 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1441 | | |
1442 | | |
1443 | | static uint16_t sNativeProperties_sortedPropertyIndices[20]; |
1444 | | static PropertyInfo sNativeProperties_propertyInfos[20]; |
1445 | | |
1446 | | static const NativePropertiesN<2> sNativeProperties = { |
1447 | | false, 0, |
1448 | | false, 0, |
1449 | | true, 0 /* sMethods */, |
1450 | | true, 1 /* sAttributes */, |
1451 | | false, 0, |
1452 | | false, 0, |
1453 | | false, 0, |
1454 | | -1, |
1455 | | 20, |
1456 | | sNativeProperties_sortedPropertyIndices, |
1457 | | { |
1458 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
1459 | | { sAttributes, &sNativeProperties_propertyInfos[3] } |
1460 | | } |
1461 | | }; |
1462 | | static_assert(20 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1463 | | "We have a property info count that is oversized"); |
1464 | | |
1465 | | static bool |
1466 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
1467 | 0 | { |
1468 | 0 | AUTO_PROFILER_LABEL_FAST("SpeechRecognition constructor", DOM, cx); |
1469 | 0 |
|
1470 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
1471 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
1472 | 0 | if (!args.isConstructing()) { |
1473 | 0 | // XXXbz wish I could get the name from the callee instead of |
1474 | 0 | // Adding more relocations |
1475 | 0 | return ThrowConstructorWithoutNew(cx, "SpeechRecognition"); |
1476 | 0 | } |
1477 | 0 | |
1478 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
1479 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
1480 | 0 | return false; |
1481 | 0 | } |
1482 | 0 | |
1483 | 0 | GlobalObject global(cx, obj); |
1484 | 0 | if (global.Failed()) { |
1485 | 0 | return false; |
1486 | 0 | } |
1487 | 0 | |
1488 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1489 | 0 | Maybe<JSAutoRealm> ar; |
1490 | 0 | if (objIsXray) { |
1491 | 0 | obj = js::CheckedUnwrap(obj); |
1492 | 0 | if (!obj) { |
1493 | 0 | return false; |
1494 | 0 | } |
1495 | 0 | ar.emplace(cx, obj); |
1496 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
1497 | 0 | return false; |
1498 | 0 | } |
1499 | 0 | } |
1500 | 0 | FastErrorResult rv; |
1501 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SpeechRecognition>(mozilla::dom::SpeechRecognition::Constructor(global, rv))); |
1502 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1503 | 0 | return false; |
1504 | 0 | } |
1505 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1506 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
1507 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
1508 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
1509 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1510 | 0 | return false; |
1511 | 0 | } |
1512 | 0 | return true; |
1513 | 0 | } |
1514 | | |
1515 | | static const js::ClassOps sInterfaceObjectClassOps = { |
1516 | | nullptr, /* addProperty */ |
1517 | | nullptr, /* delProperty */ |
1518 | | nullptr, /* enumerate */ |
1519 | | nullptr, /* newEnumerate */ |
1520 | | nullptr, /* resolve */ |
1521 | | nullptr, /* mayResolve */ |
1522 | | nullptr, /* finalize */ |
1523 | | _constructor, /* call */ |
1524 | | nullptr, /* hasInstance */ |
1525 | | _constructor, /* construct */ |
1526 | | nullptr, /* trace */ |
1527 | | }; |
1528 | | |
1529 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
1530 | | { |
1531 | | "Function", |
1532 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
1533 | | &sInterfaceObjectClassOps, |
1534 | | JS_NULL_CLASS_SPEC, |
1535 | | JS_NULL_CLASS_EXT, |
1536 | | &sInterfaceObjectClassObjectOps |
1537 | | }, |
1538 | | eInterface, |
1539 | | true, |
1540 | | prototypes::id::SpeechRecognition, |
1541 | | PrototypeTraits<prototypes::id::SpeechRecognition>::Depth, |
1542 | | sNativePropertyHooks, |
1543 | | "function SpeechRecognition() {\n [native code]\n}", |
1544 | | EventTarget_Binding::GetConstructorObject |
1545 | | }; |
1546 | | |
1547 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1548 | | { |
1549 | | "SpeechRecognitionPrototype", |
1550 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1551 | | JS_NULL_CLASS_OPS, |
1552 | | JS_NULL_CLASS_SPEC, |
1553 | | JS_NULL_CLASS_EXT, |
1554 | | JS_NULL_OBJECT_OPS |
1555 | | }, |
1556 | | eInterfacePrototype, |
1557 | | false, |
1558 | | prototypes::id::SpeechRecognition, |
1559 | | PrototypeTraits<prototypes::id::SpeechRecognition>::Depth, |
1560 | | sNativePropertyHooks, |
1561 | | "[object SpeechRecognitionPrototype]", |
1562 | | EventTarget_Binding::GetProtoObject |
1563 | | }; |
1564 | | |
1565 | | bool |
1566 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
1567 | 0 | { |
1568 | 0 | static bool sPrefValue; |
1569 | 0 | static bool sPrefCacheSetUp = false; |
1570 | 0 | if (!sPrefCacheSetUp) { |
1571 | 0 | sPrefCacheSetUp = true; |
1572 | 0 | Preferences::AddBoolVarCache(&sPrefValue, "media.webspeech.recognition.enable"); |
1573 | 0 | } |
1574 | 0 |
|
1575 | 0 | return sPrefValue && |
1576 | 0 | SpeechRecognition::IsAuthorized(aCx, aObj); |
1577 | 0 | } |
1578 | | |
1579 | | static const js::ClassOps sClassOps = { |
1580 | | _addProperty, /* addProperty */ |
1581 | | nullptr, /* delProperty */ |
1582 | | nullptr, /* enumerate */ |
1583 | | nullptr, /* newEnumerate */ |
1584 | | nullptr, /* resolve */ |
1585 | | nullptr, /* mayResolve */ |
1586 | | _finalize, /* finalize */ |
1587 | | nullptr, /* call */ |
1588 | | nullptr, /* hasInstance */ |
1589 | | nullptr, /* construct */ |
1590 | | nullptr, /* trace */ |
1591 | | }; |
1592 | | |
1593 | | static const js::ClassExtension sClassExtension = { |
1594 | | nullptr, /* weakmapKeyDelegateOp */ |
1595 | | _objectMoved /* objectMovedOp */ |
1596 | | }; |
1597 | | |
1598 | | static const DOMJSClass sClass = { |
1599 | | { "SpeechRecognition", |
1600 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1601 | | &sClassOps, |
1602 | | JS_NULL_CLASS_SPEC, |
1603 | | &sClassExtension, |
1604 | | JS_NULL_OBJECT_OPS |
1605 | | }, |
1606 | | { prototypes::id::EventTarget, prototypes::id::SpeechRecognition, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
1607 | | IsBaseOf<nsISupports, mozilla::dom::SpeechRecognition >::value, |
1608 | | sNativePropertyHooks, |
1609 | | FindAssociatedGlobalForNative<mozilla::dom::SpeechRecognition>::Get, |
1610 | | GetProtoObjectHandle, |
1611 | | GetCCParticipant<mozilla::dom::SpeechRecognition>::Get() |
1612 | | }; |
1613 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1614 | | "Must have the right minimal number of reserved slots."); |
1615 | | static_assert(1 >= 1, |
1616 | | "Must have enough reserved slots."); |
1617 | | |
1618 | | const JSClass* |
1619 | | GetJSClass() |
1620 | 0 | { |
1621 | 0 | return sClass.ToJSClass(); |
1622 | 0 | } |
1623 | | |
1624 | | bool |
1625 | | Wrap(JSContext* aCx, mozilla::dom::SpeechRecognition* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1626 | 0 | { |
1627 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SpeechRecognition>::value, |
1628 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1629 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::SpeechRecognition*>(aObject) == |
1630 | 0 | reinterpret_cast<mozilla::dom::SpeechRecognition*>(aObject), |
1631 | 0 | "Multiple inheritance for mozilla::dom::SpeechRecognition is broken."); |
1632 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
1633 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
1634 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
1635 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1636 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1637 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1638 | 0 | "You should probably not be using Wrap() directly; use " |
1639 | 0 | "GetOrCreateDOMReflector instead"); |
1640 | 0 |
|
1641 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1642 | 0 | "nsISupports must be on our primary inheritance chain"); |
1643 | 0 |
|
1644 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1645 | 0 | if (!global) { |
1646 | 0 | return false; |
1647 | 0 | } |
1648 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1649 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1650 | 0 |
|
1651 | 0 | // That might have ended up wrapping us already, due to the wonders |
1652 | 0 | // of XBL. Check for that, and bail out as needed. |
1653 | 0 | aReflector.set(aCache->GetWrapper()); |
1654 | 0 | if (aReflector) { |
1655 | | #ifdef DEBUG |
1656 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1657 | | #endif // DEBUG |
1658 | | return true; |
1659 | 0 | } |
1660 | 0 |
|
1661 | 0 | JSAutoRealm ar(aCx, global); |
1662 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1663 | 0 | if (!canonicalProto) { |
1664 | 0 | return false; |
1665 | 0 | } |
1666 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1667 | 0 | if (aGivenProto) { |
1668 | 0 | proto = aGivenProto; |
1669 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1670 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1671 | 0 | // to wrap the proto here. |
1672 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1673 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1674 | 0 | return false; |
1675 | 0 | } |
1676 | 0 | } |
1677 | 0 | } else { |
1678 | 0 | proto = canonicalProto; |
1679 | 0 | } |
1680 | 0 |
|
1681 | 0 | BindingJSObjectCreator<mozilla::dom::SpeechRecognition> creator(aCx); |
1682 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1683 | 0 | if (!aReflector) { |
1684 | 0 | return false; |
1685 | 0 | } |
1686 | 0 | |
1687 | 0 | aCache->SetWrapper(aReflector); |
1688 | 0 | creator.InitializationSucceeded(); |
1689 | 0 |
|
1690 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1691 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1692 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1693 | 0 | // otherwise we won't be able to properly recreate it later, since |
1694 | 0 | // we won't know what proto to use. Note that we don't check |
1695 | 0 | // aGivenProto here, since it's entirely possible (and even |
1696 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1697 | 0 | // same as canonicalProto. |
1698 | 0 | if (proto != canonicalProto) { |
1699 | 0 | PreserveWrapper(aObject); |
1700 | 0 | } |
1701 | 0 |
|
1702 | 0 | return true; |
1703 | 0 | } |
1704 | | |
1705 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1706 | | nullptr, |
1707 | | nullptr, |
1708 | | nullptr, |
1709 | | { sNativeProperties.Upcast(), nullptr }, |
1710 | | prototypes::id::SpeechRecognition, |
1711 | | constructors::id::SpeechRecognition, |
1712 | | EventTarget_Binding::sNativePropertyHooks, |
1713 | | &DefaultXrayExpandoObjectClass |
1714 | | } }; |
1715 | | |
1716 | | void |
1717 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1718 | 0 | { |
1719 | 0 | JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx)); |
1720 | 0 | if (!parentProto) { |
1721 | 0 | return; |
1722 | 0 | } |
1723 | 0 | |
1724 | 0 | JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx)); |
1725 | 0 | if (!constructorProto) { |
1726 | 0 | return; |
1727 | 0 | } |
1728 | 0 | |
1729 | 0 | static bool sIdsInited = false; |
1730 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1731 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1732 | 0 | return; |
1733 | 0 | } |
1734 | 0 | sIdsInited = true; |
1735 | 0 | } |
1736 | 0 |
|
1737 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SpeechRecognition); |
1738 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SpeechRecognition); |
1739 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1740 | 0 | &sPrototypeClass.mBase, protoCache, |
1741 | 0 | nullptr, |
1742 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
1743 | 0 | interfaceCache, |
1744 | 0 | sNativeProperties.Upcast(), |
1745 | 0 | nullptr, |
1746 | 0 | "SpeechRecognition", aDefineOnGlobal, |
1747 | 0 | nullptr, |
1748 | 0 | false); |
1749 | 0 | } |
1750 | | |
1751 | | JSObject* |
1752 | | GetConstructorObject(JSContext* aCx) |
1753 | 0 | { |
1754 | 0 | return GetConstructorObjectHandle(aCx); |
1755 | 0 | } |
1756 | | |
1757 | | } // namespace SpeechRecognition_Binding |
1758 | | |
1759 | | |
1760 | | |
1761 | | } // namespace dom |
1762 | | } // namespace mozilla |