Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM HTMLAllCollection.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_HTMLALLCOLLECTIONBINDING_H_
#define DOM_HTMLALLCOLLECTIONBINDING_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/UnionMember.h"
class nsIHTMLCollection;
namespace mozilla {
namespace dom {
class Element;
class HTMLAllCollection;
struct NativePropertyHooks;
class OwningHTMLCollectionOrElement;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningHTMLCollectionOrElement& aUnion, const char* aName, uint32_t aFlags = 0);
void
ImplCycleCollectionUnlink(OwningHTMLCollectionOrElement& aUnion);
class HTMLCollectionOrElement : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eHTMLCollection,
eElement
};
public:
enum class Type
{
eHTMLCollection = TypeOrUninit::eHTMLCollection,
eElement = TypeOrUninit::eElement
};
private:
union Value
{
UnionMember<NonNull<nsIHTMLCollection> > mHTMLCollection;
UnionMember<NonNull<mozilla::dom::Element> > mElement;
};
TypeOrUninit mType;
Value mValue;
HTMLCollectionOrElement(const HTMLCollectionOrElement&) = delete;
HTMLCollectionOrElement& operator=(const HTMLCollectionOrElement&) = delete;
public:
explicit inline HTMLCollectionOrElement()
: mType(eUninitialized)
{
}
inline ~HTMLCollectionOrElement()
{
Uninit();
}
[[nodiscard]] inline NonNull<nsIHTMLCollection>&
RawSetAsHTMLCollection()
{
if (mType == eHTMLCollection) {
return mValue.mHTMLCollection.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eHTMLCollection;
return mValue.mHTMLCollection.SetValue();
}
[[nodiscard]] inline NonNull<nsIHTMLCollection>&
SetAsHTMLCollection()
{
if (mType == eHTMLCollection) {
return mValue.mHTMLCollection.Value();
}
Uninit();
mType = eHTMLCollection;
return mValue.mHTMLCollection.SetValue();
}
inline bool
IsHTMLCollection() const
{
return mType == eHTMLCollection;
}
inline NonNull<nsIHTMLCollection>&
GetAsHTMLCollection()
{
MOZ_RELEASE_ASSERT(IsHTMLCollection(), "Wrong type!");
return mValue.mHTMLCollection.Value();
}
inline nsIHTMLCollection&
GetAsHTMLCollection() const
{
MOZ_RELEASE_ASSERT(IsHTMLCollection(), "Wrong type!");
return mValue.mHTMLCollection.Value();
}
[[nodiscard]] inline NonNull<mozilla::dom::Element>&
RawSetAsElement()
{
if (mType == eElement) {
return mValue.mElement.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eElement;
return mValue.mElement.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::Element>&
SetAsElement()
{
if (mType == eElement) {
return mValue.mElement.Value();
}
Uninit();
mType = eElement;
return mValue.mElement.SetValue();
}
inline bool
IsElement() const
{
return mType == eElement;
}
inline NonNull<mozilla::dom::Element>&
GetAsElement()
{
MOZ_RELEASE_ASSERT(IsElement(), "Wrong type!");
return mValue.mElement.Value();
}
inline mozilla::dom::Element&
GetAsElement() const
{
MOZ_RELEASE_ASSERT(IsElement(), "Wrong type!");
return mValue.mElement.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 eHTMLCollection: {
DestroyHTMLCollection();
break;
}
case eElement: {
DestroyElement();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToHTMLCollection(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToHTMLCollection(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyHTMLCollection()
{
MOZ_RELEASE_ASSERT(IsHTMLCollection(), "Wrong type!");
mValue.mHTMLCollection.Destroy();
mType = eUninitialized;
}
bool
TrySetToElement(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToElement(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyElement()
{
MOZ_RELEASE_ASSERT(IsElement(), "Wrong type!");
mValue.mElement.Destroy();
mType = eUninitialized;
}
};
class OwningHTMLCollectionOrElement : public AllOwningUnionBase
{
friend void ImplCycleCollectionUnlink(OwningHTMLCollectionOrElement& aUnion);
enum TypeOrUninit
{
eUninitialized,
eHTMLCollection,
eElement
};
public:
enum class Type
{
eHTMLCollection = TypeOrUninit::eHTMLCollection,
eElement = TypeOrUninit::eElement
};
private:
union Value
{
UnionMember<OwningNonNull<nsIHTMLCollection> > mHTMLCollection;
UnionMember<OwningNonNull<mozilla::dom::Element> > mElement;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningHTMLCollectionOrElement()
: mType(eUninitialized)
{
}
OwningHTMLCollectionOrElement(OwningHTMLCollectionOrElement&& aOther);
explicit inline OwningHTMLCollectionOrElement(const OwningHTMLCollectionOrElement& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningHTMLCollectionOrElement()
{
Uninit();
}
[[nodiscard]] OwningNonNull<nsIHTMLCollection>&
RawSetAsHTMLCollection();
[[nodiscard]] OwningNonNull<nsIHTMLCollection>&
SetAsHTMLCollection();
inline bool
IsHTMLCollection() const
{
return mType == eHTMLCollection;
}
inline OwningNonNull<nsIHTMLCollection>&
GetAsHTMLCollection()
{
MOZ_RELEASE_ASSERT(IsHTMLCollection(), "Wrong type!");
return mValue.mHTMLCollection.Value();
}
inline OwningNonNull<nsIHTMLCollection> const &
GetAsHTMLCollection() const
{
MOZ_RELEASE_ASSERT(IsHTMLCollection(), "Wrong type!");
return mValue.mHTMLCollection.Value();
}
[[nodiscard]] OwningNonNull<mozilla::dom::Element>&
RawSetAsElement();
[[nodiscard]] OwningNonNull<mozilla::dom::Element>&
SetAsElement();
inline bool
IsElement() const
{
return mType == eElement;
}
inline OwningNonNull<mozilla::dom::Element>&
GetAsElement()
{
MOZ_RELEASE_ASSERT(IsElement(), "Wrong type!");
return mValue.mElement.Value();
}
inline OwningNonNull<mozilla::dom::Element> const &
GetAsElement() const
{
MOZ_RELEASE_ASSERT(IsElement(), "Wrong type!");
return mValue.mElement.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();
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
OwningHTMLCollectionOrElement&
operator=(OwningHTMLCollectionOrElement&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningHTMLCollectionOrElement&
operator=(const OwningHTMLCollectionOrElement& aOther);
private:
bool
TrySetToHTMLCollection(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToHTMLCollection(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyHTMLCollection();
bool
TrySetToElement(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToElement(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyElement();
};
namespace HTMLAllCollection_Binding {
typedef mozilla::dom::HTMLAllCollection NativeType;
bool
Wrap(JSContext* aCx, mozilla::dom::HTMLAllCollection* 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::HTMLAllCollection,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace HTMLAllCollection_Binding
} // namespace mozilla::dom
#endif // DOM_HTMLALLCOLLECTIONBINDING_H_