LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - TextEncoderBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 24 130 18.5 %
Date: 2017-07-14 16:53:18 Functions: 3 11 27.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13