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