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