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