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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM HTMLHRElement.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "HTMLElementBinding.h"
       4             : #include "HTMLHRElementBinding.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/HTMLHRElement.h"
      11             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      12             : #include "mozilla/dom/PrimitiveConversions.h"
      13             : #include "mozilla/dom/XrayExpandoClass.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18             : namespace HTMLHRElementBinding {
      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_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitGetterCallArgs args)
      25             : {
      26           0 :   DOMString result;
      27           0 :   self->GetAlign(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_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* 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->SetAlign(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 align_getterinfo = {
      58             :   { (JSJitGetterOp)get_align },
      59             :   { prototypes::id::HTMLHRElement },
      60             :   { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth },
      61             :   JSJitInfo::Getter,
      62             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      63             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      64             :   false,  /* isInfallible. False in setters. */
      65             :   false,  /* isMovable.  Not relevant for setters. */
      66             :   false, /* 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 align_setterinfo = {
      75             :   { (JSJitGetterOp)set_align },
      76             :   { prototypes::id::HTMLHRElement },
      77             :   { PrototypeTraits<prototypes::id::HTMLHRElement>::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_color(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitGetterCallArgs args)
      94             : {
      95           0 :   DOMString result;
      96           0 :   self->GetColor(result);
      97           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      98           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      99           0 :     return false;
     100             :   }
     101           0 :   return true;
     102             : }
     103             : 
     104             : static bool
     105           0 : set_color(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitSetterCallArgs args)
     106             : {
     107           0 :   binding_detail::FakeString arg0;
     108           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     109           0 :     return false;
     110             :   }
     111           0 :   CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
     112           0 :   Maybe<AutoCEReaction> ceReaction;
     113           0 :   if (reactionsStack) {
     114           0 :     ceReaction.emplace(reactionsStack);
     115             :   }
     116           0 :   binding_detail::FastErrorResult rv;
     117           0 :   self->SetColor(NonNullHelper(Constify(arg0)), rv);
     118           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     119           0 :     return false;
     120             :   }
     121           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     122             : 
     123           0 :   return true;
     124             : }
     125             : 
     126             : static const JSJitInfo color_getterinfo = {
     127             :   { (JSJitGetterOp)get_color },
     128             :   { prototypes::id::HTMLHRElement },
     129             :   { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth },
     130             :   JSJitInfo::Getter,
     131             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     132             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     133             :   false,  /* isInfallible. False in setters. */
     134             :   false,  /* isMovable.  Not relevant for setters. */
     135             :   false, /* isEliminatable.  Not relevant for setters. */
     136             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     137             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     138             :   false,  /* isTypedMethod.  Only relevant for methods. */
     139             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     140             : };
     141             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     142             : static_assert(0 < 1, "There is no slot for us");
     143             : static const JSJitInfo color_setterinfo = {
     144             :   { (JSJitGetterOp)set_color },
     145             :   { prototypes::id::HTMLHRElement },
     146             :   { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth },
     147             :   JSJitInfo::Setter,
     148             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     149             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     150             :   false,  /* isInfallible. False in setters. */
     151             :   false,  /* isMovable.  Not relevant for setters. */
     152             :   false, /* isEliminatable.  Not relevant for setters. */
     153             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     154             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     155             :   false,  /* isTypedMethod.  Only relevant for methods. */
     156             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     157             : };
     158             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     159             : static_assert(0 < 1, "There is no slot for us");
     160             : 
     161             : static bool
     162           0 : get_noShade(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitGetterCallArgs args)
     163             : {
     164           0 :   bool result(self->NoShade());
     165           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     166           0 :   args.rval().setBoolean(result);
     167           0 :   return true;
     168             : }
     169             : 
     170             : static bool
     171           0 : set_noShade(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitSetterCallArgs args)
     172             : {
     173             :   bool arg0;
     174           0 :   if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
     175           0 :     return false;
     176             :   }
     177           0 :   CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
     178           0 :   Maybe<AutoCEReaction> ceReaction;
     179           0 :   if (reactionsStack) {
     180           0 :     ceReaction.emplace(reactionsStack);
     181             :   }
     182           0 :   binding_detail::FastErrorResult rv;
     183           0 :   self->SetNoShade(arg0, rv);
     184           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     185           0 :     return false;
     186             :   }
     187           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     188             : 
     189           0 :   return true;
     190             : }
     191             : 
     192             : static const JSJitInfo noShade_getterinfo = {
     193             :   { (JSJitGetterOp)get_noShade },
     194             :   { prototypes::id::HTMLHRElement },
     195             :   { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth },
     196             :   JSJitInfo::Getter,
     197             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     198             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     199             :   true,  /* isInfallible. False in setters. */
     200             :   false,  /* isMovable.  Not relevant for setters. */
     201             :   false, /* isEliminatable.  Not relevant for setters. */
     202             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     203             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     204             :   false,  /* isTypedMethod.  Only relevant for methods. */
     205             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     206             : };
     207             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     208             : static_assert(0 < 1, "There is no slot for us");
     209             : static const JSJitInfo noShade_setterinfo = {
     210             :   { (JSJitGetterOp)set_noShade },
     211             :   { prototypes::id::HTMLHRElement },
     212             :   { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth },
     213             :   JSJitInfo::Setter,
     214             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     215             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     216             :   false,  /* isInfallible. False in setters. */
     217             :   false,  /* isMovable.  Not relevant for setters. */
     218             :   false, /* isEliminatable.  Not relevant for setters. */
     219             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     220             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     221             :   false,  /* isTypedMethod.  Only relevant for methods. */
     222             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     223             : };
     224             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     225             : static_assert(0 < 1, "There is no slot for us");
     226             : 
     227             : static bool
     228           0 : get_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitGetterCallArgs args)
     229             : {
     230           0 :   DOMString result;
     231           0 :   self->GetSize(result);
     232           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     233           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     234           0 :     return false;
     235             :   }
     236           0 :   return true;
     237             : }
     238             : 
     239             : static bool
     240           0 : set_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitSetterCallArgs args)
     241             : {
     242           0 :   binding_detail::FakeString arg0;
     243           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     244           0 :     return false;
     245             :   }
     246           0 :   CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
     247           0 :   Maybe<AutoCEReaction> ceReaction;
     248           0 :   if (reactionsStack) {
     249           0 :     ceReaction.emplace(reactionsStack);
     250             :   }
     251           0 :   binding_detail::FastErrorResult rv;
     252           0 :   self->SetSize(NonNullHelper(Constify(arg0)), rv);
     253           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     254           0 :     return false;
     255             :   }
     256           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     257             : 
     258           0 :   return true;
     259             : }
     260             : 
     261             : static const JSJitInfo size_getterinfo = {
     262             :   { (JSJitGetterOp)get_size },
     263             :   { prototypes::id::HTMLHRElement },
     264             :   { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth },
     265             :   JSJitInfo::Getter,
     266             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     267             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     268             :   false,  /* isInfallible. False in setters. */
     269             :   false,  /* isMovable.  Not relevant for setters. */
     270             :   false, /* isEliminatable.  Not relevant for setters. */
     271             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     272             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     273             :   false,  /* isTypedMethod.  Only relevant for methods. */
     274             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     275             : };
     276             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     277             : static_assert(0 < 1, "There is no slot for us");
     278             : static const JSJitInfo size_setterinfo = {
     279             :   { (JSJitGetterOp)set_size },
     280             :   { prototypes::id::HTMLHRElement },
     281             :   { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth },
     282             :   JSJitInfo::Setter,
     283             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     284             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     285             :   false,  /* isInfallible. False in setters. */
     286             :   false,  /* isMovable.  Not relevant for setters. */
     287             :   false, /* isEliminatable.  Not relevant for setters. */
     288             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     289             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     290             :   false,  /* isTypedMethod.  Only relevant for methods. */
     291             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     292             : };
     293             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     294             : static_assert(0 < 1, "There is no slot for us");
     295             : 
     296             : static bool
     297           0 : get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitGetterCallArgs args)
     298             : {
     299           0 :   DOMString result;
     300           0 :   self->GetWidth(result);
     301           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     302           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     303           0 :     return false;
     304             :   }
     305           0 :   return true;
     306             : }
     307             : 
     308             : static bool
     309           0 : set_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitSetterCallArgs args)
     310             : {
     311           0 :   binding_detail::FakeString arg0;
     312           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     313           0 :     return false;
     314             :   }
     315           0 :   CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
     316           0 :   Maybe<AutoCEReaction> ceReaction;
     317           0 :   if (reactionsStack) {
     318           0 :     ceReaction.emplace(reactionsStack);
     319             :   }
     320           0 :   binding_detail::FastErrorResult rv;
     321           0 :   self->SetWidth(NonNullHelper(Constify(arg0)), rv);
     322           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     323           0 :     return false;
     324             :   }
     325           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     326             : 
     327           0 :   return true;
     328             : }
     329             : 
     330             : static const JSJitInfo width_getterinfo = {
     331             :   { (JSJitGetterOp)get_width },
     332             :   { prototypes::id::HTMLHRElement },
     333             :   { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth },
     334             :   JSJitInfo::Getter,
     335             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     336             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     337             :   false,  /* isInfallible. False in setters. */
     338             :   false,  /* isMovable.  Not relevant for setters. */
     339             :   false, /* isEliminatable.  Not relevant for setters. */
     340             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     341             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     342             :   false,  /* isTypedMethod.  Only relevant for methods. */
     343             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     344             : };
     345             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     346             : static_assert(0 < 1, "There is no slot for us");
     347             : static const JSJitInfo width_setterinfo = {
     348             :   { (JSJitGetterOp)set_width },
     349             :   { prototypes::id::HTMLHRElement },
     350             :   { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth },
     351             :   JSJitInfo::Setter,
     352             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     353             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     354             :   false,  /* isInfallible. False in setters. */
     355             :   false,  /* isMovable.  Not relevant for setters. */
     356             :   false, /* isEliminatable.  Not relevant for setters. */
     357             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     358             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     359             :   false,  /* isTypedMethod.  Only relevant for methods. */
     360             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     361             : };
     362             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     363             : static_assert(0 < 1, "There is no slot for us");
     364             : 
     365             : static bool
     366           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     367             : {
     368           0 :   mozilla::dom::HTMLHRElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLHRElement>(obj);
     369             :   // We don't want to preserve if we don't have a wrapper, and we
     370             :   // obviously can't preserve if we're not initialized.
     371           0 :   if (self && self->GetWrapperPreserveColor()) {
     372           0 :     PreserveWrapper(self);
     373             :   }
     374           0 :   return true;
     375             : }
     376             : 
     377             : static void
     378           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     379             : {
     380           0 :   mozilla::dom::HTMLHRElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLHRElement>(obj);
     381           0 :   if (self) {
     382           0 :     ClearWrapper(self, self, obj);
     383           0 :     AddForDeferredFinalization<mozilla::dom::HTMLHRElement>(self);
     384             :   }
     385           0 : }
     386             : 
     387             : static void
     388           0 : _objectMoved(JSObject* obj, const JSObject* old)
     389             : {
     390           0 :   mozilla::dom::HTMLHRElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLHRElement>(obj);
     391           0 :   if (self) {
     392           0 :     UpdateWrapper(self, self, obj, old);
     393             :   }
     394           0 : }
     395             : 
     396             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     397             : #if defined(__clang__)
     398             : #pragma clang diagnostic push
     399             : #pragma clang diagnostic ignored "-Wmissing-braces"
     400             : #endif
     401             : static const JSPropertySpec sAttributes_specs[] = {
     402             :   { "align", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &align_getterinfo, GenericBindingSetter, &align_setterinfo },
     403             :   { "color", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &color_getterinfo, GenericBindingSetter, &color_setterinfo },
     404             :   { "noShade", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &noShade_getterinfo, GenericBindingSetter, &noShade_setterinfo },
     405             :   { "size", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &size_getterinfo, GenericBindingSetter, &size_setterinfo },
     406             :   { "width", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &width_getterinfo, GenericBindingSetter, &width_setterinfo },
     407             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     408             : };
     409             : #if defined(__clang__)
     410             : #pragma clang diagnostic pop
     411             : #endif
     412             : 
     413             : 
     414             : // Can't be const because the pref-enabled boolean needs to be writable
     415             : static Prefable<const JSPropertySpec> sAttributes[] = {
     416             :   { nullptr, &sAttributes_specs[0] },
     417             :   { nullptr, nullptr }
     418             : };
     419             : 
     420             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     421             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     422             : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     423             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     424             : 
     425             : 
     426             : static uint16_t sNativeProperties_sortedPropertyIndices[5];
     427             : static PropertyInfo sNativeProperties_propertyInfos[5];
     428             : 
     429             : static const NativePropertiesN<1> sNativeProperties = {
     430             :   false, 0,
     431             :   false, 0,
     432             :   false, 0,
     433             :   true,  0 /* sAttributes */,
     434             :   false, 0,
     435             :   false, 0,
     436             :   false, 0,
     437             :   -1,
     438             :   5,
     439             :   sNativeProperties_sortedPropertyIndices,
     440             :   {
     441             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
     442             :   }
     443             : };
     444             : static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     445             :     "We have a property info count that is oversized");
     446             : 
     447             : static bool
     448           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     449             : {
     450           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     451           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     452           0 :   if (!args.isConstructing()) {
     453             :     // XXXbz wish I could get the name from the callee instead of
     454             :     // Adding more relocations
     455           0 :     return ThrowConstructorWithoutNew(cx, "HTMLHRElement");
     456             :   }
     457             : 
     458           0 :   GlobalObject global(cx, obj);
     459           0 :   if (global.Failed()) {
     460           0 :     return false;
     461             :   }
     462             : 
     463             :   // The newTarget might be a cross-compartment wrapper. Get the underlying object
     464             :   // so we can do the spec's object-identity checks.
     465           0 :   JS::Rooted<JSObject*> newTarget(cx, js::CheckedUnwrap(&args.newTarget().toObject()));
     466           0 :   if (!newTarget) {
     467           0 :     return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
     468             :   }
     469             : 
     470             :   // Step 2 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
     471             :   // Enter the compartment of our underlying newTarget object, so we end
     472             :   // up comparing to the constructor object for our interface from that global.
     473             :   {
     474           0 :     JSAutoCompartment ac(cx, newTarget);
     475           0 :     JS::Handle<JSObject*> constructor(GetConstructorObjectHandle(cx));
     476           0 :     if (!constructor) {
     477           0 :       return false;
     478             :     }
     479           0 :     if (newTarget == constructor) {
     480           0 :       return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
     481             :     }
     482             :   }
     483             : 
     484           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     485           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     486           0 :     return false;
     487             :   }
     488           0 :   if (!desiredProto) {
     489             :     // Step 7 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
     490             :     // This fallback behavior is designed to match analogous behavior for the
     491             :     // JavaScript built-ins. So we enter the compartment of our underlying
     492             :     // newTarget object and fall back to the prototype object from that global.
     493             :     // XXX The spec says to use GetFunctionRealm(), which is not actually
     494             :     // the same thing as what we have here (e.g. in the case of scripted callable proxies
     495             :     // whose target is not same-compartment with the proxy, or bound functions, etc).
     496             :     // https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
     497             :     {
     498           0 :       JSAutoCompartment ac(cx, newTarget);
     499           0 :       desiredProto = GetProtoObjectHandle(cx);
     500           0 :       if (!desiredProto) {
     501           0 :           return false;
     502             :       }
     503             :     }
     504             : 
     505             :     // desiredProto is in the compartment of the underlying newTarget object.
     506             :     // Wrap it into the context compartment.
     507           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     508           0 :       return false;
     509             :     }
     510             :   }
     511             : 
     512           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     513           0 :   Maybe<JSAutoCompartment> ac;
     514           0 :   if (objIsXray) {
     515           0 :     obj = js::CheckedUnwrap(obj);
     516           0 :     if (!obj) {
     517           0 :       return false;
     518             :     }
     519           0 :     ac.emplace(cx, obj);
     520           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     521           0 :       return false;
     522             :     }
     523             :   }
     524           0 :   binding_detail::FastErrorResult rv;
     525           0 :   auto result(StrongOrRawPtr<mozilla::dom::HTMLHRElement>(CreateHTMLElement(global, args, rv)));
     526           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     527           0 :     return false;
     528             :   }
     529           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     530             :   static_assert(!IsPointer<decltype(result)>::value,
     531             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     532           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     533           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     534           0 :     return false;
     535             :   }
     536           0 :   return true;
     537             : }
     538             : 
     539             : static const js::ClassOps sInterfaceObjectClassOps = {
     540             :     nullptr,               /* addProperty */
     541             :     nullptr,               /* delProperty */
     542             :     nullptr,               /* getProperty */
     543             :     nullptr,               /* setProperty */
     544             :     nullptr,               /* enumerate */
     545             :     nullptr,               /* newEnumerate */
     546             :     nullptr,               /* resolve */
     547             :     nullptr,               /* mayResolve */
     548             :     nullptr,               /* finalize */
     549             :     _constructor, /* call */
     550             :     nullptr,               /* hasInstance */
     551             :     _constructor, /* construct */
     552             :     nullptr,               /* trace */
     553             : };
     554             : 
     555             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     556             :   {
     557             :     "Function",
     558             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     559             :     &sInterfaceObjectClassOps,
     560             :     JS_NULL_CLASS_SPEC,
     561             :     JS_NULL_CLASS_EXT,
     562             :     &sInterfaceObjectClassObjectOps
     563             :   },
     564             :   eInterface,
     565             :   true,
     566             :   prototypes::id::HTMLHRElement,
     567             :   PrototypeTraits<prototypes::id::HTMLHRElement>::Depth,
     568             :   sNativePropertyHooks,
     569             :   "function HTMLHRElement() {\n    [native code]\n}",
     570             :   HTMLElementBinding::GetConstructorObject
     571             : };
     572             : 
     573             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     574             :   {
     575             :     "HTMLHRElementPrototype",
     576             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     577             :     JS_NULL_CLASS_OPS,
     578             :     JS_NULL_CLASS_SPEC,
     579             :     JS_NULL_CLASS_EXT,
     580             :     JS_NULL_OBJECT_OPS
     581             :   },
     582             :   eInterfacePrototype,
     583             :   false,
     584             :   prototypes::id::HTMLHRElement,
     585             :   PrototypeTraits<prototypes::id::HTMLHRElement>::Depth,
     586             :   sNativePropertyHooks,
     587             :   "[object HTMLHRElementPrototype]",
     588             :   HTMLElementBinding::GetProtoObject
     589             : };
     590             : 
     591             : JSObject*
     592           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     593             : {
     594           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     595             : }
     596             : 
     597             : static const js::ClassOps sClassOps = {
     598             :   _addProperty, /* addProperty */
     599             :   nullptr,               /* delProperty */
     600             :   nullptr,               /* getProperty */
     601             :   nullptr,               /* setProperty */
     602             :   nullptr,               /* enumerate */
     603             :   nullptr, /* newEnumerate */
     604             :   nullptr, /* resolve */
     605             :   nullptr, /* mayResolve */
     606             :   _finalize, /* finalize */
     607             :   nullptr, /* call */
     608             :   nullptr,               /* hasInstance */
     609             :   nullptr,               /* construct */
     610             :   nullptr, /* trace */
     611             : };
     612             : 
     613             : static const js::ClassExtension sClassExtension = {
     614             :   nullptr, /* weakmapKeyDelegateOp */
     615             :   _objectMoved /* objectMovedOp */
     616             : };
     617             : 
     618             : static const DOMJSClass sClass = {
     619             :   { "HTMLHRElement",
     620             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     621             :     &sClassOps,
     622             :     JS_NULL_CLASS_SPEC,
     623             :     &sClassExtension,
     624             :     JS_NULL_OBJECT_OPS
     625             :   },
     626             :   { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLHRElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     627             :   IsBaseOf<nsISupports, mozilla::dom::HTMLHRElement >::value,
     628             :   sNativePropertyHooks,
     629             :   FindAssociatedGlobalForNative<mozilla::dom::HTMLHRElement>::Get,
     630             :   GetProtoObjectHandle,
     631             :   GetCCParticipant<mozilla::dom::HTMLHRElement>::Get()
     632             : };
     633             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     634             :               "Must have the right minimal number of reserved slots.");
     635             : static_assert(1 >= 1,
     636             :               "Must have enough reserved slots.");
     637             : 
     638             : const JSClass*
     639           0 : GetJSClass()
     640             : {
     641           0 :   return sClass.ToJSClass();
     642             : }
     643             : 
     644             : bool
     645           0 : Wrap(JSContext* aCx, mozilla::dom::HTMLHRElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     646             : {
     647             :   MOZ_ASSERT(static_cast<mozilla::dom::HTMLHRElement*>(aObject) ==
     648             :              reinterpret_cast<mozilla::dom::HTMLHRElement*>(aObject),
     649             :              "Multiple inheritance for mozilla::dom::HTMLHRElement is broken.");
     650             :   MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
     651             :              reinterpret_cast<nsGenericHTMLElement*>(aObject),
     652             :              "Multiple inheritance for nsGenericHTMLElement is broken.");
     653             :   MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
     654             :              reinterpret_cast<mozilla::dom::Element*>(aObject),
     655             :              "Multiple inheritance for mozilla::dom::Element is broken.");
     656             :   MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
     657             :              reinterpret_cast<nsINode*>(aObject),
     658             :              "Multiple inheritance for nsINode is broken.");
     659             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     660             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     661             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     662           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     663           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     664           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     665             :              "You should probably not be using Wrap() directly; use "
     666             :              "GetOrCreateDOMReflector instead");
     667             : 
     668           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     669             :              "nsISupports must be on our primary inheritance chain");
     670             : 
     671           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     672           0 :   if (!global) {
     673           0 :     return false;
     674             :   }
     675           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     676           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     677             : 
     678             :   // That might have ended up wrapping us already, due to the wonders
     679             :   // of XBL.  Check for that, and bail out as needed.
     680           0 :   aReflector.set(aCache->GetWrapper());
     681           0 :   if (aReflector) {
     682             : #ifdef DEBUG
     683           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     684             : #endif // DEBUG
     685           0 :     return true;
     686             :   }
     687             : 
     688           0 :   JSAutoCompartment ac(aCx, global);
     689           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     690           0 :   if (!canonicalProto) {
     691           0 :     return false;
     692             :   }
     693           0 :   JS::Rooted<JSObject*> proto(aCx);
     694           0 :   if (aGivenProto) {
     695           0 :     proto = aGivenProto;
     696             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     697             :     // coming in, we changed compartments to that of "parent" so may need
     698             :     // to wrap the proto here.
     699           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     700           0 :       if (!JS_WrapObject(aCx, &proto)) {
     701           0 :         return false;
     702             :       }
     703             :     }
     704             :   } else {
     705           0 :     proto = canonicalProto;
     706             :   }
     707             : 
     708           0 :   BindingJSObjectCreator<mozilla::dom::HTMLHRElement> creator(aCx);
     709           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     710           0 :   if (!aReflector) {
     711           0 :     return false;
     712             :   }
     713             : 
     714           0 :   aCache->SetWrapper(aReflector);
     715           0 :   creator.InitializationSucceeded();
     716             : 
     717           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     718             :              aCache->GetWrapperPreserveColor() == aReflector);
     719             :   // If proto != canonicalProto, we have to preserve our wrapper;
     720             :   // otherwise we won't be able to properly recreate it later, since
     721             :   // we won't know what proto to use.  Note that we don't check
     722             :   // aGivenProto here, since it's entirely possible (and even
     723             :   // somewhat common) to have a non-null aGivenProto which is the
     724             :   // same as canonicalProto.
     725           0 :   if (proto != canonicalProto) {
     726           0 :     PreserveWrapper(aObject);
     727             :   }
     728             : 
     729           0 :   return true;
     730             : }
     731             : 
     732             : const NativePropertyHooks sNativePropertyHooks[] = { {
     733             :   nullptr,
     734             :   nullptr,
     735             :   nullptr,
     736             :   { sNativeProperties.Upcast(), nullptr },
     737             :   prototypes::id::HTMLHRElement,
     738             :   constructors::id::HTMLHRElement,
     739             :   HTMLElementBinding::sNativePropertyHooks,
     740             :   &DefaultXrayExpandoObjectClass
     741             : } };
     742             : 
     743             : void
     744           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     745             : {
     746           0 :   JS::Handle<JSObject*> parentProto(HTMLElementBinding::GetProtoObjectHandle(aCx));
     747           0 :   if (!parentProto) {
     748           0 :     return;
     749             :   }
     750             : 
     751           0 :   JS::Handle<JSObject*> constructorProto(HTMLElementBinding::GetConstructorObjectHandle(aCx));
     752           0 :   if (!constructorProto) {
     753           0 :     return;
     754             :   }
     755             : 
     756             :   static bool sIdsInited = false;
     757           0 :   if (!sIdsInited && NS_IsMainThread()) {
     758           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     759           0 :       return;
     760             :     }
     761           0 :     sIdsInited = true;
     762             :   }
     763             : 
     764           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLHRElement);
     765           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLHRElement);
     766           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     767             :                               &sPrototypeClass.mBase, protoCache,
     768             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     769             :                               interfaceCache,
     770             :                               sNativeProperties.Upcast(),
     771             :                               nullptr,
     772             :                               "HTMLHRElement", aDefineOnGlobal,
     773             :                               nullptr,
     774           0 :                               false);
     775             : }
     776             : 
     777             : JS::Handle<JSObject*>
     778           0 : GetProtoObjectHandle(JSContext* aCx)
     779             : {
     780             :   /* Get the interface prototype object for this class.  This will create the
     781             :      object as needed. */
     782           0 :   bool aDefineOnGlobal = true;
     783             : 
     784             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     785           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     786           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     787           0 :     return nullptr;
     788             :   }
     789             : 
     790             :   /* Check to see whether the interface objects are already installed */
     791           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     792           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::HTMLHRElement)) {
     793           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     794           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     795             :   }
     796             : 
     797             :   /*
     798             :    * The object might _still_ be null, but that's OK.
     799             :    *
     800             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     801             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     802             :    * changed after they have been set.
     803             :    *
     804             :    * Calling address() avoids the read read barrier that does gray
     805             :    * unmarking, but it's not possible for the object to be gray here.
     806             :    */
     807             : 
     808           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::HTMLHRElement);
     809           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     810           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     811             : }
     812             : 
     813             : JS::Handle<JSObject*>
     814           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     815             : {
     816             :   /* Get the interface object for this class.  This will create the object as
     817             :      needed. */
     818             : 
     819             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     820           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     821           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     822           0 :     return nullptr;
     823             :   }
     824             : 
     825             :   /* Check to see whether the interface objects are already installed */
     826           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     827           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::HTMLHRElement)) {
     828           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     829           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     830             :   }
     831             : 
     832             :   /*
     833             :    * The object might _still_ be null, but that's OK.
     834             :    *
     835             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     836             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     837             :    * changed after they have been set.
     838             :    *
     839             :    * Calling address() avoids the read read barrier that does gray
     840             :    * unmarking, but it's not possible for the object to be gray here.
     841             :    */
     842             : 
     843           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::HTMLHRElement);
     844           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     845           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     846             : }
     847             : 
     848             : JSObject*
     849           0 : GetConstructorObject(JSContext* aCx)
     850             : {
     851           0 :   return GetConstructorObjectHandle(aCx);
     852             : }
     853             : 
     854             : } // namespace HTMLHRElementBinding
     855             : 
     856             : 
     857             : 
     858             : } // namespace dom
     859             : } // namespace mozilla

Generated by: LCOV version 1.13