| /* |
| 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" |
| #include "JSFontFaceSet.h" |
| |
| #include "Document.h" |
| #include "EventNames.h" |
| #include "ExceptionCode.h" |
| #include "FontFaceSet.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSDOMConvert.h" |
| #include "JSDOMIterator.h" |
| #include "JSDOMPromise.h" |
| #include "JSEventListener.h" |
| #include "JSFontFace.h" |
| #include "JSFontFaceSet.h" |
| #include "RuntimeEnabledFeatures.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*, FontFaceSet::LoadStatus); |
| |
| JSString* jsStringWithCache(ExecState* state, FontFaceSet::LoadStatus enumerationValue) |
| { |
| static NeverDestroyed<const String> values[] = { |
| ASCIILiteral("loading"), |
| ASCIILiteral("loaded"), |
| }; |
| static_assert(static_cast<size_t>(FontFaceSet::LoadStatus::Loading) == 0, "FontFaceSet::LoadStatus::Loading is not 0 as expected"); |
| static_assert(static_cast<size_t>(FontFaceSet::LoadStatus::Loaded) == 1, "FontFaceSet::LoadStatus::Loaded 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<FontFaceSet::LoadStatus> { |
| static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, FontFaceSet::LoadStatus value) { return jsStringWithCache(state, value); } |
| }; |
| |
| template<> Optional<FontFaceSet::LoadStatus> parse<FontFaceSet::LoadStatus>(ExecState& state, JSValue value) |
| { |
| auto stringValue = value.toWTFString(&state); |
| if (stringValue == "loading") |
| return FontFaceSet::LoadStatus::Loading; |
| if (stringValue == "loaded") |
| return FontFaceSet::LoadStatus::Loaded; |
| return Nullopt; |
| } |
| |
| template<> FontFaceSet::LoadStatus convert<FontFaceSet::LoadStatus>(ExecState& state, JSValue value) |
| { |
| VM& vm = state.vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| auto result = parse<FontFaceSet::LoadStatus>(state, value); |
| if (UNLIKELY(!result)) { |
| throwTypeError(&state, throwScope); |
| return { }; |
| } |
| return result.value(); |
| } |
| |
| template<> inline const char* expectedEnumerationValues<FontFaceSet::LoadStatus>() |
| { |
| return "\"loading\", \"loaded\""; |
| } |
| |
| // Functions |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionHas(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionAdd(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionDelete(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionClear(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionLoad(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionCheck(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionSymbolIterator(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionEntries(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionKeys(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionValues(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionForEach(JSC::ExecState*); |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsFontFaceSetSize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsFontFaceSetOnloading(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceSetOnloading(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsFontFaceSetOnloadingdone(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceSetOnloadingdone(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsFontFaceSetOnloadingerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceSetOnloadingerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsFontFaceSetReady(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsFontFaceSetStatus(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsFontFaceSetConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceSetConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSFontFaceSetPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSFontFaceSetPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSFontFaceSetPrototype* ptr = new (NotNull, JSC::allocateCell<JSFontFaceSetPrototype>(vm.heap)) JSFontFaceSetPrototype(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: |
| JSFontFaceSetPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSFontFaceSet> JSFontFaceSetConstructor; |
| |
| template<> EncodedJSValue JSC_HOST_CALL JSFontFaceSetConstructor::construct(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| auto* castedThis = jsCast<JSFontFaceSetConstructor*>(state->callee()); |
| ASSERT(castedThis); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto initialFaces = toRefPtrNativeArray<FontFace, JSFontFace>(*state, state->uncheckedArgument(0)); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| ScriptExecutionContext* context = castedThis->scriptExecutionContext(); |
| if (UNLIKELY(!context)) |
| return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "FontFaceSet"); |
| ASSERT(context->isDocument()); |
| auto& document = downcast<Document>(*context); |
| auto object = FontFaceSet::create(document, WTFMove(initialFaces)); |
| return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))); |
| } |
| |
| template<> JSValue JSFontFaceSetConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| return JSEventTarget::getConstructor(vm, &globalObject); |
| } |
| |
| template<> void JSFontFaceSetConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSFontFaceSet::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("FontFaceSet"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSFontFaceSetConstructor::s_info = { "FontFaceSet", &Base::s_info, 0, CREATE_METHOD_TABLE(JSFontFaceSetConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSFontFaceSetPrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceSetConstructor) } }, |
| { "size", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "onloading", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetOnloading), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceSetOnloading) } }, |
| { "onloadingdone", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetOnloadingdone), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceSetOnloadingdone) } }, |
| { "onloadingerror", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetOnloadingerror), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceSetOnloadingerror) } }, |
| { "ready", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetReady), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "status", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetStatus), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "has", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsFontFaceSetPrototypeFunctionHas), (intptr_t) (1) } }, |
| { "add", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsFontFaceSetPrototypeFunctionAdd), (intptr_t) (1) } }, |
| { "delete", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsFontFaceSetPrototypeFunctionDelete), (intptr_t) (1) } }, |
| { "clear", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsFontFaceSetPrototypeFunctionClear), (intptr_t) (0) } }, |
| { "load", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsFontFaceSetPrototypeFunctionLoad), (intptr_t) (1) } }, |
| { "check", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsFontFaceSetPrototypeFunctionCheck), (intptr_t) (1) } }, |
| { "entries", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsFontFaceSetPrototypeFunctionEntries), (intptr_t) (0) } }, |
| { "keys", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsFontFaceSetPrototypeFunctionKeys), (intptr_t) (0) } }, |
| { "values", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsFontFaceSetPrototypeFunctionValues), (intptr_t) (0) } }, |
| { "forEach", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsFontFaceSetPrototypeFunctionForEach), (intptr_t) (1) } }, |
| }; |
| |
| const ClassInfo JSFontFaceSetPrototype::s_info = { "FontFaceSetPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSFontFaceSetPrototype) }; |
| |
| void JSFontFaceSetPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSFontFaceSetPrototypeTableValues, *this); |
| if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) { |
| Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("entries"), strlen("entries")); |
| VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| } |
| if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) { |
| Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("keys"), strlen("keys")); |
| VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| } |
| if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) { |
| Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("values"), strlen("values")); |
| VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| } |
| if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) { |
| Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("forEach"), strlen("forEach")); |
| VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| } |
| if (RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) { |
| putDirect(vm, vm.propertyNames->iteratorSymbol, JSFunction::create(vm, globalObject(), 0, ASCIILiteral("[Symbol.Iterator]"), jsFontFaceSetPrototypeFunctionSymbolIterator), DontEnum); |
| } |
| } |
| |
| const ClassInfo JSFontFaceSet::s_info = { "FontFaceSet", &Base::s_info, 0, CREATE_METHOD_TABLE(JSFontFaceSet) }; |
| |
| JSFontFaceSet::JSFontFaceSet(Structure* structure, JSDOMGlobalObject& globalObject, Ref<FontFaceSet>&& impl) |
| : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSFontFaceSet::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSFontFaceSetPrototype::create(vm, globalObject, JSFontFaceSetPrototype::createStructure(vm, globalObject, JSEventTarget::prototype(vm, globalObject))); |
| } |
| |
| JSObject* JSFontFaceSet::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSFontFaceSet>(vm, globalObject); |
| } |
| |
| EncodedJSValue jsFontFaceSetSize(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<JSFontFaceSet*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFaceSet", "size"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.size()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFontFaceSetOnloading(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<JSFontFaceSet*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFaceSet", "onloading"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().loadingEvent)); |
| } |
| |
| |
| EncodedJSValue jsFontFaceSetOnloadingdone(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<JSFontFaceSet*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFaceSet", "onloadingdone"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().loadingdoneEvent)); |
| } |
| |
| |
| EncodedJSValue jsFontFaceSetOnloadingerror(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<JSFontFaceSet*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFaceSet", "onloadingerror"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().loadingerrorEvent)); |
| } |
| |
| |
| EncodedJSValue jsFontFaceSetReady(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<JSFontFaceSet*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFaceSet", "ready"); |
| } |
| return JSValue::encode(castedThis->ready(*state)); |
| } |
| |
| |
| EncodedJSValue jsFontFaceSetStatus(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<JSFontFaceSet*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFaceSet", "status"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.status()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFontFaceSetConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSFontFaceSetPrototype* domObject = jsDynamicCast<JSFontFaceSetPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSFontFaceSet::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSFontFaceSetConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSFontFaceSetPrototype* domObject = jsDynamicCast<JSFontFaceSetPrototype*>(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 setJSFontFaceSetOnloading(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); |
| JSFontFaceSet* castedThis = jsDynamicCast<JSFontFaceSet*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "FontFaceSet", "onloading"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().loadingEvent, value); |
| return true; |
| } |
| |
| |
| bool setJSFontFaceSetOnloadingdone(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); |
| JSFontFaceSet* castedThis = jsDynamicCast<JSFontFaceSet*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "FontFaceSet", "onloadingdone"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().loadingdoneEvent, value); |
| return true; |
| } |
| |
| |
| bool setJSFontFaceSetOnloadingerror(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); |
| JSFontFaceSet* castedThis = jsDynamicCast<JSFontFaceSet*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "FontFaceSet", "onloadingerror"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().loadingerrorEvent, value); |
| return true; |
| } |
| |
| |
| JSValue JSFontFaceSet::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSFontFaceSetConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionHas(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSFontFaceSet*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "FontFaceSet", "has"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSFontFaceSet::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto font = JSFontFace::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!font)) |
| return throwArgumentTypeError(*state, throwScope, 0, "font", "FontFaceSet", "has", "FontFace"); |
| JSValue result = jsBoolean(impl.has(*font)); |
| return JSValue::encode(result); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionAdd(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSFontFaceSet*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "FontFaceSet", "add"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSFontFaceSet::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto font = JSFontFace::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!font)) |
| return throwArgumentTypeError(*state, throwScope, 0, "font", "FontFaceSet", "add", "FontFace"); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.add(*font)); |
| return JSValue::encode(result); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionDelete(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSFontFaceSet*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "FontFaceSet", "delete"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSFontFaceSet::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto font = JSFontFace::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!font)) |
| return throwArgumentTypeError(*state, throwScope, 0, "font", "FontFaceSet", "delete", "FontFace"); |
| JSValue result = jsBoolean(impl.remove(*font)); |
| return JSValue::encode(result); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionClear(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSFontFaceSet*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "FontFaceSet", "clear"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSFontFaceSet::info()); |
| auto& impl = castedThis->wrapped(); |
| impl.clear(); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| static EncodedJSValue jsFontFaceSetPrototypeFunctionLoadPromise(ExecState*, Ref<DeferredPromise>&&); |
| |
| EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionLoad(ExecState* state) |
| { |
| ASSERT(state); |
| return JSValue::encode(callPromiseFunction<jsFontFaceSetPrototypeFunctionLoadPromise, PromiseExecutionScope::WindowOnly>(*state)); |
| } |
| |
| static inline EncodedJSValue jsFontFaceSetPrototypeFunctionLoadPromise(ExecState* state, Ref<DeferredPromise>&& promise) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSFontFaceSet*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "FontFaceSet", "load"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSFontFaceSet::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto font = state->uncheckedArgument(0).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto text = state->argument(1).isUndefined() ? ASCIILiteral(" ") : state->uncheckedArgument(1).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.load(WTFMove(font), WTFMove(text), WTFMove(promise)); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionCheck(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSFontFaceSet*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "FontFaceSet", "check"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSFontFaceSet::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCode ec = 0; |
| auto font = state->uncheckedArgument(0).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto text = state->argument(1).isUndefined() ? ASCIILiteral(" ") : state->uncheckedArgument(1).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| JSValue result = jsBoolean(impl.check(WTFMove(font), WTFMove(text), ec)); |
| |
| setDOMException(state, throwScope, ec); |
| return JSValue::encode(result); |
| } |
| |
| using FontFaceSetIterator = JSDOMIterator<JSFontFaceSet>; |
| using FontFaceSetIteratorPrototype = JSDOMIteratorPrototype<JSFontFaceSet>; |
| |
| template<> |
| const JSC::ClassInfo FontFaceSetIterator::s_info = { "FontFaceSet Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(FontFaceSetIterator) }; |
| |
| template<> |
| const JSC::ClassInfo FontFaceSetIteratorPrototype::s_info = { "FontFaceSet Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(FontFaceSetIteratorPrototype) }; |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionSymbolIterator(JSC::ExecState* state) |
| { |
| return iteratorCreate<JSFontFaceSet>(*state, IterationKind::Value, "[Symbol.Iterator]"); |
| } |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionEntries(JSC::ExecState* state) |
| { |
| return iteratorCreate<JSFontFaceSet>(*state, IterationKind::KeyValue, "entries"); |
| } |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionKeys(JSC::ExecState* state) |
| { |
| return iteratorCreate<JSFontFaceSet>(*state, IterationKind::Key, "keys"); |
| } |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionValues(JSC::ExecState* state) |
| { |
| return iteratorCreate<JSFontFaceSet>(*state, IterationKind::Value, "values"); |
| } |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionForEach(JSC::ExecState* state) |
| { |
| return iteratorForEach<JSFontFaceSet>(*state, "forEach"); |
| } |
| |
| void JSFontFaceSet::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| { |
| auto* thisObject = jsCast<JSFontFaceSet*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| Base::visitChildren(thisObject, visitor); |
| thisObject->wrapped().visitJSEventListeners(visitor); |
| visitor.append(&thisObject->m_ready); |
| } |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| #if PLATFORM(WIN) |
| #pragma warning(disable: 4483) |
| extern "C" { extern void (*const __identifier("??_7FontFaceSet@WebCore@@6B@")[])(); } |
| #else |
| extern "C" { extern void* _ZTVN7WebCore11FontFaceSetE[]; } |
| #endif |
| #endif |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<FontFaceSet>&& impl) |
| { |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| #if PLATFORM(WIN) |
| void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7FontFaceSet@WebCore@@6B@")); |
| #else |
| void* expectedVTablePointer = &_ZTVN7WebCore11FontFaceSetE[2]; |
| #if COMPILER(CLANG) |
| // If this fails FontFaceSet does not have a vtable, so you need to add the |
| // ImplementationLacksVTable attribute to the interface definition |
| static_assert(__is_polymorphic(FontFaceSet), "FontFaceSet is not polymorphic"); |
| #endif |
| #endif |
| // If you hit this assertion you either have a use after free bug, or |
| // FontFaceSet has subclasses. If FontFaceSet has subclasses that get passed |
| // to toJS() we currently require FontFaceSet you to opt out of binding hardening |
| // by adding the SkipVTableValidation attribute to the interface IDL definition |
| RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| #endif |
| return createWrapper<FontFaceSet>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, FontFaceSet& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| FontFaceSet* JSFontFaceSet::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSFontFaceSet*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |