| /* |
| 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 "JSFontFace.h" |
| |
| #include "Document.h" |
| #include "ExceptionCode.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSDOMConvert.h" |
| #include "JSDOMPromise.h" |
| #include "URL.h" |
| #include <runtime/Error.h> |
| #include <runtime/FunctionPrototype.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*, FontFace::LoadStatus); |
| |
| JSString* jsStringWithCache(ExecState* state, FontFace::LoadStatus enumerationValue) |
| { |
| static NeverDestroyed<const String> values[] = { |
| ASCIILiteral("unloaded"), |
| ASCIILiteral("loading"), |
| ASCIILiteral("loaded"), |
| ASCIILiteral("error"), |
| }; |
| static_assert(static_cast<size_t>(FontFace::LoadStatus::Unloaded) == 0, "FontFace::LoadStatus::Unloaded is not 0 as expected"); |
| static_assert(static_cast<size_t>(FontFace::LoadStatus::Loading) == 1, "FontFace::LoadStatus::Loading is not 1 as expected"); |
| static_assert(static_cast<size_t>(FontFace::LoadStatus::Loaded) == 2, "FontFace::LoadStatus::Loaded is not 2 as expected"); |
| static_assert(static_cast<size_t>(FontFace::LoadStatus::Error) == 3, "FontFace::LoadStatus::Error is not 3 as expected"); |
| ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]); |
| } |
| |
| template<> struct JSValueTraits<FontFace::LoadStatus> { |
| static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, FontFace::LoadStatus value) { return jsStringWithCache(state, value); } |
| }; |
| |
| template<> Optional<FontFace::LoadStatus> parse<FontFace::LoadStatus>(ExecState& state, JSValue value) |
| { |
| auto stringValue = value.toWTFString(&state); |
| if (stringValue == "unloaded") |
| return FontFace::LoadStatus::Unloaded; |
| if (stringValue == "loading") |
| return FontFace::LoadStatus::Loading; |
| if (stringValue == "loaded") |
| return FontFace::LoadStatus::Loaded; |
| if (stringValue == "error") |
| return FontFace::LoadStatus::Error; |
| return Nullopt; |
| } |
| |
| template<> FontFace::LoadStatus convert<FontFace::LoadStatus>(ExecState& state, JSValue value) |
| { |
| VM& vm = state.vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| auto result = parse<FontFace::LoadStatus>(state, value); |
| if (UNLIKELY(!result)) { |
| throwTypeError(&state, throwScope); |
| return { }; |
| } |
| return result.value(); |
| } |
| |
| template<> inline const char* expectedEnumerationValues<FontFace::LoadStatus>() |
| { |
| return "\"unloaded\", \"loading\", \"loaded\", \"error\""; |
| } |
| |
| template<> Optional<FontFace::Descriptors> convertDictionary<FontFace::Descriptors>(ExecState& state, JSValue value) |
| { |
| VM& vm = state.vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| if (value.isUndefinedOrNull()) |
| return FontFace::Descriptors { "normal", "normal", "normal", "U+0-10FFFF", "normal", "normal" }; |
| auto* object = value.getObject(); |
| if (UNLIKELY(!object || object->type() == RegExpObjectType)) { |
| throwTypeError(&state, throwScope); |
| return Nullopt; |
| } |
| auto style = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "style")), "normal"); |
| RETURN_IF_EXCEPTION(throwScope, Nullopt); |
| auto weight = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "weight")), "normal"); |
| RETURN_IF_EXCEPTION(throwScope, Nullopt); |
| auto stretch = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "stretch")), "normal"); |
| RETURN_IF_EXCEPTION(throwScope, Nullopt); |
| auto unicodeRange = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "unicodeRange")), "U+0-10FFFF"); |
| RETURN_IF_EXCEPTION(throwScope, Nullopt); |
| auto variant = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "variant")), "normal"); |
| RETURN_IF_EXCEPTION(throwScope, Nullopt); |
| auto featureSettings = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "featureSettings")), "normal"); |
| return FontFace::Descriptors { WTFMove(style), WTFMove(weight), WTFMove(stretch), WTFMove(unicodeRange), WTFMove(variant), WTFMove(featureSettings) }; |
| } |
| |
| // Functions |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsFontFacePrototypeFunctionLoad(JSC::ExecState*); |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsFontFaceFamily(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceFamily(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsFontFaceStyle(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceStyle(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsFontFaceWeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceWeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsFontFaceStretch(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceStretch(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsFontFaceUnicodeRange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceUnicodeRange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsFontFaceVariant(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceVariant(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsFontFaceFeatureSettings(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceFeatureSettings(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsFontFaceStatus(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsFontFaceLoaded(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsFontFaceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFontFaceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSFontFacePrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSFontFacePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSFontFacePrototype* ptr = new (NotNull, JSC::allocateCell<JSFontFacePrototype>(vm.heap)) JSFontFacePrototype(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: |
| JSFontFacePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSFontFace> JSFontFaceConstructor; |
| |
| template<> EncodedJSValue JSC_HOST_CALL JSFontFaceConstructor::construct(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| auto* castedThis = jsCast<JSFontFaceConstructor*>(state->callee()); |
| ASSERT(castedThis); |
| if (UNLIKELY(state->argumentCount() < 2)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCode ec = 0; |
| auto family = state->uncheckedArgument(0).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto source = state->uncheckedArgument(1); |
| auto descriptors = state->argument(2).isUndefined() ? FontFace::Descriptors() : convertDictionary<FontFace::Descriptors>(*state, state->uncheckedArgument(2)); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| ScriptExecutionContext* context = castedThis->scriptExecutionContext(); |
| if (UNLIKELY(!context)) |
| return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "FontFace"); |
| ASSERT(context->isDocument()); |
| auto& document = downcast<Document>(*context); |
| auto object = FontFace::create(*state, document, WTFMove(family), WTFMove(source), descriptors.value(), ec); |
| if (UNLIKELY(ec)) { |
| setDOMException(state, throwScope, ec); |
| return JSValue::encode(JSValue()); |
| } |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))); |
| } |
| |
| template<> JSValue JSFontFaceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| UNUSED_PARAM(vm); |
| return globalObject.functionPrototype(); |
| } |
| |
| template<> void JSFontFaceConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSFontFace::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("FontFace"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(2), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSFontFaceConstructor::s_info = { "FontFace", &Base::s_info, 0, CREATE_METHOD_TABLE(JSFontFaceConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSFontFacePrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceConstructor) } }, |
| { "family", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceFamily), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceFamily) } }, |
| { "style", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceStyle), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceStyle) } }, |
| { "weight", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceWeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceWeight) } }, |
| { "stretch", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceStretch), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceStretch) } }, |
| { "unicodeRange", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceUnicodeRange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceUnicodeRange) } }, |
| { "variant", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceVariant), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceVariant) } }, |
| { "featureSettings", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceFeatureSettings), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceFeatureSettings) } }, |
| { "status", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceStatus), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "loaded", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceLoaded), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "load", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsFontFacePrototypeFunctionLoad), (intptr_t) (0) } }, |
| }; |
| |
| const ClassInfo JSFontFacePrototype::s_info = { "FontFacePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSFontFacePrototype) }; |
| |
| void JSFontFacePrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSFontFacePrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSFontFace::s_info = { "FontFace", &Base::s_info, 0, CREATE_METHOD_TABLE(JSFontFace) }; |
| |
| JSFontFace::JSFontFace(Structure* structure, JSDOMGlobalObject& globalObject, Ref<FontFace>&& impl) |
| : JSDOMWrapper<FontFace>(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSFontFace::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSFontFacePrototype::create(vm, globalObject, JSFontFacePrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); |
| } |
| |
| JSObject* JSFontFace::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSFontFace>(vm, globalObject); |
| } |
| |
| void JSFontFace::destroy(JSC::JSCell* cell) |
| { |
| JSFontFace* thisObject = static_cast<JSFontFace*>(cell); |
| thisObject->JSFontFace::~JSFontFace(); |
| } |
| |
| EncodedJSValue jsFontFaceFamily(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<JSFontFace*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFace", "family"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.family()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFontFaceStyle(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<JSFontFace*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFace", "style"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.style()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFontFaceWeight(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<JSFontFace*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFace", "weight"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.weight()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFontFaceStretch(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<JSFontFace*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFace", "stretch"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.stretch()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFontFaceUnicodeRange(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<JSFontFace*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFace", "unicodeRange"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.unicodeRange()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFontFaceVariant(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<JSFontFace*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFace", "variant"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.variant()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFontFaceFeatureSettings(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<JSFontFace*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFace", "featureSettings"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.featureSettings()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFontFaceStatus(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<JSFontFace*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFace", "status"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.status()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFontFaceLoaded(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<JSFontFace*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "FontFace", "loaded"); |
| } |
| return JSValue::encode(castedThis->loaded(*state)); |
| } |
| |
| |
| EncodedJSValue jsFontFaceConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSFontFacePrototype* domObject = jsDynamicCast<JSFontFacePrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSFontFace::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSFontFaceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSFontFacePrototype* domObject = jsDynamicCast<JSFontFacePrototype*>(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 setJSFontFaceFamily(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); |
| JSFontFace* castedThis = jsDynamicCast<JSFontFace*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "FontFace", "family"); |
| } |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto nativeValue = value.toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setFamily(WTFMove(nativeValue), ec); |
| setDOMException(state, throwScope, ec); |
| return true; |
| } |
| |
| |
| bool setJSFontFaceStyle(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); |
| JSFontFace* castedThis = jsDynamicCast<JSFontFace*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "FontFace", "style"); |
| } |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto nativeValue = value.toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setStyle(WTFMove(nativeValue), ec); |
| setDOMException(state, throwScope, ec); |
| return true; |
| } |
| |
| |
| bool setJSFontFaceWeight(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); |
| JSFontFace* castedThis = jsDynamicCast<JSFontFace*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "FontFace", "weight"); |
| } |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto nativeValue = value.toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setWeight(WTFMove(nativeValue), ec); |
| setDOMException(state, throwScope, ec); |
| return true; |
| } |
| |
| |
| bool setJSFontFaceStretch(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); |
| JSFontFace* castedThis = jsDynamicCast<JSFontFace*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "FontFace", "stretch"); |
| } |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto nativeValue = value.toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setStretch(WTFMove(nativeValue), ec); |
| setDOMException(state, throwScope, ec); |
| return true; |
| } |
| |
| |
| bool setJSFontFaceUnicodeRange(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); |
| JSFontFace* castedThis = jsDynamicCast<JSFontFace*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "FontFace", "unicodeRange"); |
| } |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto nativeValue = value.toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setUnicodeRange(WTFMove(nativeValue), ec); |
| setDOMException(state, throwScope, ec); |
| return true; |
| } |
| |
| |
| bool setJSFontFaceVariant(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); |
| JSFontFace* castedThis = jsDynamicCast<JSFontFace*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "FontFace", "variant"); |
| } |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto nativeValue = value.toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setVariant(WTFMove(nativeValue), ec); |
| setDOMException(state, throwScope, ec); |
| return true; |
| } |
| |
| |
| bool setJSFontFaceFeatureSettings(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); |
| JSFontFace* castedThis = jsDynamicCast<JSFontFace*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "FontFace", "featureSettings"); |
| } |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto nativeValue = value.toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setFeatureSettings(WTFMove(nativeValue), ec); |
| setDOMException(state, throwScope, ec); |
| return true; |
| } |
| |
| |
| JSValue JSFontFace::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSFontFaceConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsFontFacePrototypeFunctionLoad(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSFontFace*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return createRejectedPromiseWithTypeError(*state, makeThisTypeErrorMessage("FontFace", "load")); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSFontFace::info()); |
| return JSValue::encode(castedThis->load(*state)); |
| } |
| |
| void JSFontFace::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| { |
| auto* thisObject = jsCast<JSFontFace*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| Base::visitChildren(thisObject, visitor); |
| visitor.append(&thisObject->m_loaded); |
| } |
| |
| bool JSFontFaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) |
| { |
| UNUSED_PARAM(handle); |
| UNUSED_PARAM(visitor); |
| return false; |
| } |
| |
| void JSFontFaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| { |
| auto* jsFontFace = jsCast<JSFontFace*>(handle.slot()->asCell()); |
| auto& world = *static_cast<DOMWrapperWorld*>(context); |
| uncacheWrapper(world, &jsFontFace->wrapped(), jsFontFace); |
| } |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| #if PLATFORM(WIN) |
| #pragma warning(disable: 4483) |
| extern "C" { extern void (*const __identifier("??_7FontFace@WebCore@@6B@")[])(); } |
| #else |
| extern "C" { extern void* _ZTVN7WebCore8FontFaceE[]; } |
| #endif |
| #endif |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<FontFace>&& impl) |
| { |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| #if PLATFORM(WIN) |
| void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7FontFace@WebCore@@6B@")); |
| #else |
| void* expectedVTablePointer = &_ZTVN7WebCore8FontFaceE[2]; |
| #if COMPILER(CLANG) |
| // If this fails FontFace does not have a vtable, so you need to add the |
| // ImplementationLacksVTable attribute to the interface definition |
| static_assert(__is_polymorphic(FontFace), "FontFace is not polymorphic"); |
| #endif |
| #endif |
| // If you hit this assertion you either have a use after free bug, or |
| // FontFace has subclasses. If FontFace has subclasses that get passed |
| // to toJS() we currently require FontFace you to opt out of binding hardening |
| // by adding the SkipVTableValidation attribute to the interface IDL definition |
| RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| #endif |
| return createWrapper<FontFace>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, FontFace& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| FontFace* JSFontFace::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSFontFace*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |