Coverage Report

Created: 2018-09-25 14:53

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