blob: 1a07104d79d487c2ee3cd30e49fc4aa2ee70da74 [file] [log] [blame]
/*
This file is part of the WebKit open source project.
This file has been generated by generate-bindings.pl. DO NOT MODIFY!
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#if ENABLE(VIDEO_TRACK)
#include "JSTextTrack.h"
#include "Element.h"
#include "EventNames.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include "JSEventListener.h"
#include "JSNodeCustom.h"
#include "JSTextTrackCue.h"
#include "JSTextTrackCueList.h"
#include "JSVTTRegion.h"
#include "JSVTTRegionList.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
template<typename T> Optional<T> parse(ExecState&, JSValue);
template<typename T> const char* expectedEnumerationValues();
JSString* jsStringWithCache(ExecState*, TextTrack::Mode);
JSString* jsStringWithCache(ExecState* state, TextTrack::Mode enumerationValue)
{
static NeverDestroyed<const String> values[] = {
ASCIILiteral("disabled"),
ASCIILiteral("hidden"),
ASCIILiteral("showing"),
};
static_assert(static_cast<size_t>(TextTrack::Mode::Disabled) == 0, "TextTrack::Mode::Disabled is not 0 as expected");
static_assert(static_cast<size_t>(TextTrack::Mode::Hidden) == 1, "TextTrack::Mode::Hidden is not 1 as expected");
static_assert(static_cast<size_t>(TextTrack::Mode::Showing) == 2, "TextTrack::Mode::Showing is not 2 as expected");
ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
}
template<> struct JSValueTraits<TextTrack::Mode> {
static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, TextTrack::Mode value) { return jsStringWithCache(state, value); }
};
template<> Optional<TextTrack::Mode> parse<TextTrack::Mode>(ExecState& state, JSValue value)
{
auto stringValue = value.toWTFString(&state);
if (stringValue == "disabled")
return TextTrack::Mode::Disabled;
if (stringValue == "hidden")
return TextTrack::Mode::Hidden;
if (stringValue == "showing")
return TextTrack::Mode::Showing;
return Nullopt;
}
template<> TextTrack::Mode convert<TextTrack::Mode>(ExecState& state, JSValue value)
{
VM& vm = state.vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto result = parse<TextTrack::Mode>(state, value);
if (UNLIKELY(!result)) {
throwTypeError(&state, throwScope);
return { };
}
return result.value();
}
template<> inline const char* expectedEnumerationValues<TextTrack::Mode>()
{
return "\"disabled\", \"hidden\", \"showing\"";
}
JSString* jsStringWithCache(ExecState*, TextTrack::Kind);
JSString* jsStringWithCache(ExecState* state, TextTrack::Kind enumerationValue)
{
static NeverDestroyed<const String> values[] = {
ASCIILiteral("subtitles"),
ASCIILiteral("captions"),
ASCIILiteral("descriptions"),
ASCIILiteral("chapters"),
ASCIILiteral("metadata"),
ASCIILiteral("forced"),
};
static_assert(static_cast<size_t>(TextTrack::Kind::Subtitles) == 0, "TextTrack::Kind::Subtitles is not 0 as expected");
static_assert(static_cast<size_t>(TextTrack::Kind::Captions) == 1, "TextTrack::Kind::Captions is not 1 as expected");
static_assert(static_cast<size_t>(TextTrack::Kind::Descriptions) == 2, "TextTrack::Kind::Descriptions is not 2 as expected");
static_assert(static_cast<size_t>(TextTrack::Kind::Chapters) == 3, "TextTrack::Kind::Chapters is not 3 as expected");
static_assert(static_cast<size_t>(TextTrack::Kind::Metadata) == 4, "TextTrack::Kind::Metadata is not 4 as expected");
static_assert(static_cast<size_t>(TextTrack::Kind::Forced) == 5, "TextTrack::Kind::Forced is not 5 as expected");
ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
}
template<> struct JSValueTraits<TextTrack::Kind> {
static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, TextTrack::Kind value) { return jsStringWithCache(state, value); }
};
template<> Optional<TextTrack::Kind> parse<TextTrack::Kind>(ExecState& state, JSValue value)
{
auto stringValue = value.toWTFString(&state);
if (stringValue == "subtitles")
return TextTrack::Kind::Subtitles;
if (stringValue == "captions")
return TextTrack::Kind::Captions;
if (stringValue == "descriptions")
return TextTrack::Kind::Descriptions;
if (stringValue == "chapters")
return TextTrack::Kind::Chapters;
if (stringValue == "metadata")
return TextTrack::Kind::Metadata;
if (stringValue == "forced")
return TextTrack::Kind::Forced;
return Nullopt;
}
template<> TextTrack::Kind convert<TextTrack::Kind>(ExecState& state, JSValue value)
{
VM& vm = state.vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto result = parse<TextTrack::Kind>(state, value);
if (UNLIKELY(!result)) {
throwTypeError(&state, throwScope);
return { };
}
return result.value();
}
template<> inline const char* expectedEnumerationValues<TextTrack::Kind>()
{
return "\"subtitles\", \"captions\", \"descriptions\", \"chapters\", \"metadata\", \"forced\"";
}
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionAddCue(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionRemoveCue(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionAddRegion(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionRemoveRegion(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsTextTrackId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsTextTrackKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSTextTrackKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsTextTrackLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsTextTrackLanguage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSTextTrackLanguage(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsTextTrackInBandMetadataTrackDispatchType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsTextTrackMode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSTextTrackMode(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsTextTrackCues(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsTextTrackActiveCues(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsTextTrackOncuechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSTextTrackOncuechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsTextTrackRegions(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsTextTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSTextTrackConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSTextTrackPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSTextTrackPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSTextTrackPrototype* ptr = new (NotNull, JSC::allocateCell<JSTextTrackPrototype>(vm.heap)) JSTextTrackPrototype(vm, globalObject, structure);
ptr->finishCreation(vm);
return ptr;
}
DECLARE_INFO;
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
}
private:
JSTextTrackPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSTextTrack> JSTextTrackConstructor;
template<> JSValue JSTextTrackConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
return JSEventTarget::getConstructor(vm, &globalObject);
}
template<> void JSTextTrackConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSTextTrack::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TextTrack"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSTextTrackConstructor::s_info = { "TextTrack", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTextTrackConstructor) };
/* Hash table for prototype */
static const HashTableValue JSTextTrackPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackConstructor) } },
{ "id", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "kind", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackKind), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackKind) } },
{ "label", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackLabel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "language", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackLanguage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackLanguage) } },
{ "inBandMetadataTrackDispatchType", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackInBandMetadataTrackDispatchType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "mode", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackMode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackMode) } },
{ "cues", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackCues), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "activeCues", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackActiveCues), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "oncuechange", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackOncuechange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextTrackOncuechange) } },
{ "regions", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextTrackRegions), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "addCue", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTextTrackPrototypeFunctionAddCue), (intptr_t) (1) } },
{ "removeCue", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTextTrackPrototypeFunctionRemoveCue), (intptr_t) (1) } },
{ "addRegion", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTextTrackPrototypeFunctionAddRegion), (intptr_t) (1) } },
{ "removeRegion", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTextTrackPrototypeFunctionRemoveRegion), (intptr_t) (1) } },
};
const ClassInfo JSTextTrackPrototype::s_info = { "TextTrackPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTextTrackPrototype) };
void JSTextTrackPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSTextTrackPrototypeTableValues, *this);
}
const ClassInfo JSTextTrack::s_info = { "TextTrack", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTextTrack) };
JSTextTrack::JSTextTrack(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TextTrack>&& impl)
: JSEventTarget(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSTextTrack::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSTextTrackPrototype::create(vm, globalObject, JSTextTrackPrototype::createStructure(vm, globalObject, JSEventTarget::prototype(vm, globalObject)));
}
JSObject* JSTextTrack::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSTextTrack>(vm, globalObject);
}
EncodedJSValue jsTextTrackId(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSTextTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "TextTrack", "id");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.id());
return JSValue::encode(result);
}
EncodedJSValue jsTextTrackKind(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSTextTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "TextTrack", "kind");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.kindForBindings());
return JSValue::encode(result);
}
EncodedJSValue jsTextTrackLabel(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSTextTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "TextTrack", "label");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.label());
return JSValue::encode(result);
}
EncodedJSValue jsTextTrackLanguage(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSTextTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "TextTrack", "language");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.language());
return JSValue::encode(result);
}
EncodedJSValue jsTextTrackInBandMetadataTrackDispatchType(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSTextTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "TextTrack", "inBandMetadataTrackDispatchType");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.inBandMetadataTrackDispatchType());
return JSValue::encode(result);
}
EncodedJSValue jsTextTrackMode(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSTextTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "TextTrack", "mode");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.mode());
return JSValue::encode(result);
}
EncodedJSValue jsTextTrackCues(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSTextTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "TextTrack", "cues");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.cues());
return JSValue::encode(result);
}
EncodedJSValue jsTextTrackActiveCues(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSTextTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "TextTrack", "activeCues");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.activeCues());
return JSValue::encode(result);
}
EncodedJSValue jsTextTrackOncuechange(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSTextTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "TextTrack", "oncuechange");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().cuechangeEvent));
}
EncodedJSValue jsTextTrackRegions(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSTextTrack*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "TextTrack", "regions");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.regions());
return JSValue::encode(result);
}
EncodedJSValue jsTextTrackConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTextTrackPrototype* domObject = jsDynamicCast<JSTextTrackPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSTextTrack::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSTextTrackConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSTextTrackPrototype* domObject = jsDynamicCast<JSTextTrackPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject)) {
throwVMTypeError(state, throwScope);
return false;
}
// Shadowing a built-in constructor
return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
}
bool setJSTextTrackKind(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSTextTrack* castedThis = jsDynamicCast<JSTextTrack*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "TextTrack", "kind");
}
auto& impl = castedThis->wrapped();
auto nativeValue = parse<TextTrack::Kind>(*state, value);
RETURN_IF_EXCEPTION(throwScope, false);
if (UNLIKELY(!nativeValue))
return false;
impl.setKindForBindings(nativeValue.value());
return true;
}
bool setJSTextTrackLanguage(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSTextTrack* castedThis = jsDynamicCast<JSTextTrack*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "TextTrack", "language");
}
castedThis->setLanguage(*state, value);
return true;
}
bool setJSTextTrackMode(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSTextTrack* castedThis = jsDynamicCast<JSTextTrack*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "TextTrack", "mode");
}
auto& impl = castedThis->wrapped();
auto nativeValue = parse<TextTrack::Mode>(*state, value);
RETURN_IF_EXCEPTION(throwScope, false);
if (UNLIKELY(!nativeValue))
return false;
impl.setMode(nativeValue.value());
return true;
}
bool setJSTextTrackOncuechange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSTextTrack* castedThis = jsDynamicCast<JSTextTrack*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "TextTrack", "oncuechange");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().cuechangeEvent, value);
return true;
}
JSValue JSTextTrack::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSTextTrackConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionAddCue(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSTextTrack*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "TextTrack", "addCue");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSTextTrack::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
ExceptionCode ec = 0;
TextTrackCue* cue = nullptr;
if (!state->uncheckedArgument(0).isUndefinedOrNull()) {
cue = JSTextTrackCue::toWrapped(state->uncheckedArgument(0));
if (UNLIKELY(!cue))
return throwArgumentTypeError(*state, throwScope, 0, "cue", "TextTrack", "addCue", "TextTrackCue");
}
impl.addCue(WTFMove(cue), ec);
setDOMException(state, throwScope, ec);
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionRemoveCue(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSTextTrack*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "TextTrack", "removeCue");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSTextTrack::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
ExceptionCode ec = 0;
TextTrackCue* cue = nullptr;
if (!state->uncheckedArgument(0).isUndefinedOrNull()) {
cue = JSTextTrackCue::toWrapped(state->uncheckedArgument(0));
if (UNLIKELY(!cue))
return throwArgumentTypeError(*state, throwScope, 0, "cue", "TextTrack", "removeCue", "TextTrackCue");
}
impl.removeCue(WTFMove(cue), ec);
setDOMException(state, throwScope, ec);
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionAddRegion(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSTextTrack*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "TextTrack", "addRegion");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSTextTrack::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
VTTRegion* region = nullptr;
if (!state->uncheckedArgument(0).isUndefinedOrNull()) {
region = JSVTTRegion::toWrapped(state->uncheckedArgument(0));
if (UNLIKELY(!region))
return throwArgumentTypeError(*state, throwScope, 0, "region", "TextTrack", "addRegion", "VTTRegion");
}
impl.addRegion(WTFMove(region));
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsTextTrackPrototypeFunctionRemoveRegion(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSTextTrack*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "TextTrack", "removeRegion");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSTextTrack::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
ExceptionCode ec = 0;
VTTRegion* region = nullptr;
if (!state->uncheckedArgument(0).isUndefinedOrNull()) {
region = JSVTTRegion::toWrapped(state->uncheckedArgument(0));
if (UNLIKELY(!region))
return throwArgumentTypeError(*state, throwScope, 0, "region", "TextTrack", "removeRegion", "VTTRegion");
}
impl.removeRegion(WTFMove(region), ec);
setDOMException(state, throwScope, ec);
return JSValue::encode(jsUndefined());
}
void JSTextTrack::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSTextTrack*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
thisObject->wrapped().visitJSEventListeners(visitor);
thisObject->visitAdditionalChildren(visitor);
}
bool JSTextTrackOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
auto* jsTextTrack = jsCast<JSTextTrack*>(handle.slot()->asCell());
if (jsTextTrack->wrapped().isFiringEventListeners())
return true;
Element* element = WTF::getPtr(jsTextTrack->wrapped().element());
if (!element)
return false;
void* root = WebCore::root(element);
return visitor.containsOpaqueRoot(root);
}
void JSTextTrackOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsTextTrack = jsCast<JSTextTrack*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsTextTrack->wrapped(), jsTextTrack);
}
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TextTrack>&& impl)
{
return createWrapper<TextTrack>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TextTrack& impl)
{
return wrap(state, globalObject, impl);
}
TextTrack* JSTextTrack::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSTextTrack*>(value))
return &wrapper->wrapped();
return nullptr;
}
}
#endif // ENABLE(VIDEO_TRACK)