/work/obj-fuzz/dist/include/mozilla/dom/EventHandlerBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM EventHandler.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_EventHandlerBinding_h |
4 | | #define mozilla_dom_EventHandlerBinding_h |
5 | | |
6 | | #include "GeckoProfiler.h" |
7 | | #include "js/RootingAPI.h" |
8 | | #include "jspubtd.h" |
9 | | #include "mozilla/ErrorResult.h" |
10 | | #include "mozilla/dom/BindingDeclarations.h" |
11 | | #include "mozilla/dom/CallbackFunction.h" |
12 | | #include "mozilla/dom/FakeString.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "mozilla/dom/ToJSValue.h" |
15 | | #include "mozilla/dom/UnionMember.h" |
16 | | |
17 | | namespace mozilla { |
18 | | namespace dom { |
19 | | |
20 | | class Event; |
21 | | class EventHandlerNonNull; |
22 | | class EventOrString; |
23 | | struct NativePropertyHooks; |
24 | | class OnBeforeUnloadEventHandlerNonNull; |
25 | | class OnErrorEventHandlerNonNull; |
26 | | class OwningEventOrString; |
27 | | class ProtoAndIfaceCache; |
28 | | |
29 | | } // namespace dom |
30 | | } // namespace mozilla |
31 | | |
32 | | namespace mozilla { |
33 | | namespace dom { |
34 | | |
35 | | void |
36 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningEventOrString& aUnion, const char* aName, uint32_t aFlags = 0); |
37 | | |
38 | | |
39 | | void |
40 | | ImplCycleCollectionUnlink(OwningEventOrString& aUnion); |
41 | | |
42 | | |
43 | | class EventOrString |
44 | | { |
45 | | friend class EventOrStringArgument; |
46 | | enum Type |
47 | | { |
48 | | eUninitialized, |
49 | | eEvent, |
50 | | eString |
51 | | }; |
52 | | |
53 | | union Value |
54 | | { |
55 | | UnionMember<NonNull<mozilla::dom::Event> > mEvent; |
56 | | UnionMember<binding_detail::FakeString > mString; |
57 | | |
58 | | }; |
59 | | |
60 | | Type mType; |
61 | | Value mValue; |
62 | | |
63 | | EventOrString(const EventOrString&) = delete; |
64 | | EventOrString& operator=(const EventOrString&) = delete; |
65 | | public: |
66 | | explicit inline EventOrString() |
67 | | : mType(eUninitialized) |
68 | 0 | { |
69 | 0 | } |
70 | | |
71 | | inline ~EventOrString() |
72 | 0 | { |
73 | 0 | Uninit(); |
74 | 0 | } |
75 | | |
76 | | inline NonNull<mozilla::dom::Event>& |
77 | | RawSetAsEvent() |
78 | 0 | { |
79 | 0 | if (mType == eEvent) { |
80 | 0 | return mValue.mEvent.Value(); |
81 | 0 | } |
82 | 0 | MOZ_ASSERT(mType == eUninitialized); |
83 | 0 | mType = eEvent; |
84 | 0 | return mValue.mEvent.SetValue(); |
85 | 0 | } |
86 | | |
87 | | inline NonNull<mozilla::dom::Event>& |
88 | | SetAsEvent() |
89 | 0 | { |
90 | 0 | if (mType == eEvent) { |
91 | 0 | return mValue.mEvent.Value(); |
92 | 0 | } |
93 | 0 | Uninit(); |
94 | 0 | mType = eEvent; |
95 | 0 | return mValue.mEvent.SetValue(); |
96 | 0 | } |
97 | | |
98 | | inline bool |
99 | | IsEvent() const |
100 | 0 | { |
101 | 0 | return mType == eEvent; |
102 | 0 | } |
103 | | |
104 | | inline NonNull<mozilla::dom::Event>& |
105 | | GetAsEvent() |
106 | 0 | { |
107 | 0 | MOZ_ASSERT(IsEvent(), "Wrong type!"); |
108 | 0 | return mValue.mEvent.Value(); |
109 | 0 | } |
110 | | |
111 | | inline mozilla::dom::Event& |
112 | | GetAsEvent() const |
113 | 0 | { |
114 | 0 | MOZ_ASSERT(IsEvent(), "Wrong type!"); |
115 | 0 | return mValue.mEvent.Value(); |
116 | 0 | } |
117 | | |
118 | | inline binding_detail::FakeString& |
119 | | RawSetAsString() |
120 | 0 | { |
121 | 0 | if (mType == eString) { |
122 | 0 | return mValue.mString.Value(); |
123 | 0 | } |
124 | 0 | MOZ_ASSERT(mType == eUninitialized); |
125 | 0 | mType = eString; |
126 | 0 | return mValue.mString.SetValue(); |
127 | 0 | } |
128 | | |
129 | | inline binding_detail::FakeString& |
130 | | SetAsString() |
131 | 0 | { |
132 | 0 | if (mType == eString) { |
133 | 0 | return mValue.mString.Value(); |
134 | 0 | } |
135 | 0 | Uninit(); |
136 | 0 | mType = eString; |
137 | 0 | return mValue.mString.SetValue(); |
138 | 0 | } |
139 | | |
140 | | inline bool |
141 | | IsString() const |
142 | 0 | { |
143 | 0 | return mType == eString; |
144 | 0 | } |
145 | | |
146 | | inline binding_detail::FakeString& |
147 | | GetAsString() |
148 | 0 | { |
149 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
150 | 0 | return mValue.mString.Value(); |
151 | 0 | } |
152 | | |
153 | | inline const nsAString& |
154 | | GetAsString() const |
155 | 0 | { |
156 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
157 | 0 | return mValue.mString.Value(); |
158 | 0 | } |
159 | | |
160 | | inline void |
161 | | Uninit() |
162 | | { |
163 | | switch (mType) { |
164 | | case eUninitialized: { |
165 | | break; |
166 | | } |
167 | | case eEvent: { |
168 | | DestroyEvent(); |
169 | | break; |
170 | | } |
171 | | case eString: { |
172 | | DestroyString(); |
173 | | break; |
174 | | } |
175 | | } |
176 | | } |
177 | | |
178 | | bool |
179 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
180 | | |
181 | | private: |
182 | | inline void |
183 | | DestroyEvent() |
184 | 0 | { |
185 | 0 | MOZ_ASSERT(IsEvent(), "Wrong type!"); |
186 | 0 | mValue.mEvent.Destroy(); |
187 | 0 | mType = eUninitialized; |
188 | 0 | } |
189 | | |
190 | | inline void |
191 | | DestroyString() |
192 | 0 | { |
193 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
194 | 0 | mValue.mString.Destroy(); |
195 | 0 | mType = eUninitialized; |
196 | 0 | } |
197 | | }; |
198 | | |
199 | | |
200 | | class OwningEventOrString : public AllOwningUnionBase |
201 | | { |
202 | | friend void ImplCycleCollectionUnlink(OwningEventOrString& aUnion); |
203 | | enum Type |
204 | | { |
205 | | eUninitialized, |
206 | | eEvent, |
207 | | eString |
208 | | }; |
209 | | |
210 | | union Value |
211 | | { |
212 | | UnionMember<OwningNonNull<mozilla::dom::Event> > mEvent; |
213 | | UnionMember<nsString > mString; |
214 | | |
215 | | }; |
216 | | |
217 | | Type mType; |
218 | | Value mValue; |
219 | | |
220 | | public: |
221 | | explicit inline OwningEventOrString() |
222 | | : mType(eUninitialized) |
223 | 0 | { |
224 | 0 | } |
225 | | |
226 | | explicit inline OwningEventOrString(const OwningEventOrString& aOther) |
227 | | : mType(eUninitialized) |
228 | 0 | { |
229 | 0 | *this = aOther; |
230 | 0 | } |
231 | | |
232 | | inline ~OwningEventOrString() |
233 | 0 | { |
234 | 0 | Uninit(); |
235 | 0 | } |
236 | | |
237 | | OwningNonNull<mozilla::dom::Event>& |
238 | | RawSetAsEvent(); |
239 | | |
240 | | OwningNonNull<mozilla::dom::Event>& |
241 | | SetAsEvent(); |
242 | | |
243 | | bool |
244 | | TrySetToEvent(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
245 | | |
246 | | inline bool |
247 | | IsEvent() const |
248 | 0 | { |
249 | 0 | return mType == eEvent; |
250 | 0 | } |
251 | | |
252 | | inline OwningNonNull<mozilla::dom::Event>& |
253 | | GetAsEvent() |
254 | 0 | { |
255 | 0 | MOZ_ASSERT(IsEvent(), "Wrong type!"); |
256 | 0 | return mValue.mEvent.Value(); |
257 | 0 | } |
258 | | |
259 | | inline OwningNonNull<mozilla::dom::Event> const & |
260 | | GetAsEvent() const |
261 | 0 | { |
262 | 0 | MOZ_ASSERT(IsEvent(), "Wrong type!"); |
263 | 0 | return mValue.mEvent.Value(); |
264 | 0 | } |
265 | | |
266 | | nsString& |
267 | | RawSetAsString(); |
268 | | |
269 | | nsString& |
270 | | SetAsString(); |
271 | | |
272 | | bool |
273 | | TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
274 | | |
275 | | inline void |
276 | | SetStringData(const nsString::char_type* aData, nsString::size_type aLength) |
277 | 0 | { |
278 | 0 | RawSetAsString().Assign(aData, aLength); |
279 | 0 | } |
280 | | |
281 | | inline bool |
282 | | IsString() const |
283 | 0 | { |
284 | 0 | return mType == eString; |
285 | 0 | } |
286 | | |
287 | | inline nsString& |
288 | | GetAsString() |
289 | 0 | { |
290 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
291 | 0 | return mValue.mString.Value(); |
292 | 0 | } |
293 | | |
294 | | inline nsString const & |
295 | | GetAsString() const |
296 | 0 | { |
297 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
298 | 0 | return mValue.mString.Value(); |
299 | 0 | } |
300 | | |
301 | | void |
302 | | Uninit(); |
303 | | |
304 | | bool |
305 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
306 | | |
307 | | void |
308 | | TraceUnion(JSTracer* trc); |
309 | | |
310 | | OwningEventOrString& |
311 | | operator=(const OwningEventOrString& aOther); |
312 | | |
313 | | private: |
314 | | void |
315 | | DestroyEvent(); |
316 | | |
317 | | void |
318 | | DestroyString(); |
319 | | }; |
320 | | |
321 | | |
322 | | class EventHandlerNonNull : public CallbackFunction |
323 | | { |
324 | | public: |
325 | | explicit inline EventHandlerNonNull(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
326 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
327 | 0 | { |
328 | 0 | } |
329 | | |
330 | | explicit inline EventHandlerNonNull(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
331 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
332 | 0 | { |
333 | 0 | } |
334 | | |
335 | | explicit inline EventHandlerNonNull(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
336 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
337 | 0 | { |
338 | 0 | } |
339 | | |
340 | | explicit inline EventHandlerNonNull(CallbackFunction* aOther) |
341 | | : CallbackFunction(aOther) |
342 | 0 | { |
343 | 0 | } |
344 | | |
345 | | template <typename T> |
346 | | inline void |
347 | | Call(const T& thisVal, Event& event, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
348 | 0 | { |
349 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
350 | 0 | if (!aExecutionReason) { |
351 | 0 | aExecutionReason = "EventHandlerNonNull"; |
352 | 0 | } |
353 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
354 | 0 | if (!s.GetContext()) { |
355 | 0 | MOZ_ASSERT(aRv.Failed()); |
356 | 0 | return; |
357 | 0 | } |
358 | 0 | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
359 | 0 | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
360 | 0 | aRv.Throw(NS_ERROR_FAILURE); |
361 | 0 | return; |
362 | 0 | } |
363 | 0 | return Call(s.GetContext(), thisValJS, event, aRetVal, aRv); |
364 | 0 | } |
365 | | |
366 | | inline void |
367 | | Call(Event& event, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
368 | 0 | { |
369 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
370 | 0 | if (!aExecutionReason) { |
371 | 0 | aExecutionReason = "EventHandlerNonNull"; |
372 | 0 | } |
373 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
374 | 0 | if (!s.GetContext()) { |
375 | 0 | MOZ_ASSERT(aRv.Failed()); |
376 | 0 | return; |
377 | 0 | } |
378 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, event, aRetVal, aRv); |
379 | 0 | } |
380 | | |
381 | | template <typename T> |
382 | | inline void |
383 | | Call(const T& thisVal, Event& event, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr) |
384 | | { |
385 | | return Call(thisVal, event, aRetVal, IgnoreErrors(), aExecutionReason); |
386 | | } |
387 | | |
388 | | inline void |
389 | | Call(Event& event, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr) |
390 | 0 | { |
391 | 0 | return Call(event, aRetVal, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
392 | 0 | } |
393 | | |
394 | | inline bool |
395 | | operator==(const EventHandlerNonNull& aOther) const |
396 | 0 | { |
397 | 0 | return CallbackFunction::operator==(aOther); |
398 | 0 | } |
399 | | |
400 | | private: |
401 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, Event& event, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv); |
402 | | }; |
403 | | |
404 | | |
405 | | class OnBeforeUnloadEventHandlerNonNull : public CallbackFunction |
406 | | { |
407 | | public: |
408 | | explicit inline OnBeforeUnloadEventHandlerNonNull(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
409 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
410 | 0 | { |
411 | 0 | } |
412 | | |
413 | | explicit inline OnBeforeUnloadEventHandlerNonNull(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
414 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
415 | 0 | { |
416 | 0 | } |
417 | | |
418 | | explicit inline OnBeforeUnloadEventHandlerNonNull(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
419 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
420 | 0 | { |
421 | 0 | } |
422 | | |
423 | | explicit inline OnBeforeUnloadEventHandlerNonNull(CallbackFunction* aOther) |
424 | | : CallbackFunction(aOther) |
425 | 0 | { |
426 | 0 | } |
427 | | |
428 | | template <typename T> |
429 | | inline void |
430 | | Call(const T& thisVal, Event& event, nsString& aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
431 | 0 | { |
432 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
433 | 0 | if (!aExecutionReason) { |
434 | 0 | aExecutionReason = "OnBeforeUnloadEventHandlerNonNull"; |
435 | 0 | } |
436 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
437 | 0 | if (!s.GetContext()) { |
438 | 0 | MOZ_ASSERT(aRv.Failed()); |
439 | 0 | return; |
440 | 0 | } |
441 | 0 | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
442 | 0 | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
443 | 0 | aRv.Throw(NS_ERROR_FAILURE); |
444 | 0 | return; |
445 | 0 | } |
446 | 0 | return Call(s.GetContext(), thisValJS, event, aRetVal, aRv); |
447 | 0 | } |
448 | | |
449 | | inline void |
450 | | Call(Event& event, nsString& aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
451 | 0 | { |
452 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
453 | 0 | if (!aExecutionReason) { |
454 | 0 | aExecutionReason = "OnBeforeUnloadEventHandlerNonNull"; |
455 | 0 | } |
456 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
457 | 0 | if (!s.GetContext()) { |
458 | 0 | MOZ_ASSERT(aRv.Failed()); |
459 | 0 | return; |
460 | 0 | } |
461 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, event, aRetVal, aRv); |
462 | 0 | } |
463 | | |
464 | | template <typename T> |
465 | | inline void |
466 | | Call(const T& thisVal, Event& event, nsString& aRetVal, const char* aExecutionReason = nullptr) |
467 | | { |
468 | | return Call(thisVal, event, aRetVal, IgnoreErrors(), aExecutionReason); |
469 | | } |
470 | | |
471 | | inline void |
472 | | Call(Event& event, nsString& aRetVal, const char* aExecutionReason = nullptr) |
473 | 0 | { |
474 | 0 | return Call(event, aRetVal, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
475 | 0 | } |
476 | | |
477 | | inline bool |
478 | | operator==(const OnBeforeUnloadEventHandlerNonNull& aOther) const |
479 | 0 | { |
480 | 0 | return CallbackFunction::operator==(aOther); |
481 | 0 | } |
482 | | |
483 | | private: |
484 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, Event& event, nsString& aRetVal, ErrorResult& aRv); |
485 | | }; |
486 | | |
487 | | |
488 | | class OnErrorEventHandlerNonNull : public CallbackFunction |
489 | | { |
490 | | public: |
491 | | explicit inline OnErrorEventHandlerNonNull(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
492 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
493 | 0 | { |
494 | 0 | } |
495 | | |
496 | | explicit inline OnErrorEventHandlerNonNull(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
497 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
498 | 0 | { |
499 | 0 | } |
500 | | |
501 | | explicit inline OnErrorEventHandlerNonNull(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
502 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
503 | 0 | { |
504 | 0 | } |
505 | | |
506 | | explicit inline OnErrorEventHandlerNonNull(CallbackFunction* aOther) |
507 | | : CallbackFunction(aOther) |
508 | 0 | { |
509 | 0 | } |
510 | | |
511 | | template <typename T> |
512 | | inline void |
513 | | Call(const T& thisVal, const EventOrString& event, const Optional<nsAString>& source, const Optional<uint32_t>& lineno, const Optional<uint32_t>& column, const Optional<JS::Handle<JS::Value>>& error, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
514 | 0 | { |
515 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
516 | 0 | if (!aExecutionReason) { |
517 | 0 | aExecutionReason = "OnErrorEventHandlerNonNull"; |
518 | 0 | } |
519 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
520 | 0 | if (!s.GetContext()) { |
521 | 0 | MOZ_ASSERT(aRv.Failed()); |
522 | 0 | return; |
523 | 0 | } |
524 | 0 | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
525 | 0 | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
526 | 0 | aRv.Throw(NS_ERROR_FAILURE); |
527 | 0 | return; |
528 | 0 | } |
529 | 0 | return Call(s.GetContext(), thisValJS, event, source, lineno, column, error, aRetVal, aRv); |
530 | 0 | } |
531 | | |
532 | | inline void |
533 | | Call(const EventOrString& event, const Optional<nsAString>& source, const Optional<uint32_t>& lineno, const Optional<uint32_t>& column, const Optional<JS::Handle<JS::Value>>& error, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
534 | 0 | { |
535 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
536 | 0 | if (!aExecutionReason) { |
537 | 0 | aExecutionReason = "OnErrorEventHandlerNonNull"; |
538 | 0 | } |
539 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
540 | 0 | if (!s.GetContext()) { |
541 | 0 | MOZ_ASSERT(aRv.Failed()); |
542 | 0 | return; |
543 | 0 | } |
544 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, event, source, lineno, column, error, aRetVal, aRv); |
545 | 0 | } |
546 | | |
547 | | template <typename T> |
548 | | inline void |
549 | | Call(const T& thisVal, const EventOrString& event, const Optional<nsAString>& source, const Optional<uint32_t>& lineno, const Optional<uint32_t>& column, const Optional<JS::Handle<JS::Value>>& error, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr) |
550 | | { |
551 | | return Call(thisVal, event, source, lineno, column, error, aRetVal, IgnoreErrors(), aExecutionReason); |
552 | | } |
553 | | |
554 | | inline void |
555 | | Call(const EventOrString& event, const Optional<nsAString>& source, const Optional<uint32_t>& lineno, const Optional<uint32_t>& column, const Optional<JS::Handle<JS::Value>>& error, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr) |
556 | 0 | { |
557 | 0 | return Call(event, source, lineno, column, error, aRetVal, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
558 | 0 | } |
559 | | |
560 | | inline bool |
561 | | operator==(const OnErrorEventHandlerNonNull& aOther) const |
562 | 0 | { |
563 | 0 | return CallbackFunction::operator==(aOther); |
564 | 0 | } |
565 | | |
566 | | private: |
567 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const EventOrString& event, const Optional<nsAString>& source, const Optional<uint32_t>& lineno, const Optional<uint32_t>& column, const Optional<JS::Handle<JS::Value>>& error, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv); |
568 | | }; |
569 | | |
570 | | |
571 | | namespace binding_detail { |
572 | | class FastEventHandlerNonNull : public EventHandlerNonNull |
573 | | { |
574 | | public: |
575 | | explicit inline FastEventHandlerNonNull(JSObject* aCallback, JSObject* aCallbackGlobal) |
576 | | : EventHandlerNonNull(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
577 | 0 | { |
578 | 0 | } |
579 | | |
580 | | inline void |
581 | | Trace(JSTracer* aTracer) |
582 | 0 | { |
583 | 0 | EventHandlerNonNull::Trace(aTracer); |
584 | 0 | } |
585 | | |
586 | | inline void |
587 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
588 | 0 | { |
589 | 0 | EventHandlerNonNull::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
590 | 0 | } |
591 | | }; |
592 | | } // namespace binding_detail |
593 | | |
594 | | |
595 | | namespace binding_detail { |
596 | | class FastOnBeforeUnloadEventHandlerNonNull : public OnBeforeUnloadEventHandlerNonNull |
597 | | { |
598 | | public: |
599 | | explicit inline FastOnBeforeUnloadEventHandlerNonNull(JSObject* aCallback, JSObject* aCallbackGlobal) |
600 | | : OnBeforeUnloadEventHandlerNonNull(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
601 | 0 | { |
602 | 0 | } |
603 | | |
604 | | inline void |
605 | | Trace(JSTracer* aTracer) |
606 | 0 | { |
607 | 0 | OnBeforeUnloadEventHandlerNonNull::Trace(aTracer); |
608 | 0 | } |
609 | | |
610 | | inline void |
611 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
612 | 0 | { |
613 | 0 | OnBeforeUnloadEventHandlerNonNull::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
614 | 0 | } |
615 | | }; |
616 | | } // namespace binding_detail |
617 | | |
618 | | |
619 | | namespace binding_detail { |
620 | | class FastOnErrorEventHandlerNonNull : public OnErrorEventHandlerNonNull |
621 | | { |
622 | | public: |
623 | | explicit inline FastOnErrorEventHandlerNonNull(JSObject* aCallback, JSObject* aCallbackGlobal) |
624 | | : OnErrorEventHandlerNonNull(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
625 | 0 | { |
626 | 0 | } |
627 | | |
628 | | inline void |
629 | | Trace(JSTracer* aTracer) |
630 | 0 | { |
631 | 0 | OnErrorEventHandlerNonNull::Trace(aTracer); |
632 | 0 | } |
633 | | |
634 | | inline void |
635 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
636 | 0 | { |
637 | 0 | OnErrorEventHandlerNonNull::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
638 | 0 | } |
639 | | }; |
640 | | } // namespace binding_detail |
641 | | |
642 | | |
643 | | } // namespace dom |
644 | | } // namespace mozilla |
645 | | |
646 | | #endif // mozilla_dom_EventHandlerBinding_h |