Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM SVGRect.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "SVGRectBinding.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/PrimitiveConversions.h"
11 : #include "mozilla/dom/SVGIRect.h"
12 : #include "mozilla/dom/XrayExpandoClass.h"
13 : #include "nsISupports.h"
14 : #include "xpcjsid.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : namespace SVGRectBinding {
20 :
21 : static bool
22 0 : get_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitGetterCallArgs args)
23 : {
24 0 : float result(self->X());
25 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
26 0 : args.rval().set(JS_NumberValue(double(result)));
27 0 : return true;
28 : }
29 :
30 : static bool
31 0 : set_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitSetterCallArgs args)
32 : {
33 : float arg0;
34 0 : if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
35 0 : return false;
36 0 : } else if (!mozilla::IsFinite(arg0)) {
37 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGRect.x");
38 0 : return false;
39 : }
40 0 : binding_detail::FastErrorResult rv;
41 0 : self->SetX(arg0, rv);
42 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
43 0 : return false;
44 : }
45 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
46 :
47 0 : return true;
48 : }
49 :
50 : static const JSJitInfo x_getterinfo = {
51 : { (JSJitGetterOp)get_x },
52 : { prototypes::id::SVGRect },
53 : { PrototypeTraits<prototypes::id::SVGRect>::Depth },
54 : JSJitInfo::Getter,
55 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
56 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
57 : true, /* isInfallible. False in setters. */
58 : false, /* isMovable. Not relevant for setters. */
59 : false, /* isEliminatable. Not relevant for setters. */
60 : false, /* isAlwaysInSlot. Only relevant for getters. */
61 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
62 : false, /* isTypedMethod. Only relevant for methods. */
63 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
64 : };
65 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
66 : static_assert(0 < 1, "There is no slot for us");
67 : static const JSJitInfo x_setterinfo = {
68 : { (JSJitGetterOp)set_x },
69 : { prototypes::id::SVGRect },
70 : { PrototypeTraits<prototypes::id::SVGRect>::Depth },
71 : JSJitInfo::Setter,
72 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
73 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
74 : false, /* isInfallible. False in setters. */
75 : false, /* isMovable. Not relevant for setters. */
76 : false, /* isEliminatable. Not relevant for setters. */
77 : false, /* isAlwaysInSlot. Only relevant for getters. */
78 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
79 : false, /* isTypedMethod. Only relevant for methods. */
80 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
81 : };
82 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
83 : static_assert(0 < 1, "There is no slot for us");
84 :
85 : static bool
86 0 : get_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitGetterCallArgs args)
87 : {
88 0 : float result(self->Y());
89 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
90 0 : args.rval().set(JS_NumberValue(double(result)));
91 0 : return true;
92 : }
93 :
94 : static bool
95 0 : set_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitSetterCallArgs args)
96 : {
97 : float arg0;
98 0 : if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
99 0 : return false;
100 0 : } else if (!mozilla::IsFinite(arg0)) {
101 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGRect.y");
102 0 : return false;
103 : }
104 0 : binding_detail::FastErrorResult rv;
105 0 : self->SetY(arg0, rv);
106 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
107 0 : return false;
108 : }
109 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
110 :
111 0 : return true;
112 : }
113 :
114 : static const JSJitInfo y_getterinfo = {
115 : { (JSJitGetterOp)get_y },
116 : { prototypes::id::SVGRect },
117 : { PrototypeTraits<prototypes::id::SVGRect>::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 : static const JSJitInfo y_setterinfo = {
132 : { (JSJitGetterOp)set_y },
133 : { prototypes::id::SVGRect },
134 : { PrototypeTraits<prototypes::id::SVGRect>::Depth },
135 : JSJitInfo::Setter,
136 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
137 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
138 : false, /* isInfallible. False in setters. */
139 : false, /* isMovable. Not relevant for setters. */
140 : false, /* isEliminatable. Not relevant for setters. */
141 : false, /* isAlwaysInSlot. Only relevant for getters. */
142 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
143 : false, /* isTypedMethod. Only relevant for methods. */
144 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
145 : };
146 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
147 : static_assert(0 < 1, "There is no slot for us");
148 :
149 : static bool
150 0 : get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitGetterCallArgs args)
151 : {
152 0 : float result(self->Width());
153 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
154 0 : args.rval().set(JS_NumberValue(double(result)));
155 0 : return true;
156 : }
157 :
158 : static bool
159 0 : set_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitSetterCallArgs args)
160 : {
161 : float arg0;
162 0 : if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
163 0 : return false;
164 0 : } else if (!mozilla::IsFinite(arg0)) {
165 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGRect.width");
166 0 : return false;
167 : }
168 0 : binding_detail::FastErrorResult rv;
169 0 : self->SetWidth(arg0, rv);
170 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
171 0 : return false;
172 : }
173 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
174 :
175 0 : return true;
176 : }
177 :
178 : static const JSJitInfo width_getterinfo = {
179 : { (JSJitGetterOp)get_width },
180 : { prototypes::id::SVGRect },
181 : { PrototypeTraits<prototypes::id::SVGRect>::Depth },
182 : JSJitInfo::Getter,
183 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
184 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
185 : true, /* isInfallible. False in setters. */
186 : false, /* isMovable. Not relevant for setters. */
187 : false, /* isEliminatable. Not relevant for setters. */
188 : false, /* isAlwaysInSlot. Only relevant for getters. */
189 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
190 : false, /* isTypedMethod. Only relevant for methods. */
191 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
192 : };
193 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
194 : static_assert(0 < 1, "There is no slot for us");
195 : static const JSJitInfo width_setterinfo = {
196 : { (JSJitGetterOp)set_width },
197 : { prototypes::id::SVGRect },
198 : { PrototypeTraits<prototypes::id::SVGRect>::Depth },
199 : JSJitInfo::Setter,
200 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
201 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
202 : false, /* isInfallible. False in setters. */
203 : false, /* isMovable. Not relevant for setters. */
204 : false, /* isEliminatable. Not relevant for setters. */
205 : false, /* isAlwaysInSlot. Only relevant for getters. */
206 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
207 : false, /* isTypedMethod. Only relevant for methods. */
208 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
209 : };
210 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
211 : static_assert(0 < 1, "There is no slot for us");
212 :
213 : static bool
214 0 : get_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitGetterCallArgs args)
215 : {
216 0 : float result(self->Height());
217 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
218 0 : args.rval().set(JS_NumberValue(double(result)));
219 0 : return true;
220 : }
221 :
222 : static bool
223 0 : set_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitSetterCallArgs args)
224 : {
225 : float arg0;
226 0 : if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
227 0 : return false;
228 0 : } else if (!mozilla::IsFinite(arg0)) {
229 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGRect.height");
230 0 : return false;
231 : }
232 0 : binding_detail::FastErrorResult rv;
233 0 : self->SetHeight(arg0, rv);
234 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
235 0 : return false;
236 : }
237 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
238 :
239 0 : return true;
240 : }
241 :
242 : static const JSJitInfo height_getterinfo = {
243 : { (JSJitGetterOp)get_height },
244 : { prototypes::id::SVGRect },
245 : { PrototypeTraits<prototypes::id::SVGRect>::Depth },
246 : JSJitInfo::Getter,
247 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
248 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
249 : true, /* isInfallible. False in setters. */
250 : false, /* isMovable. Not relevant for setters. */
251 : false, /* isEliminatable. Not relevant for setters. */
252 : false, /* isAlwaysInSlot. Only relevant for getters. */
253 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
254 : false, /* isTypedMethod. Only relevant for methods. */
255 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
256 : };
257 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
258 : static_assert(0 < 1, "There is no slot for us");
259 : static const JSJitInfo height_setterinfo = {
260 : { (JSJitGetterOp)set_height },
261 : { prototypes::id::SVGRect },
262 : { PrototypeTraits<prototypes::id::SVGRect>::Depth },
263 : JSJitInfo::Setter,
264 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
265 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
266 : false, /* isInfallible. False in setters. */
267 : false, /* isMovable. Not relevant for setters. */
268 : false, /* isEliminatable. Not relevant for setters. */
269 : false, /* isAlwaysInSlot. Only relevant for getters. */
270 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
271 : false, /* isTypedMethod. Only relevant for methods. */
272 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
273 : };
274 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
275 : static_assert(0 < 1, "There is no slot for us");
276 :
277 : static bool
278 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
279 : {
280 0 : mozilla::dom::SVGIRect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGIRect>(obj);
281 : // We don't want to preserve if we don't have a wrapper, and we
282 : // obviously can't preserve if we're not initialized.
283 0 : if (self && self->GetWrapperPreserveColor()) {
284 0 : PreserveWrapper(self);
285 : }
286 0 : return true;
287 : }
288 :
289 : static void
290 0 : _finalize(js::FreeOp* fop, JSObject* obj)
291 : {
292 0 : mozilla::dom::SVGIRect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGIRect>(obj);
293 0 : if (self) {
294 0 : ClearWrapper(self, self, obj);
295 0 : AddForDeferredFinalization<mozilla::dom::SVGIRect>(self);
296 : }
297 0 : }
298 :
299 : static void
300 0 : _objectMoved(JSObject* obj, const JSObject* old)
301 : {
302 0 : mozilla::dom::SVGIRect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGIRect>(obj);
303 0 : if (self) {
304 0 : UpdateWrapper(self, self, obj, old);
305 : }
306 0 : }
307 :
308 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
309 : #if defined(__clang__)
310 : #pragma clang diagnostic push
311 : #pragma clang diagnostic ignored "-Wmissing-braces"
312 : #endif
313 : static const JSFunctionSpec sMethods_specs[] = {
314 : JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
315 : JS_FS_END
316 : };
317 : #if defined(__clang__)
318 : #pragma clang diagnostic pop
319 : #endif
320 :
321 : static PrefableDisablers sMethods_disablers0 = {
322 : true, false, 0, &WantsQueryInterface<mozilla::dom::SVGIRect>::Enabled
323 : };
324 :
325 : // Can't be const because the pref-enabled boolean needs to be writable
326 : static Prefable<const JSFunctionSpec> sMethods[] = {
327 : { &sMethods_disablers0, &sMethods_specs[0] },
328 : { nullptr, nullptr }
329 : };
330 :
331 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
332 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
333 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
334 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
335 :
336 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
337 : #if defined(__clang__)
338 : #pragma clang diagnostic push
339 : #pragma clang diagnostic ignored "-Wmissing-braces"
340 : #endif
341 : static const JSPropertySpec sAttributes_specs[] = {
342 : { "x", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &x_getterinfo, GenericBindingSetter, &x_setterinfo },
343 : { "y", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &y_getterinfo, GenericBindingSetter, &y_setterinfo },
344 : { "width", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &width_getterinfo, GenericBindingSetter, &width_setterinfo },
345 : { "height", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &height_getterinfo, GenericBindingSetter, &height_setterinfo },
346 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
347 : };
348 : #if defined(__clang__)
349 : #pragma clang diagnostic pop
350 : #endif
351 :
352 :
353 : // Can't be const because the pref-enabled boolean needs to be writable
354 : static Prefable<const JSPropertySpec> sAttributes[] = {
355 : { nullptr, &sAttributes_specs[0] },
356 : { nullptr, nullptr }
357 : };
358 :
359 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
360 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
361 : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
362 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
363 :
364 :
365 : static uint16_t sNativeProperties_sortedPropertyIndices[5];
366 : static PropertyInfo sNativeProperties_propertyInfos[5];
367 :
368 : static const NativePropertiesN<2> sNativeProperties = {
369 : false, 0,
370 : false, 0,
371 : true, 0 /* sMethods */,
372 : true, 1 /* sAttributes */,
373 : false, 0,
374 : false, 0,
375 : false, 0,
376 : -1,
377 : 5,
378 : sNativeProperties_sortedPropertyIndices,
379 : {
380 : { sMethods, &sNativeProperties_propertyInfos[0] },
381 : { sAttributes, &sNativeProperties_propertyInfos[1] }
382 : }
383 : };
384 : static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
385 : "We have a property info count that is oversized");
386 :
387 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
388 : {
389 : "Function",
390 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
391 : &sBoringInterfaceObjectClassClassOps,
392 : JS_NULL_CLASS_SPEC,
393 : JS_NULL_CLASS_EXT,
394 : &sInterfaceObjectClassObjectOps
395 : },
396 : eInterface,
397 : true,
398 : prototypes::id::SVGRect,
399 : PrototypeTraits<prototypes::id::SVGRect>::Depth,
400 : sNativePropertyHooks,
401 : "function SVGRect() {\n [native code]\n}",
402 : JS::GetRealmFunctionPrototype
403 : };
404 :
405 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
406 : {
407 : "SVGRectPrototype",
408 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
409 : JS_NULL_CLASS_OPS,
410 : JS_NULL_CLASS_SPEC,
411 : JS_NULL_CLASS_EXT,
412 : JS_NULL_OBJECT_OPS
413 : },
414 : eInterfacePrototype,
415 : false,
416 : prototypes::id::SVGRect,
417 : PrototypeTraits<prototypes::id::SVGRect>::Depth,
418 : sNativePropertyHooks,
419 : "[object SVGRectPrototype]",
420 : JS::GetRealmObjectPrototype
421 : };
422 :
423 : JSObject*
424 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
425 : {
426 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
427 : }
428 :
429 : static const js::ClassOps sClassOps = {
430 : _addProperty, /* addProperty */
431 : nullptr, /* delProperty */
432 : nullptr, /* getProperty */
433 : nullptr, /* setProperty */
434 : nullptr, /* enumerate */
435 : nullptr, /* newEnumerate */
436 : nullptr, /* resolve */
437 : nullptr, /* mayResolve */
438 : _finalize, /* finalize */
439 : nullptr, /* call */
440 : nullptr, /* hasInstance */
441 : nullptr, /* construct */
442 : nullptr, /* trace */
443 : };
444 :
445 : static const js::ClassExtension sClassExtension = {
446 : nullptr, /* weakmapKeyDelegateOp */
447 : _objectMoved /* objectMovedOp */
448 : };
449 :
450 : static const DOMJSClass sClass = {
451 : { "SVGRect",
452 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
453 : &sClassOps,
454 : JS_NULL_CLASS_SPEC,
455 : &sClassExtension,
456 : JS_NULL_OBJECT_OPS
457 : },
458 : { prototypes::id::SVGRect, 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 },
459 : IsBaseOf<nsISupports, mozilla::dom::SVGIRect >::value,
460 : sNativePropertyHooks,
461 : FindAssociatedGlobalForNative<mozilla::dom::SVGIRect>::Get,
462 : GetProtoObjectHandle,
463 : GetCCParticipant<mozilla::dom::SVGIRect>::Get()
464 : };
465 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
466 : "Must have the right minimal number of reserved slots.");
467 : static_assert(1 >= 1,
468 : "Must have enough reserved slots.");
469 :
470 : const JSClass*
471 0 : GetJSClass()
472 : {
473 0 : return sClass.ToJSClass();
474 : }
475 :
476 : bool
477 0 : Wrap(JSContext* aCx, mozilla::dom::SVGIRect* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
478 : {
479 : MOZ_ASSERT(static_cast<mozilla::dom::SVGIRect*>(aObject) ==
480 : reinterpret_cast<mozilla::dom::SVGIRect*>(aObject),
481 : "Multiple inheritance for mozilla::dom::SVGIRect is broken.");
482 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
483 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
484 0 : MOZ_ASSERT(!aCache->GetWrapper(),
485 : "You should probably not be using Wrap() directly; use "
486 : "GetOrCreateDOMReflector instead");
487 :
488 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
489 : "nsISupports must be on our primary inheritance chain");
490 :
491 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
492 0 : if (!global) {
493 0 : return false;
494 : }
495 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
496 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
497 :
498 : // That might have ended up wrapping us already, due to the wonders
499 : // of XBL. Check for that, and bail out as needed.
500 0 : aReflector.set(aCache->GetWrapper());
501 0 : if (aReflector) {
502 : #ifdef DEBUG
503 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
504 : #endif // DEBUG
505 0 : return true;
506 : }
507 :
508 0 : JSAutoCompartment ac(aCx, global);
509 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
510 0 : if (!canonicalProto) {
511 0 : return false;
512 : }
513 0 : JS::Rooted<JSObject*> proto(aCx);
514 0 : if (aGivenProto) {
515 0 : proto = aGivenProto;
516 : // Unfortunately, while aGivenProto was in the compartment of aCx
517 : // coming in, we changed compartments to that of "parent" so may need
518 : // to wrap the proto here.
519 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
520 0 : if (!JS_WrapObject(aCx, &proto)) {
521 0 : return false;
522 : }
523 : }
524 : } else {
525 0 : proto = canonicalProto;
526 : }
527 :
528 0 : BindingJSObjectCreator<mozilla::dom::SVGIRect> creator(aCx);
529 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
530 0 : if (!aReflector) {
531 0 : return false;
532 : }
533 :
534 0 : aCache->SetWrapper(aReflector);
535 0 : creator.InitializationSucceeded();
536 :
537 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
538 : aCache->GetWrapperPreserveColor() == aReflector);
539 : // If proto != canonicalProto, we have to preserve our wrapper;
540 : // otherwise we won't be able to properly recreate it later, since
541 : // we won't know what proto to use. Note that we don't check
542 : // aGivenProto here, since it's entirely possible (and even
543 : // somewhat common) to have a non-null aGivenProto which is the
544 : // same as canonicalProto.
545 0 : if (proto != canonicalProto) {
546 0 : PreserveWrapper(aObject);
547 : }
548 :
549 0 : return true;
550 : }
551 :
552 : const NativePropertyHooks sNativePropertyHooks[] = { {
553 : nullptr,
554 : nullptr,
555 : nullptr,
556 : { sNativeProperties.Upcast(), nullptr },
557 : prototypes::id::SVGRect,
558 : constructors::id::SVGRect,
559 : nullptr,
560 : &DefaultXrayExpandoObjectClass
561 : } };
562 :
563 : void
564 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
565 : {
566 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
567 0 : if (!parentProto) {
568 0 : return;
569 : }
570 :
571 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
572 0 : if (!constructorProto) {
573 0 : return;
574 : }
575 :
576 : static bool sIdsInited = false;
577 0 : if (!sIdsInited && NS_IsMainThread()) {
578 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
579 0 : return;
580 : }
581 0 : sIdsInited = true;
582 : }
583 :
584 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGRect);
585 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGRect);
586 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
587 : &sPrototypeClass.mBase, protoCache,
588 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
589 : interfaceCache,
590 : sNativeProperties.Upcast(),
591 : nullptr,
592 : "SVGRect", aDefineOnGlobal,
593 : nullptr,
594 0 : false);
595 : }
596 :
597 : JS::Handle<JSObject*>
598 0 : GetProtoObjectHandle(JSContext* aCx)
599 : {
600 : /* Get the interface prototype object for this class. This will create the
601 : object as needed. */
602 0 : bool aDefineOnGlobal = true;
603 :
604 : /* Make sure our global is sane. Hopefully we can remove this sometime */
605 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
606 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
607 0 : return nullptr;
608 : }
609 :
610 : /* Check to see whether the interface objects are already installed */
611 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
612 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::SVGRect)) {
613 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
614 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
615 : }
616 :
617 : /*
618 : * The object might _still_ be null, but that's OK.
619 : *
620 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
621 : * traced by TraceProtoAndIfaceCache() and its contents are never
622 : * changed after they have been set.
623 : *
624 : * Calling address() avoids the read read barrier that does gray
625 : * unmarking, but it's not possible for the object to be gray here.
626 : */
627 :
628 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::SVGRect);
629 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
630 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
631 : }
632 :
633 : JS::Handle<JSObject*>
634 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
635 : {
636 : /* Get the interface object for this class. This will create the object as
637 : needed. */
638 :
639 : /* Make sure our global is sane. Hopefully we can remove this sometime */
640 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
641 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
642 0 : return nullptr;
643 : }
644 :
645 : /* Check to see whether the interface objects are already installed */
646 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
647 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::SVGRect)) {
648 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
649 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
650 : }
651 :
652 : /*
653 : * The object might _still_ be null, but that's OK.
654 : *
655 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
656 : * traced by TraceProtoAndIfaceCache() and its contents are never
657 : * changed after they have been set.
658 : *
659 : * Calling address() avoids the read read barrier that does gray
660 : * unmarking, but it's not possible for the object to be gray here.
661 : */
662 :
663 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::SVGRect);
664 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
665 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
666 : }
667 :
668 : JSObject*
669 0 : GetConstructorObject(JSContext* aCx)
670 : {
671 0 : return GetConstructorObjectHandle(aCx);
672 : }
673 :
674 : } // namespace SVGRectBinding
675 :
676 :
677 :
678 : } // namespace dom
679 : } // namespace mozilla
|