LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - ImageBitmapRenderingContextBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 22 126 17.5 %
Date: 2017-07-14 16:53:18 Functions: 3 12 25.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13