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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM EventHandler.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "EventHandlerBinding.h"
       4             : #include "mozilla/OwningNonNull.h"
       5             : #include "mozilla/dom/BindingUtils.h"
       6             : #include "mozilla/dom/Event.h"
       7             : #include "mozilla/dom/NonRefcountedDOMObject.h"
       8             : #include "mozilla/dom/Nullable.h"
       9             : #include "mozilla/dom/PrimitiveConversions.h"
      10             : #include "mozilla/dom/UnionConversions.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace dom {
      14             : 
      15             : void
      16           0 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningEventOrString& aUnion, const char* aName, uint32_t aFlags)
      17             : {
      18           0 :   if (aUnion.IsEvent()) {
      19           0 :     ImplCycleCollectionTraverse(aCallback, aUnion.GetAsEvent(), "mEvent", aFlags);
      20             :   }
      21           0 : }
      22             : 
      23             : 
      24             : void
      25           0 : ImplCycleCollectionUnlink(OwningEventOrString& aUnion)
      26             : {
      27           0 :   aUnion.Uninit();
      28           0 : }
      29             : 
      30             : 
      31             : bool
      32           0 : EventOrString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
      33             : {
      34           0 :   switch (mType) {
      35             :     case eUninitialized: {
      36           0 :       return false;
      37             :       break;
      38             :     }
      39             :     case eEvent: {
      40           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mEvent.Value(), rval)) {
      41           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      42           0 :         return false;
      43             :       }
      44           0 :       return true;
      45             :       break;
      46             :     }
      47             :     case eString: {
      48           0 :       if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
      49           0 :         return false;
      50             :       }
      51           0 :       return true;
      52             :       break;
      53             :     }
      54             :     default: {
      55           0 :       return false;
      56             :       break;
      57             :     }
      58             :   }
      59             : 
      60             :   return false;
      61             : }
      62             : 
      63             : 
      64             : OwningNonNull<mozilla::dom::Event>&
      65           0 : OwningEventOrString::RawSetAsEvent()
      66             : {
      67           0 :   if (mType == eEvent) {
      68           0 :     return mValue.mEvent.Value();
      69             :   }
      70           0 :   MOZ_ASSERT(mType == eUninitialized);
      71           0 :   mType = eEvent;
      72           0 :   return mValue.mEvent.SetValue();
      73             : }
      74             : 
      75             : OwningNonNull<mozilla::dom::Event>&
      76           0 : OwningEventOrString::SetAsEvent()
      77             : {
      78           0 :   if (mType == eEvent) {
      79           0 :     return mValue.mEvent.Value();
      80             :   }
      81           0 :   Uninit();
      82           0 :   mType = eEvent;
      83           0 :   return mValue.mEvent.SetValue();
      84             : }
      85             : 
      86             : bool
      87           0 : OwningEventOrString::TrySetToEvent(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
      88             : {
      89           0 :   tryNext = false;
      90             :   { // scope for memberSlot
      91           0 :     OwningNonNull<mozilla::dom::Event>& memberSlot = RawSetAsEvent();
      92             :     static_assert(IsRefcounted<mozilla::dom::Event>::value, "We can only store refcounted classes.");{
      93           0 :       nsresult rv = UnwrapObject<prototypes::id::Event, mozilla::dom::Event>(value, memberSlot);
      94           0 :       if (NS_FAILED(rv)) {
      95           0 :         DestroyEvent();
      96           0 :         tryNext = true;
      97           0 :         return true;
      98             :       }
      99             :     }
     100             :   }
     101           0 :   return true;
     102             : }
     103             : 
     104             : void
     105           0 : OwningEventOrString::DestroyEvent()
     106             : {
     107           0 :   MOZ_ASSERT(IsEvent(), "Wrong type!");
     108           0 :   mValue.mEvent.Destroy();
     109           0 :   mType = eUninitialized;
     110           0 : }
     111             : 
     112             : 
     113             : 
     114             : 
     115             : nsString&
     116           0 : OwningEventOrString::RawSetAsString()
     117             : {
     118           0 :   if (mType == eString) {
     119           0 :     return mValue.mString.Value();
     120             :   }
     121           0 :   MOZ_ASSERT(mType == eUninitialized);
     122           0 :   mType = eString;
     123           0 :   return mValue.mString.SetValue();
     124             : }
     125             : 
     126             : nsString&
     127           0 : OwningEventOrString::SetAsString()
     128             : {
     129           0 :   if (mType == eString) {
     130           0 :     return mValue.mString.Value();
     131             :   }
     132           0 :   Uninit();
     133           0 :   mType = eString;
     134           0 :   return mValue.mString.SetValue();
     135             : }
     136             : 
     137             : bool
     138           0 : OwningEventOrString::TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     139             : {
     140           0 :   tryNext = false;
     141             :   { // scope for memberSlot
     142           0 :     nsString& memberSlot = RawSetAsString();
     143           0 :     if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
     144           0 :       return false;
     145             :     }
     146             :   }
     147           0 :   return true;
     148             : }
     149             : 
     150             : 
     151             : void
     152           0 : OwningEventOrString::DestroyString()
     153             : {
     154           0 :   MOZ_ASSERT(IsString(), "Wrong type!");
     155           0 :   mValue.mString.Destroy();
     156           0 :   mType = eUninitialized;
     157           0 : }
     158             : 
     159             : 
     160             : 
     161             : 
     162             : void
     163           0 : OwningEventOrString::Uninit()
     164             : {
     165           0 :   switch (mType) {
     166             :     case eUninitialized: {
     167           0 :       break;
     168             :     }
     169             :     case eEvent: {
     170           0 :       DestroyEvent();
     171           0 :       break;
     172             :     }
     173             :     case eString: {
     174           0 :       DestroyString();
     175           0 :       break;
     176             :     }
     177             :   }
     178           0 : }
     179             : 
     180             : bool
     181           0 : OwningEventOrString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
     182             : {
     183           0 :   switch (mType) {
     184             :     case eUninitialized: {
     185           0 :       return false;
     186             :       break;
     187             :     }
     188             :     case eEvent: {
     189           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mEvent.Value(), rval)) {
     190           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     191           0 :         return false;
     192             :       }
     193           0 :       return true;
     194             :       break;
     195             :     }
     196             :     case eString: {
     197           0 :       if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
     198           0 :         return false;
     199             :       }
     200           0 :       return true;
     201             :       break;
     202             :     }
     203             :     default: {
     204           0 :       return false;
     205             :       break;
     206             :     }
     207             :   }
     208             : 
     209             :   return false;
     210             : }
     211             : 
     212             : void
     213           0 : OwningEventOrString::TraceUnion(JSTracer* trc)
     214             : {
     215           0 : }
     216             : 
     217             : OwningEventOrString&
     218           0 : OwningEventOrString::operator=(const OwningEventOrString& aOther)
     219             : {
     220           0 :   switch (aOther.mType) {
     221             :     case eUninitialized: {
     222           0 :       MOZ_ASSERT(mType == eUninitialized,
     223             :                  "We need to destroy ourselves?");
     224           0 :       break;
     225             :     }
     226             :     case eEvent: {
     227           0 :       SetAsEvent() = aOther.GetAsEvent();
     228           0 :       break;
     229             :     }
     230             :     case eString: {
     231           0 :       SetAsString() = aOther.GetAsString();
     232           0 :       break;
     233             :     }
     234             :   }
     235           0 :   return *this;
     236             : }
     237             : 
     238             : 
     239             : void
     240          15 : EventHandlerNonNull::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, Event& event, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv)
     241             : {
     242          30 :   JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
     243          30 :   JS::AutoValueVector argv(cx);
     244          15 :   if (!argv.resize(1)) {
     245           0 :     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     246           0 :     return;
     247             :   }
     248          15 :   unsigned argc = 1;
     249             : 
     250             :   do {
     251          15 :     if (!GetOrCreateDOMReflector(cx, event, argv[0])) {
     252           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     253           0 :       aRv.Throw(NS_ERROR_UNEXPECTED);
     254           0 :       return;
     255             :     }
     256          15 :     break;
     257             :   } while (0);
     258             : 
     259          30 :   JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
     260          45 :   if (JS::IsCallable(mCallback) && !JS::Call(cx, aThisVal, callable,
     261          30 :                 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
     262           0 :     aRv.NoteJSContextException(cx);
     263           0 :     return;
     264             :   }
     265          30 :   JS::Rooted<JS::Value> rvalDecl(cx);
     266             : #ifdef __clang__
     267             : #pragma clang diagnostic push
     268             : #pragma clang diagnostic ignored "-Wunreachable-code"
     269             : #pragma clang diagnostic ignored "-Wunreachable-code-return"
     270             : #endif // __clang__
     271          15 :   if ((false) && !CallerSubsumes(rval)) {
     272           0 :     ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "return value of EventHandlerNonNull");
     273           0 :     aRv.Throw(NS_ERROR_UNEXPECTED);
     274           0 :     return;
     275             :   }
     276             : #ifdef __clang__
     277             : #pragma clang diagnostic pop
     278             : #endif // __clang__
     279          15 :   rvalDecl = rval;
     280          15 :   aRetVal.set(rvalDecl);
     281             : }
     282             : 
     283             : 
     284             : 
     285             : void
     286           0 : OnBeforeUnloadEventHandlerNonNull::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, Event& event, nsString& aRetVal, ErrorResult& aRv)
     287             : {
     288           0 :   JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
     289           0 :   JS::AutoValueVector argv(cx);
     290           0 :   if (!argv.resize(1)) {
     291           0 :     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     292           0 :     return;
     293             :   }
     294           0 :   unsigned argc = 1;
     295             : 
     296             :   do {
     297           0 :     if (!GetOrCreateDOMReflector(cx, event, argv[0])) {
     298           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     299           0 :       aRv.Throw(NS_ERROR_UNEXPECTED);
     300           0 :       return;
     301             :     }
     302           0 :     break;
     303             :   } while (0);
     304             : 
     305           0 :   JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
     306           0 :   if (JS::IsCallable(mCallback) && !JS::Call(cx, aThisVal, callable,
     307           0 :                 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
     308           0 :     aRv.NoteJSContextException(cx);
     309           0 :     return;
     310             :   }
     311           0 :   binding_detail::FakeString rvalDecl;
     312           0 :   if (!ConvertJSValueToString(cx, rval, eNull, eNull, rvalDecl)) {
     313           0 :     aRv.Throw(NS_ERROR_UNEXPECTED);
     314           0 :     return;
     315             :   }
     316           0 :   aRetVal = rvalDecl;
     317             : }
     318             : 
     319             : 
     320             : 
     321             : void
     322           0 : OnErrorEventHandlerNonNull::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const EventOrString& event, const Optional<nsAString>& source, const Optional<uint32_t>& lineno, const Optional<uint32_t>& column, const Optional<JS::Handle<JS::Value>>& error, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv)
     323             : {
     324           0 :   JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
     325           0 :   JS::AutoValueVector argv(cx);
     326           0 :   if (!argv.resize(5)) {
     327           0 :     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     328           0 :     return;
     329             :   }
     330           0 :   unsigned argc = 5;
     331             : 
     332             :   do {
     333           0 :     if (error.WasPassed()) {
     334           0 :       JS::ExposeValueToActiveJS(error.Value());
     335           0 :       argv[4].set(error.Value());
     336           0 :       if (!MaybeWrapValue(cx, argv[4])) {
     337           0 :         aRv.Throw(NS_ERROR_UNEXPECTED);
     338           0 :         return;
     339             :       }
     340           0 :       break;
     341           0 :     } else if (argc == 5) {
     342             :       // This is our current trailing argument; reduce argc
     343           0 :       --argc;
     344             :     } else {
     345           0 :       argv[4].setUndefined();
     346             :     }
     347             :   } while (0);
     348             : 
     349             :   do {
     350           0 :     if (column.WasPassed()) {
     351           0 :       argv[3].setNumber(column.Value());
     352           0 :       break;
     353           0 :     } else if (argc == 4) {
     354             :       // This is our current trailing argument; reduce argc
     355           0 :       --argc;
     356             :     } else {
     357           0 :       argv[3].setUndefined();
     358             :     }
     359             :   } while (0);
     360             : 
     361             :   do {
     362           0 :     if (lineno.WasPassed()) {
     363           0 :       argv[2].setNumber(lineno.Value());
     364           0 :       break;
     365           0 :     } else if (argc == 3) {
     366             :       // This is our current trailing argument; reduce argc
     367           0 :       --argc;
     368             :     } else {
     369           0 :       argv[2].setUndefined();
     370             :     }
     371             :   } while (0);
     372             : 
     373             :   do {
     374           0 :     if (source.WasPassed()) {
     375           0 :       nsString mutableStr(source.Value());
     376           0 :       if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[1])) {
     377           0 :         aRv.Throw(NS_ERROR_UNEXPECTED);
     378           0 :         return;
     379             :       }
     380           0 :       break;
     381           0 :     } else if (argc == 2) {
     382             :       // This is our current trailing argument; reduce argc
     383           0 :       --argc;
     384             :     } else {
     385           0 :       argv[1].setUndefined();
     386             :     }
     387             :   } while (0);
     388             : 
     389             :   do {
     390           0 :     if (!event.ToJSVal(cx, CallbackKnownNotGray(), argv[0])) {
     391           0 :       aRv.Throw(NS_ERROR_UNEXPECTED);
     392           0 :       return;
     393             :     }
     394           0 :     break;
     395             :   } while (0);
     396             : 
     397           0 :   JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
     398           0 :   if (JS::IsCallable(mCallback) && !JS::Call(cx, aThisVal, callable,
     399           0 :                 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
     400           0 :     aRv.NoteJSContextException(cx);
     401           0 :     return;
     402             :   }
     403           0 :   JS::Rooted<JS::Value> rvalDecl(cx);
     404             : #ifdef __clang__
     405             : #pragma clang diagnostic push
     406             : #pragma clang diagnostic ignored "-Wunreachable-code"
     407             : #pragma clang diagnostic ignored "-Wunreachable-code-return"
     408             : #endif // __clang__
     409           0 :   if ((false) && !CallerSubsumes(rval)) {
     410           0 :     ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "return value of OnErrorEventHandlerNonNull");
     411           0 :     aRv.Throw(NS_ERROR_UNEXPECTED);
     412           0 :     return;
     413             :   }
     414             : #ifdef __clang__
     415             : #pragma clang diagnostic pop
     416             : #endif // __clang__
     417           0 :   rvalDecl = rval;
     418           0 :   aRetVal.set(rvalDecl);
     419             : }
     420             : 
     421             : 
     422             : 
     423             : namespace binding_detail {
     424             : } // namespace binding_detail
     425             : 
     426             : 
     427             : namespace binding_detail {
     428             : } // namespace binding_detail
     429             : 
     430             : 
     431             : namespace binding_detail {
     432             : } // namespace binding_detail
     433             : 
     434             : 
     435             : } // namespace dom
     436             : } // namespace mozilla

Generated by: LCOV version 1.13