Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM HTMLScriptElement.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_HTMLSCRIPTELEMENTBINDING_H_
#define DOM_HTMLSCRIPTELEMENTBINDING_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"
namespace mozilla {
namespace dom {
class HTMLScriptElement;
struct NativePropertyHooks;
class OwningTrustedScriptOrNullIsEmptyString;
class OwningTrustedScriptOrString;
class OwningTrustedScriptURLOrString;
class ProtoAndIfaceCache;
class TrustedScript;
class TrustedScriptURL;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningTrustedScriptOrNullIsEmptyString& aUnion, const char* aName, uint32_t aFlags = 0);
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningTrustedScriptOrString& aUnion, const char* aName, uint32_t aFlags = 0);
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningTrustedScriptURLOrString& aUnion, const char* aName, uint32_t aFlags = 0);
void
ImplCycleCollectionUnlink(OwningTrustedScriptOrNullIsEmptyString& aUnion);
void
ImplCycleCollectionUnlink(OwningTrustedScriptOrString& aUnion);
void
ImplCycleCollectionUnlink(OwningTrustedScriptURLOrString& aUnion);
class TrustedScriptOrNullIsEmptyString : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eTrustedScript,
eNullIsEmptyString
};
public:
enum class Type
{
eTrustedScript = TypeOrUninit::eTrustedScript,
eNullIsEmptyString = TypeOrUninit::eNullIsEmptyString
};
private:
union Value
{
UnionMember<NonNull<mozilla::dom::TrustedScript> > mTrustedScript;
UnionMember<binding_detail::FakeString<char16_t> > mNullIsEmptyString;
};
TypeOrUninit mType;
Value mValue;
TrustedScriptOrNullIsEmptyString(const TrustedScriptOrNullIsEmptyString&) = delete;
TrustedScriptOrNullIsEmptyString& operator=(const TrustedScriptOrNullIsEmptyString&) = delete;
public:
explicit inline TrustedScriptOrNullIsEmptyString()
: mType(eUninitialized)
{
}
inline ~TrustedScriptOrNullIsEmptyString()
{
Uninit();
}
[[nodiscard]] inline NonNull<mozilla::dom::TrustedScript>&
RawSetAsTrustedScript()
{
if (mType == eTrustedScript) {
return mValue.mTrustedScript.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eTrustedScript;
return mValue.mTrustedScript.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::TrustedScript>&
SetAsTrustedScript()
{
if (mType == eTrustedScript) {
return mValue.mTrustedScript.Value();
}
Uninit();
mType = eTrustedScript;
return mValue.mTrustedScript.SetValue();
}
inline bool
IsTrustedScript() const
{
return mType == eTrustedScript;
}
inline NonNull<mozilla::dom::TrustedScript>&
GetAsTrustedScript()
{
MOZ_RELEASE_ASSERT(IsTrustedScript(), "Wrong type!");
return mValue.mTrustedScript.Value();
}
inline mozilla::dom::TrustedScript&
GetAsTrustedScript() const
{
MOZ_RELEASE_ASSERT(IsTrustedScript(), "Wrong type!");
return mValue.mTrustedScript.Value();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
RawSetAsNullIsEmptyString()
{
if (mType == eNullIsEmptyString) {
return mValue.mNullIsEmptyString.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eNullIsEmptyString;
return mValue.mNullIsEmptyString.SetValue();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
SetAsNullIsEmptyString()
{
if (mType == eNullIsEmptyString) {
return mValue.mNullIsEmptyString.Value();
}
Uninit();
mType = eNullIsEmptyString;
return mValue.mNullIsEmptyString.SetValue();
}
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsNullIsEmptyString().AssignLiteral(aData);
}
inline bool
IsNullIsEmptyString() const
{
return mType == eNullIsEmptyString;
}
inline binding_detail::FakeString<char16_t>&
GetAsNullIsEmptyString()
{
MOZ_RELEASE_ASSERT(IsNullIsEmptyString(), "Wrong type!");
return mValue.mNullIsEmptyString.Value();
}
inline const nsAString&
GetAsNullIsEmptyString() const
{
MOZ_RELEASE_ASSERT(IsNullIsEmptyString(), "Wrong type!");
return mValue.mNullIsEmptyString.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 eTrustedScript: {
DestroyTrustedScript();
break;
}
case eNullIsEmptyString: {
DestroyNullIsEmptyString();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToTrustedScript(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToTrustedScript(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyTrustedScript()
{
MOZ_RELEASE_ASSERT(IsTrustedScript(), "Wrong type!");
mValue.mTrustedScript.Destroy();
mType = eUninitialized;
}
bool
TrySetToNullIsEmptyString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyNullIsEmptyString()
{
MOZ_RELEASE_ASSERT(IsNullIsEmptyString(), "Wrong type!");
mValue.mNullIsEmptyString.Destroy();
mType = eUninitialized;
}
};
class OwningTrustedScriptOrNullIsEmptyString : public AllOwningUnionBase
{
friend void ImplCycleCollectionUnlink(OwningTrustedScriptOrNullIsEmptyString& aUnion);
enum TypeOrUninit
{
eUninitialized,
eTrustedScript,
eNullIsEmptyString
};
public:
enum class Type
{
eTrustedScript = TypeOrUninit::eTrustedScript,
eNullIsEmptyString = TypeOrUninit::eNullIsEmptyString
};
private:
union Value
{
UnionMember<OwningNonNull<mozilla::dom::TrustedScript> > mTrustedScript;
UnionMember<nsString > mNullIsEmptyString;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningTrustedScriptOrNullIsEmptyString()
: mType(eUninitialized)
{
}
OwningTrustedScriptOrNullIsEmptyString(OwningTrustedScriptOrNullIsEmptyString&& aOther);
explicit inline OwningTrustedScriptOrNullIsEmptyString(const OwningTrustedScriptOrNullIsEmptyString& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningTrustedScriptOrNullIsEmptyString()
{
Uninit();
}
[[nodiscard]] OwningNonNull<mozilla::dom::TrustedScript>&
RawSetAsTrustedScript();
[[nodiscard]] OwningNonNull<mozilla::dom::TrustedScript>&
SetAsTrustedScript();
inline bool
IsTrustedScript() const
{
return mType == eTrustedScript;
}
inline OwningNonNull<mozilla::dom::TrustedScript>&
GetAsTrustedScript()
{
MOZ_RELEASE_ASSERT(IsTrustedScript(), "Wrong type!");
return mValue.mTrustedScript.Value();
}
inline OwningNonNull<mozilla::dom::TrustedScript> const &
GetAsTrustedScript() const
{
MOZ_RELEASE_ASSERT(IsTrustedScript(), "Wrong type!");
return mValue.mTrustedScript.Value();
}
[[nodiscard]] nsString&
RawSetAsNullIsEmptyString();
[[nodiscard]] nsString&
SetAsNullIsEmptyString();
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsNullIsEmptyString().AssignLiteral(aData);
}
inline bool
IsNullIsEmptyString() const
{
return mType == eNullIsEmptyString;
}
inline nsString&
GetAsNullIsEmptyString()
{
MOZ_RELEASE_ASSERT(IsNullIsEmptyString(), "Wrong type!");
return mValue.mNullIsEmptyString.Value();
}
inline nsString const &
GetAsNullIsEmptyString() const
{
MOZ_RELEASE_ASSERT(IsNullIsEmptyString(), "Wrong type!");
return mValue.mNullIsEmptyString.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;
OwningTrustedScriptOrNullIsEmptyString&
operator=(OwningTrustedScriptOrNullIsEmptyString&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningTrustedScriptOrNullIsEmptyString&
operator=(const OwningTrustedScriptOrNullIsEmptyString& aOther);
private:
bool
TrySetToTrustedScript(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToTrustedScript(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyTrustedScript();
bool
TrySetToNullIsEmptyString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyNullIsEmptyString();
};
class TrustedScriptOrString : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eTrustedScript,
eString
};
public:
enum class Type
{
eTrustedScript = TypeOrUninit::eTrustedScript,
eString = TypeOrUninit::eString
};
private:
union Value
{
UnionMember<NonNull<mozilla::dom::TrustedScript> > mTrustedScript;
UnionMember<binding_detail::FakeString<char16_t> > mString;
};
TypeOrUninit mType;
Value mValue;
TrustedScriptOrString(const TrustedScriptOrString&) = delete;
TrustedScriptOrString& operator=(const TrustedScriptOrString&) = delete;
public:
explicit inline TrustedScriptOrString()
: mType(eUninitialized)
{
}
inline ~TrustedScriptOrString()
{
Uninit();
}
[[nodiscard]] inline NonNull<mozilla::dom::TrustedScript>&
RawSetAsTrustedScript()
{
if (mType == eTrustedScript) {
return mValue.mTrustedScript.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eTrustedScript;
return mValue.mTrustedScript.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::TrustedScript>&
SetAsTrustedScript()
{
if (mType == eTrustedScript) {
return mValue.mTrustedScript.Value();
}
Uninit();
mType = eTrustedScript;
return mValue.mTrustedScript.SetValue();
}
inline bool
IsTrustedScript() const
{
return mType == eTrustedScript;
}
inline NonNull<mozilla::dom::TrustedScript>&
GetAsTrustedScript()
{
MOZ_RELEASE_ASSERT(IsTrustedScript(), "Wrong type!");
return mValue.mTrustedScript.Value();
}
inline mozilla::dom::TrustedScript&
GetAsTrustedScript() const
{
MOZ_RELEASE_ASSERT(IsTrustedScript(), "Wrong type!");
return mValue.mTrustedScript.Value();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
RawSetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eString;
return mValue.mString.SetValue();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
SetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
Uninit();
mType = eString;
return mValue.mString.SetValue();
}
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsString().AssignLiteral(aData);
}
inline bool
IsString() const
{
return mType == eString;
}
inline binding_detail::FakeString<char16_t>&
GetAsString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
inline const nsAString&
GetAsString() const
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.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 eTrustedScript: {
DestroyTrustedScript();
break;
}
case eString: {
DestroyString();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToTrustedScript(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToTrustedScript(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyTrustedScript()
{
MOZ_RELEASE_ASSERT(IsTrustedScript(), "Wrong type!");
mValue.mTrustedScript.Destroy();
mType = eUninitialized;
}
bool
TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
mValue.mString.Destroy();
mType = eUninitialized;
}
};
class OwningTrustedScriptOrString : public AllOwningUnionBase
{
friend void ImplCycleCollectionUnlink(OwningTrustedScriptOrString& aUnion);
enum TypeOrUninit
{
eUninitialized,
eTrustedScript,
eString
};
public:
enum class Type
{
eTrustedScript = TypeOrUninit::eTrustedScript,
eString = TypeOrUninit::eString
};
private:
union Value
{
UnionMember<OwningNonNull<mozilla::dom::TrustedScript> > mTrustedScript;
UnionMember<nsString > mString;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningTrustedScriptOrString()
: mType(eUninitialized)
{
}
OwningTrustedScriptOrString(OwningTrustedScriptOrString&& aOther);
explicit inline OwningTrustedScriptOrString(const OwningTrustedScriptOrString& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningTrustedScriptOrString()
{
Uninit();
}
[[nodiscard]] OwningNonNull<mozilla::dom::TrustedScript>&
RawSetAsTrustedScript();
[[nodiscard]] OwningNonNull<mozilla::dom::TrustedScript>&
SetAsTrustedScript();
inline bool
IsTrustedScript() const
{
return mType == eTrustedScript;
}
inline OwningNonNull<mozilla::dom::TrustedScript>&
GetAsTrustedScript()
{
MOZ_RELEASE_ASSERT(IsTrustedScript(), "Wrong type!");
return mValue.mTrustedScript.Value();
}
inline OwningNonNull<mozilla::dom::TrustedScript> const &
GetAsTrustedScript() const
{
MOZ_RELEASE_ASSERT(IsTrustedScript(), "Wrong type!");
return mValue.mTrustedScript.Value();
}
[[nodiscard]] nsString&
RawSetAsString();
[[nodiscard]] nsString&
SetAsString();
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsString().AssignLiteral(aData);
}
inline bool
IsString() const
{
return mType == eString;
}
inline nsString&
GetAsString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
inline nsString const &
GetAsString() const
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.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;
OwningTrustedScriptOrString&
operator=(OwningTrustedScriptOrString&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningTrustedScriptOrString&
operator=(const OwningTrustedScriptOrString& aOther);
private:
bool
TrySetToTrustedScript(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToTrustedScript(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyTrustedScript();
bool
TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyString();
};
class TrustedScriptURLOrString : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eTrustedScriptURL,
eString
};
public:
enum class Type
{
eTrustedScriptURL = TypeOrUninit::eTrustedScriptURL,
eString = TypeOrUninit::eString
};
private:
union Value
{
UnionMember<NonNull<mozilla::dom::TrustedScriptURL> > mTrustedScriptURL;
UnionMember<binding_detail::FakeString<char16_t> > mString;
};
TypeOrUninit mType;
Value mValue;
TrustedScriptURLOrString(const TrustedScriptURLOrString&) = delete;
TrustedScriptURLOrString& operator=(const TrustedScriptURLOrString&) = delete;
public:
explicit inline TrustedScriptURLOrString()
: mType(eUninitialized)
{
}
inline ~TrustedScriptURLOrString()
{
Uninit();
}
[[nodiscard]] inline NonNull<mozilla::dom::TrustedScriptURL>&
RawSetAsTrustedScriptURL()
{
if (mType == eTrustedScriptURL) {
return mValue.mTrustedScriptURL.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eTrustedScriptURL;
return mValue.mTrustedScriptURL.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::TrustedScriptURL>&
SetAsTrustedScriptURL()
{
if (mType == eTrustedScriptURL) {
return mValue.mTrustedScriptURL.Value();
}
Uninit();
mType = eTrustedScriptURL;
return mValue.mTrustedScriptURL.SetValue();
}
inline bool
IsTrustedScriptURL() const
{
return mType == eTrustedScriptURL;
}
inline NonNull<mozilla::dom::TrustedScriptURL>&
GetAsTrustedScriptURL()
{
MOZ_RELEASE_ASSERT(IsTrustedScriptURL(), "Wrong type!");
return mValue.mTrustedScriptURL.Value();
}
inline mozilla::dom::TrustedScriptURL&
GetAsTrustedScriptURL() const
{
MOZ_RELEASE_ASSERT(IsTrustedScriptURL(), "Wrong type!");
return mValue.mTrustedScriptURL.Value();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
RawSetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eString;
return mValue.mString.SetValue();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
SetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
Uninit();
mType = eString;
return mValue.mString.SetValue();
}
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsString().AssignLiteral(aData);
}
inline bool
IsString() const
{
return mType == eString;
}
inline binding_detail::FakeString<char16_t>&
GetAsString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
inline const nsAString&
GetAsString() const
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.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 eTrustedScriptURL: {
DestroyTrustedScriptURL();
break;
}
case eString: {
DestroyString();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToTrustedScriptURL(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToTrustedScriptURL(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyTrustedScriptURL()
{
MOZ_RELEASE_ASSERT(IsTrustedScriptURL(), "Wrong type!");
mValue.mTrustedScriptURL.Destroy();
mType = eUninitialized;
}
bool
TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
mValue.mString.Destroy();
mType = eUninitialized;
}
};
class OwningTrustedScriptURLOrString : public AllOwningUnionBase
{
friend void ImplCycleCollectionUnlink(OwningTrustedScriptURLOrString& aUnion);
enum TypeOrUninit
{
eUninitialized,
eTrustedScriptURL,
eString
};
public:
enum class Type
{
eTrustedScriptURL = TypeOrUninit::eTrustedScriptURL,
eString = TypeOrUninit::eString
};
private:
union Value
{
UnionMember<OwningNonNull<mozilla::dom::TrustedScriptURL> > mTrustedScriptURL;
UnionMember<nsString > mString;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningTrustedScriptURLOrString()
: mType(eUninitialized)
{
}
OwningTrustedScriptURLOrString(OwningTrustedScriptURLOrString&& aOther);
explicit inline OwningTrustedScriptURLOrString(const OwningTrustedScriptURLOrString& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningTrustedScriptURLOrString()
{
Uninit();
}
[[nodiscard]] OwningNonNull<mozilla::dom::TrustedScriptURL>&
RawSetAsTrustedScriptURL();
[[nodiscard]] OwningNonNull<mozilla::dom::TrustedScriptURL>&
SetAsTrustedScriptURL();
inline bool
IsTrustedScriptURL() const
{
return mType == eTrustedScriptURL;
}
inline OwningNonNull<mozilla::dom::TrustedScriptURL>&
GetAsTrustedScriptURL()
{
MOZ_RELEASE_ASSERT(IsTrustedScriptURL(), "Wrong type!");
return mValue.mTrustedScriptURL.Value();
}
inline OwningNonNull<mozilla::dom::TrustedScriptURL> const &
GetAsTrustedScriptURL() const
{
MOZ_RELEASE_ASSERT(IsTrustedScriptURL(), "Wrong type!");
return mValue.mTrustedScriptURL.Value();
}
[[nodiscard]] nsString&
RawSetAsString();
[[nodiscard]] nsString&
SetAsString();
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsString().AssignLiteral(aData);
}
inline bool
IsString() const
{
return mType == eString;
}
inline nsString&
GetAsString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
inline nsString const &
GetAsString() const
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.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;
OwningTrustedScriptURLOrString&
operator=(OwningTrustedScriptURLOrString&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningTrustedScriptURLOrString&
operator=(const OwningTrustedScriptURLOrString& aOther);
private:
bool
TrySetToTrustedScriptURL(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToTrustedScriptURL(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyTrustedScriptURL();
bool
TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyString();
};
namespace HTMLScriptElement_Binding {
typedef mozilla::dom::HTMLScriptElement NativeType;
bool
CountMaybeMissingProperty(JS::Handle<JSObject*> proxy, JS::Handle<jsid> id);
bool
Wrap(JSContext* aCx, mozilla::dom::HTMLScriptElement* 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::HTMLScriptElement,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace HTMLScriptElement_Binding
} // namespace mozilla::dom
#endif // DOM_HTMLSCRIPTELEMENTBINDING_H_