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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM XMLHttpRequestEventTarget.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "EventHandlerBinding.h"
       4             : #include "EventTargetBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "XMLHttpRequestEventTargetBinding.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/dom/BindingUtils.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/Nullable.h"
      12             : #include "mozilla/dom/XMLHttpRequestEventTarget.h"
      13             : #include "mozilla/dom/XrayExpandoClass.h"
      14             : #include "nsThreadUtils.h"
      15             : #include "xpcprivate.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : namespace XMLHttpRequestEventTargetBinding {
      21             : 
      22             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
      23             :               "Can't inherit from an interface with a different ownership model.");
      24             : 
      25             : static bool
      26           0 : get_onloadstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitGetterCallArgs args)
      27             : {
      28           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnloadstart());
      29           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      30           0 :   if (result) {
      31           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
      32           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
      33           0 :       return false;
      34             :     }
      35           0 :     return true;
      36             :   } else {
      37           0 :     args.rval().setNull();
      38           0 :     return true;
      39             :   }
      40             : }
      41             : 
      42             : static bool
      43           0 : set_onloadstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitSetterCallArgs args)
      44             : {
      45           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
      46           0 :   if (args[0].isObject()) {
      47             :     { // scope for tempRoot
      48           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
      49           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
      50             :     }
      51             :   } else {
      52           0 :     arg0 = nullptr;
      53             :   }
      54           0 :   self->SetOnloadstart(Constify(arg0));
      55           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      56             : 
      57           0 :   return true;
      58             : }
      59             : 
      60             : static const JSJitInfo onloadstart_getterinfo = {
      61             :   { (JSJitGetterOp)get_onloadstart },
      62             :   { prototypes::id::XMLHttpRequestEventTarget },
      63             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
      64             :   JSJitInfo::Getter,
      65             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      66             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
      67             :   false,  /* isInfallible. False in setters. */
      68             :   false,  /* isMovable.  Not relevant for setters. */
      69             :   false, /* isEliminatable.  Not relevant for setters. */
      70             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      71             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      72             :   false,  /* isTypedMethod.  Only relevant for methods. */
      73             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      74             : };
      75             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      76             : static_assert(0 < 1, "There is no slot for us");
      77             : static const JSJitInfo onloadstart_setterinfo = {
      78             :   { (JSJitGetterOp)set_onloadstart },
      79             :   { prototypes::id::XMLHttpRequestEventTarget },
      80             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
      81             :   JSJitInfo::Setter,
      82             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      83             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
      84             :   false,  /* isInfallible. False in setters. */
      85             :   false,  /* isMovable.  Not relevant for setters. */
      86             :   false, /* isEliminatable.  Not relevant for setters. */
      87             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      88             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      89             :   false,  /* isTypedMethod.  Only relevant for methods. */
      90             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      91             : };
      92             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      93             : static_assert(0 < 1, "There is no slot for us");
      94             : 
      95             : static bool
      96           0 : get_onprogress(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitGetterCallArgs args)
      97             : {
      98           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnprogress());
      99           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     100           0 :   if (result) {
     101           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     102           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     103           0 :       return false;
     104             :     }
     105           0 :     return true;
     106             :   } else {
     107           0 :     args.rval().setNull();
     108           0 :     return true;
     109             :   }
     110             : }
     111             : 
     112             : static bool
     113           0 : set_onprogress(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitSetterCallArgs args)
     114             : {
     115           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     116           0 :   if (args[0].isObject()) {
     117             :     { // scope for tempRoot
     118           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     119           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     120             :     }
     121             :   } else {
     122           0 :     arg0 = nullptr;
     123             :   }
     124           0 :   self->SetOnprogress(Constify(arg0));
     125           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     126             : 
     127           0 :   return true;
     128             : }
     129             : 
     130             : static const JSJitInfo onprogress_getterinfo = {
     131             :   { (JSJitGetterOp)get_onprogress },
     132             :   { prototypes::id::XMLHttpRequestEventTarget },
     133             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     134             :   JSJitInfo::Getter,
     135             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     136             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     137             :   false,  /* isInfallible. False in setters. */
     138             :   false,  /* isMovable.  Not relevant for setters. */
     139             :   false, /* isEliminatable.  Not relevant for setters. */
     140             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     141             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     142             :   false,  /* isTypedMethod.  Only relevant for methods. */
     143             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     144             : };
     145             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     146             : static_assert(0 < 1, "There is no slot for us");
     147             : static const JSJitInfo onprogress_setterinfo = {
     148             :   { (JSJitGetterOp)set_onprogress },
     149             :   { prototypes::id::XMLHttpRequestEventTarget },
     150             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     151             :   JSJitInfo::Setter,
     152             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     153             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     154             :   false,  /* isInfallible. False in setters. */
     155             :   false,  /* isMovable.  Not relevant for setters. */
     156             :   false, /* isEliminatable.  Not relevant for setters. */
     157             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     158             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     159             :   false,  /* isTypedMethod.  Only relevant for methods. */
     160             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     161             : };
     162             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     163             : static_assert(0 < 1, "There is no slot for us");
     164             : 
     165             : static bool
     166           0 : get_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitGetterCallArgs args)
     167             : {
     168           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnabort());
     169           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     170           0 :   if (result) {
     171           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     172           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     173           0 :       return false;
     174             :     }
     175           0 :     return true;
     176             :   } else {
     177           0 :     args.rval().setNull();
     178           0 :     return true;
     179             :   }
     180             : }
     181             : 
     182             : static bool
     183           0 : set_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitSetterCallArgs args)
     184             : {
     185           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     186           0 :   if (args[0].isObject()) {
     187             :     { // scope for tempRoot
     188           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     189           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     190             :     }
     191             :   } else {
     192           0 :     arg0 = nullptr;
     193             :   }
     194           0 :   self->SetOnabort(Constify(arg0));
     195           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     196             : 
     197           0 :   return true;
     198             : }
     199             : 
     200             : static const JSJitInfo onabort_getterinfo = {
     201             :   { (JSJitGetterOp)get_onabort },
     202             :   { prototypes::id::XMLHttpRequestEventTarget },
     203             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     204             :   JSJitInfo::Getter,
     205             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     206             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     207             :   false,  /* isInfallible. False in setters. */
     208             :   false,  /* isMovable.  Not relevant for setters. */
     209             :   false, /* isEliminatable.  Not relevant for setters. */
     210             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     211             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     212             :   false,  /* isTypedMethod.  Only relevant for methods. */
     213             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     214             : };
     215             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     216             : static_assert(0 < 1, "There is no slot for us");
     217             : static const JSJitInfo onabort_setterinfo = {
     218             :   { (JSJitGetterOp)set_onabort },
     219             :   { prototypes::id::XMLHttpRequestEventTarget },
     220             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     221             :   JSJitInfo::Setter,
     222             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     223             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     224             :   false,  /* isInfallible. False in setters. */
     225             :   false,  /* isMovable.  Not relevant for setters. */
     226             :   false, /* isEliminatable.  Not relevant for setters. */
     227             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     228             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     229             :   false,  /* isTypedMethod.  Only relevant for methods. */
     230             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     231             : };
     232             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     233             : static_assert(0 < 1, "There is no slot for us");
     234             : 
     235             : static bool
     236           0 : get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitGetterCallArgs args)
     237             : {
     238           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnerror());
     239           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     240           0 :   if (result) {
     241           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     242           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     243           0 :       return false;
     244             :     }
     245           0 :     return true;
     246             :   } else {
     247           0 :     args.rval().setNull();
     248           0 :     return true;
     249             :   }
     250             : }
     251             : 
     252             : static bool
     253           0 : set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitSetterCallArgs args)
     254             : {
     255           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     256           0 :   if (args[0].isObject()) {
     257             :     { // scope for tempRoot
     258           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     259           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     260             :     }
     261             :   } else {
     262           0 :     arg0 = nullptr;
     263             :   }
     264           0 :   self->SetOnerror(Constify(arg0));
     265           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     266             : 
     267           0 :   return true;
     268             : }
     269             : 
     270             : static const JSJitInfo onerror_getterinfo = {
     271             :   { (JSJitGetterOp)get_onerror },
     272             :   { prototypes::id::XMLHttpRequestEventTarget },
     273             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     274             :   JSJitInfo::Getter,
     275             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     276             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     277             :   false,  /* isInfallible. False in setters. */
     278             :   false,  /* isMovable.  Not relevant for setters. */
     279             :   false, /* isEliminatable.  Not relevant for setters. */
     280             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     281             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     282             :   false,  /* isTypedMethod.  Only relevant for methods. */
     283             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     284             : };
     285             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     286             : static_assert(0 < 1, "There is no slot for us");
     287             : static const JSJitInfo onerror_setterinfo = {
     288             :   { (JSJitGetterOp)set_onerror },
     289             :   { prototypes::id::XMLHttpRequestEventTarget },
     290             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     291             :   JSJitInfo::Setter,
     292             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     293             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     294             :   false,  /* isInfallible. False in setters. */
     295             :   false,  /* isMovable.  Not relevant for setters. */
     296             :   false, /* isEliminatable.  Not relevant for setters. */
     297             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     298             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     299             :   false,  /* isTypedMethod.  Only relevant for methods. */
     300             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     301             : };
     302             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     303             : static_assert(0 < 1, "There is no slot for us");
     304             : 
     305             : static bool
     306           0 : get_onload(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitGetterCallArgs args)
     307             : {
     308           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnload());
     309           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     310           0 :   if (result) {
     311           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     312           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     313           0 :       return false;
     314             :     }
     315           0 :     return true;
     316             :   } else {
     317           0 :     args.rval().setNull();
     318           0 :     return true;
     319             :   }
     320             : }
     321             : 
     322             : static bool
     323           0 : set_onload(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitSetterCallArgs args)
     324             : {
     325           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     326           0 :   if (args[0].isObject()) {
     327             :     { // scope for tempRoot
     328           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     329           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     330             :     }
     331             :   } else {
     332           0 :     arg0 = nullptr;
     333             :   }
     334           0 :   self->SetOnload(Constify(arg0));
     335           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     336             : 
     337           0 :   return true;
     338             : }
     339             : 
     340             : static const JSJitInfo onload_getterinfo = {
     341             :   { (JSJitGetterOp)get_onload },
     342             :   { prototypes::id::XMLHttpRequestEventTarget },
     343             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     344             :   JSJitInfo::Getter,
     345             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     346             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     347             :   false,  /* isInfallible. False in setters. */
     348             :   false,  /* isMovable.  Not relevant for setters. */
     349             :   false, /* isEliminatable.  Not relevant for setters. */
     350             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     351             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     352             :   false,  /* isTypedMethod.  Only relevant for methods. */
     353             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     354             : };
     355             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     356             : static_assert(0 < 1, "There is no slot for us");
     357             : static const JSJitInfo onload_setterinfo = {
     358             :   { (JSJitGetterOp)set_onload },
     359             :   { prototypes::id::XMLHttpRequestEventTarget },
     360             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     361             :   JSJitInfo::Setter,
     362             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     363             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     364             :   false,  /* isInfallible. False in setters. */
     365             :   false,  /* isMovable.  Not relevant for setters. */
     366             :   false, /* isEliminatable.  Not relevant for setters. */
     367             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     368             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     369             :   false,  /* isTypedMethod.  Only relevant for methods. */
     370             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     371             : };
     372             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     373             : static_assert(0 < 1, "There is no slot for us");
     374             : 
     375             : static bool
     376           0 : get_ontimeout(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitGetterCallArgs args)
     377             : {
     378           0 :   RefPtr<EventHandlerNonNull> result(self->GetOntimeout());
     379           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     380           0 :   if (result) {
     381           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     382           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     383           0 :       return false;
     384             :     }
     385           0 :     return true;
     386             :   } else {
     387           0 :     args.rval().setNull();
     388           0 :     return true;
     389             :   }
     390             : }
     391             : 
     392             : static bool
     393           0 : set_ontimeout(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitSetterCallArgs args)
     394             : {
     395           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     396           0 :   if (args[0].isObject()) {
     397             :     { // scope for tempRoot
     398           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     399           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     400             :     }
     401             :   } else {
     402           0 :     arg0 = nullptr;
     403             :   }
     404           0 :   self->SetOntimeout(Constify(arg0));
     405           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     406             : 
     407           0 :   return true;
     408             : }
     409             : 
     410             : static const JSJitInfo ontimeout_getterinfo = {
     411             :   { (JSJitGetterOp)get_ontimeout },
     412             :   { prototypes::id::XMLHttpRequestEventTarget },
     413             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     414             :   JSJitInfo::Getter,
     415             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     416             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     417             :   false,  /* isInfallible. False in setters. */
     418             :   false,  /* isMovable.  Not relevant for setters. */
     419             :   false, /* isEliminatable.  Not relevant for setters. */
     420             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     421             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     422             :   false,  /* isTypedMethod.  Only relevant for methods. */
     423             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     424             : };
     425             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     426             : static_assert(0 < 1, "There is no slot for us");
     427             : static const JSJitInfo ontimeout_setterinfo = {
     428             :   { (JSJitGetterOp)set_ontimeout },
     429             :   { prototypes::id::XMLHttpRequestEventTarget },
     430             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     431             :   JSJitInfo::Setter,
     432             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     433             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     434             :   false,  /* isInfallible. False in setters. */
     435             :   false,  /* isMovable.  Not relevant for setters. */
     436             :   false, /* isEliminatable.  Not relevant for setters. */
     437             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     438             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     439             :   false,  /* isTypedMethod.  Only relevant for methods. */
     440             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     441             : };
     442             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     443             : static_assert(0 < 1, "There is no slot for us");
     444             : 
     445             : static bool
     446           0 : get_onloadend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitGetterCallArgs args)
     447             : {
     448           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnloadend());
     449           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     450           0 :   if (result) {
     451           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     452           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     453           0 :       return false;
     454             :     }
     455           0 :     return true;
     456             :   } else {
     457           0 :     args.rval().setNull();
     458           0 :     return true;
     459             :   }
     460             : }
     461             : 
     462             : static bool
     463           0 : set_onloadend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequestEventTarget* self, JSJitSetterCallArgs args)
     464             : {
     465           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     466           0 :   if (args[0].isObject()) {
     467             :     { // scope for tempRoot
     468           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     469           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     470             :     }
     471             :   } else {
     472           0 :     arg0 = nullptr;
     473             :   }
     474           0 :   self->SetOnloadend(Constify(arg0));
     475           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     476             : 
     477           0 :   return true;
     478             : }
     479             : 
     480             : static const JSJitInfo onloadend_getterinfo = {
     481             :   { (JSJitGetterOp)get_onloadend },
     482             :   { prototypes::id::XMLHttpRequestEventTarget },
     483             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     484             :   JSJitInfo::Getter,
     485             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     486             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     487             :   false,  /* isInfallible. False in setters. */
     488             :   false,  /* isMovable.  Not relevant for setters. */
     489             :   false, /* isEliminatable.  Not relevant for setters. */
     490             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     491             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     492             :   false,  /* isTypedMethod.  Only relevant for methods. */
     493             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     494             : };
     495             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     496             : static_assert(0 < 1, "There is no slot for us");
     497             : static const JSJitInfo onloadend_setterinfo = {
     498             :   { (JSJitGetterOp)set_onloadend },
     499             :   { prototypes::id::XMLHttpRequestEventTarget },
     500             :   { PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth },
     501             :   JSJitInfo::Setter,
     502             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     503             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     504             :   false,  /* isInfallible. False in setters. */
     505             :   false,  /* isMovable.  Not relevant for setters. */
     506             :   false, /* isEliminatable.  Not relevant for setters. */
     507             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     508             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     509             :   false,  /* isTypedMethod.  Only relevant for methods. */
     510             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     511             : };
     512             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     513             : static_assert(0 < 1, "There is no slot for us");
     514             : 
     515             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     516             : #if defined(__clang__)
     517             : #pragma clang diagnostic push
     518             : #pragma clang diagnostic ignored "-Wmissing-braces"
     519             : #endif
     520             : static const JSPropertySpec sAttributes_specs[] = {
     521             :   { "onloadstart", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onloadstart_getterinfo, GenericBindingSetter, &onloadstart_setterinfo },
     522             :   { "onprogress", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onprogress_getterinfo, GenericBindingSetter, &onprogress_setterinfo },
     523             :   { "onabort", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onabort_getterinfo, GenericBindingSetter, &onabort_setterinfo },
     524             :   { "onerror", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onerror_getterinfo, GenericBindingSetter, &onerror_setterinfo },
     525             :   { "onload", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onload_getterinfo, GenericBindingSetter, &onload_setterinfo },
     526             :   { "ontimeout", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &ontimeout_getterinfo, GenericBindingSetter, &ontimeout_setterinfo },
     527             :   { "onloadend", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onloadend_getterinfo, GenericBindingSetter, &onloadend_setterinfo },
     528             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     529             : };
     530             : #if defined(__clang__)
     531             : #pragma clang diagnostic pop
     532             : #endif
     533             : 
     534             : 
     535             : // Can't be const because the pref-enabled boolean needs to be writable
     536             : static Prefable<const JSPropertySpec> sAttributes[] = {
     537             :   { nullptr, &sAttributes_specs[0] },
     538             :   { nullptr, nullptr }
     539             : };
     540             : 
     541             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     542             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     543             : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     544             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     545             : 
     546             : 
     547             : static uint16_t sNativeProperties_sortedPropertyIndices[7];
     548             : static PropertyInfo sNativeProperties_propertyInfos[7];
     549             : 
     550             : static const NativePropertiesN<1> sNativeProperties = {
     551             :   false, 0,
     552             :   false, 0,
     553             :   false, 0,
     554             :   true,  0 /* sAttributes */,
     555             :   false, 0,
     556             :   false, 0,
     557             :   false, 0,
     558             :   -1,
     559             :   7,
     560             :   sNativeProperties_sortedPropertyIndices,
     561             :   {
     562             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
     563             :   }
     564             : };
     565             : static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     566             :     "We have a property info count that is oversized");
     567             : 
     568             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     569             :   {
     570             :     "Function",
     571             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     572             :     &sBoringInterfaceObjectClassClassOps,
     573             :     JS_NULL_CLASS_SPEC,
     574             :     JS_NULL_CLASS_EXT,
     575             :     &sInterfaceObjectClassObjectOps
     576             :   },
     577             :   eInterface,
     578             :   true,
     579             :   prototypes::id::XMLHttpRequestEventTarget,
     580             :   PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth,
     581             :   sNativePropertyHooks,
     582             :   "function XMLHttpRequestEventTarget() {\n    [native code]\n}",
     583             :   EventTargetBinding::GetConstructorObject
     584             : };
     585             : 
     586             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     587             :   {
     588             :     "XMLHttpRequestEventTargetPrototype",
     589             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     590             :     JS_NULL_CLASS_OPS,
     591             :     JS_NULL_CLASS_SPEC,
     592             :     JS_NULL_CLASS_EXT,
     593             :     JS_NULL_OBJECT_OPS
     594             :   },
     595             :   eInterfacePrototype,
     596             :   false,
     597             :   prototypes::id::XMLHttpRequestEventTarget,
     598             :   PrototypeTraits<prototypes::id::XMLHttpRequestEventTarget>::Depth,
     599             :   sNativePropertyHooks,
     600             :   "[object XMLHttpRequestEventTargetPrototype]",
     601             :   EventTargetBinding::GetProtoObject
     602             : };
     603             : 
     604             : bool
     605           1 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     606             : {
     607           1 :   if (!NS_IsMainThread()) {
     608           1 :     const char* name = js::GetObjectClass(aObj)->name;
     609           1 :     if (strcmp(name, "DedicatedWorkerGlobalScope") && strcmp(name, "SharedWorkerGlobalScope")) {
     610           0 :       return false;
     611             :     }
     612             :   }
     613             : 
     614           1 :   return true;
     615             : }
     616             : 
     617             : JSObject*
     618           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     619             : {
     620           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     621             : }
     622             : 
     623             : const NativePropertyHooks sNativePropertyHooks[] = { {
     624             :   nullptr,
     625             :   nullptr,
     626             :   nullptr,
     627             :   { sNativeProperties.Upcast(), nullptr },
     628             :   prototypes::id::XMLHttpRequestEventTarget,
     629             :   constructors::id::XMLHttpRequestEventTarget,
     630             :   EventTargetBinding::sNativePropertyHooks,
     631             :   &DefaultXrayExpandoObjectClass
     632             : } };
     633             : 
     634             : void
     635           6 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     636             : {
     637           6 :   JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
     638           6 :   if (!parentProto) {
     639           0 :     return;
     640             :   }
     641             : 
     642           6 :   JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
     643           6 :   if (!constructorProto) {
     644           0 :     return;
     645             :   }
     646             : 
     647             :   static bool sIdsInited = false;
     648           6 :   if (!sIdsInited && NS_IsMainThread()) {
     649           2 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     650           0 :       return;
     651             :     }
     652           2 :     sIdsInited = true;
     653             :   }
     654             : 
     655           6 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::XMLHttpRequestEventTarget);
     656           6 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::XMLHttpRequestEventTarget);
     657           6 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     658             :                               &sPrototypeClass.mBase, protoCache,
     659             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     660             :                               interfaceCache,
     661             :                               sNativeProperties.Upcast(),
     662             :                               nullptr,
     663             :                               "XMLHttpRequestEventTarget", aDefineOnGlobal,
     664             :                               nullptr,
     665           6 :                               false);
     666             : }
     667             : 
     668             : JS::Handle<JSObject*>
     669           7 : GetProtoObjectHandle(JSContext* aCx)
     670             : {
     671             :   /* Get the interface prototype object for this class.  This will create the
     672             :      object as needed. */
     673           7 :   bool aDefineOnGlobal = true;
     674             : 
     675             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     676           7 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     677           7 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     678           0 :     return nullptr;
     679             :   }
     680             : 
     681             :   /* Check to see whether the interface objects are already installed */
     682           7 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     683           7 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::XMLHttpRequestEventTarget)) {
     684          12 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     685           6 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     686             :   }
     687             : 
     688             :   /*
     689             :    * The object might _still_ be null, but that's OK.
     690             :    *
     691             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     692             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     693             :    * changed after they have been set.
     694             :    *
     695             :    * Calling address() avoids the read read barrier that does gray
     696             :    * unmarking, but it's not possible for the object to be gray here.
     697             :    */
     698             : 
     699           7 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::XMLHttpRequestEventTarget);
     700           7 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     701           7 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     702             : }
     703             : 
     704             : JSObject*
     705           0 : GetProtoObject(JSContext* aCx)
     706             : {
     707           0 :   return GetProtoObjectHandle(aCx);
     708             : }
     709             : 
     710             : JS::Handle<JSObject*>
     711           8 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     712             : {
     713             :   /* Get the interface object for this class.  This will create the object as
     714             :      needed. */
     715             : 
     716             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     717           8 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     718           8 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     719           0 :     return nullptr;
     720             :   }
     721             : 
     722             :   /* Check to see whether the interface objects are already installed */
     723           8 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     724           8 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::XMLHttpRequestEventTarget)) {
     725           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     726           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     727             :   }
     728             : 
     729             :   /*
     730             :    * The object might _still_ be null, but that's OK.
     731             :    *
     732             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     733             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     734             :    * changed after they have been set.
     735             :    *
     736             :    * Calling address() avoids the read read barrier that does gray
     737             :    * unmarking, but it's not possible for the object to be gray here.
     738             :    */
     739             : 
     740           8 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::XMLHttpRequestEventTarget);
     741           8 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     742           8 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     743             : }
     744             : 
     745             : JSObject*
     746           1 : GetConstructorObject(JSContext* aCx)
     747             : {
     748           1 :   return GetConstructorObjectHandle(aCx);
     749             : }
     750             : 
     751             : } // namespace XMLHttpRequestEventTargetBinding
     752             : 
     753             : 
     754             : 
     755             : } // namespace dom
     756             : } // namespace mozilla

Generated by: LCOV version 1.13