| /* |
| 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(WEB_ANIMATIONS) |
| |
| #include "JSWebAnimation.h" |
| |
| #include "ExceptionCode.h" |
| #include "JSAnimationEffect.h" |
| #include "JSAnimationTimeline.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include <runtime/Error.h> |
| #include <runtime/FunctionPrototype.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsWebAnimationEffect(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsWebAnimationTimeline(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsWebAnimationConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSWebAnimationConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSWebAnimationPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSWebAnimationPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSWebAnimationPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebAnimationPrototype>(vm.heap)) JSWebAnimationPrototype(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: |
| JSWebAnimationPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSWebAnimation> JSWebAnimationConstructor; |
| |
| template<> EncodedJSValue JSC_HOST_CALL JSWebAnimationConstructor::construct(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| auto* castedThis = jsCast<JSWebAnimationConstructor*>(state->callee()); |
| ASSERT(castedThis); |
| if (UNLIKELY(state->argumentCount() < 2)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| AnimationEffect* effect = nullptr; |
| if (!state->uncheckedArgument(0).isUndefinedOrNull()) { |
| effect = JSAnimationEffect::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!effect)) |
| return throwArgumentTypeError(*state, throwScope, 0, "effect", "Animation", nullptr, "AnimationEffect"); |
| } |
| AnimationTimeline* timeline = nullptr; |
| if (!state->uncheckedArgument(1).isUndefinedOrNull()) { |
| timeline = JSAnimationTimeline::toWrapped(state->uncheckedArgument(1)); |
| if (UNLIKELY(!timeline)) |
| return throwArgumentTypeError(*state, throwScope, 1, "timeline", "Animation", nullptr, "AnimationTimeline"); |
| } |
| auto object = WebAnimation::create(WTFMove(effect), WTFMove(timeline)); |
| return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))); |
| } |
| |
| template<> JSValue JSWebAnimationConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| UNUSED_PARAM(vm); |
| return globalObject.functionPrototype(); |
| } |
| |
| template<> void JSWebAnimationConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSWebAnimation::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("Animation"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(2), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSWebAnimationConstructor::s_info = { "Animation", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAnimationConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSWebAnimationPrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebAnimationConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebAnimationConstructor) } }, |
| { "effect", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebAnimationEffect), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "timeline", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebAnimationTimeline), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| }; |
| |
| const ClassInfo JSWebAnimationPrototype::s_info = { "AnimationPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAnimationPrototype) }; |
| |
| void JSWebAnimationPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSWebAnimationPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSWebAnimation::s_info = { "Animation", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAnimation) }; |
| |
| JSWebAnimation::JSWebAnimation(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebAnimation>&& impl) |
| : JSDOMWrapper<WebAnimation>(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSWebAnimation::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSWebAnimationPrototype::create(vm, globalObject, JSWebAnimationPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); |
| } |
| |
| JSObject* JSWebAnimation::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSWebAnimation>(vm, globalObject); |
| } |
| |
| void JSWebAnimation::destroy(JSC::JSCell* cell) |
| { |
| JSWebAnimation* thisObject = static_cast<JSWebAnimation*>(cell); |
| thisObject->JSWebAnimation::~JSWebAnimation(); |
| } |
| |
| EncodedJSValue jsWebAnimationEffect(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<JSWebAnimation*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "Animation", "effect"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.effect()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsWebAnimationTimeline(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<JSWebAnimation*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "Animation", "timeline"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.timeline()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsWebAnimationConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSWebAnimationPrototype* domObject = jsDynamicCast<JSWebAnimationPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSWebAnimation::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSWebAnimationConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSWebAnimationPrototype* domObject = jsDynamicCast<JSWebAnimationPrototype*>(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); |
| } |
| |
| JSValue JSWebAnimation::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSWebAnimationConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| bool JSWebAnimationOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) |
| { |
| UNUSED_PARAM(handle); |
| UNUSED_PARAM(visitor); |
| return false; |
| } |
| |
| void JSWebAnimationOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| { |
| auto* jsWebAnimation = jsCast<JSWebAnimation*>(handle.slot()->asCell()); |
| auto& world = *static_cast<DOMWrapperWorld*>(context); |
| uncacheWrapper(world, &jsWebAnimation->wrapped(), jsWebAnimation); |
| } |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebAnimation>&& impl) |
| { |
| #if COMPILER(CLANG) |
| // If you hit this failure the interface definition has the ImplementationLacksVTable |
| // attribute. You should remove that attribute. If the class has subclasses |
| // that may be passed through this toJS() function you should use the SkipVTableValidation |
| // attribute to WebAnimation. |
| static_assert(!__is_polymorphic(WebAnimation), "WebAnimation is polymorphic but the IDL claims it is not"); |
| #endif |
| return createWrapper<WebAnimation>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebAnimation& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| WebAnimation* JSWebAnimation::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSWebAnimation*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |
| |
| #endif // ENABLE(WEB_ANIMATIONS) |