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