| 1 | /* |
| 2 | This file is part of the WebKit open source project. |
| 3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Library General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Library General Public License |
| 16 | along with this library; see the file COPYING.LIB. If not, write to |
| 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | #include "JSAnimationEffect.h" |
| 23 | |
| 24 | #include "JSComputedEffectTiming.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructorNotConstructable.h" |
| 27 | #include "JSDOMConvertDictionary.h" |
| 28 | #include "JSDOMExceptionHandling.h" |
| 29 | #include "JSDOMGlobalObject.h" |
| 30 | #include "JSDOMOperation.h" |
| 31 | #include "JSDOMWrapperCache.h" |
| 32 | #include "JSEffectTiming.h" |
| 33 | #include "JSOptionalEffectTiming.h" |
| 34 | #include "ScriptExecutionContext.h" |
| 35 | #include <JavaScriptCore/FunctionPrototype.h> |
| 36 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 37 | #include <JavaScriptCore/JSCInlines.h> |
| 38 | #include <wtf/GetPtr.h> |
| 39 | #include <wtf/PointerPreparations.h> |
| 40 | #include <wtf/URL.h> |
| 41 | |
| 42 | |
| 43 | namespace WebCore { |
| 44 | using namespace JSC; |
| 45 | |
| 46 | // Functions |
| 47 | |
| 48 | JSC::EncodedJSValue JSC_HOST_CALL jsAnimationEffectPrototypeFunctionGetTiming(JSC::ExecState*); |
| 49 | JSC::EncodedJSValue JSC_HOST_CALL jsAnimationEffectPrototypeFunctionGetComputedTiming(JSC::ExecState*); |
| 50 | JSC::EncodedJSValue JSC_HOST_CALL jsAnimationEffectPrototypeFunctionUpdateTiming(JSC::ExecState*); |
| 51 | |
| 52 | // Attributes |
| 53 | |
| 54 | JSC::EncodedJSValue jsAnimationEffectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 55 | bool setJSAnimationEffectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 56 | |
| 57 | class JSAnimationEffectPrototype : public JSC::JSNonFinalObject { |
| 58 | public: |
| 59 | using Base = JSC::JSNonFinalObject; |
| 60 | static JSAnimationEffectPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 61 | { |
| 62 | JSAnimationEffectPrototype* ptr = new (NotNull, JSC::allocateCell<JSAnimationEffectPrototype>(vm.heap)) JSAnimationEffectPrototype(vm, globalObject, structure); |
| 63 | ptr->finishCreation(vm); |
| 64 | return ptr; |
| 65 | } |
| 66 | |
| 67 | DECLARE_INFO; |
| 68 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 69 | { |
| 70 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 71 | } |
| 72 | |
| 73 | private: |
| 74 | JSAnimationEffectPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 75 | : JSC::JSNonFinalObject(vm, structure) |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | void finishCreation(JSC::VM&); |
| 80 | }; |
| 81 | |
| 82 | using JSAnimationEffectConstructor = JSDOMConstructorNotConstructable<JSAnimationEffect>; |
| 83 | |
| 84 | template<> JSValue JSAnimationEffectConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 85 | { |
| 86 | UNUSED_PARAM(vm); |
| 87 | return globalObject.functionPrototype(); |
| 88 | } |
| 89 | |
| 90 | template<> void JSAnimationEffectConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 91 | { |
| 92 | putDirect(vm, vm.propertyNames->prototype, JSAnimationEffect::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 93 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("AnimationEffect"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 94 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 95 | } |
| 96 | |
| 97 | template<> const ClassInfo JSAnimationEffectConstructor::s_info = { "AnimationEffect" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAnimationEffectConstructor) }; |
| 98 | |
| 99 | /* Hash table for prototype */ |
| 100 | |
| 101 | static const HashTableValue JSAnimationEffectPrototypeTableValues[] = |
| 102 | { |
| 103 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAnimationEffectConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAnimationEffectConstructor) } }, |
| 104 | { "getTiming" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsAnimationEffectPrototypeFunctionGetTiming), (intptr_t) (0) } }, |
| 105 | { "getComputedTiming" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsAnimationEffectPrototypeFunctionGetComputedTiming), (intptr_t) (0) } }, |
| 106 | { "updateTiming" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsAnimationEffectPrototypeFunctionUpdateTiming), (intptr_t) (0) } }, |
| 107 | }; |
| 108 | |
| 109 | const ClassInfo JSAnimationEffectPrototype::s_info = { "AnimationEffectPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAnimationEffectPrototype) }; |
| 110 | |
| 111 | void JSAnimationEffectPrototype::finishCreation(VM& vm) |
| 112 | { |
| 113 | Base::finishCreation(vm); |
| 114 | reifyStaticProperties(vm, JSAnimationEffect::info(), JSAnimationEffectPrototypeTableValues, *this); |
| 115 | } |
| 116 | |
| 117 | const ClassInfo JSAnimationEffect::s_info = { "AnimationEffect" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAnimationEffect) }; |
| 118 | |
| 119 | JSAnimationEffect::JSAnimationEffect(Structure* structure, JSDOMGlobalObject& globalObject, Ref<AnimationEffect>&& impl) |
| 120 | : JSDOMWrapper<AnimationEffect>(structure, globalObject, WTFMove(impl)) |
| 121 | { |
| 122 | } |
| 123 | |
| 124 | void JSAnimationEffect::finishCreation(VM& vm) |
| 125 | { |
| 126 | Base::finishCreation(vm); |
| 127 | ASSERT(inherits(vm, info())); |
| 128 | |
| 129 | } |
| 130 | |
| 131 | JSObject* JSAnimationEffect::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 132 | { |
| 133 | return JSAnimationEffectPrototype::create(vm, &globalObject, JSAnimationEffectPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 134 | } |
| 135 | |
| 136 | JSObject* JSAnimationEffect::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 137 | { |
| 138 | return getDOMPrototype<JSAnimationEffect>(vm, globalObject); |
| 139 | } |
| 140 | |
| 141 | JSValue JSAnimationEffect::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 142 | { |
| 143 | return getDOMConstructor<JSAnimationEffectConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 144 | } |
| 145 | |
| 146 | void JSAnimationEffect::destroy(JSC::JSCell* cell) |
| 147 | { |
| 148 | JSAnimationEffect* thisObject = static_cast<JSAnimationEffect*>(cell); |
| 149 | thisObject->JSAnimationEffect::~JSAnimationEffect(); |
| 150 | } |
| 151 | |
| 152 | template<> inline JSAnimationEffect* IDLOperation<JSAnimationEffect>::cast(ExecState& state) |
| 153 | { |
| 154 | return jsDynamicCast<JSAnimationEffect*>(state.vm(), state.thisValue()); |
| 155 | } |
| 156 | |
| 157 | EncodedJSValue jsAnimationEffectConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 158 | { |
| 159 | VM& vm = state->vm(); |
| 160 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 161 | auto* prototype = jsDynamicCast<JSAnimationEffectPrototype*>(vm, JSValue::decode(thisValue)); |
| 162 | if (UNLIKELY(!prototype)) |
| 163 | return throwVMTypeError(state, throwScope); |
| 164 | return JSValue::encode(JSAnimationEffect::getConstructor(state->vm(), prototype->globalObject())); |
| 165 | } |
| 166 | |
| 167 | bool setJSAnimationEffectConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 168 | { |
| 169 | VM& vm = state->vm(); |
| 170 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 171 | auto* prototype = jsDynamicCast<JSAnimationEffectPrototype*>(vm, JSValue::decode(thisValue)); |
| 172 | if (UNLIKELY(!prototype)) { |
| 173 | throwVMTypeError(state, throwScope); |
| 174 | return false; |
| 175 | } |
| 176 | // Shadowing a built-in constructor |
| 177 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 178 | } |
| 179 | |
| 180 | static inline JSC::EncodedJSValue jsAnimationEffectPrototypeFunctionGetTimingBody(JSC::ExecState* state, typename IDLOperation<JSAnimationEffect>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 181 | { |
| 182 | UNUSED_PARAM(state); |
| 183 | UNUSED_PARAM(throwScope); |
| 184 | auto& impl = castedThis->wrapped(); |
| 185 | return JSValue::encode(toJS<IDLDictionary<EffectTiming>>(*state, *castedThis->globalObject(), impl.getTiming())); |
| 186 | } |
| 187 | |
| 188 | EncodedJSValue JSC_HOST_CALL jsAnimationEffectPrototypeFunctionGetTiming(ExecState* state) |
| 189 | { |
| 190 | return IDLOperation<JSAnimationEffect>::call<jsAnimationEffectPrototypeFunctionGetTimingBody>(*state, "getTiming" ); |
| 191 | } |
| 192 | |
| 193 | static inline JSC::EncodedJSValue jsAnimationEffectPrototypeFunctionGetComputedTimingBody(JSC::ExecState* state, typename IDLOperation<JSAnimationEffect>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 194 | { |
| 195 | UNUSED_PARAM(state); |
| 196 | UNUSED_PARAM(throwScope); |
| 197 | auto& impl = castedThis->wrapped(); |
| 198 | return JSValue::encode(toJS<IDLDictionary<ComputedEffectTiming>>(*state, *castedThis->globalObject(), impl.getComputedTiming())); |
| 199 | } |
| 200 | |
| 201 | EncodedJSValue JSC_HOST_CALL jsAnimationEffectPrototypeFunctionGetComputedTiming(ExecState* state) |
| 202 | { |
| 203 | return IDLOperation<JSAnimationEffect>::call<jsAnimationEffectPrototypeFunctionGetComputedTimingBody>(*state, "getComputedTiming" ); |
| 204 | } |
| 205 | |
| 206 | static inline JSC::EncodedJSValue jsAnimationEffectPrototypeFunctionUpdateTimingBody(JSC::ExecState* state, typename IDLOperation<JSAnimationEffect>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 207 | { |
| 208 | UNUSED_PARAM(state); |
| 209 | UNUSED_PARAM(throwScope); |
| 210 | auto& impl = castedThis->wrapped(); |
| 211 | auto timing = convert<IDLDictionary<OptionalEffectTiming>>(*state, state->argument(0)); |
| 212 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 213 | propagateException(*state, throwScope, impl.updateTiming(WTFMove(timing))); |
| 214 | return JSValue::encode(jsUndefined()); |
| 215 | } |
| 216 | |
| 217 | EncodedJSValue JSC_HOST_CALL jsAnimationEffectPrototypeFunctionUpdateTiming(ExecState* state) |
| 218 | { |
| 219 | return IDLOperation<JSAnimationEffect>::call<jsAnimationEffectPrototypeFunctionUpdateTimingBody>(*state, "updateTiming" ); |
| 220 | } |
| 221 | |
| 222 | void JSAnimationEffect::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 223 | { |
| 224 | auto* thisObject = jsCast<JSAnimationEffect*>(cell); |
| 225 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 226 | if (thisObject->scriptExecutionContext()) |
| 227 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 228 | Base::heapSnapshot(cell, builder); |
| 229 | } |
| 230 | |
| 231 | bool JSAnimationEffectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 232 | { |
| 233 | UNUSED_PARAM(handle); |
| 234 | UNUSED_PARAM(visitor); |
| 235 | UNUSED_PARAM(reason); |
| 236 | return false; |
| 237 | } |
| 238 | |
| 239 | void JSAnimationEffectOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 240 | { |
| 241 | auto* jsAnimationEffect = static_cast<JSAnimationEffect*>(handle.slot()->asCell()); |
| 242 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 243 | uncacheWrapper(world, &jsAnimationEffect->wrapped(), jsAnimationEffect); |
| 244 | } |
| 245 | |
| 246 | AnimationEffect* JSAnimationEffect::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 247 | { |
| 248 | if (auto* wrapper = jsDynamicCast<JSAnimationEffect*>(vm, value)) |
| 249 | return &wrapper->wrapped(); |
| 250 | return nullptr; |
| 251 | } |
| 252 | |
| 253 | } |
| 254 | |