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