Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM EventTarget.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_EVENTTARGETBINDING_H_
#define DOM_EVENTTARGETBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/AbortSignal.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/UnionMember.h"
namespace mozilla {
namespace dom {
class AbortSignal;
struct AddEventListenerOptionsAtoms;
struct EventListenerOptionsAtoms;
class EventTarget;
struct NativePropertyHooks;
class OwningAddEventListenerOptionsOrBoolean;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningAddEventListenerOptionsOrBoolean& aUnion, const char* aName, uint32_t aFlags = 0);
void
ImplCycleCollectionUnlink(OwningAddEventListenerOptionsOrBoolean& aUnion);
struct EventListenerOptions : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR bool mCapture;
MOZ_INIT_OUTSIDE_CTOR bool mMozSystemGroup;
EventListenerOptions();
explicit inline EventListenerOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
EventListenerOptions(EventListenerOptions&& aOther) = default;
explicit inline EventListenerOptions(const EventListenerOptions& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
EventListenerOptions&
operator=(const EventListenerOptions& aOther);
bool
operator==(const EventListenerOptions& aOther) const;
private:
static bool
InitIds(JSContext* cx, EventListenerOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct FastEventListenerOptions : public EventListenerOptions
{
inline FastEventListenerOptions()
: EventListenerOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct AddEventListenerOptions : public EventListenerOptions
{
MOZ_INIT_OUTSIDE_CTOR bool mOnce;
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mPassive;
MOZ_INIT_OUTSIDE_CTOR Optional<OwningNonNull<mozilla::dom::AbortSignal>> mSignal;
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mWantUntrusted;
AddEventListenerOptions();
explicit inline AddEventListenerOptions(const FastDictionaryInitializer& )
: EventListenerOptions(FastDictionaryInitializer())
{
// Do nothing here; this is used by our "Fast" subclass
}
AddEventListenerOptions(AddEventListenerOptions&& aOther) = default;
explicit inline AddEventListenerOptions(const AddEventListenerOptions& aOther)
: EventListenerOptions(FastDictionaryInitializer())
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
inline void
TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
{
ImplCycleCollectionTraverse(aCallback, mSignal, "mSignal", aFlags);
}
inline void
UnlinkForCC()
{
ImplCycleCollectionUnlink(mSignal);
}
AddEventListenerOptions&
operator=(const AddEventListenerOptions& aOther);
private:
static bool
InitIds(JSContext* cx, AddEventListenerOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct FastAddEventListenerOptions : public AddEventListenerOptions
{
inline FastAddEventListenerOptions()
: AddEventListenerOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
class EventListenerOptionsOrBoolean : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eEventListenerOptions,
eBoolean
};
public:
enum class Type
{
eEventListenerOptions = TypeOrUninit::eEventListenerOptions,
eBoolean = TypeOrUninit::eBoolean
};
private:
union Value
{
UnionMember<binding_detail::FastEventListenerOptions > mEventListenerOptions;
UnionMember<bool > mBoolean;
};
TypeOrUninit mType;
Value mValue;
EventListenerOptionsOrBoolean(const EventListenerOptionsOrBoolean&) = delete;
EventListenerOptionsOrBoolean& operator=(const EventListenerOptionsOrBoolean&) = delete;
public:
explicit inline EventListenerOptionsOrBoolean()
: mType(eUninitialized)
{
}
inline ~EventListenerOptionsOrBoolean()
{
Uninit();
}
[[nodiscard]] inline binding_detail::FastEventListenerOptions&
RawSetAsEventListenerOptions()
{
if (mType == eEventListenerOptions) {
return mValue.mEventListenerOptions.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eEventListenerOptions;
return mValue.mEventListenerOptions.SetValue();
}
[[nodiscard]] inline binding_detail::FastEventListenerOptions&
SetAsEventListenerOptions()
{
if (mType == eEventListenerOptions) {
return mValue.mEventListenerOptions.Value();
}
Uninit();
mType = eEventListenerOptions;
return mValue.mEventListenerOptions.SetValue();
}
inline bool
IsEventListenerOptions() const
{
return mType == eEventListenerOptions;
}
inline binding_detail::FastEventListenerOptions&
GetAsEventListenerOptions()
{
MOZ_RELEASE_ASSERT(IsEventListenerOptions(), "Wrong type!");
return mValue.mEventListenerOptions.Value();
}
inline const EventListenerOptions&
GetAsEventListenerOptions() const
{
MOZ_RELEASE_ASSERT(IsEventListenerOptions(), "Wrong type!");
return mValue.mEventListenerOptions.Value();
}
[[nodiscard]] inline bool&
RawSetAsBoolean()
{
if (mType == eBoolean) {
return mValue.mBoolean.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eBoolean;
return mValue.mBoolean.SetValue();
}
[[nodiscard]] inline bool&
SetAsBoolean()
{
if (mType == eBoolean) {
return mValue.mBoolean.Value();
}
Uninit();
mType = eBoolean;
return mValue.mBoolean.SetValue();
}
inline bool
IsBoolean() const
{
return mType == eBoolean;
}
inline bool&
GetAsBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
inline bool
GetAsBoolean() const
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
inline void
Uninit()
{
switch (mType) {
case eUninitialized: {
break;
}
case eEventListenerOptions: {
DestroyEventListenerOptions();
break;
}
case eBoolean: {
DestroyBoolean();
break;
}
}
}
private:
bool
TrySetToEventListenerOptions(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToEventListenerOptions(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyEventListenerOptions()
{
MOZ_RELEASE_ASSERT(IsEventListenerOptions(), "Wrong type!");
mValue.mEventListenerOptions.Destroy();
mType = eUninitialized;
}
bool
TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
mValue.mBoolean.Destroy();
mType = eUninitialized;
}
};
class OwningEventListenerOptionsOrBoolean : public AllOwningUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eEventListenerOptions,
eBoolean
};
public:
enum class Type
{
eEventListenerOptions = TypeOrUninit::eEventListenerOptions,
eBoolean = TypeOrUninit::eBoolean
};
private:
union Value
{
UnionMember<EventListenerOptions > mEventListenerOptions;
UnionMember<bool > mBoolean;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningEventListenerOptionsOrBoolean()
: mType(eUninitialized)
{
}
OwningEventListenerOptionsOrBoolean(OwningEventListenerOptionsOrBoolean&& aOther);
explicit inline OwningEventListenerOptionsOrBoolean(const OwningEventListenerOptionsOrBoolean& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningEventListenerOptionsOrBoolean()
{
Uninit();
}
[[nodiscard]] EventListenerOptions&
RawSetAsEventListenerOptions();
[[nodiscard]] EventListenerOptions&
SetAsEventListenerOptions();
inline bool
IsEventListenerOptions() const
{
return mType == eEventListenerOptions;
}
inline EventListenerOptions&
GetAsEventListenerOptions()
{
MOZ_RELEASE_ASSERT(IsEventListenerOptions(), "Wrong type!");
return mValue.mEventListenerOptions.Value();
}
inline EventListenerOptions const &
GetAsEventListenerOptions() const
{
MOZ_RELEASE_ASSERT(IsEventListenerOptions(), "Wrong type!");
return mValue.mEventListenerOptions.Value();
}
[[nodiscard]] bool&
RawSetAsBoolean();
[[nodiscard]] bool&
SetAsBoolean();
inline bool
IsBoolean() const
{
return mType == eBoolean;
}
inline bool&
GetAsBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
inline bool const &
GetAsBoolean() const
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
Uninit();
OwningEventListenerOptionsOrBoolean&
operator=(OwningEventListenerOptionsOrBoolean&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningEventListenerOptionsOrBoolean&
operator=(const OwningEventListenerOptionsOrBoolean& aOther);
private:
bool
TrySetToEventListenerOptions(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToEventListenerOptions(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyEventListenerOptions();
bool
TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyBoolean();
};
class AddEventListenerOptionsOrBoolean : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eAddEventListenerOptions,
eBoolean
};
public:
enum class Type
{
eAddEventListenerOptions = TypeOrUninit::eAddEventListenerOptions,
eBoolean = TypeOrUninit::eBoolean
};
private:
union Value
{
UnionMember<binding_detail::FastAddEventListenerOptions > mAddEventListenerOptions;
UnionMember<bool > mBoolean;
};
TypeOrUninit mType;
Value mValue;
AddEventListenerOptionsOrBoolean(const AddEventListenerOptionsOrBoolean&) = delete;
AddEventListenerOptionsOrBoolean& operator=(const AddEventListenerOptionsOrBoolean&) = delete;
public:
explicit inline AddEventListenerOptionsOrBoolean()
: mType(eUninitialized)
{
}
inline ~AddEventListenerOptionsOrBoolean()
{
Uninit();
}
[[nodiscard]] inline binding_detail::FastAddEventListenerOptions&
RawSetAsAddEventListenerOptions()
{
if (mType == eAddEventListenerOptions) {
return mValue.mAddEventListenerOptions.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eAddEventListenerOptions;
return mValue.mAddEventListenerOptions.SetValue();
}
[[nodiscard]] inline binding_detail::FastAddEventListenerOptions&
SetAsAddEventListenerOptions()
{
if (mType == eAddEventListenerOptions) {
return mValue.mAddEventListenerOptions.Value();
}
Uninit();
mType = eAddEventListenerOptions;
return mValue.mAddEventListenerOptions.SetValue();
}
inline bool
IsAddEventListenerOptions() const
{
return mType == eAddEventListenerOptions;
}
inline binding_detail::FastAddEventListenerOptions&
GetAsAddEventListenerOptions()
{
MOZ_RELEASE_ASSERT(IsAddEventListenerOptions(), "Wrong type!");
return mValue.mAddEventListenerOptions.Value();
}
inline const AddEventListenerOptions&
GetAsAddEventListenerOptions() const
{
MOZ_RELEASE_ASSERT(IsAddEventListenerOptions(), "Wrong type!");
return mValue.mAddEventListenerOptions.Value();
}
[[nodiscard]] inline bool&
RawSetAsBoolean()
{
if (mType == eBoolean) {
return mValue.mBoolean.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eBoolean;
return mValue.mBoolean.SetValue();
}
[[nodiscard]] inline bool&
SetAsBoolean()
{
if (mType == eBoolean) {
return mValue.mBoolean.Value();
}
Uninit();
mType = eBoolean;
return mValue.mBoolean.SetValue();
}
inline bool
IsBoolean() const
{
return mType == eBoolean;
}
inline bool&
GetAsBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
inline bool
GetAsBoolean() const
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
inline void
Uninit()
{
switch (mType) {
case eUninitialized: {
break;
}
case eAddEventListenerOptions: {
DestroyAddEventListenerOptions();
break;
}
case eBoolean: {
DestroyBoolean();
break;
}
}
}
private:
bool
TrySetToAddEventListenerOptions(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToAddEventListenerOptions(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyAddEventListenerOptions()
{
MOZ_RELEASE_ASSERT(IsAddEventListenerOptions(), "Wrong type!");
mValue.mAddEventListenerOptions.Destroy();
mType = eUninitialized;
}
bool
TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
mValue.mBoolean.Destroy();
mType = eUninitialized;
}
};
class OwningAddEventListenerOptionsOrBoolean : public AllOwningUnionBase
{
friend void ImplCycleCollectionUnlink(OwningAddEventListenerOptionsOrBoolean& aUnion);
enum TypeOrUninit
{
eUninitialized,
eAddEventListenerOptions,
eBoolean
};
public:
enum class Type
{
eAddEventListenerOptions = TypeOrUninit::eAddEventListenerOptions,
eBoolean = TypeOrUninit::eBoolean
};
private:
union Value
{
UnionMember<AddEventListenerOptions > mAddEventListenerOptions;
UnionMember<bool > mBoolean;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningAddEventListenerOptionsOrBoolean()
: mType(eUninitialized)
{
}
OwningAddEventListenerOptionsOrBoolean(OwningAddEventListenerOptionsOrBoolean&& aOther);
explicit inline OwningAddEventListenerOptionsOrBoolean(const OwningAddEventListenerOptionsOrBoolean& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningAddEventListenerOptionsOrBoolean()
{
Uninit();
}
[[nodiscard]] AddEventListenerOptions&
RawSetAsAddEventListenerOptions();
[[nodiscard]] AddEventListenerOptions&
SetAsAddEventListenerOptions();
inline bool
IsAddEventListenerOptions() const
{
return mType == eAddEventListenerOptions;
}
inline AddEventListenerOptions&
GetAsAddEventListenerOptions()
{
MOZ_RELEASE_ASSERT(IsAddEventListenerOptions(), "Wrong type!");
return mValue.mAddEventListenerOptions.Value();
}
inline AddEventListenerOptions const &
GetAsAddEventListenerOptions() const
{
MOZ_RELEASE_ASSERT(IsAddEventListenerOptions(), "Wrong type!");
return mValue.mAddEventListenerOptions.Value();
}
[[nodiscard]] bool&
RawSetAsBoolean();
[[nodiscard]] bool&
SetAsBoolean();
inline bool
IsBoolean() const
{
return mType == eBoolean;
}
inline bool&
GetAsBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
inline bool const &
GetAsBoolean() const
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
Uninit();
OwningAddEventListenerOptionsOrBoolean&
operator=(OwningAddEventListenerOptionsOrBoolean&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningAddEventListenerOptionsOrBoolean&
operator=(const OwningAddEventListenerOptionsOrBoolean& aOther);
private:
bool
TrySetToAddEventListenerOptions(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToAddEventListenerOptions(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyAddEventListenerOptions();
bool
TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyBoolean();
};
namespace EventTarget_Binding {
typedef mozilla::dom::EventTarget NativeType;
bool
Wrap(JSContext* aCx, mozilla::dom::EventTarget* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx)
{
/* Get the interface prototype object for this class. This will create the
object as needed. */
return GetPerInterfaceObjectHandle(aCx, prototypes::id::EventTarget,
&CreateInterfaceObjects,
/* aDefineOnGlobal = */ true);
}
JSObject*
GetProtoObject(JSContext* aCx);
inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true)
{
/* Get the interface object for this class. This will create the object as
needed. */
return GetPerInterfaceObjectHandle(aCx, constructors::id::EventTarget,
&CreateInterfaceObjects,
aDefineOnGlobal);
}
JSObject*
GetConstructorObject(JSContext* aCx);
} // namespace EventTarget_Binding
} // namespace mozilla::dom
#endif // DOM_EVENTTARGETBINDING_H_