Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM Coordinates.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "CoordinatesBinding.h"
4 : #include "WrapperFactory.h"
5 : #include "mozilla/FloatingPoint.h"
6 : #include "mozilla/OwningNonNull.h"
7 : #include "mozilla/dom/BindingUtils.h"
8 : #include "mozilla/dom/DOMJSClass.h"
9 : #include "mozilla/dom/NonRefcountedDOMObject.h"
10 : #include "mozilla/dom/Nullable.h"
11 : #include "mozilla/dom/PrimitiveConversions.h"
12 : #include "mozilla/dom/XrayExpandoClass.h"
13 : #include "nsGeoPosition.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : namespace CoordinatesBinding {
19 :
20 : static bool
21 0 : get_latitude(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Coordinates* self, JSJitGetterCallArgs args)
22 : {
23 0 : double result(self->Latitude());
24 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
25 0 : args.rval().set(JS_NumberValue(double(result)));
26 0 : return true;
27 : }
28 :
29 : static const JSJitInfo latitude_getterinfo = {
30 : { (JSJitGetterOp)get_latitude },
31 : { prototypes::id::Coordinates },
32 : { PrototypeTraits<prototypes::id::Coordinates>::Depth },
33 : JSJitInfo::Getter,
34 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
35 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
36 : true, /* isInfallible. False in setters. */
37 : false, /* isMovable. Not relevant for setters. */
38 : false, /* isEliminatable. Not relevant for setters. */
39 : false, /* isAlwaysInSlot. Only relevant for getters. */
40 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
41 : false, /* isTypedMethod. Only relevant for methods. */
42 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
43 : };
44 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
45 : static_assert(0 < 1, "There is no slot for us");
46 :
47 : static bool
48 0 : get_longitude(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Coordinates* self, JSJitGetterCallArgs args)
49 : {
50 0 : double result(self->Longitude());
51 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
52 0 : args.rval().set(JS_NumberValue(double(result)));
53 0 : return true;
54 : }
55 :
56 : static const JSJitInfo longitude_getterinfo = {
57 : { (JSJitGetterOp)get_longitude },
58 : { prototypes::id::Coordinates },
59 : { PrototypeTraits<prototypes::id::Coordinates>::Depth },
60 : JSJitInfo::Getter,
61 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
62 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
63 : true, /* isInfallible. False in setters. */
64 : false, /* isMovable. Not relevant for setters. */
65 : false, /* isEliminatable. Not relevant for setters. */
66 : false, /* isAlwaysInSlot. Only relevant for getters. */
67 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
68 : false, /* isTypedMethod. Only relevant for methods. */
69 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
70 : };
71 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
72 : static_assert(0 < 1, "There is no slot for us");
73 :
74 : static bool
75 0 : get_altitude(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Coordinates* self, JSJitGetterCallArgs args)
76 : {
77 0 : Nullable<double> result(self->GetAltitude());
78 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
79 0 : if (result.IsNull()) {
80 0 : args.rval().setNull();
81 0 : return true;
82 : }
83 0 : args.rval().set(JS_NumberValue(double(result.Value())));
84 0 : return true;
85 : }
86 :
87 : static const JSJitInfo altitude_getterinfo = {
88 : { (JSJitGetterOp)get_altitude },
89 : { prototypes::id::Coordinates },
90 : { PrototypeTraits<prototypes::id::Coordinates>::Depth },
91 : JSJitInfo::Getter,
92 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
93 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
94 : true, /* isInfallible. False in setters. */
95 : false, /* isMovable. Not relevant for setters. */
96 : false, /* isEliminatable. Not relevant for setters. */
97 : false, /* isAlwaysInSlot. Only relevant for getters. */
98 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
99 : false, /* isTypedMethod. Only relevant for methods. */
100 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
101 : };
102 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
103 : static_assert(0 < 1, "There is no slot for us");
104 :
105 : static bool
106 0 : get_accuracy(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Coordinates* self, JSJitGetterCallArgs args)
107 : {
108 0 : double result(self->Accuracy());
109 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
110 0 : args.rval().set(JS_NumberValue(double(result)));
111 0 : return true;
112 : }
113 :
114 : static const JSJitInfo accuracy_getterinfo = {
115 : { (JSJitGetterOp)get_accuracy },
116 : { prototypes::id::Coordinates },
117 : { PrototypeTraits<prototypes::id::Coordinates>::Depth },
118 : JSJitInfo::Getter,
119 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
120 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
121 : true, /* isInfallible. False in setters. */
122 : false, /* isMovable. Not relevant for setters. */
123 : false, /* isEliminatable. Not relevant for setters. */
124 : false, /* isAlwaysInSlot. Only relevant for getters. */
125 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
126 : false, /* isTypedMethod. Only relevant for methods. */
127 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
128 : };
129 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
130 : static_assert(0 < 1, "There is no slot for us");
131 :
132 : static bool
133 0 : get_altitudeAccuracy(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Coordinates* self, JSJitGetterCallArgs args)
134 : {
135 0 : Nullable<double> result(self->GetAltitudeAccuracy());
136 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
137 0 : if (result.IsNull()) {
138 0 : args.rval().setNull();
139 0 : return true;
140 : }
141 0 : args.rval().set(JS_NumberValue(double(result.Value())));
142 0 : return true;
143 : }
144 :
145 : static const JSJitInfo altitudeAccuracy_getterinfo = {
146 : { (JSJitGetterOp)get_altitudeAccuracy },
147 : { prototypes::id::Coordinates },
148 : { PrototypeTraits<prototypes::id::Coordinates>::Depth },
149 : JSJitInfo::Getter,
150 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
151 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
152 : true, /* isInfallible. False in setters. */
153 : false, /* isMovable. Not relevant for setters. */
154 : false, /* isEliminatable. Not relevant for setters. */
155 : false, /* isAlwaysInSlot. Only relevant for getters. */
156 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
157 : false, /* isTypedMethod. Only relevant for methods. */
158 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
159 : };
160 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
161 : static_assert(0 < 1, "There is no slot for us");
162 :
163 : static bool
164 0 : get_heading(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Coordinates* self, JSJitGetterCallArgs args)
165 : {
166 0 : Nullable<double> result(self->GetHeading());
167 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
168 0 : if (result.IsNull()) {
169 0 : args.rval().setNull();
170 0 : return true;
171 : }
172 0 : args.rval().set(JS_NumberValue(double(result.Value())));
173 0 : return true;
174 : }
175 :
176 : static const JSJitInfo heading_getterinfo = {
177 : { (JSJitGetterOp)get_heading },
178 : { prototypes::id::Coordinates },
179 : { PrototypeTraits<prototypes::id::Coordinates>::Depth },
180 : JSJitInfo::Getter,
181 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
182 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
183 : true, /* isInfallible. False in setters. */
184 : false, /* isMovable. Not relevant for setters. */
185 : false, /* isEliminatable. Not relevant for setters. */
186 : false, /* isAlwaysInSlot. Only relevant for getters. */
187 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
188 : false, /* isTypedMethod. Only relevant for methods. */
189 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
190 : };
191 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
192 : static_assert(0 < 1, "There is no slot for us");
193 :
194 : static bool
195 0 : get_speed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Coordinates* self, JSJitGetterCallArgs args)
196 : {
197 0 : Nullable<double> result(self->GetSpeed());
198 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
199 0 : if (result.IsNull()) {
200 0 : args.rval().setNull();
201 0 : return true;
202 : }
203 0 : args.rval().set(JS_NumberValue(double(result.Value())));
204 0 : return true;
205 : }
206 :
207 : static const JSJitInfo speed_getterinfo = {
208 : { (JSJitGetterOp)get_speed },
209 : { prototypes::id::Coordinates },
210 : { PrototypeTraits<prototypes::id::Coordinates>::Depth },
211 : JSJitInfo::Getter,
212 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
213 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
214 : true, /* isInfallible. False in setters. */
215 : false, /* isMovable. Not relevant for setters. */
216 : false, /* isEliminatable. Not relevant for setters. */
217 : false, /* isAlwaysInSlot. Only relevant for getters. */
218 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
219 : false, /* isTypedMethod. Only relevant for methods. */
220 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
221 : };
222 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
223 : static_assert(0 < 1, "There is no slot for us");
224 :
225 : static bool
226 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
227 : {
228 0 : mozilla::dom::Coordinates* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Coordinates>(obj);
229 : // We don't want to preserve if we don't have a wrapper, and we
230 : // obviously can't preserve if we're not initialized.
231 0 : if (self && self->GetWrapperPreserveColor()) {
232 0 : PreserveWrapper(self);
233 : }
234 0 : return true;
235 : }
236 :
237 : static void
238 0 : _finalize(js::FreeOp* fop, JSObject* obj)
239 : {
240 0 : mozilla::dom::Coordinates* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Coordinates>(obj);
241 0 : if (self) {
242 0 : ClearWrapper(self, self, obj);
243 0 : AddForDeferredFinalization<mozilla::dom::Coordinates>(self);
244 : }
245 0 : }
246 :
247 : static void
248 0 : _objectMoved(JSObject* obj, const JSObject* old)
249 : {
250 0 : mozilla::dom::Coordinates* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Coordinates>(obj);
251 0 : if (self) {
252 0 : UpdateWrapper(self, self, obj, old);
253 : }
254 0 : }
255 :
256 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
257 : #if defined(__clang__)
258 : #pragma clang diagnostic push
259 : #pragma clang diagnostic ignored "-Wmissing-braces"
260 : #endif
261 : static const JSPropertySpec sAttributes_specs[] = {
262 : { "latitude", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &latitude_getterinfo, nullptr, nullptr },
263 : { "longitude", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &longitude_getterinfo, nullptr, nullptr },
264 : { "altitude", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &altitude_getterinfo, nullptr, nullptr },
265 : { "accuracy", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &accuracy_getterinfo, nullptr, nullptr },
266 : { "altitudeAccuracy", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &altitudeAccuracy_getterinfo, nullptr, nullptr },
267 : { "heading", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &heading_getterinfo, nullptr, nullptr },
268 : { "speed", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &speed_getterinfo, nullptr, nullptr },
269 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
270 : };
271 : #if defined(__clang__)
272 : #pragma clang diagnostic pop
273 : #endif
274 :
275 :
276 : // Can't be const because the pref-enabled boolean needs to be writable
277 : static Prefable<const JSPropertySpec> sAttributes[] = {
278 : { nullptr, &sAttributes_specs[0] },
279 : { nullptr, nullptr }
280 : };
281 :
282 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
283 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
284 : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
285 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
286 :
287 :
288 : static uint16_t sNativeProperties_sortedPropertyIndices[7];
289 : static PropertyInfo sNativeProperties_propertyInfos[7];
290 :
291 : static const NativePropertiesN<1> sNativeProperties = {
292 : false, 0,
293 : false, 0,
294 : false, 0,
295 : true, 0 /* sAttributes */,
296 : false, 0,
297 : false, 0,
298 : false, 0,
299 : -1,
300 : 7,
301 : sNativeProperties_sortedPropertyIndices,
302 : {
303 : { sAttributes, &sNativeProperties_propertyInfos[0] }
304 : }
305 : };
306 : static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
307 : "We have a property info count that is oversized");
308 :
309 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
310 : {
311 : "CoordinatesPrototype",
312 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
313 : JS_NULL_CLASS_OPS,
314 : JS_NULL_CLASS_SPEC,
315 : JS_NULL_CLASS_EXT,
316 : JS_NULL_OBJECT_OPS
317 : },
318 : eInterfacePrototype,
319 : false,
320 : prototypes::id::Coordinates,
321 : PrototypeTraits<prototypes::id::Coordinates>::Depth,
322 : sNativePropertyHooks,
323 : "[object CoordinatesPrototype]",
324 : JS::GetRealmObjectPrototype
325 : };
326 :
327 : static const js::ClassOps sClassOps = {
328 : _addProperty, /* addProperty */
329 : nullptr, /* delProperty */
330 : nullptr, /* getProperty */
331 : nullptr, /* setProperty */
332 : nullptr, /* enumerate */
333 : nullptr, /* newEnumerate */
334 : nullptr, /* resolve */
335 : nullptr, /* mayResolve */
336 : _finalize, /* finalize */
337 : nullptr, /* call */
338 : nullptr, /* hasInstance */
339 : nullptr, /* construct */
340 : nullptr, /* trace */
341 : };
342 :
343 : static const js::ClassExtension sClassExtension = {
344 : nullptr, /* weakmapKeyDelegateOp */
345 : _objectMoved /* objectMovedOp */
346 : };
347 :
348 : static const DOMJSClass sClass = {
349 : { "Coordinates",
350 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
351 : &sClassOps,
352 : JS_NULL_CLASS_SPEC,
353 : &sClassExtension,
354 : JS_NULL_OBJECT_OPS
355 : },
356 : { prototypes::id::Coordinates, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
357 : IsBaseOf<nsISupports, mozilla::dom::Coordinates >::value,
358 : sNativePropertyHooks,
359 : FindAssociatedGlobalForNative<mozilla::dom::Coordinates>::Get,
360 : GetProtoObjectHandle,
361 : GetCCParticipant<mozilla::dom::Coordinates>::Get()
362 : };
363 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
364 : "Must have the right minimal number of reserved slots.");
365 : static_assert(1 >= 1,
366 : "Must have enough reserved slots.");
367 :
368 : const JSClass*
369 0 : GetJSClass()
370 : {
371 0 : return sClass.ToJSClass();
372 : }
373 :
374 : bool
375 0 : Wrap(JSContext* aCx, mozilla::dom::Coordinates* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
376 : {
377 : MOZ_ASSERT(static_cast<mozilla::dom::Coordinates*>(aObject) ==
378 : reinterpret_cast<mozilla::dom::Coordinates*>(aObject),
379 : "Multiple inheritance for mozilla::dom::Coordinates is broken.");
380 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
381 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
382 0 : MOZ_ASSERT(!aCache->GetWrapper(),
383 : "You should probably not be using Wrap() directly; use "
384 : "GetOrCreateDOMReflector instead");
385 :
386 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
387 : "nsISupports must be on our primary inheritance chain");
388 :
389 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
390 0 : if (!global) {
391 0 : return false;
392 : }
393 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
394 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
395 :
396 : // That might have ended up wrapping us already, due to the wonders
397 : // of XBL. Check for that, and bail out as needed.
398 0 : aReflector.set(aCache->GetWrapper());
399 0 : if (aReflector) {
400 : #ifdef DEBUG
401 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
402 : #endif // DEBUG
403 0 : return true;
404 : }
405 :
406 0 : JSAutoCompartment ac(aCx, global);
407 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
408 0 : if (!canonicalProto) {
409 0 : return false;
410 : }
411 0 : JS::Rooted<JSObject*> proto(aCx);
412 0 : if (aGivenProto) {
413 0 : proto = aGivenProto;
414 : // Unfortunately, while aGivenProto was in the compartment of aCx
415 : // coming in, we changed compartments to that of "parent" so may need
416 : // to wrap the proto here.
417 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
418 0 : if (!JS_WrapObject(aCx, &proto)) {
419 0 : return false;
420 : }
421 : }
422 : } else {
423 0 : proto = canonicalProto;
424 : }
425 :
426 0 : BindingJSObjectCreator<mozilla::dom::Coordinates> creator(aCx);
427 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
428 0 : if (!aReflector) {
429 0 : return false;
430 : }
431 :
432 0 : aCache->SetWrapper(aReflector);
433 0 : creator.InitializationSucceeded();
434 :
435 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
436 : aCache->GetWrapperPreserveColor() == aReflector);
437 : // If proto != canonicalProto, we have to preserve our wrapper;
438 : // otherwise we won't be able to properly recreate it later, since
439 : // we won't know what proto to use. Note that we don't check
440 : // aGivenProto here, since it's entirely possible (and even
441 : // somewhat common) to have a non-null aGivenProto which is the
442 : // same as canonicalProto.
443 0 : if (proto != canonicalProto) {
444 0 : PreserveWrapper(aObject);
445 : }
446 :
447 0 : return true;
448 : }
449 :
450 : const NativePropertyHooks sNativePropertyHooks[] = { {
451 : nullptr,
452 : nullptr,
453 : nullptr,
454 : { sNativeProperties.Upcast(), nullptr },
455 : prototypes::id::Coordinates,
456 : constructors::id::_ID_Count,
457 : nullptr,
458 : &DefaultXrayExpandoObjectClass
459 : } };
460 :
461 : void
462 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
463 : {
464 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
465 0 : if (!parentProto) {
466 0 : return;
467 : }
468 :
469 : static bool sIdsInited = false;
470 0 : if (!sIdsInited && NS_IsMainThread()) {
471 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
472 0 : return;
473 : }
474 0 : sIdsInited = true;
475 : }
476 :
477 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Coordinates);
478 0 : JS::Heap<JSObject*>* interfaceCache = nullptr;
479 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
480 : &sPrototypeClass.mBase, protoCache,
481 : nullptr, nullptr, 0, nullptr,
482 : interfaceCache,
483 : sNativeProperties.Upcast(),
484 : nullptr,
485 : nullptr, aDefineOnGlobal,
486 : nullptr,
487 0 : false);
488 : }
489 :
490 : JS::Handle<JSObject*>
491 0 : GetProtoObjectHandle(JSContext* aCx)
492 : {
493 : /* Get the interface prototype object for this class. This will create the
494 : object as needed. */
495 0 : bool aDefineOnGlobal = true;
496 :
497 : /* Make sure our global is sane. Hopefully we can remove this sometime */
498 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
499 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
500 0 : return nullptr;
501 : }
502 :
503 : /* Check to see whether the interface objects are already installed */
504 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
505 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::Coordinates)) {
506 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
507 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
508 : }
509 :
510 : /*
511 : * The object might _still_ be null, but that's OK.
512 : *
513 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
514 : * traced by TraceProtoAndIfaceCache() and its contents are never
515 : * changed after they have been set.
516 : *
517 : * Calling address() avoids the read read barrier that does gray
518 : * unmarking, but it's not possible for the object to be gray here.
519 : */
520 :
521 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::Coordinates);
522 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
523 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
524 : }
525 :
526 : } // namespace CoordinatesBinding
527 :
528 :
529 :
530 : } // namespace dom
531 : } // namespace mozilla
|