Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM Selection.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_SELECTIONBINDING_H_
#define DOM_SELECTIONBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/dom/UnionMember.h"
#include "nsCycleCollectionParticipant.h"
namespace mozilla {
namespace dom {
struct GetComposedRangesOptionsAtoms;
struct NativePropertyHooks;
class OwningShadowRootOrGetComposedRangesOptions;
class ProtoAndIfaceCache;
class Selection;
class ShadowRoot;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningShadowRootOrGetComposedRangesOptions& aUnion, const char* aName, uint32_t aFlags = 0);
void
ImplCycleCollectionUnlink(OwningShadowRootOrGetComposedRangesOptions& aUnion);
struct GetComposedRangesOptions : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Sequence<OwningNonNull<mozilla::dom::ShadowRoot>> mShadowRoots;
GetComposedRangesOptions();
explicit inline GetComposedRangesOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
GetComposedRangesOptions(GetComposedRangesOptions&& aOther) = default;
explicit inline GetComposedRangesOptions(const GetComposedRangesOptions& 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);
inline void
TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
{
ImplCycleCollectionTraverse(aCallback, mShadowRoots, "mShadowRoots", aFlags);
}
inline void
UnlinkForCC()
{
ImplCycleCollectionUnlink(mShadowRoots);
}
GetComposedRangesOptions&
operator=(const GetComposedRangesOptions& aOther);
private:
static bool
InitIds(JSContext* cx, GetComposedRangesOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct FastGetComposedRangesOptions : public GetComposedRangesOptions
{
inline FastGetComposedRangesOptions()
: GetComposedRangesOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
class ShadowRootOrGetComposedRangesOptions : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eShadowRoot,
eGetComposedRangesOptions
};
public:
enum class Type
{
eShadowRoot = TypeOrUninit::eShadowRoot,
eGetComposedRangesOptions = TypeOrUninit::eGetComposedRangesOptions
};
private:
union Value
{
UnionMember<NonNull<mozilla::dom::ShadowRoot> > mShadowRoot;
UnionMember<binding_detail::FastGetComposedRangesOptions > mGetComposedRangesOptions;
};
TypeOrUninit mType;
Value mValue;
ShadowRootOrGetComposedRangesOptions(const ShadowRootOrGetComposedRangesOptions&) = delete;
ShadowRootOrGetComposedRangesOptions& operator=(const ShadowRootOrGetComposedRangesOptions&) = delete;
public:
explicit inline ShadowRootOrGetComposedRangesOptions()
: mType(eUninitialized)
{
}
inline ~ShadowRootOrGetComposedRangesOptions()
{
Uninit();
}
[[nodiscard]] inline NonNull<mozilla::dom::ShadowRoot>&
RawSetAsShadowRoot()
{
if (mType == eShadowRoot) {
return mValue.mShadowRoot.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eShadowRoot;
return mValue.mShadowRoot.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::ShadowRoot>&
SetAsShadowRoot()
{
if (mType == eShadowRoot) {
return mValue.mShadowRoot.Value();
}
Uninit();
mType = eShadowRoot;
return mValue.mShadowRoot.SetValue();
}
inline bool
IsShadowRoot() const
{
return mType == eShadowRoot;
}
inline NonNull<mozilla::dom::ShadowRoot>&
GetAsShadowRoot()
{
MOZ_RELEASE_ASSERT(IsShadowRoot(), "Wrong type!");
return mValue.mShadowRoot.Value();
}
inline mozilla::dom::ShadowRoot&
GetAsShadowRoot() const
{
MOZ_RELEASE_ASSERT(IsShadowRoot(), "Wrong type!");
return mValue.mShadowRoot.Value();
}
[[nodiscard]] inline binding_detail::FastGetComposedRangesOptions&
RawSetAsGetComposedRangesOptions()
{
if (mType == eGetComposedRangesOptions) {
return mValue.mGetComposedRangesOptions.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eGetComposedRangesOptions;
return mValue.mGetComposedRangesOptions.SetValue();
}
[[nodiscard]] inline binding_detail::FastGetComposedRangesOptions&
SetAsGetComposedRangesOptions()
{
if (mType == eGetComposedRangesOptions) {
return mValue.mGetComposedRangesOptions.Value();
}
Uninit();
mType = eGetComposedRangesOptions;
return mValue.mGetComposedRangesOptions.SetValue();
}
inline bool
IsGetComposedRangesOptions() const
{
return mType == eGetComposedRangesOptions;
}
inline binding_detail::FastGetComposedRangesOptions&
GetAsGetComposedRangesOptions()
{
MOZ_RELEASE_ASSERT(IsGetComposedRangesOptions(), "Wrong type!");
return mValue.mGetComposedRangesOptions.Value();
}
inline const GetComposedRangesOptions&
GetAsGetComposedRangesOptions() const
{
MOZ_RELEASE_ASSERT(IsGetComposedRangesOptions(), "Wrong type!");
return mValue.mGetComposedRangesOptions.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 eShadowRoot: {
DestroyShadowRoot();
break;
}
case eGetComposedRangesOptions: {
DestroyGetComposedRangesOptions();
break;
}
}
}
private:
bool
TrySetToShadowRoot(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToShadowRoot(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyShadowRoot()
{
MOZ_RELEASE_ASSERT(IsShadowRoot(), "Wrong type!");
mValue.mShadowRoot.Destroy();
mType = eUninitialized;
}
bool
TrySetToGetComposedRangesOptions(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToGetComposedRangesOptions(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyGetComposedRangesOptions()
{
MOZ_RELEASE_ASSERT(IsGetComposedRangesOptions(), "Wrong type!");
mValue.mGetComposedRangesOptions.Destroy();
mType = eUninitialized;
}
};
class OwningShadowRootOrGetComposedRangesOptions : public AllOwningUnionBase
{
friend void ImplCycleCollectionUnlink(OwningShadowRootOrGetComposedRangesOptions& aUnion);
enum TypeOrUninit
{
eUninitialized,
eShadowRoot,
eGetComposedRangesOptions
};
public:
enum class Type
{
eShadowRoot = TypeOrUninit::eShadowRoot,
eGetComposedRangesOptions = TypeOrUninit::eGetComposedRangesOptions
};
private:
union Value
{
UnionMember<OwningNonNull<mozilla::dom::ShadowRoot> > mShadowRoot;
UnionMember<GetComposedRangesOptions > mGetComposedRangesOptions;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningShadowRootOrGetComposedRangesOptions()
: mType(eUninitialized)
{
}
OwningShadowRootOrGetComposedRangesOptions(OwningShadowRootOrGetComposedRangesOptions&& aOther);
explicit inline OwningShadowRootOrGetComposedRangesOptions(const OwningShadowRootOrGetComposedRangesOptions& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningShadowRootOrGetComposedRangesOptions()
{
Uninit();
}
[[nodiscard]] OwningNonNull<mozilla::dom::ShadowRoot>&
RawSetAsShadowRoot();
[[nodiscard]] OwningNonNull<mozilla::dom::ShadowRoot>&
SetAsShadowRoot();
inline bool
IsShadowRoot() const
{
return mType == eShadowRoot;
}
inline OwningNonNull<mozilla::dom::ShadowRoot>&
GetAsShadowRoot()
{
MOZ_RELEASE_ASSERT(IsShadowRoot(), "Wrong type!");
return mValue.mShadowRoot.Value();
}
inline OwningNonNull<mozilla::dom::ShadowRoot> const &
GetAsShadowRoot() const
{
MOZ_RELEASE_ASSERT(IsShadowRoot(), "Wrong type!");
return mValue.mShadowRoot.Value();
}
[[nodiscard]] GetComposedRangesOptions&
RawSetAsGetComposedRangesOptions();
[[nodiscard]] GetComposedRangesOptions&
SetAsGetComposedRangesOptions();
inline bool
IsGetComposedRangesOptions() const
{
return mType == eGetComposedRangesOptions;
}
inline GetComposedRangesOptions&
GetAsGetComposedRangesOptions()
{
MOZ_RELEASE_ASSERT(IsGetComposedRangesOptions(), "Wrong type!");
return mValue.mGetComposedRangesOptions.Value();
}
inline GetComposedRangesOptions const &
GetAsGetComposedRangesOptions() const
{
MOZ_RELEASE_ASSERT(IsGetComposedRangesOptions(), "Wrong type!");
return mValue.mGetComposedRangesOptions.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();
OwningShadowRootOrGetComposedRangesOptions&
operator=(OwningShadowRootOrGetComposedRangesOptions&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningShadowRootOrGetComposedRangesOptions&
operator=(const OwningShadowRootOrGetComposedRangesOptions& aOther);
private:
bool
TrySetToShadowRoot(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToShadowRoot(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyShadowRoot();
bool
TrySetToGetComposedRangesOptions(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToGetComposedRangesOptions(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyGetComposedRangesOptions();
};
namespace Selection_Binding {
typedef mozilla::dom::Selection NativeType;
bool
Wrap(JSContext* aCx, mozilla::dom::Selection* 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, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::Selection,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace Selection_Binding
} // namespace mozilla::dom
#endif // DOM_SELECTIONBINDING_H_