/* THIS FILE IS AUTOGENERATED FROM VTTCue.webidl BY Codegen.py - DO NOT EDIT */ #include #include "MainThreadUtils.h" #include "TextTrackCueBinding.h" #include "VTTCueBinding.h" #include "WrapperFactory.h" #include "js/CallAndConstruct.h" #include "js/Exception.h" #include "js/MapAndSet.h" #include "js/Object.h" #include "js/PropertyAndElement.h" #include "js/PropertyDescriptor.h" #include "js/experimental/JitInfo.h" #include "jsapi.h" #include "mozilla/Atomics.h" #include "mozilla/FloatingPoint.h" #include "mozilla/OwningNonNull.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/dom/BindingCallContext.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/DOMJSClass.h" #include "mozilla/dom/DocumentFragment.h" #include "mozilla/dom/HTMLDivElement.h" #include "mozilla/dom/NonRefcountedDOMObject.h" #include "mozilla/dom/Nullable.h" #include "mozilla/dom/PrimitiveConversions.h" #include "mozilla/dom/TextTrackCue.h" #include "mozilla/dom/TextTrackRegion.h" #include "mozilla/dom/XrayExpandoClass.h" #include "nsContentUtils.h" namespace mozilla { namespace dom { namespace binding_detail {}; // Just to make sure it's known as a namespace using namespace mozilla::dom::binding_detail; namespace binding_detail { constexpr nsLiteralCString EnumStrings::Values[1]; } // namespace binding_detail bool ToJSValue(JSContext* aCx, AutoKeyword aArgument, JS::MutableHandle aValue) { MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings::Values)); JSString* resultStr = JS_NewStringCopyN(aCx, binding_detail::EnumStrings::Values[uint32_t(aArgument)].BeginReading(), binding_detail::EnumStrings::Values[uint32_t(aArgument)].Length()); if (!resultStr) { return false; } aValue.setString(resultStr); return true; } namespace binding_detail { constexpr nsLiteralCString EnumStrings::Values[3]; } // namespace binding_detail bool ToJSValue(JSContext* aCx, LineAlignSetting aArgument, JS::MutableHandle aValue) { MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings::Values)); JSString* resultStr = JS_NewStringCopyN(aCx, binding_detail::EnumStrings::Values[uint32_t(aArgument)].BeginReading(), binding_detail::EnumStrings::Values[uint32_t(aArgument)].Length()); if (!resultStr) { return false; } aValue.setString(resultStr); return true; } namespace binding_detail { constexpr nsLiteralCString EnumStrings::Values[4]; } // namespace binding_detail bool ToJSValue(JSContext* aCx, PositionAlignSetting aArgument, JS::MutableHandle aValue) { MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings::Values)); JSString* resultStr = JS_NewStringCopyN(aCx, binding_detail::EnumStrings::Values[uint32_t(aArgument)].BeginReading(), binding_detail::EnumStrings::Values[uint32_t(aArgument)].Length()); if (!resultStr) { return false; } aValue.setString(resultStr); return true; } namespace binding_detail { constexpr nsLiteralCString EnumStrings::Values[5]; } // namespace binding_detail bool ToJSValue(JSContext* aCx, AlignSetting aArgument, JS::MutableHandle aValue) { MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings::Values)); JSString* resultStr = JS_NewStringCopyN(aCx, binding_detail::EnumStrings::Values[uint32_t(aArgument)].BeginReading(), binding_detail::EnumStrings::Values[uint32_t(aArgument)].Length()); if (!resultStr) { return false; } aValue.setString(resultStr); return true; } namespace binding_detail { constexpr nsLiteralCString EnumStrings::Values[3]; } // namespace binding_detail bool ToJSValue(JSContext* aCx, DirectionSetting aArgument, JS::MutableHandle aValue) { MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings::Values)); JSString* resultStr = JS_NewStringCopyN(aCx, binding_detail::EnumStrings::Values[uint32_t(aArgument)].BeginReading(), binding_detail::EnumStrings::Values[uint32_t(aArgument)].Length()); if (!resultStr) { return false; } aValue.setString(resultStr); return true; } bool DoubleOrAutoKeyword::TrySetToDouble(BindingCallContext& cx, JS::Handle value, bool& tryNext, bool passedToJSImpl) { tryNext = false; { // scope for memberSlot double& memberSlot = RawSetAsDouble(); if (!ValueToPrimitive(cx, value, "Double branch of (double or AutoKeyword)", &memberSlot)) { return false; } else if (!std::isfinite(memberSlot)) { cx.ThrowErrorMessage("Double branch of (double or AutoKeyword)"); return false; } } return true; } bool DoubleOrAutoKeyword::TrySetToDouble(JSContext* cx_, JS::Handle value, bool& tryNext, bool passedToJSImpl) { BindingCallContext cx(cx_, nullptr); return TrySetToDouble(cx, value, tryNext, passedToJSImpl); } bool DoubleOrAutoKeyword::TrySetToAutoKeyword(BindingCallContext& cx, JS::Handle value, bool& tryNext, bool passedToJSImpl) { tryNext = false; { // scope for memberSlot AutoKeyword& memberSlot = RawSetAsAutoKeyword(); { int index; if (!binding_detail::FindEnumStringIndex(cx, value, binding_detail::EnumStrings::Values, "AutoKeyword", "AutoKeyword branch of (double or AutoKeyword)", &index)) { return false; } MOZ_ASSERT(index >= 0); memberSlot = static_cast(index); } } return true; } bool DoubleOrAutoKeyword::TrySetToAutoKeyword(JSContext* cx_, JS::Handle value, bool& tryNext, bool passedToJSImpl) { BindingCallContext cx(cx_, nullptr); return TrySetToAutoKeyword(cx, value, tryNext, passedToJSImpl); } bool DoubleOrAutoKeyword::Init(BindingCallContext& cx, JS::Handle value, const char* sourceDescription, bool passedToJSImpl) { MOZ_ASSERT(mType == eUninitialized); bool done = false, failed = false, tryNext; do { if (value.isNumber()) { done = (failed = !TrySetToDouble(cx, value, tryNext)) || !tryNext; break; } done = (failed = !TrySetToAutoKeyword(cx, value, tryNext)) || !tryNext; break; } while (false); if (failed) { return false; } if (!done) { cx.ThrowErrorMessage(sourceDescription, ""); return false; } return true; } bool DoubleOrAutoKeyword::Init(JSContext* cx_, JS::Handle value, const char* sourceDescription, bool passedToJSImpl) { BindingCallContext cx(cx_, nullptr); return Init(cx, value, sourceDescription, passedToJSImpl); } bool DoubleOrAutoKeyword::ToJSVal(JSContext* cx, JS::Handle scopeObj, JS::MutableHandle rval) const { switch (mType) { case eUninitialized: { return false; } case eDouble: { rval.set(JS::NumberValue(double(mValue.mDouble.Value()))); return true; } case eAutoKeyword: { if (!ToJSValue(cx, mValue.mAutoKeyword.Value(), rval)) { return false; } return true; } default: { return false; } } } OwningDoubleOrAutoKeyword::OwningDoubleOrAutoKeyword(OwningDoubleOrAutoKeyword&& aOther) : mType(eUninitialized) { switch (aOther.mType) { case eUninitialized: { MOZ_ASSERT(mType == eUninitialized, "We need to destroy ourselves?"); break; } case eDouble: { mType = eDouble; mValue.mDouble.SetValue(std::move(aOther.mValue.mDouble.Value())); break; } case eAutoKeyword: { mType = eAutoKeyword; mValue.mAutoKeyword.SetValue(std::move(aOther.mValue.mAutoKeyword.Value())); break; } } } bool OwningDoubleOrAutoKeyword::TrySetToDouble(BindingCallContext& cx, JS::Handle value, bool& tryNext, bool passedToJSImpl) { tryNext = false; { // scope for memberSlot double& memberSlot = RawSetAsDouble(); if (!ValueToPrimitive(cx, value, "Double branch of (double or AutoKeyword)", &memberSlot)) { return false; } else if (!std::isfinite(memberSlot)) { cx.ThrowErrorMessage("Double branch of (double or AutoKeyword)"); return false; } } return true; } bool OwningDoubleOrAutoKeyword::TrySetToDouble(JSContext* cx_, JS::Handle value, bool& tryNext, bool passedToJSImpl) { BindingCallContext cx(cx_, nullptr); return TrySetToDouble(cx, value, tryNext, passedToJSImpl); } [[nodiscard]] double& OwningDoubleOrAutoKeyword::RawSetAsDouble() { if (mType == eDouble) { return mValue.mDouble.Value(); } MOZ_ASSERT(mType == eUninitialized); mType = eDouble; return mValue.mDouble.SetValue(); } [[nodiscard]] double& OwningDoubleOrAutoKeyword::SetAsDouble() { if (mType == eDouble) { return mValue.mDouble.Value(); } Uninit(); mType = eDouble; return mValue.mDouble.SetValue(); } void OwningDoubleOrAutoKeyword::DestroyDouble() { MOZ_RELEASE_ASSERT(IsDouble(), "Wrong type!"); mValue.mDouble.Destroy(); mType = eUninitialized; } bool OwningDoubleOrAutoKeyword::TrySetToAutoKeyword(BindingCallContext& cx, JS::Handle value, bool& tryNext, bool passedToJSImpl) { tryNext = false; { // scope for memberSlot AutoKeyword& memberSlot = RawSetAsAutoKeyword(); { int index; if (!binding_detail::FindEnumStringIndex(cx, value, binding_detail::EnumStrings::Values, "AutoKeyword", "AutoKeyword branch of (double or AutoKeyword)", &index)) { return false; } MOZ_ASSERT(index >= 0); memberSlot = static_cast(index); } } return true; } bool OwningDoubleOrAutoKeyword::TrySetToAutoKeyword(JSContext* cx_, JS::Handle value, bool& tryNext, bool passedToJSImpl) { BindingCallContext cx(cx_, nullptr); return TrySetToAutoKeyword(cx, value, tryNext, passedToJSImpl); } [[nodiscard]] AutoKeyword& OwningDoubleOrAutoKeyword::RawSetAsAutoKeyword() { if (mType == eAutoKeyword) { return mValue.mAutoKeyword.Value(); } MOZ_ASSERT(mType == eUninitialized); mType = eAutoKeyword; return mValue.mAutoKeyword.SetValue(); } [[nodiscard]] AutoKeyword& OwningDoubleOrAutoKeyword::SetAsAutoKeyword() { if (mType == eAutoKeyword) { return mValue.mAutoKeyword.Value(); } Uninit(); mType = eAutoKeyword; return mValue.mAutoKeyword.SetValue(); } void OwningDoubleOrAutoKeyword::DestroyAutoKeyword() { MOZ_RELEASE_ASSERT(IsAutoKeyword(), "Wrong type!"); mValue.mAutoKeyword.Destroy(); mType = eUninitialized; } bool OwningDoubleOrAutoKeyword::Init(BindingCallContext& cx, JS::Handle value, const char* sourceDescription, bool passedToJSImpl) { MOZ_ASSERT(mType == eUninitialized); bool done = false, failed = false, tryNext; do { if (value.isNumber()) { done = (failed = !TrySetToDouble(cx, value, tryNext)) || !tryNext; break; } done = (failed = !TrySetToAutoKeyword(cx, value, tryNext)) || !tryNext; break; } while (false); if (failed) { return false; } if (!done) { cx.ThrowErrorMessage(sourceDescription, ""); return false; } return true; } bool OwningDoubleOrAutoKeyword::Init(JSContext* cx_, JS::Handle value, const char* sourceDescription, bool passedToJSImpl) { BindingCallContext cx(cx_, nullptr); return Init(cx, value, sourceDescription, passedToJSImpl); } void OwningDoubleOrAutoKeyword::Uninit() { switch (mType) { case eUninitialized: { break; } case eDouble: { DestroyDouble(); break; } case eAutoKeyword: { DestroyAutoKeyword(); break; } } } bool OwningDoubleOrAutoKeyword::ToJSVal(JSContext* cx, JS::Handle scopeObj, JS::MutableHandle rval) const { switch (mType) { case eUninitialized: { return false; } case eDouble: { rval.set(JS::NumberValue(double(mValue.mDouble.Value()))); return true; } case eAutoKeyword: { if (!ToJSValue(cx, mValue.mAutoKeyword.Value(), rval)) { return false; } return true; } default: { return false; } } } OwningDoubleOrAutoKeyword& OwningDoubleOrAutoKeyword::operator=(OwningDoubleOrAutoKeyword&& aOther) { this->~OwningDoubleOrAutoKeyword(); new (this) OwningDoubleOrAutoKeyword (std::move(aOther)); return *this; } OwningDoubleOrAutoKeyword& OwningDoubleOrAutoKeyword::operator=(const OwningDoubleOrAutoKeyword& aOther) { switch (aOther.mType) { case eUninitialized: { MOZ_ASSERT(mType == eUninitialized, "We need to destroy ourselves?"); break; } case eDouble: { SetAsDouble() = aOther.GetAsDouble(); break; } case eAutoKeyword: { SetAsAutoKeyword() = aOther.GetAsAutoKeyword(); break; } } return *this; } namespace VTTCue_Binding { static_assert(IsRefcounted::value == IsRefcounted::value, "Can't inherit from an interface with a different ownership model."); MOZ_CAN_RUN_SCRIPT static bool get_region(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "region", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); auto result(StrongOrRawPtr(MOZ_KnownLive(self)->GetRegion())); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!result) { args.rval().setNull(); return true; } if (!GetOrCreateDOMReflector(cx, result, args.rval())) { MOZ_ASSERT(JS_IsExceptionPending(cx)); return false; } return true; } MOZ_CAN_RUN_SCRIPT static bool set_region(JSContext* cx_, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { BindingCallContext cx(cx_, "VTTCue.region setter"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "region", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); mozilla::dom::TextTrackRegion* arg0; if (args[0].isObject()) { { // Our JSContext should be in the right global to do unwrapping in. nsresult rv = UnwrapObject(args[0], arg0, cx); if (NS_FAILED(rv)) { cx.ThrowErrorMessage("Value being assigned", "VTTRegion"); return false; } } } else if (args[0].isNullOrUndefined()) { arg0 = nullptr; } else { cx.ThrowErrorMessage("Value being assigned"); return false; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetRegion(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetRegion(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo region_getterinfo = { { get_region }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo region_setterinfo = { { (JSJitGetterOp)set_region }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_vertical(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "vertical", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); DirectionSetting result(MOZ_KnownLive(self)->Vertical()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!ToJSValue(cx, result, args.rval())) { return false; } return true; } MOZ_CAN_RUN_SCRIPT static bool set_vertical(JSContext* cx_, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { BindingCallContext cx(cx_, "VTTCue.vertical setter"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "vertical", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); DirectionSetting arg0; { int index; if (!binding_detail::FindEnumStringIndex(cx, args[0], binding_detail::EnumStrings::Values, "DirectionSetting", "value being assigned", &index)) { return false; } if (index < 0) { return true; } arg0 = static_cast(index); } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetVertical(arg0))>, "Should be returning void here"); MOZ_KnownLive(self)->SetVertical(arg0); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo vertical_getterinfo = { { get_vertical }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo vertical_setterinfo = { { (JSJitGetterOp)set_vertical }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_snapToLines(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "snapToLines", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); bool result(MOZ_KnownLive(self)->SnapToLines()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); args.rval().setBoolean(result); return true; } MOZ_CAN_RUN_SCRIPT static bool set_snapToLines(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "snapToLines", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); bool arg0; if (!ValueToPrimitive(cx, args[0], "Value being assigned", &arg0)) { return false; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetSnapToLines(arg0))>, "Should be returning void here"); MOZ_KnownLive(self)->SetSnapToLines(arg0); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo snapToLines_getterinfo = { { get_snapToLines }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ true, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo snapToLines_setterinfo = { { (JSJitGetterOp)set_snapToLines }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_line(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "line", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); OwningDoubleOrAutoKeyword result; // NOTE: This assert does NOT call the function. static_assert(std::is_void_vGetLine(result))>, "Should be returning void here"); MOZ_KnownLive(self)->GetLine(result); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!result.ToJSVal(cx, obj, args.rval())) { return false; } return true; } MOZ_CAN_RUN_SCRIPT static bool set_line(JSContext* cx_, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { BindingCallContext cx(cx_, "VTTCue.line setter"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "line", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); DoubleOrAutoKeyword arg0; if (!arg0.Init(cx, args[0], "Value being assigned", false)) { return false; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetLine(Constify(arg0)))>, "Should be returning void here"); MOZ_KnownLive(self)->SetLine(Constify(arg0)); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo line_getterinfo = { { get_line }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo line_setterinfo = { { (JSJitGetterOp)set_line }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_lineAlign(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "lineAlign", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); LineAlignSetting result(MOZ_KnownLive(self)->LineAlign()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!ToJSValue(cx, result, args.rval())) { return false; } return true; } MOZ_CAN_RUN_SCRIPT static bool set_lineAlign(JSContext* cx_, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { BindingCallContext cx(cx_, "VTTCue.lineAlign setter"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "lineAlign", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); LineAlignSetting arg0; { int index; if (!binding_detail::FindEnumStringIndex(cx, args[0], binding_detail::EnumStrings::Values, "LineAlignSetting", "value being assigned", &index)) { return false; } if (index < 0) { return true; } arg0 = static_cast(index); } FastErrorResult rv; // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetLineAlign(arg0, rv))>, "Should be returning void here"); MOZ_KnownLive(self)->SetLineAlign(arg0, rv); if (rv.MaybeSetPendingException(cx, "VTTCue.lineAlign setter")) [[unlikely]] { return false; } MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo lineAlign_getterinfo = { { get_lineAlign }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo lineAlign_setterinfo = { { (JSJitGetterOp)set_lineAlign }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_position(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "position", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); OwningDoubleOrAutoKeyword result; // NOTE: This assert does NOT call the function. static_assert(std::is_void_vGetPosition(result))>, "Should be returning void here"); MOZ_KnownLive(self)->GetPosition(result); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!result.ToJSVal(cx, obj, args.rval())) { return false; } return true; } MOZ_CAN_RUN_SCRIPT static bool set_position(JSContext* cx_, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { BindingCallContext cx(cx_, "VTTCue.position setter"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "position", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); DoubleOrAutoKeyword arg0; if (!arg0.Init(cx, args[0], "Value being assigned", false)) { return false; } FastErrorResult rv; // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetPosition(Constify(arg0), rv))>, "Should be returning void here"); MOZ_KnownLive(self)->SetPosition(Constify(arg0), rv); if (rv.MaybeSetPendingException(cx, "VTTCue.position setter")) [[unlikely]] { return false; } MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo position_getterinfo = { { get_position }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo position_setterinfo = { { (JSJitGetterOp)set_position }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_positionAlign(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "positionAlign", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); PositionAlignSetting result(MOZ_KnownLive(self)->PositionAlign()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!ToJSValue(cx, result, args.rval())) { return false; } return true; } MOZ_CAN_RUN_SCRIPT static bool set_positionAlign(JSContext* cx_, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { BindingCallContext cx(cx_, "VTTCue.positionAlign setter"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "positionAlign", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); PositionAlignSetting arg0; { int index; if (!binding_detail::FindEnumStringIndex(cx, args[0], binding_detail::EnumStrings::Values, "PositionAlignSetting", "value being assigned", &index)) { return false; } if (index < 0) { return true; } arg0 = static_cast(index); } FastErrorResult rv; // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetPositionAlign(arg0, rv))>, "Should be returning void here"); MOZ_KnownLive(self)->SetPositionAlign(arg0, rv); if (rv.MaybeSetPendingException(cx, "VTTCue.positionAlign setter")) [[unlikely]] { return false; } MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo positionAlign_getterinfo = { { get_positionAlign }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo positionAlign_setterinfo = { { (JSJitGetterOp)set_positionAlign }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_size(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "size", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); double result(MOZ_KnownLive(self)->Size()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); args.rval().set(JS::NumberValue(double(result))); return true; } MOZ_CAN_RUN_SCRIPT static bool set_size(JSContext* cx_, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { BindingCallContext cx(cx_, "VTTCue.size setter"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "size", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); double arg0; if (!ValueToPrimitive(cx, args[0], "Value being assigned", &arg0)) { return false; } else if (!std::isfinite(arg0)) { cx.ThrowErrorMessage("Value being assigned"); return false; } FastErrorResult rv; // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetSize(arg0, rv))>, "Should be returning void here"); MOZ_KnownLive(self)->SetSize(arg0, rv); if (rv.MaybeSetPendingException(cx, "VTTCue.size setter")) [[unlikely]] { return false; } MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo size_getterinfo = { { get_size }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ true, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo size_setterinfo = { { (JSJitGetterOp)set_size }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_align(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "align", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); AlignSetting result(MOZ_KnownLive(self)->Align()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!ToJSValue(cx, result, args.rval())) { return false; } return true; } MOZ_CAN_RUN_SCRIPT static bool set_align(JSContext* cx_, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { BindingCallContext cx(cx_, "VTTCue.align setter"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "align", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); AlignSetting arg0; { int index; if (!binding_detail::FindEnumStringIndex(cx, args[0], binding_detail::EnumStrings::Values, "AlignSetting", "value being assigned", &index)) { return false; } if (index < 0) { return true; } arg0 = static_cast(index); } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetAlign(arg0))>, "Should be returning void here"); MOZ_KnownLive(self)->SetAlign(arg0); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo align_getterinfo = { { get_align }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo align_setterinfo = { { (JSJitGetterOp)set_align }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_text(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "text", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); DOMString result; // NOTE: This assert does NOT call the function. static_assert(std::is_void_vGetText(result))>, "Should be returning void here"); MOZ_KnownLive(self)->GetText(result); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { return false; } return true; } MOZ_CAN_RUN_SCRIPT static bool set_text(JSContext* cx, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "text", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); nsAutoString arg0; if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { return false; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetText(NonNullHelper(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetText(NonNullHelper(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo text_getterinfo = { { get_text }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo text_setterinfo = { { (JSJitGetterOp)set_text }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool getCueAsHTML(JSContext* cx, JS::Handle obj, void* void_self, const JSJitMethodCallArgs& args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "getCueAsHTML", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); auto result(StrongOrRawPtr(MOZ_KnownLive(self)->GetCueAsHTML())); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!GetOrCreateDOMReflector(cx, result, args.rval())) { MOZ_ASSERT(JS_IsExceptionPending(cx)); return false; } return true; } static const JSJitInfo getCueAsHTML_methodinfo = { { (JSJitGetterOp)getCueAsHTML }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Method, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_displayState(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "displayState", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); auto result(StrongOrRawPtr(MOZ_KnownLive(self)->GetDisplayState())); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!result) { args.rval().setNull(); return true; } if (!GetOrCreateDOMReflector(cx, result, args.rval())) { MOZ_ASSERT(JS_IsExceptionPending(cx)); return false; } return true; } MOZ_CAN_RUN_SCRIPT static bool set_displayState(JSContext* cx_, JS::Handle obj, void* void_self, JSJitSetterCallArgs args) { BindingCallContext cx(cx_, "VTTCue.displayState setter"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "displayState", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); mozilla::dom::HTMLDivElement* arg0; if (args[0].isObject()) { { // Our JSContext should be in the right global to do unwrapping in. nsresult rv = UnwrapObject(args[0], arg0, cx); if (NS_FAILED(rv)) { cx.ThrowErrorMessage("Value being assigned", "HTMLDivElement"); return false; } } } else if (args[0].isNullOrUndefined()) { arg0 = nullptr; } else { cx.ThrowErrorMessage("Value being assigned"); return false; } // NOTE: This assert does NOT call the function. static_assert(std::is_void_vSetDisplayState(MOZ_KnownLive(Constify(arg0))))>, "Should be returning void here"); MOZ_KnownLive(self)->SetDisplayState(MOZ_KnownLive(Constify(arg0))); MOZ_ASSERT(!JS_IsExceptionPending(cx)); return true; } static const JSJitInfo displayState_getterinfo = { { get_displayState }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static const JSJitInfo displayState_setterinfo = { { (JSJitGetterOp)set_displayState }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Setter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_hasBeenReset(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "hasBeenReset", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); bool result(MOZ_KnownLive(self)->HasBeenReset()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); args.rval().setBoolean(result); return true; } static const JSJitInfo hasBeenReset_getterinfo = { { get_hasBeenReset }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ true, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_computedLine(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "computedLine", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); double result(MOZ_KnownLive(self)->ComputedLine()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); args.rval().set(JS::NumberValue(double(result))); return true; } static const JSJitInfo computedLine_getterinfo = { { get_computedLine }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ true, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_computedPosition(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "computedPosition", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); double result(MOZ_KnownLive(self)->ComputedPosition()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); args.rval().set(JS::NumberValue(double(result))); return true; } static const JSJitInfo computedPosition_getterinfo = { { get_computedPosition }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ true, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_computedPositionAlign(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "computedPositionAlign", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); PositionAlignSetting result(MOZ_KnownLive(self)->ComputedPositionAlign()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); if (!ToJSValue(cx, result, args.rval())) { return false; } return true; } static const JSJitInfo computedPositionAlign_getterinfo = { { get_computedPositionAlign }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ false, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; MOZ_CAN_RUN_SCRIPT static bool get_getActive(JSContext* cx, JS::Handle obj, void* void_self, JSJitGetterCallArgs args) { AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "getActive", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); auto* self = static_cast(void_self); bool result(MOZ_KnownLive(self)->GetActive()); MOZ_ASSERT(!JS_IsExceptionPending(cx)); args.rval().setBoolean(result); return true; } static const JSJitInfo getActive_getterinfo = { { get_getActive }, { prototypes::id::VTTCue }, { PrototypeTraits::Depth }, JSJitInfo::Getter, JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ true, /* isInfallible. False in setters. */ false, /* isMovable. Not relevant for setters. */ false, /* isEliminatable. Not relevant for setters. */ false, /* isAlwaysInSlot. Only relevant for getters. */ false, /* isLazilyCachedInSlot. Only relevant for getters. */ false, /* isTypedMethod. Only relevant for methods. */ 0 /* Reserved slot index, if we're stored in a slot, else 0. */ }; static void _finalize(JS::GCContext* gcx, JSObject* obj) { mozilla::dom::TextTrackCue* self = UnwrapPossiblyNotInitializedDOMObject(obj); if (self) { JS::SetNativeObjectReservedSlot(obj, DOM_OBJECT_SLOT, JS::UndefinedValue()); ClearWrapper(self, self, obj); if (size_t mallocBytes = BindingJSObjectMallocBytes(self)) { JS::RemoveAssociatedMemory(obj, mallocBytes, JS::MemoryUse::DOMBinding); } AddForDeferredFinalization(self); } } MOZ_GLOBINIT static const JSFunctionSpec sMethods_specs[] = { JS_FNSPEC("getCueAsHTML", (GenericMethod), reinterpret_cast(&getCueAsHTML_methodinfo), 0, JSPROP_ENUMERATE, nullptr), JS_FS_END }; static const Prefable sMethods[] = { { nullptr, &sMethods_specs[0] }, { nullptr, nullptr } }; static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); MOZ_GLOBINIT static const JSPropertySpec sAttributes_specs[] = { JSPropertySpec::nativeAccessors("region", JSPROP_ENUMERATE, GenericGetter, ®ion_getterinfo, GenericSetter, ®ion_setterinfo), JSPropertySpec::nativeAccessors("vertical", JSPROP_ENUMERATE, GenericGetter, &vertical_getterinfo, GenericSetter, &vertical_setterinfo), JSPropertySpec::nativeAccessors("snapToLines", JSPROP_ENUMERATE, GenericGetter, &snapToLines_getterinfo, GenericSetter, &snapToLines_setterinfo), JSPropertySpec::nativeAccessors("line", JSPROP_ENUMERATE, GenericGetter, &line_getterinfo, GenericSetter, &line_setterinfo), JSPropertySpec::nativeAccessors("lineAlign", JSPROP_ENUMERATE, GenericGetter, &lineAlign_getterinfo, GenericSetter, &lineAlign_setterinfo), JSPropertySpec::nativeAccessors("position", JSPROP_ENUMERATE, GenericGetter, &position_getterinfo, GenericSetter, &position_setterinfo), JSPropertySpec::nativeAccessors("positionAlign", JSPROP_ENUMERATE, GenericGetter, &positionAlign_getterinfo, GenericSetter, &positionAlign_setterinfo), JSPropertySpec::nativeAccessors("size", JSPROP_ENUMERATE, GenericGetter, &size_getterinfo, GenericSetter, &size_setterinfo), JSPropertySpec::nativeAccessors("align", JSPROP_ENUMERATE, GenericGetter, &align_getterinfo, GenericSetter, &align_setterinfo), JSPropertySpec::nativeAccessors("text", JSPROP_ENUMERATE, GenericGetter, &text_getterinfo, GenericSetter, &text_setterinfo), JS_PS_END }; static const Prefable sAttributes[] = { { nullptr, &sAttributes_specs[0] }, { nullptr, nullptr } }; static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); MOZ_GLOBINIT static const JSPropertySpec sChromeAttributes_specs[] = { JSPropertySpec::nativeAccessors("displayState", JSPROP_ENUMERATE, GenericGetter, &displayState_getterinfo, GenericSetter, &displayState_setterinfo), JSPropertySpec::nativeAccessors("hasBeenReset", JSPROP_ENUMERATE, GenericGetter, &hasBeenReset_getterinfo, nullptr, nullptr), JSPropertySpec::nativeAccessors("computedLine", JSPROP_ENUMERATE, GenericGetter, &computedLine_getterinfo, nullptr, nullptr), JSPropertySpec::nativeAccessors("computedPosition", JSPROP_ENUMERATE, GenericGetter, &computedPosition_getterinfo, nullptr, nullptr), JSPropertySpec::nativeAccessors("computedPositionAlign", JSPROP_ENUMERATE, GenericGetter, &computedPositionAlign_getterinfo, nullptr, nullptr), JSPropertySpec::nativeAccessors("getActive", JSPROP_ENUMERATE, GenericGetter, &getActive_getterinfo, nullptr, nullptr), JS_PS_END }; static const Prefable sChromeAttributes[] = { { nullptr, &sChromeAttributes_specs[0] }, { nullptr, nullptr } }; static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); static uint16_t sNativeProperties_sortedPropertyIndices[11]; static PropertyInfo sNativeProperties_propertyInfos[11]; static const NativePropertiesN<2> sNativeProperties = { false, 0, false, 0, true, 0 /* sMethods */, true, 1 /* sAttributes */, false, 0, false, 0, false, 0, -1, 11, sNativeProperties_sortedPropertyIndices, { { sMethods, &sNativeProperties_propertyInfos[0] }, { sAttributes, &sNativeProperties_propertyInfos[1] } } }; static_assert(11 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount)), "We have a property info count that is oversized"); static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[6]; static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[6]; static const NativePropertiesN<1> sChromeOnlyNativeProperties = { false, 0, false, 0, false, 0, true, 0 /* sChromeAttributes */, false, 0, false, 0, false, 0, -1, 6, sChromeOnlyNativeProperties_sortedPropertyIndices, { { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] } } }; static_assert(6 < 1ull << (CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount)), "We have a property info count that is oversized"); bool sNativePropertiesInited = false; const NativePropertyHooks sNativePropertyHooks = { nullptr, { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast(), &sNativePropertiesInited }, prototypes::id::VTTCue, constructors::id::VTTCue, &DefaultXrayExpandoObjectClass }; static bool _constructor(JSContext* cx_, unsigned argc, JS::Value* vp) { BindingCallContext cx(cx_, "VTTCue constructor"); AUTO_PROFILER_LABEL_DYNAMIC_FAST( "VTTCue", "constructor", DOM, cx, uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS)); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::Rooted obj(cx, &args.callee()); if (!args.isConstructing()) { return ThrowConstructorWithoutNew(cx, "VTTCue"); } JS::Rooted desiredProto(cx); if (!GetDesiredProto(cx, args, prototypes::id::VTTCue, CreateInterfaceObjects, &desiredProto)) { return false; } if (!args.requireAtLeast(cx, "VTTCue constructor", 3)) { return false; } GlobalObject global(cx, obj); if (global.Failed()) { return false; } bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); double arg0; if (!ValueToPrimitive(cx, args[0], "Argument 1", &arg0)) { return false; } else if (!std::isfinite(arg0)) { cx.ThrowErrorMessage("Argument 1"); return false; } double arg1; if (!ValueToPrimitive(cx, args[1], "Argument 2", &arg1)) { return false; } else if (!std::isfinite(arg1)) { cx.ThrowErrorMessage("Argument 2"); return false; } nsAutoString arg2; if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) { return false; } Maybe ar; if (objIsXray) { // Since our object is an Xray, we can just CheckedUnwrapStatic: // we know Xrays have no dynamic unwrap behavior. obj = js::CheckedUnwrapStatic(obj); if (!obj) { return false; } ar.emplace(cx, obj); if (!JS_WrapObject(cx, &desiredProto)) { return false; } } FastErrorResult rv; auto result(StrongOrRawPtr(mozilla::dom::TextTrackCue::Constructor(global, arg0, arg1, NonNullHelper(Constify(arg2)), rv))); if (rv.MaybeSetPendingException(cx, "VTTCue constructor")) [[unlikely]] { return false; } MOZ_ASSERT(!JS_IsExceptionPending(cx)); static_assert(!std::is_pointer_v, "NewObject implies that we need to keep the object alive with a strong reference."); if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { MOZ_ASSERT(JS_IsExceptionPending(cx)); return false; } return true; } static const DOMInterfaceInfo sInterfaceObjectInfo = { { _constructor, &sNativePropertyHooks }, TextTrackCue_Binding::GetConstructorObjectHandle, PrototypeTraits::Depth, prototypes::id::VTTCue, true, 3, "VTTCue", }; static const DOMIfaceAndProtoJSClass sPrototypeClass = { { "VTTCuePrototype", JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), JS_NULL_CLASS_OPS, JS_NULL_CLASS_SPEC, JS_NULL_CLASS_EXT, JS_NULL_OBJECT_OPS }, eInterfacePrototype, prototypes::id::VTTCue, PrototypeTraits::Depth, &sNativePropertyHooks, TextTrackCue_Binding::GetProtoObject }; static JS::Handle GetProtoObjectHandle(JSContext* aCx); static const JSClassOps sClassOps = { nullptr, /* addProperty */ nullptr, /* delProperty */ nullptr, /* enumerate */ nullptr, /* newEnumerate */ nullptr, /* resolve */ nullptr, /* mayResolve */ _finalize, /* finalize */ nullptr, /* call */ nullptr, /* construct */ nullptr, /* trace */ }; static const DOMJSClass sClass = { { "VTTCue", JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_PRESERVES_WRAPPER, &sClassOps, JS_NULL_CLASS_SPEC, &NativeTypeHelpers::sClassExtension, JS_NULL_OBJECT_OPS }, { prototypes::id::EventTarget, prototypes::id::TextTrackCue, prototypes::id::VTTCue, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, std::is_base_of_v, &sNativePropertyHooks, GetProtoObjectHandle, GetCCParticipant::Get(), nullptr, NativeTypeHelpers::GetWrapperCache }; static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, "Must have the right minimal number of reserved slots."); static_assert(1 >= 1, "Must have enough reserved slots."); bool Wrap(JSContext* aCx, mozilla::dom::TextTrackCue* aObject, nsWrapperCache* aCache, JS::Handle aGivenProto, JS::MutableHandle aReflector) { static_assert(!std::is_base_of_v, "Shouldn't have wrappercached things that are not refcounted."); static_assert(std::is_same_v); MOZ_ASSERT(static_cast(aObject) == reinterpret_cast(aObject), "Multiple inheritance for mozilla::dom::TextTrackCue is broken."); MOZ_ASSERT(static_cast(aObject) == reinterpret_cast(aObject), "Multiple inheritance for mozilla::dom::EventTarget is broken."); MOZ_ASSERT(ToSupportsIsCorrect(aObject)); MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); MOZ_ASSERT(!aCache->GetWrapper(), "You should probably not be using Wrap() directly; use " "GetOrCreateDOMReflector instead"); MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), "nsISupports must be on our primary inheritance chain"); // If the wrapper cache contains a dead reflector then finalize that // now, ensuring that the finalizer for the old reflector always // runs before the new reflector is created and attached. This // avoids the awkward situation where there are multiple reflector // objects that contain pointers to the same native. if (JSObject* oldReflector = aCache->GetWrapperMaybeDead()) { _finalize(nullptr /* unused */, oldReflector); MOZ_ASSERT(!aCache->GetWrapperMaybeDead()); } JS::Rooted global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); if (!global) { return false; } MOZ_ASSERT(JS_IsGlobalObject(global)); JS::AssertObjectIsNotGray(global); // That might have ended up wrapping us already, due to the wonders // of XBL. Check for that, and bail out as needed. aReflector.set(aCache->GetWrapper()); if (aReflector) { #ifdef DEBUG AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); #endif // DEBUG return true; } JSAutoRealm ar(aCx, global); JS::Handle canonicalProto = GetProtoObjectHandle(aCx); if (!canonicalProto) { return false; } JS::Rooted proto(aCx); if (aGivenProto) { proto = aGivenProto; // Unfortunately, while aGivenProto was in the compartment of aCx // coming in, we changed compartments to that of "parent" so may need // to wrap the proto here. if (js::GetContextCompartment(aCx) != JS::GetCompartment(proto)) { if (!JS_WrapObject(aCx, &proto)) { return false; } } } else { proto = canonicalProto; } BindingJSObjectCreator creator(aCx); creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); if (!aReflector) { return false; } aCache->SetWrapper(aReflector); creator.InitializationSucceeded(); MOZ_ASSERT(aCache->GetWrapperPreserveColor() && aCache->GetWrapperPreserveColor() == aReflector); // If proto != canonicalProto, we have to preserve our wrapper; // otherwise we won't be able to properly recreate it later, since // we won't know what proto to use. Note that we don't check // aGivenProto here, since it's entirely possible (and even // somewhat common) to have a non-null aGivenProto which is the // same as canonicalProto. if (proto != canonicalProto) { PreserveWrapper(aObject); } return true; } void CreateInterfaceObjects(JSContext* aCx, JS::Handle aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal) { JS::Heap* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VTTCue); JS::Heap* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VTTCue); JS::Handle parentProto(TextTrackCue_Binding::GetProtoObjectHandle(aCx)); if (!parentProto) { return; } JS::Handle constructorProto(TextTrackCue_Binding::GetConstructorObjectHandle(aCx)); if (!constructorProto) { return; } dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, &sPrototypeClass, protoCache, constructorProto, &sInterfaceObjectInfo, 3, false, Span{}, interfaceCache, sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast(), "VTTCue", aDefineOnGlobal != DefineInterfaceProperty::No, nullptr, false, nullptr); } static JS::Handle GetProtoObjectHandle(JSContext* aCx) { /* Get the interface prototype object for this class. This will create the object as needed. */ return GetPerInterfaceObjectHandle(aCx, prototypes::id::VTTCue, &CreateInterfaceObjects, DefineInterfaceProperty::CheckExposure); } JS::Handle GetConstructorObjectHandle(JSContext* aCx) { /* Get the interface object for this class. This will create the object as needed. */ return GetPerInterfaceObjectHandle(aCx, constructors::id::VTTCue, &CreateInterfaceObjects, DefineInterfaceProperty::CheckExposure); } } // namespace VTTCue_Binding } // namespace dom } // namespace mozilla