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

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

Generated by: LCOV version 1.13