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

Generated by: LCOV version 1.13