blob: f2b192c3a9dfb7e83a6998c70a1a90c4e23a326e [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(MEDIA_SOURCE)
#include "JSSourceBuffer.h"
#include "EventNames.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include "JSEventListener.h"
#include "JSTimeRanges.h"
#include <runtime/Error.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>
#if ENABLE(VIDEO_TRACK)
#include "JSAudioTrackList.h"
#include "JSTextTrackList.h"
#include "JSVideoTrackList.h"
#endif
using namespace JSC;
namespace WebCore {
template<typename T> Optional<T> parse(ExecState&, JSValue);
template<typename T> const char* expectedEnumerationValues();
#if ENABLE(MEDIA_SOURCE)
JSString* jsStringWithCache(ExecState*, SourceBuffer::AppendMode);
JSString* jsStringWithCache(ExecState* state, SourceBuffer::AppendMode enumerationValue)
{
static NeverDestroyed<const String> values[] = {
ASCIILiteral("segments"),
ASCIILiteral("sequence"),
};
static_assert(static_cast<size_t>(SourceBuffer::AppendMode::Segments) == 0, "SourceBuffer::AppendMode::Segments is not 0 as expected");
static_assert(static_cast<size_t>(SourceBuffer::AppendMode::Sequence) == 1, "SourceBuffer::AppendMode::Sequence is not 1 as expected");
ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
}
template<> struct JSValueTraits<SourceBuffer::AppendMode> {
static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, SourceBuffer::AppendMode value) { return jsStringWithCache(state, value); }
};
template<> Optional<SourceBuffer::AppendMode> parse<SourceBuffer::AppendMode>(ExecState& state, JSValue value)
{
auto stringValue = value.toWTFString(&state);
if (stringValue == "segments")
return SourceBuffer::AppendMode::Segments;
if (stringValue == "sequence")
return SourceBuffer::AppendMode::Sequence;
return Nullopt;
}
template<> SourceBuffer::AppendMode convert<SourceBuffer::AppendMode>(ExecState& state, JSValue value)
{
VM& vm = state.vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto result = parse<SourceBuffer::AppendMode>(state, value);
if (UNLIKELY(!result)) {
throwTypeError(&state, throwScope);
return { };
}
return result.value();
}
template<> inline const char* expectedEnumerationValues<SourceBuffer::AppendMode>()
{
return "\"segments\", \"sequence\"";
}
#endif
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsSourceBufferPrototypeFunctionAppendBuffer(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsSourceBufferPrototypeFunctionAbort(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsSourceBufferPrototypeFunctionRemove(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsSourceBufferMode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSourceBufferMode(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsSourceBufferUpdating(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsSourceBufferBuffered(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsSourceBufferTimestampOffset(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSourceBufferTimestampOffset(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
#if ENABLE(VIDEO_TRACK)
JSC::EncodedJSValue jsSourceBufferAudioTracks(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
#endif
#if ENABLE(VIDEO_TRACK)
JSC::EncodedJSValue jsSourceBufferVideoTracks(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
#endif
#if ENABLE(VIDEO_TRACK)
JSC::EncodedJSValue jsSourceBufferTextTracks(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
#endif
JSC::EncodedJSValue jsSourceBufferAppendWindowStart(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSourceBufferAppendWindowStart(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsSourceBufferAppendWindowEnd(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSourceBufferAppendWindowEnd(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsSourceBufferOnupdatestart(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSourceBufferOnupdatestart(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsSourceBufferOnupdate(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSourceBufferOnupdate(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsSourceBufferOnupdateend(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSourceBufferOnupdateend(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsSourceBufferOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSourceBufferOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsSourceBufferOnabort(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSourceBufferOnabort(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsSourceBufferConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSourceBufferConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSSourceBufferPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSSourceBufferPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSSourceBufferPrototype* ptr = new (NotNull, JSC::allocateCell<JSSourceBufferPrototype>(vm.heap)) JSSourceBufferPrototype(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:
JSSourceBufferPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSSourceBuffer> JSSourceBufferConstructor;
template<> JSValue JSSourceBufferConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
return JSEventTarget::getConstructor(vm, &globalObject);
}
template<> void JSSourceBufferConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSSourceBuffer::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("SourceBuffer"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSSourceBufferConstructor::s_info = { "SourceBuffer", &Base::s_info, 0, CREATE_METHOD_TABLE(JSSourceBufferConstructor) };
/* Hash table for prototype */
static const HashTableValue JSSourceBufferPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferConstructor) } },
{ "mode", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferMode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferMode) } },
{ "updating", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferUpdating), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "buffered", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferBuffered), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "timestampOffset", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferTimestampOffset), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferTimestampOffset) } },
#if ENABLE(VIDEO_TRACK)
{ "audioTracks", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferAudioTracks), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
#if ENABLE(VIDEO_TRACK)
{ "videoTracks", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferVideoTracks), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
#if ENABLE(VIDEO_TRACK)
{ "textTracks", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferTextTracks), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
#else
{ 0, 0, NoIntrinsic, { 0, 0 } },
#endif
{ "appendWindowStart", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferAppendWindowStart), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferAppendWindowStart) } },
{ "appendWindowEnd", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferAppendWindowEnd), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferAppendWindowEnd) } },
{ "onupdatestart", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferOnupdatestart), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferOnupdatestart) } },
{ "onupdate", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferOnupdate), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferOnupdate) } },
{ "onupdateend", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferOnupdateend), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferOnupdateend) } },
{ "onerror", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferOnerror), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferOnerror) } },
{ "onabort", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSourceBufferOnabort), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSourceBufferOnabort) } },
{ "appendBuffer", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsSourceBufferPrototypeFunctionAppendBuffer), (intptr_t) (1) } },
{ "abort", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsSourceBufferPrototypeFunctionAbort), (intptr_t) (0) } },
{ "remove", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsSourceBufferPrototypeFunctionRemove), (intptr_t) (2) } },
};
const ClassInfo JSSourceBufferPrototype::s_info = { "SourceBufferPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSSourceBufferPrototype) };
void JSSourceBufferPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSSourceBufferPrototypeTableValues, *this);
}
const ClassInfo JSSourceBuffer::s_info = { "SourceBuffer", &Base::s_info, 0, CREATE_METHOD_TABLE(JSSourceBuffer) };
JSSourceBuffer::JSSourceBuffer(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SourceBuffer>&& impl)
: JSEventTarget(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSSourceBuffer::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSSourceBufferPrototype::create(vm, globalObject, JSSourceBufferPrototype::createStructure(vm, globalObject, JSEventTarget::prototype(vm, globalObject)));
}
JSObject* JSSourceBuffer::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSSourceBuffer>(vm, globalObject);
}
EncodedJSValue jsSourceBufferMode(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "mode");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.mode());
return JSValue::encode(result);
}
EncodedJSValue jsSourceBufferUpdating(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "updating");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.updating());
return JSValue::encode(result);
}
EncodedJSValue jsSourceBufferBuffered(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "buffered");
}
ExceptionCode ec = 0;
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.buffered(ec));
setDOMException(state, throwScope, ec);
return JSValue::encode(result);
}
EncodedJSValue jsSourceBufferTimestampOffset(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "timestampOffset");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.timestampOffset());
return JSValue::encode(result);
}
#if ENABLE(VIDEO_TRACK)
EncodedJSValue jsSourceBufferAudioTracks(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "audioTracks");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.audioTracks());
return JSValue::encode(result);
}
#endif
#if ENABLE(VIDEO_TRACK)
EncodedJSValue jsSourceBufferVideoTracks(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "videoTracks");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.videoTracks());
return JSValue::encode(result);
}
#endif
#if ENABLE(VIDEO_TRACK)
EncodedJSValue jsSourceBufferTextTracks(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "textTracks");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.textTracks());
return JSValue::encode(result);
}
#endif
EncodedJSValue jsSourceBufferAppendWindowStart(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "appendWindowStart");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.appendWindowStart());
return JSValue::encode(result);
}
EncodedJSValue jsSourceBufferAppendWindowEnd(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "appendWindowEnd");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.appendWindowEnd());
return JSValue::encode(result);
}
EncodedJSValue jsSourceBufferOnupdatestart(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "onupdatestart");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().updatestartEvent));
}
EncodedJSValue jsSourceBufferOnupdate(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "onupdate");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().updateEvent));
}
EncodedJSValue jsSourceBufferOnupdateend(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "onupdateend");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().updateendEvent));
}
EncodedJSValue jsSourceBufferOnerror(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "onerror");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().errorEvent));
}
EncodedJSValue jsSourceBufferOnabort(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<JSSourceBuffer*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SourceBuffer", "onabort");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().abortEvent));
}
EncodedJSValue jsSourceBufferConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSourceBufferPrototype* domObject = jsDynamicCast<JSSourceBufferPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSSourceBuffer::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSSourceBufferConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSSourceBufferPrototype* domObject = jsDynamicCast<JSSourceBufferPrototype*>(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 setJSSourceBufferMode(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);
JSSourceBuffer* castedThis = jsDynamicCast<JSSourceBuffer*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SourceBuffer", "mode");
}
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
auto nativeValue = parse<SourceBuffer::AppendMode>(*state, value);
RETURN_IF_EXCEPTION(throwScope, false);
if (UNLIKELY(!nativeValue))
return false;
impl.setMode(nativeValue.value(), ec);
setDOMException(state, throwScope, ec);
return true;
}
bool setJSSourceBufferTimestampOffset(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);
JSSourceBuffer* castedThis = jsDynamicCast<JSSourceBuffer*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SourceBuffer", "timestampOffset");
}
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
auto nativeValue = convert<double>(*state, value, ShouldAllowNonFinite::No);
RETURN_IF_EXCEPTION(throwScope, false);
impl.setTimestampOffset(WTFMove(nativeValue), ec);
setDOMException(state, throwScope, ec);
return true;
}
bool setJSSourceBufferAppendWindowStart(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);
JSSourceBuffer* castedThis = jsDynamicCast<JSSourceBuffer*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SourceBuffer", "appendWindowStart");
}
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
auto nativeValue = convert<double>(*state, value, ShouldAllowNonFinite::No);
RETURN_IF_EXCEPTION(throwScope, false);
impl.setAppendWindowStart(WTFMove(nativeValue), ec);
setDOMException(state, throwScope, ec);
return true;
}
bool setJSSourceBufferAppendWindowEnd(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);
JSSourceBuffer* castedThis = jsDynamicCast<JSSourceBuffer*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SourceBuffer", "appendWindowEnd");
}
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
auto nativeValue = convert<double>(*state, value, ShouldAllowNonFinite::Yes);
RETURN_IF_EXCEPTION(throwScope, false);
impl.setAppendWindowEnd(WTFMove(nativeValue), ec);
setDOMException(state, throwScope, ec);
return true;
}
bool setJSSourceBufferOnupdatestart(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);
JSSourceBuffer* castedThis = jsDynamicCast<JSSourceBuffer*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SourceBuffer", "onupdatestart");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().updatestartEvent, value);
return true;
}
bool setJSSourceBufferOnupdate(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);
JSSourceBuffer* castedThis = jsDynamicCast<JSSourceBuffer*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SourceBuffer", "onupdate");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().updateEvent, value);
return true;
}
bool setJSSourceBufferOnupdateend(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);
JSSourceBuffer* castedThis = jsDynamicCast<JSSourceBuffer*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SourceBuffer", "onupdateend");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().updateendEvent, value);
return true;
}
bool setJSSourceBufferOnerror(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);
JSSourceBuffer* castedThis = jsDynamicCast<JSSourceBuffer*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SourceBuffer", "onerror");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().errorEvent, value);
return true;
}
bool setJSSourceBufferOnabort(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);
JSSourceBuffer* castedThis = jsDynamicCast<JSSourceBuffer*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SourceBuffer", "onabort");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().abortEvent, value);
return true;
}
JSValue JSSourceBuffer::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSSourceBufferConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
static inline EncodedJSValue jsSourceBufferPrototypeFunctionAppendBuffer1(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSSourceBuffer*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "SourceBuffer", "appendBuffer");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSSourceBuffer::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
ExceptionCode ec = 0;
auto data = toArrayBuffer(state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
if (UNLIKELY(!data))
return throwArgumentTypeError(*state, throwScope, 0, "data", "SourceBuffer", "appendBuffer", "ArrayBuffer");
impl.appendBuffer(*data, ec);
setDOMException(state, throwScope, ec);
return JSValue::encode(jsUndefined());
}
static inline EncodedJSValue jsSourceBufferPrototypeFunctionAppendBuffer2(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSSourceBuffer*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "SourceBuffer", "appendBuffer");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSSourceBuffer::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
ExceptionCode ec = 0;
auto data = toArrayBufferView(state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
if (UNLIKELY(!data))
return throwArgumentTypeError(*state, throwScope, 0, "data", "SourceBuffer", "appendBuffer", "ArrayBufferView");
impl.appendBuffer(data.releaseNonNull(), ec);
setDOMException(state, throwScope, ec);
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsSourceBufferPrototypeFunctionAppendBuffer(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
size_t argsCount = std::min<size_t>(1, state->argumentCount());
if (argsCount == 1) {
JSValue distinguishingArg = state->uncheckedArgument(0);
if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSArrayBuffer::info()))
return jsSourceBufferPrototypeFunctionAppendBuffer1(state);
if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSArrayBufferView::info()))
return jsSourceBufferPrototypeFunctionAppendBuffer2(state);
}
return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope);
}
EncodedJSValue JSC_HOST_CALL jsSourceBufferPrototypeFunctionAbort(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSSourceBuffer*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "SourceBuffer", "abort");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSSourceBuffer::info());
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
impl.abort(ec);
setDOMException(state, throwScope, ec);
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsSourceBufferPrototypeFunctionRemove(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSSourceBuffer*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "SourceBuffer", "remove");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSSourceBuffer::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 2))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
ExceptionCode ec = 0;
auto start = convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto end = convert<double>(*state, state->uncheckedArgument(1), ShouldAllowNonFinite::Yes);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.remove(WTFMove(start), WTFMove(end), ec);
setDOMException(state, throwScope, ec);
return JSValue::encode(jsUndefined());
}
void JSSourceBuffer::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSSourceBuffer*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
thisObject->wrapped().visitJSEventListeners(visitor);
}
bool JSSourceBufferOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
auto* jsSourceBuffer = jsCast<JSSourceBuffer*>(handle.slot()->asCell());
if (jsSourceBuffer->wrapped().hasPendingActivity())
return true;
if (jsSourceBuffer->wrapped().isFiringEventListeners())
return true;
UNUSED_PARAM(visitor);
return false;
}
void JSSourceBufferOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsSourceBuffer = jsCast<JSSourceBuffer*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsSourceBuffer->wrapped(), jsSourceBuffer);
}
#if ENABLE(BINDING_INTEGRITY)
#if PLATFORM(WIN)
#pragma warning(disable: 4483)
extern "C" { extern void (*const __identifier("??_7SourceBuffer@WebCore@@6B@")[])(); }
#else
extern "C" { extern void* _ZTVN7WebCore12SourceBufferE[]; }
#endif
#endif
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SourceBuffer>&& impl)
{
#if ENABLE(BINDING_INTEGRITY)
void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
#if PLATFORM(WIN)
void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7SourceBuffer@WebCore@@6B@"));
#else
void* expectedVTablePointer = &_ZTVN7WebCore12SourceBufferE[2];
#if COMPILER(CLANG)
// If this fails SourceBuffer does not have a vtable, so you need to add the
// ImplementationLacksVTable attribute to the interface definition
static_assert(__is_polymorphic(SourceBuffer), "SourceBuffer is not polymorphic");
#endif
#endif
// If you hit this assertion you either have a use after free bug, or
// SourceBuffer has subclasses. If SourceBuffer has subclasses that get passed
// to toJS() we currently require SourceBuffer you to opt out of binding hardening
// by adding the SkipVTableValidation attribute to the interface IDL definition
RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
#endif
return createWrapper<SourceBuffer>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SourceBuffer& impl)
{
return wrap(state, globalObject, impl);
}
SourceBuffer* JSSourceBuffer::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSSourceBuffer*>(value))
return &wrapper->wrapped();
return nullptr;
}
}
#endif // ENABLE(MEDIA_SOURCE)