LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - HTMLMapElementBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 168 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13