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