| /* |
| 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(SPEECH_SYNTHESIS) |
| |
| #include "JSSpeechSynthesisUtterance.h" |
| |
| #include "EventNames.h" |
| #include "ExceptionCode.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSDOMConvert.h" |
| #include "JSEventListener.h" |
| #include "JSSpeechSynthesisVoice.h" |
| #include "URL.h" |
| #include <runtime/Error.h> |
| #include <runtime/JSString.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceText(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceText(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceLang(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceLang(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceVoice(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceVoice(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceVolume(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceVolume(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceRate(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceRate(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtterancePitch(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtterancePitch(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceOnstart(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceOnstart(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceOnend(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceOnend(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceOnpause(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceOnpause(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceOnresume(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceOnresume(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceOnmark(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceOnmark(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceOnboundary(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceOnboundary(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsSpeechSynthesisUtteranceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSSpeechSynthesisUtteranceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSSpeechSynthesisUtterancePrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSSpeechSynthesisUtterancePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSSpeechSynthesisUtterancePrototype* ptr = new (NotNull, JSC::allocateCell<JSSpeechSynthesisUtterancePrototype>(vm.heap)) JSSpeechSynthesisUtterancePrototype(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: |
| JSSpeechSynthesisUtterancePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSSpeechSynthesisUtterance> JSSpeechSynthesisUtteranceConstructor; |
| |
| template<> EncodedJSValue JSC_HOST_CALL JSSpeechSynthesisUtteranceConstructor::construct(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| auto* castedThis = jsCast<JSSpeechSynthesisUtteranceConstructor*>(state->callee()); |
| ASSERT(castedThis); |
| auto text = state->argument(0).isUndefined() ? String() : state->uncheckedArgument(0).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| ScriptExecutionContext* context = castedThis->scriptExecutionContext(); |
| if (UNLIKELY(!context)) |
| return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "SpeechSynthesisUtterance"); |
| auto object = SpeechSynthesisUtterance::create(*context, WTFMove(text)); |
| return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))); |
| } |
| |
| template<> JSValue JSSpeechSynthesisUtteranceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| return JSEventTarget::getConstructor(vm, &globalObject); |
| } |
| |
| template<> void JSSpeechSynthesisUtteranceConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSSpeechSynthesisUtterance::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("SpeechSynthesisUtterance"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSSpeechSynthesisUtteranceConstructor::s_info = { "SpeechSynthesisUtterance", &Base::s_info, 0, CREATE_METHOD_TABLE(JSSpeechSynthesisUtteranceConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSSpeechSynthesisUtterancePrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceConstructor) } }, |
| { "text", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceText), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceText) } }, |
| { "lang", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceLang), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceLang) } }, |
| { "voice", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceVoice), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceVoice) } }, |
| { "volume", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceVolume), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceVolume) } }, |
| { "rate", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceRate), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceRate) } }, |
| { "pitch", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtterancePitch), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtterancePitch) } }, |
| { "onstart", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceOnstart), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceOnstart) } }, |
| { "onend", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceOnend), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceOnend) } }, |
| { "onerror", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceOnerror), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceOnerror) } }, |
| { "onpause", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceOnpause), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceOnpause) } }, |
| { "onresume", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceOnresume), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceOnresume) } }, |
| { "onmark", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceOnmark), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceOnmark) } }, |
| { "onboundary", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechSynthesisUtteranceOnboundary), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSpeechSynthesisUtteranceOnboundary) } }, |
| }; |
| |
| const ClassInfo JSSpeechSynthesisUtterancePrototype::s_info = { "SpeechSynthesisUtterancePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSSpeechSynthesisUtterancePrototype) }; |
| |
| void JSSpeechSynthesisUtterancePrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSSpeechSynthesisUtterancePrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSSpeechSynthesisUtterance::s_info = { "SpeechSynthesisUtterance", &Base::s_info, 0, CREATE_METHOD_TABLE(JSSpeechSynthesisUtterance) }; |
| |
| JSSpeechSynthesisUtterance::JSSpeechSynthesisUtterance(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SpeechSynthesisUtterance>&& impl) |
| : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSSpeechSynthesisUtterance::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSSpeechSynthesisUtterancePrototype::create(vm, globalObject, JSSpeechSynthesisUtterancePrototype::createStructure(vm, globalObject, JSEventTarget::prototype(vm, globalObject))); |
| } |
| |
| JSObject* JSSpeechSynthesisUtterance::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSSpeechSynthesisUtterance>(vm, globalObject); |
| } |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceText(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "text"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.text()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceLang(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "lang"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.lang()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceVoice(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "voice"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.voice()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceVolume(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "volume"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.volume()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceRate(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "rate"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.rate()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtterancePitch(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "pitch"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.pitch()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceOnstart(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onstart"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().startEvent)); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceOnend(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onend"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().endEvent)); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceOnerror(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onerror"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().errorEvent)); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceOnpause(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onpause"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().pauseEvent)); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceOnresume(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onresume"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().resumeEvent)); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceOnmark(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onmark"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().markEvent)); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceOnboundary(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<JSSpeechSynthesisUtterance*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onboundary"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().boundaryEvent)); |
| } |
| |
| |
| EncodedJSValue jsSpeechSynthesisUtteranceConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSSpeechSynthesisUtterancePrototype* domObject = jsDynamicCast<JSSpeechSynthesisUtterancePrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSSpeechSynthesisUtterance::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSSpeechSynthesisUtteranceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSSpeechSynthesisUtterancePrototype* domObject = jsDynamicCast<JSSpeechSynthesisUtterancePrototype*>(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 setJSSpeechSynthesisUtteranceText(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "text"); |
| } |
| auto& impl = castedThis->wrapped(); |
| auto nativeValue = value.toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setText(WTFMove(nativeValue)); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtteranceLang(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "lang"); |
| } |
| auto& impl = castedThis->wrapped(); |
| auto nativeValue = value.toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setLang(WTFMove(nativeValue)); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtteranceVoice(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "voice"); |
| } |
| auto& impl = castedThis->wrapped(); |
| SpeechSynthesisVoice* nativeValue = nullptr; |
| if (!value.isUndefinedOrNull()) { |
| nativeValue = JSSpeechSynthesisVoice::toWrapped(value); |
| if (UNLIKELY(!nativeValue)) { |
| throwAttributeTypeError(*state, throwScope, "SpeechSynthesisUtterance", "voice", "SpeechSynthesisVoice"); |
| return false; |
| } |
| } |
| impl.setVoice(WTFMove(nativeValue)); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtteranceVolume(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "volume"); |
| } |
| auto& impl = castedThis->wrapped(); |
| auto nativeValue = convert<float>(*state, value, ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setVolume(WTFMove(nativeValue)); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtteranceRate(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "rate"); |
| } |
| auto& impl = castedThis->wrapped(); |
| auto nativeValue = convert<float>(*state, value, ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setRate(WTFMove(nativeValue)); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtterancePitch(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "pitch"); |
| } |
| auto& impl = castedThis->wrapped(); |
| auto nativeValue = convert<float>(*state, value, ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setPitch(WTFMove(nativeValue)); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtteranceOnstart(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onstart"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().startEvent, value); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtteranceOnend(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onend"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().endEvent, value); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtteranceOnerror(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onerror"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().errorEvent, value); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtteranceOnpause(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onpause"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().pauseEvent, value); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtteranceOnresume(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onresume"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().resumeEvent, value); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtteranceOnmark(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onmark"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().markEvent, value); |
| return true; |
| } |
| |
| |
| bool setJSSpeechSynthesisUtteranceOnboundary(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); |
| JSSpeechSynthesisUtterance* castedThis = jsDynamicCast<JSSpeechSynthesisUtterance*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "SpeechSynthesisUtterance", "onboundary"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().boundaryEvent, value); |
| return true; |
| } |
| |
| |
| JSValue JSSpeechSynthesisUtterance::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSSpeechSynthesisUtteranceConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| void JSSpeechSynthesisUtterance::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| { |
| auto* thisObject = jsCast<JSSpeechSynthesisUtterance*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| Base::visitChildren(thisObject, visitor); |
| thisObject->wrapped().visitJSEventListeners(visitor); |
| } |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| #if PLATFORM(WIN) |
| #pragma warning(disable: 4483) |
| extern "C" { extern void (*const __identifier("??_7SpeechSynthesisUtterance@WebCore@@6B@")[])(); } |
| #else |
| extern "C" { extern void* _ZTVN7WebCore24SpeechSynthesisUtteranceE[]; } |
| #endif |
| #endif |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SpeechSynthesisUtterance>&& impl) |
| { |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| #if PLATFORM(WIN) |
| void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7SpeechSynthesisUtterance@WebCore@@6B@")); |
| #else |
| void* expectedVTablePointer = &_ZTVN7WebCore24SpeechSynthesisUtteranceE[2]; |
| #if COMPILER(CLANG) |
| // If this fails SpeechSynthesisUtterance does not have a vtable, so you need to add the |
| // ImplementationLacksVTable attribute to the interface definition |
| static_assert(__is_polymorphic(SpeechSynthesisUtterance), "SpeechSynthesisUtterance is not polymorphic"); |
| #endif |
| #endif |
| // If you hit this assertion you either have a use after free bug, or |
| // SpeechSynthesisUtterance has subclasses. If SpeechSynthesisUtterance has subclasses that get passed |
| // to toJS() we currently require SpeechSynthesisUtterance you to opt out of binding hardening |
| // by adding the SkipVTableValidation attribute to the interface IDL definition |
| RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| #endif |
| return createWrapper<SpeechSynthesisUtterance>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SpeechSynthesisUtterance& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| SpeechSynthesisUtterance* JSSpeechSynthesisUtterance::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSSpeechSynthesisUtterance*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |
| |
| #endif // ENABLE(SPEECH_SYNTHESIS) |