Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM EventListener.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_EventListenerBinding_h
4 : #define mozilla_dom_EventListenerBinding_h
5 :
6 : #include "js/RootingAPI.h"
7 : #include "jspubtd.h"
8 : #include "mozilla/ErrorResult.h"
9 : #include "mozilla/dom/BindingDeclarations.h"
10 : #include "mozilla/dom/CallbackInterface.h"
11 : #include "mozilla/dom/Nullable.h"
12 : #include "mozilla/dom/ToJSValue.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : class Event;
18 : class EventListener;
19 : struct EventListenerAtoms;
20 : struct NativePropertyHooks;
21 : class ProtoAndIfaceCache;
22 :
23 : } // namespace dom
24 : } // namespace mozilla
25 :
26 : namespace mozilla {
27 : namespace dom {
28 :
29 22 : class EventListener : public CallbackInterface
30 : {
31 : public:
32 : explicit inline EventListener(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
33 : : CallbackInterface(aCx, aCallback, aIncumbentGlobal)
34 : {
35 : }
36 :
37 192 : explicit inline EventListener(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
38 192 : : CallbackInterface(aCallback, FastCallbackConstructor())
39 : {
40 192 : }
41 :
42 : explicit inline EventListener(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
43 : : CallbackInterface(aCallback, aAsyncStack, aIncumbentGlobal)
44 : {
45 : }
46 :
47 : template <typename T>
48 : inline void
49 32 : HandleEvent(const T& thisVal, Event& event, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
50 : {
51 32 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
52 32 : if (!aExecutionReason) {
53 32 : aExecutionReason = "EventListener.handleEvent";
54 : }
55 64 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
56 32 : if (!s.GetContext()) {
57 0 : MOZ_ASSERT(aRv.Failed());
58 0 : return;
59 : }
60 64 : JS::Rooted<JS::Value> thisValJS(s.GetContext());
61 32 : if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
62 0 : aRv.Throw(NS_ERROR_FAILURE);
63 0 : return;
64 : }
65 32 : return HandleEvent(s.GetContext(), thisValJS, event, aRv);
66 : }
67 :
68 : inline void
69 : HandleEvent(Event& event, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
70 : {
71 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
72 : if (!aExecutionReason) {
73 : aExecutionReason = "EventListener.handleEvent";
74 : }
75 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
76 : if (!s.GetContext()) {
77 : MOZ_ASSERT(aRv.Failed());
78 : return;
79 : }
80 : return HandleEvent(s.GetContext(), JS::UndefinedHandleValue, event, aRv);
81 : }
82 :
83 : template <typename T>
84 : inline void
85 : HandleEvent(const T& thisVal, Event& event, const char* aExecutionReason = nullptr)
86 : {
87 : IgnoredErrorResult rv;
88 : return HandleEvent(thisVal, event, rv, aExecutionReason);
89 : }
90 :
91 : inline void
92 : HandleEvent(Event& event, const char* aExecutionReason = nullptr)
93 : {
94 : IgnoredErrorResult rv;
95 : return HandleEvent(event, rv, aExecutionReason, eReportExceptions, nullptr);
96 : }
97 :
98 : inline bool
99 67 : operator==(const EventListener& aOther) const
100 : {
101 67 : return CallbackInterface::operator==(aOther);
102 : }
103 :
104 : private:
105 : void HandleEvent(JSContext* cx, JS::Handle<JS::Value> aThisVal, Event& event, ErrorResult& aRv);
106 :
107 : static bool
108 : InitIds(JSContext* cx, EventListenerAtoms* atomsCache);
109 : };
110 :
111 :
112 : namespace binding_detail {
113 66 : class FastEventListener : public EventListener
114 : {
115 : public:
116 192 : explicit inline FastEventListener(JS::Handle<JSObject*> aCallback)
117 192 : : EventListener(aCallback, FastCallbackConstructor())
118 : {
119 192 : }
120 :
121 : inline void
122 0 : Trace(JSTracer* aTracer)
123 : {
124 0 : EventListener::Trace(aTracer);
125 0 : }
126 :
127 : inline void
128 192 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
129 : {
130 192 : EventListener::FinishSlowJSInitIfMoreThanOneOwner(aCx);
131 192 : }
132 : };
133 : } // namespace binding_detail
134 :
135 :
136 : } // namespace dom
137 : } // namespace mozilla
138 :
139 : #endif // mozilla_dom_EventListenerBinding_h
|