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