Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM Notification.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_NotificationBinding_h
4 : #define mozilla_dom_NotificationBinding_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/CallbackFunction.h"
11 : #include "mozilla/dom/Nullable.h"
12 : #include "mozilla/dom/ToJSValue.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : struct GetNotificationOptionsAtoms;
18 : struct NativePropertyHooks;
19 : class Notification;
20 : struct NotificationAtoms;
21 : struct NotificationBehavior;
22 : struct NotificationBehaviorAtoms;
23 : struct NotificationOptionsAtoms;
24 : class NotificationPermissionCallback;
25 : class ProtoAndIfaceCache;
26 :
27 : } // namespace dom
28 : } // namespace mozilla
29 :
30 : namespace mozilla {
31 : namespace dom {
32 :
33 : enum class NotificationPermission : uint8_t {
34 : Default,
35 : Denied,
36 : Granted,
37 : EndGuard_
38 : };
39 :
40 : namespace NotificationPermissionValues {
41 : extern const EnumEntry strings[4];
42 : } // namespace NotificationPermissionValues
43 :
44 : bool
45 : ToJSValue(JSContext* aCx, NotificationPermission aArgument, JS::MutableHandle<JS::Value> aValue);
46 :
47 :
48 : enum class NotificationDirection : uint8_t {
49 : Auto,
50 : Ltr,
51 : Rtl,
52 : EndGuard_
53 : };
54 :
55 : namespace NotificationDirectionValues {
56 : extern const EnumEntry strings[4];
57 : } // namespace NotificationDirectionValues
58 :
59 : bool
60 : ToJSValue(JSContext* aCx, NotificationDirection aArgument, JS::MutableHandle<JS::Value> aValue);
61 :
62 :
63 0 : struct GetNotificationOptions : public DictionaryBase
64 : {
65 : MOZ_INIT_OUTSIDE_CTOR nsString mTag;
66 :
67 : GetNotificationOptions();
68 :
69 0 : explicit inline GetNotificationOptions(const FastDictionaryInitializer& )
70 0 : {
71 : // Do nothing here; this is used by our "Fast" subclass
72 0 : }
73 :
74 : explicit inline GetNotificationOptions(const GetNotificationOptions& aOther)
75 : {
76 : *this = aOther;
77 : }
78 :
79 : bool
80 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
81 :
82 : bool
83 : Init(const nsAString& aJSON);
84 :
85 : bool
86 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
87 :
88 : bool
89 : ToJSON(nsAString& aJSON) const;
90 :
91 : void
92 : TraceDictionary(JSTracer* trc);
93 :
94 : GetNotificationOptions&
95 : operator=(const GetNotificationOptions& aOther);
96 :
97 : private:
98 : static bool
99 : InitIds(JSContext* cx, GetNotificationOptionsAtoms* atomsCache);
100 : };
101 :
102 : namespace binding_detail {
103 0 : struct FastGetNotificationOptions : public GetNotificationOptions
104 : {
105 0 : inline FastGetNotificationOptions()
106 0 : : GetNotificationOptions(FastDictionaryInitializer())
107 : {
108 : // Doesn't matter what int we pass to the parent constructor
109 0 : }
110 : };
111 : } // namespace binding_detail
112 :
113 :
114 0 : struct NotificationBehavior : public DictionaryBase
115 : {
116 : MOZ_INIT_OUTSIDE_CTOR bool mNoclear;
117 : MOZ_INIT_OUTSIDE_CTOR bool mNoscreen;
118 : MOZ_INIT_OUTSIDE_CTOR bool mShowOnlyOnce;
119 : MOZ_INIT_OUTSIDE_CTOR nsString mSoundFile;
120 : MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<uint32_t>> mVibrationPattern;
121 :
122 : NotificationBehavior();
123 :
124 0 : explicit inline NotificationBehavior(const FastDictionaryInitializer& )
125 0 : {
126 : // Do nothing here; this is used by our "Fast" subclass
127 0 : }
128 :
129 0 : explicit inline NotificationBehavior(const NotificationBehavior& aOther)
130 0 : {
131 0 : *this = aOther;
132 0 : }
133 :
134 : bool
135 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
136 :
137 : bool
138 : Init(const nsAString& aJSON);
139 :
140 : bool
141 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
142 :
143 : bool
144 : ToJSON(nsAString& aJSON) const;
145 :
146 : void
147 : TraceDictionary(JSTracer* trc);
148 :
149 : NotificationBehavior&
150 : operator=(const NotificationBehavior& aOther);
151 :
152 : private:
153 : static bool
154 : InitIds(JSContext* cx, NotificationBehaviorAtoms* atomsCache);
155 : };
156 :
157 : namespace binding_detail {
158 : struct FastNotificationBehavior : public NotificationBehavior
159 : {
160 : inline FastNotificationBehavior()
161 : : NotificationBehavior(FastDictionaryInitializer())
162 : {
163 : // Doesn't matter what int we pass to the parent constructor
164 : }
165 : };
166 : } // namespace binding_detail
167 :
168 :
169 0 : struct NotificationOptions : public DictionaryBase
170 : {
171 : MOZ_INIT_OUTSIDE_CTOR nsString mBody;
172 : MOZ_INIT_OUTSIDE_CTOR JS::Value mData;
173 : MOZ_INIT_OUTSIDE_CTOR NotificationDirection mDir;
174 : MOZ_INIT_OUTSIDE_CTOR nsString mIcon;
175 : MOZ_INIT_OUTSIDE_CTOR nsString mLang;
176 : MOZ_INIT_OUTSIDE_CTOR NotificationBehavior mMozbehavior;
177 : MOZ_INIT_OUTSIDE_CTOR bool mRequireInteraction;
178 : MOZ_INIT_OUTSIDE_CTOR nsString mTag;
179 :
180 : NotificationOptions();
181 :
182 0 : explicit inline NotificationOptions(const FastDictionaryInitializer& )
183 0 : : mData(JS::UndefinedValue()),
184 0 : mMozbehavior(FastDictionaryInitializer())
185 : {
186 : // Do nothing here; this is used by our "Fast" subclass
187 0 : }
188 :
189 : private:
190 : NotificationOptions(const NotificationOptions&) = delete;
191 : NotificationOptions& operator=(const NotificationOptions&) = delete;
192 :
193 : static bool
194 : InitIds(JSContext* cx, NotificationOptionsAtoms* atomsCache);
195 :
196 : public:
197 : bool
198 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
199 :
200 : bool
201 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
202 :
203 : void
204 : TraceDictionary(JSTracer* trc);
205 : };
206 :
207 : namespace binding_detail {
208 0 : struct FastNotificationOptions : public NotificationOptions
209 : {
210 0 : inline FastNotificationOptions()
211 0 : : NotificationOptions(FastDictionaryInitializer())
212 : {
213 : // Doesn't matter what int we pass to the parent constructor
214 0 : }
215 : };
216 : } // namespace binding_detail
217 :
218 :
219 0 : class NotificationPermissionCallback : public CallbackFunction
220 : {
221 : public:
222 0 : explicit inline NotificationPermissionCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
223 0 : : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
224 : {
225 0 : MOZ_ASSERT(JS::IsCallable(mCallback));
226 0 : }
227 :
228 : explicit inline NotificationPermissionCallback(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
229 : : CallbackFunction(aCallback, FastCallbackConstructor())
230 : {
231 : MOZ_ASSERT(JS::IsCallable(mCallback));
232 : }
233 :
234 : explicit inline NotificationPermissionCallback(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
235 : : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
236 : {
237 : MOZ_ASSERT(JS::IsCallable(mCallback));
238 : }
239 :
240 : explicit inline NotificationPermissionCallback(CallbackFunction* aOther)
241 : : CallbackFunction(aOther)
242 : {
243 : }
244 :
245 : template <typename T>
246 : inline void
247 : Call(const T& thisVal, NotificationPermission permission, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
248 : {
249 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
250 : if (!aExecutionReason) {
251 : aExecutionReason = "NotificationPermissionCallback";
252 : }
253 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
254 : if (!s.GetContext()) {
255 : MOZ_ASSERT(aRv.Failed());
256 : return;
257 : }
258 : JS::Rooted<JS::Value> thisValJS(s.GetContext());
259 : if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
260 : aRv.Throw(NS_ERROR_FAILURE);
261 : return;
262 : }
263 : return Call(s.GetContext(), thisValJS, permission, aRv);
264 : }
265 :
266 : inline void
267 0 : Call(NotificationPermission permission, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
268 : {
269 0 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
270 0 : if (!aExecutionReason) {
271 0 : aExecutionReason = "NotificationPermissionCallback";
272 : }
273 0 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
274 0 : if (!s.GetContext()) {
275 0 : MOZ_ASSERT(aRv.Failed());
276 0 : return;
277 : }
278 0 : return Call(s.GetContext(), JS::UndefinedHandleValue, permission, aRv);
279 : }
280 :
281 : template <typename T>
282 : inline void
283 : Call(const T& thisVal, NotificationPermission permission, const char* aExecutionReason = nullptr)
284 : {
285 : IgnoredErrorResult rv;
286 : return Call(thisVal, permission, rv, aExecutionReason);
287 : }
288 :
289 : inline void
290 : Call(NotificationPermission permission, const char* aExecutionReason = nullptr)
291 : {
292 : IgnoredErrorResult rv;
293 : return Call(permission, rv, aExecutionReason, eReportExceptions, nullptr);
294 : }
295 :
296 : inline bool
297 : operator==(const NotificationPermissionCallback& aOther) const
298 : {
299 : return CallbackFunction::operator==(aOther);
300 : }
301 :
302 : private:
303 : void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, NotificationPermission permission, ErrorResult& aRv);
304 : };
305 :
306 :
307 : namespace binding_detail {
308 : class FastNotificationPermissionCallback : public NotificationPermissionCallback
309 : {
310 : public:
311 : explicit inline FastNotificationPermissionCallback(JS::Handle<JSObject*> aCallback)
312 : : NotificationPermissionCallback(aCallback, FastCallbackConstructor())
313 : {
314 : }
315 :
316 : inline void
317 : Trace(JSTracer* aTracer)
318 : {
319 : NotificationPermissionCallback::Trace(aTracer);
320 : }
321 :
322 : inline void
323 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
324 : {
325 : NotificationPermissionCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
326 : }
327 : };
328 : } // namespace binding_detail
329 :
330 :
331 : namespace NotificationBinding {
332 :
333 : typedef mozilla::dom::Notification NativeType;
334 :
335 : bool
336 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
337 :
338 : JSObject*
339 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
340 :
341 : const JSClass*
342 : GetJSClass();
343 :
344 : bool
345 : Wrap(JSContext* aCx, mozilla::dom::Notification* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
346 :
347 : template <class T>
348 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
349 : {
350 0 : JS::Rooted<JSObject*> reflector(aCx);
351 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
352 : }
353 :
354 : // We declare this as an array so that retrieving a pointer to this
355 : // binding's property hooks only requires compile/link-time resolvable
356 : // address arithmetic. Declaring it as a pointer instead would require
357 : // doing a run-time load to fetch a pointer to this binding's property
358 : // hooks. And then structures which embedded a pointer to this structure
359 : // would require a run-time load for proper initialization, which would
360 : // then induce static constructors. Lots of static constructors.
361 : extern const NativePropertyHooks sNativePropertyHooks[];
362 :
363 : void
364 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
365 :
366 : JS::Handle<JSObject*>
367 : GetProtoObjectHandle(JSContext* aCx);
368 :
369 : JS::Handle<JSObject*>
370 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
371 :
372 : JSObject*
373 : GetConstructorObject(JSContext* aCx);
374 :
375 : } // namespace NotificationBinding
376 :
377 :
378 :
379 : } // namespace dom
380 : } // namespace mozilla
381 :
382 : #endif // mozilla_dom_NotificationBinding_h
|