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