Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM EventListener.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_EVENTLISTENERBINDING_H_
#define DOM_EVENTLISTENERBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackInterface.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/ToJSValue.h"
namespace mozilla {
namespace dom {
class Event;
class EventListener;
struct EventListenerAtoms;
struct NativePropertyHooks;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
class EventListener : public CallbackInterface
{
public:
explicit inline EventListener(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackInterface(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
}
explicit inline EventListener(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackInterface(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
explicit inline EventListener(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackInterface(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
}
template <typename T>
inline void
HandleEvent(const T& thisVal, Event& event, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "EventListener.handleEvent";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
JS::Rooted<JS::Value> thisValJS(s.GetContext());
if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
return HandleEvent(s.GetCallContext(), thisValJS, event, aRv);
}
inline void
HandleEvent(Event& event, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "EventListener.handleEvent";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
return HandleEvent(s.GetCallContext(), JS::UndefinedHandleValue, event, aRv);
}
template <typename T>
inline void
HandleEvent(const T& thisVal, Event& event, const char* aExecutionReason = nullptr)
{
return HandleEvent(thisVal, event, IgnoreErrors(), aExecutionReason);
}
inline void
HandleEvent(Event& event, const char* aExecutionReason = nullptr)
{
return HandleEvent(event, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const EventListener& aOther) const
{
return CallbackInterface::operator==(aOther);
}
private:
void HandleEvent(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, Event& event, ErrorResult& aRv);
static bool
InitIds(JSContext* cx, EventListenerAtoms* atomsCache);
};
namespace binding_detail {
class FastEventListener : public EventListener
{
public:
explicit inline FastEventListener(JSObject* aCallback, JSObject* aCallbackGlobal)
: EventListener(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
EventListener::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
EventListener::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
} // namespace mozilla::dom
#endif // DOM_EVENTLISTENERBINDING_H_