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 "JSKeyframeEffect.h" |
23 | |
24 | #include "JSCompositeOperation.h" |
25 | #include "JSCompositeOperationOrAuto.h" |
26 | #include "JSDOMAttribute.h" |
27 | #include "JSDOMBinding.h" |
28 | #include "JSDOMConstructor.h" |
29 | #include "JSDOMConvertEnumeration.h" |
30 | #include "JSDOMConvertInterface.h" |
31 | #include "JSDOMConvertNullable.h" |
32 | #include "JSDOMConvertNumbers.h" |
33 | #include "JSDOMConvertObject.h" |
34 | #include "JSDOMConvertSequences.h" |
35 | #include "JSDOMConvertStrings.h" |
36 | #include "JSDOMConvertUnion.h" |
37 | #include "JSDOMExceptionHandling.h" |
38 | #include "JSDOMGlobalObject.h" |
39 | #include "JSDOMOperation.h" |
40 | #include "JSDOMWrapperCache.h" |
41 | #include "JSElement.h" |
42 | #include "JSIterationCompositeOperation.h" |
43 | #include "JSKeyframeEffect.h" |
44 | #include "JSKeyframeEffectOptions.h" |
45 | #include "ScriptExecutionContext.h" |
46 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
47 | #include <JavaScriptCore/JSArray.h> |
48 | #include <JavaScriptCore/JSCInlines.h> |
49 | #include <JavaScriptCore/ObjectConstructor.h> |
50 | #include <wtf/GetPtr.h> |
51 | #include <wtf/PointerPreparations.h> |
52 | #include <wtf/URL.h> |
53 | #include <wtf/Variant.h> |
54 | |
55 | |
56 | namespace WebCore { |
57 | using namespace JSC; |
58 | |
59 | template<> KeyframeEffect::BasePropertyIndexedKeyframe convertDictionary<KeyframeEffect::BasePropertyIndexedKeyframe>(ExecState& state, JSValue value) |
60 | { |
61 | VM& vm = state.vm(); |
62 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
63 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
64 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
65 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
66 | throwTypeError(&state, throwScope); |
67 | return { }; |
68 | } |
69 | KeyframeEffect::BasePropertyIndexedKeyframe result; |
70 | JSValue compositeValue; |
71 | if (isNullOrUndefined) |
72 | compositeValue = jsUndefined(); |
73 | else { |
74 | compositeValue = object->get(&state, Identifier::fromString(&state, "composite" )); |
75 | RETURN_IF_EXCEPTION(throwScope, { }); |
76 | } |
77 | if (!compositeValue.isUndefined()) { |
78 | result.composite = convert<IDLUnion<IDLSequence<IDLEnumeration<CompositeOperationOrAuto>>, IDLEnumeration<CompositeOperationOrAuto>>>(state, compositeValue); |
79 | RETURN_IF_EXCEPTION(throwScope, { }); |
80 | } else |
81 | result.composite = Converter<IDLUnion<IDLSequence<IDLEnumeration<CompositeOperationOrAuto>>, IDLEnumeration<CompositeOperationOrAuto>>>::ReturnType{ }; |
82 | JSValue easingValue; |
83 | if (isNullOrUndefined) |
84 | easingValue = jsUndefined(); |
85 | else { |
86 | easingValue = object->get(&state, Identifier::fromString(&state, "easing" )); |
87 | RETURN_IF_EXCEPTION(throwScope, { }); |
88 | } |
89 | if (!easingValue.isUndefined()) { |
90 | result.easing = convert<IDLUnion<IDLSequence<IDLDOMString>, IDLDOMString>>(state, easingValue); |
91 | RETURN_IF_EXCEPTION(throwScope, { }); |
92 | } else |
93 | result.easing = Converter<IDLUnion<IDLSequence<IDLDOMString>, IDLDOMString>>::ReturnType{ }; |
94 | JSValue offsetValue; |
95 | if (isNullOrUndefined) |
96 | offsetValue = jsUndefined(); |
97 | else { |
98 | offsetValue = object->get(&state, Identifier::fromString(&state, "offset" )); |
99 | RETURN_IF_EXCEPTION(throwScope, { }); |
100 | } |
101 | if (!offsetValue.isUndefined()) { |
102 | result.offset = convert<IDLUnion<IDLNull, IDLSequence<IDLNullable<IDLDouble>>, IDLDouble>>(state, offsetValue); |
103 | RETURN_IF_EXCEPTION(throwScope, { }); |
104 | } else |
105 | result.offset = Converter<IDLUnion<IDLNull, IDLSequence<IDLNullable<IDLDouble>>, IDLDouble>>::ReturnType{ }; |
106 | return result; |
107 | } |
108 | |
109 | template<> KeyframeEffect::BaseKeyframe convertDictionary<KeyframeEffect::BaseKeyframe>(ExecState& state, JSValue value) |
110 | { |
111 | VM& vm = state.vm(); |
112 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
113 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
114 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
115 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
116 | throwTypeError(&state, throwScope); |
117 | return { }; |
118 | } |
119 | KeyframeEffect::BaseKeyframe result; |
120 | JSValue compositeValue; |
121 | if (isNullOrUndefined) |
122 | compositeValue = jsUndefined(); |
123 | else { |
124 | compositeValue = object->get(&state, Identifier::fromString(&state, "composite" )); |
125 | RETURN_IF_EXCEPTION(throwScope, { }); |
126 | } |
127 | if (!compositeValue.isUndefined()) { |
128 | result.composite = convert<IDLEnumeration<CompositeOperationOrAuto>>(state, compositeValue); |
129 | RETURN_IF_EXCEPTION(throwScope, { }); |
130 | } else |
131 | result.composite = CompositeOperationOrAuto::Auto; |
132 | JSValue easingValue; |
133 | if (isNullOrUndefined) |
134 | easingValue = jsUndefined(); |
135 | else { |
136 | easingValue = object->get(&state, Identifier::fromString(&state, "easing" )); |
137 | RETURN_IF_EXCEPTION(throwScope, { }); |
138 | } |
139 | if (!easingValue.isUndefined()) { |
140 | result.easing = convert<IDLDOMString>(state, easingValue); |
141 | RETURN_IF_EXCEPTION(throwScope, { }); |
142 | } else |
143 | result.easing = "linear"_s ; |
144 | JSValue offsetValue; |
145 | if (isNullOrUndefined) |
146 | offsetValue = jsUndefined(); |
147 | else { |
148 | offsetValue = object->get(&state, Identifier::fromString(&state, "offset" )); |
149 | RETURN_IF_EXCEPTION(throwScope, { }); |
150 | } |
151 | if (!offsetValue.isUndefined()) { |
152 | result.offset = convert<IDLNullable<IDLDouble>>(state, offsetValue); |
153 | RETURN_IF_EXCEPTION(throwScope, { }); |
154 | } else |
155 | result.offset = WTF::nullopt; |
156 | return result; |
157 | } |
158 | |
159 | template<> KeyframeEffect::BaseComputedKeyframe convertDictionary<KeyframeEffect::BaseComputedKeyframe>(ExecState& state, JSValue value) |
160 | { |
161 | VM& vm = state.vm(); |
162 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
163 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
164 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
165 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
166 | throwTypeError(&state, throwScope); |
167 | return { }; |
168 | } |
169 | KeyframeEffect::BaseComputedKeyframe result; |
170 | JSValue compositeValue; |
171 | if (isNullOrUndefined) |
172 | compositeValue = jsUndefined(); |
173 | else { |
174 | compositeValue = object->get(&state, Identifier::fromString(&state, "composite" )); |
175 | RETURN_IF_EXCEPTION(throwScope, { }); |
176 | } |
177 | if (!compositeValue.isUndefined()) { |
178 | result.composite = convert<IDLEnumeration<CompositeOperationOrAuto>>(state, compositeValue); |
179 | RETURN_IF_EXCEPTION(throwScope, { }); |
180 | } else |
181 | result.composite = CompositeOperationOrAuto::Auto; |
182 | JSValue computedOffsetValue; |
183 | if (isNullOrUndefined) |
184 | computedOffsetValue = jsUndefined(); |
185 | else { |
186 | computedOffsetValue = object->get(&state, Identifier::fromString(&state, "computedOffset" )); |
187 | RETURN_IF_EXCEPTION(throwScope, { }); |
188 | } |
189 | if (!computedOffsetValue.isUndefined()) { |
190 | result.computedOffset = convert<IDLDouble>(state, computedOffsetValue); |
191 | RETURN_IF_EXCEPTION(throwScope, { }); |
192 | } |
193 | JSValue easingValue; |
194 | if (isNullOrUndefined) |
195 | easingValue = jsUndefined(); |
196 | else { |
197 | easingValue = object->get(&state, Identifier::fromString(&state, "easing" )); |
198 | RETURN_IF_EXCEPTION(throwScope, { }); |
199 | } |
200 | if (!easingValue.isUndefined()) { |
201 | result.easing = convert<IDLDOMString>(state, easingValue); |
202 | RETURN_IF_EXCEPTION(throwScope, { }); |
203 | } else |
204 | result.easing = "linear"_s ; |
205 | JSValue offsetValue; |
206 | if (isNullOrUndefined) |
207 | offsetValue = jsUndefined(); |
208 | else { |
209 | offsetValue = object->get(&state, Identifier::fromString(&state, "offset" )); |
210 | RETURN_IF_EXCEPTION(throwScope, { }); |
211 | } |
212 | if (!offsetValue.isUndefined()) { |
213 | result.offset = convert<IDLNullable<IDLDouble>>(state, offsetValue); |
214 | RETURN_IF_EXCEPTION(throwScope, { }); |
215 | } else |
216 | result.offset = WTF::nullopt; |
217 | return result; |
218 | } |
219 | |
220 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const KeyframeEffect::BaseComputedKeyframe& dictionary) |
221 | { |
222 | auto& vm = state.vm(); |
223 | |
224 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
225 | |
226 | auto compositeValue = toJS<IDLEnumeration<CompositeOperationOrAuto>>(state, dictionary.composite); |
227 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "composite" ), compositeValue); |
228 | if (!IDLDouble::isNullValue(dictionary.computedOffset)) { |
229 | auto computedOffsetValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.computedOffset)); |
230 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "computedOffset" ), computedOffsetValue); |
231 | } |
232 | auto easingValue = toJS<IDLDOMString>(state, dictionary.easing); |
233 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "easing" ), easingValue); |
234 | auto offsetValue = toJS<IDLNullable<IDLDouble>>(dictionary.offset); |
235 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "offset" ), offsetValue); |
236 | return result; |
237 | } |
238 | |
239 | // Functions |
240 | |
241 | JSC::EncodedJSValue JSC_HOST_CALL jsKeyframeEffectPrototypeFunctionGetKeyframes(JSC::ExecState*); |
242 | JSC::EncodedJSValue JSC_HOST_CALL jsKeyframeEffectPrototypeFunctionSetKeyframes(JSC::ExecState*); |
243 | |
244 | // Attributes |
245 | |
246 | JSC::EncodedJSValue jsKeyframeEffectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
247 | bool setJSKeyframeEffectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
248 | JSC::EncodedJSValue jsKeyframeEffectTarget(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
249 | bool setJSKeyframeEffectTarget(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
250 | JSC::EncodedJSValue jsKeyframeEffectIterationComposite(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
251 | bool setJSKeyframeEffectIterationComposite(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
252 | JSC::EncodedJSValue jsKeyframeEffectComposite(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
253 | bool setJSKeyframeEffectComposite(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
254 | |
255 | class JSKeyframeEffectPrototype : public JSC::JSNonFinalObject { |
256 | public: |
257 | using Base = JSC::JSNonFinalObject; |
258 | static JSKeyframeEffectPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
259 | { |
260 | JSKeyframeEffectPrototype* ptr = new (NotNull, JSC::allocateCell<JSKeyframeEffectPrototype>(vm.heap)) JSKeyframeEffectPrototype(vm, globalObject, structure); |
261 | ptr->finishCreation(vm); |
262 | return ptr; |
263 | } |
264 | |
265 | DECLARE_INFO; |
266 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
267 | { |
268 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
269 | } |
270 | |
271 | private: |
272 | JSKeyframeEffectPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
273 | : JSC::JSNonFinalObject(vm, structure) |
274 | { |
275 | } |
276 | |
277 | void finishCreation(JSC::VM&); |
278 | }; |
279 | |
280 | using JSKeyframeEffectConstructor = JSDOMConstructor<JSKeyframeEffect>; |
281 | |
282 | static inline EncodedJSValue constructJSKeyframeEffect1(ExecState* state) |
283 | { |
284 | VM& vm = state->vm(); |
285 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
286 | UNUSED_PARAM(throwScope); |
287 | auto* castedThis = jsCast<JSKeyframeEffectConstructor*>(state->jsCallee()); |
288 | ASSERT(castedThis); |
289 | auto target = convert<IDLNullable<IDLInterface<Element>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "target" , "KeyframeEffect" , nullptr, "Element" ); }); |
290 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
291 | auto keyframes = convert<IDLNullable<IDLObject>>(*state, state->uncheckedArgument(1)); |
292 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
293 | auto options = state->argument(2).isUndefined() ? Optional<Converter<IDLUnion<IDLUnrestrictedDouble, IDLDictionary<KeyframeEffectOptions>>>::ReturnType>() : Optional<Converter<IDLUnion<IDLUnrestrictedDouble, IDLDictionary<KeyframeEffectOptions>>>::ReturnType>(convert<IDLUnion<IDLUnrestrictedDouble, IDLDictionary<KeyframeEffectOptions>>>(*state, state->uncheckedArgument(2))); |
294 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
295 | auto object = KeyframeEffect::create(*state, WTFMove(target), WTFMove(keyframes), WTFMove(options)); |
296 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
297 | return JSValue::encode(toJSNewlyCreated<IDLInterface<KeyframeEffect>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object))); |
298 | } |
299 | |
300 | static inline EncodedJSValue constructJSKeyframeEffect2(ExecState* state) |
301 | { |
302 | VM& vm = state->vm(); |
303 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
304 | UNUSED_PARAM(throwScope); |
305 | auto* castedThis = jsCast<JSKeyframeEffectConstructor*>(state->jsCallee()); |
306 | ASSERT(castedThis); |
307 | auto source = convert<IDLInterface<KeyframeEffect>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "source" , "KeyframeEffect" , nullptr, "KeyframeEffect" ); }); |
308 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
309 | auto object = KeyframeEffect::create(*state, *source); |
310 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
311 | return JSValue::encode(toJSNewlyCreated<IDLInterface<KeyframeEffect>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object))); |
312 | } |
313 | |
314 | template<> EncodedJSValue JSC_HOST_CALL JSKeyframeEffectConstructor::construct(ExecState* state) |
315 | { |
316 | VM& vm = state->vm(); |
317 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
318 | UNUSED_PARAM(throwScope); |
319 | size_t argsCount = std::min<size_t>(3, state->argumentCount()); |
320 | if (argsCount == 1) { |
321 | return constructJSKeyframeEffect2(state); |
322 | } |
323 | if (argsCount == 2) { |
324 | return constructJSKeyframeEffect1(state); |
325 | } |
326 | if (argsCount == 3) { |
327 | return constructJSKeyframeEffect1(state); |
328 | } |
329 | return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope); |
330 | } |
331 | |
332 | template<> JSValue JSKeyframeEffectConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
333 | { |
334 | return JSAnimationEffect::getConstructor(vm, &globalObject); |
335 | } |
336 | |
337 | template<> void JSKeyframeEffectConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
338 | { |
339 | putDirect(vm, vm.propertyNames->prototype, JSKeyframeEffect::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
340 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("KeyframeEffect"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
341 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
342 | } |
343 | |
344 | template<> const ClassInfo JSKeyframeEffectConstructor::s_info = { "KeyframeEffect" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSKeyframeEffectConstructor) }; |
345 | |
346 | /* Hash table for prototype */ |
347 | |
348 | static const HashTableValue JSKeyframeEffectPrototypeTableValues[] = |
349 | { |
350 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsKeyframeEffectConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSKeyframeEffectConstructor) } }, |
351 | { "target" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsKeyframeEffectTarget), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSKeyframeEffectTarget) } }, |
352 | { "iterationComposite" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsKeyframeEffectIterationComposite), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSKeyframeEffectIterationComposite) } }, |
353 | { "composite" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsKeyframeEffectComposite), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSKeyframeEffectComposite) } }, |
354 | { "getKeyframes" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsKeyframeEffectPrototypeFunctionGetKeyframes), (intptr_t) (0) } }, |
355 | { "setKeyframes" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsKeyframeEffectPrototypeFunctionSetKeyframes), (intptr_t) (1) } }, |
356 | }; |
357 | |
358 | const ClassInfo JSKeyframeEffectPrototype::s_info = { "KeyframeEffectPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSKeyframeEffectPrototype) }; |
359 | |
360 | void JSKeyframeEffectPrototype::finishCreation(VM& vm) |
361 | { |
362 | Base::finishCreation(vm); |
363 | reifyStaticProperties(vm, JSKeyframeEffect::info(), JSKeyframeEffectPrototypeTableValues, *this); |
364 | } |
365 | |
366 | const ClassInfo JSKeyframeEffect::s_info = { "KeyframeEffect" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSKeyframeEffect) }; |
367 | |
368 | JSKeyframeEffect::JSKeyframeEffect(Structure* structure, JSDOMGlobalObject& globalObject, Ref<KeyframeEffect>&& impl) |
369 | : JSAnimationEffect(structure, globalObject, WTFMove(impl)) |
370 | { |
371 | } |
372 | |
373 | void JSKeyframeEffect::finishCreation(VM& vm) |
374 | { |
375 | Base::finishCreation(vm); |
376 | ASSERT(inherits(vm, info())); |
377 | |
378 | } |
379 | |
380 | JSObject* JSKeyframeEffect::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
381 | { |
382 | return JSKeyframeEffectPrototype::create(vm, &globalObject, JSKeyframeEffectPrototype::createStructure(vm, &globalObject, JSAnimationEffect::prototype(vm, globalObject))); |
383 | } |
384 | |
385 | JSObject* JSKeyframeEffect::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
386 | { |
387 | return getDOMPrototype<JSKeyframeEffect>(vm, globalObject); |
388 | } |
389 | |
390 | JSValue JSKeyframeEffect::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
391 | { |
392 | return getDOMConstructor<JSKeyframeEffectConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
393 | } |
394 | |
395 | template<> inline JSKeyframeEffect* IDLAttribute<JSKeyframeEffect>::cast(ExecState& state, EncodedJSValue thisValue) |
396 | { |
397 | return jsDynamicCast<JSKeyframeEffect*>(state.vm(), JSValue::decode(thisValue)); |
398 | } |
399 | |
400 | template<> inline JSKeyframeEffect* IDLOperation<JSKeyframeEffect>::cast(ExecState& state) |
401 | { |
402 | return jsDynamicCast<JSKeyframeEffect*>(state.vm(), state.thisValue()); |
403 | } |
404 | |
405 | EncodedJSValue jsKeyframeEffectConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
406 | { |
407 | VM& vm = state->vm(); |
408 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
409 | auto* prototype = jsDynamicCast<JSKeyframeEffectPrototype*>(vm, JSValue::decode(thisValue)); |
410 | if (UNLIKELY(!prototype)) |
411 | return throwVMTypeError(state, throwScope); |
412 | return JSValue::encode(JSKeyframeEffect::getConstructor(state->vm(), prototype->globalObject())); |
413 | } |
414 | |
415 | bool setJSKeyframeEffectConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
416 | { |
417 | VM& vm = state->vm(); |
418 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
419 | auto* prototype = jsDynamicCast<JSKeyframeEffectPrototype*>(vm, JSValue::decode(thisValue)); |
420 | if (UNLIKELY(!prototype)) { |
421 | throwVMTypeError(state, throwScope); |
422 | return false; |
423 | } |
424 | // Shadowing a built-in constructor |
425 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
426 | } |
427 | |
428 | static inline JSValue jsKeyframeEffectTargetGetter(ExecState& state, JSKeyframeEffect& thisObject, ThrowScope& throwScope) |
429 | { |
430 | UNUSED_PARAM(throwScope); |
431 | UNUSED_PARAM(state); |
432 | auto& impl = thisObject.wrapped(); |
433 | JSValue result = toJS<IDLNullable<IDLInterface<Element>>>(state, *thisObject.globalObject(), throwScope, impl.target()); |
434 | return result; |
435 | } |
436 | |
437 | EncodedJSValue jsKeyframeEffectTarget(ExecState* state, EncodedJSValue thisValue, PropertyName) |
438 | { |
439 | return IDLAttribute<JSKeyframeEffect>::get<jsKeyframeEffectTargetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "target" ); |
440 | } |
441 | |
442 | static inline bool setJSKeyframeEffectTargetSetter(ExecState& state, JSKeyframeEffect& thisObject, JSValue value, ThrowScope& throwScope) |
443 | { |
444 | UNUSED_PARAM(throwScope); |
445 | auto& impl = thisObject.wrapped(); |
446 | auto nativeValue = convert<IDLNullable<IDLInterface<Element>>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "KeyframeEffect" , "target" , "Element" ); }); |
447 | RETURN_IF_EXCEPTION(throwScope, false); |
448 | AttributeSetter::call(state, throwScope, [&] { |
449 | return impl.setTarget(WTFMove(nativeValue)); |
450 | }); |
451 | return true; |
452 | } |
453 | |
454 | bool setJSKeyframeEffectTarget(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
455 | { |
456 | return IDLAttribute<JSKeyframeEffect>::set<setJSKeyframeEffectTargetSetter>(*state, thisValue, encodedValue, "target" ); |
457 | } |
458 | |
459 | static inline JSValue jsKeyframeEffectIterationCompositeGetter(ExecState& state, JSKeyframeEffect& thisObject, ThrowScope& throwScope) |
460 | { |
461 | UNUSED_PARAM(throwScope); |
462 | UNUSED_PARAM(state); |
463 | auto& impl = thisObject.wrapped(); |
464 | JSValue result = toJS<IDLEnumeration<IterationCompositeOperation>>(state, throwScope, impl.iterationComposite()); |
465 | return result; |
466 | } |
467 | |
468 | EncodedJSValue jsKeyframeEffectIterationComposite(ExecState* state, EncodedJSValue thisValue, PropertyName) |
469 | { |
470 | return IDLAttribute<JSKeyframeEffect>::get<jsKeyframeEffectIterationCompositeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "iterationComposite" ); |
471 | } |
472 | |
473 | static inline bool setJSKeyframeEffectIterationCompositeSetter(ExecState& state, JSKeyframeEffect& thisObject, JSValue value, ThrowScope& throwScope) |
474 | { |
475 | UNUSED_PARAM(throwScope); |
476 | auto& impl = thisObject.wrapped(); |
477 | auto optionalNativeValue = parseEnumeration<IterationCompositeOperation>(state, value); |
478 | RETURN_IF_EXCEPTION(throwScope, false); |
479 | if (UNLIKELY(!optionalNativeValue)) |
480 | return false; |
481 | auto nativeValue = optionalNativeValue.value(); |
482 | AttributeSetter::call(state, throwScope, [&] { |
483 | return impl.setIterationComposite(WTFMove(nativeValue)); |
484 | }); |
485 | return true; |
486 | } |
487 | |
488 | bool setJSKeyframeEffectIterationComposite(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
489 | { |
490 | return IDLAttribute<JSKeyframeEffect>::set<setJSKeyframeEffectIterationCompositeSetter>(*state, thisValue, encodedValue, "iterationComposite" ); |
491 | } |
492 | |
493 | static inline JSValue jsKeyframeEffectCompositeGetter(ExecState& state, JSKeyframeEffect& thisObject, ThrowScope& throwScope) |
494 | { |
495 | UNUSED_PARAM(throwScope); |
496 | UNUSED_PARAM(state); |
497 | auto& impl = thisObject.wrapped(); |
498 | JSValue result = toJS<IDLEnumeration<CompositeOperation>>(state, throwScope, impl.composite()); |
499 | return result; |
500 | } |
501 | |
502 | EncodedJSValue jsKeyframeEffectComposite(ExecState* state, EncodedJSValue thisValue, PropertyName) |
503 | { |
504 | return IDLAttribute<JSKeyframeEffect>::get<jsKeyframeEffectCompositeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "composite" ); |
505 | } |
506 | |
507 | static inline bool setJSKeyframeEffectCompositeSetter(ExecState& state, JSKeyframeEffect& thisObject, JSValue value, ThrowScope& throwScope) |
508 | { |
509 | UNUSED_PARAM(throwScope); |
510 | auto& impl = thisObject.wrapped(); |
511 | auto optionalNativeValue = parseEnumeration<CompositeOperation>(state, value); |
512 | RETURN_IF_EXCEPTION(throwScope, false); |
513 | if (UNLIKELY(!optionalNativeValue)) |
514 | return false; |
515 | auto nativeValue = optionalNativeValue.value(); |
516 | AttributeSetter::call(state, throwScope, [&] { |
517 | return impl.setComposite(WTFMove(nativeValue)); |
518 | }); |
519 | return true; |
520 | } |
521 | |
522 | bool setJSKeyframeEffectComposite(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
523 | { |
524 | return IDLAttribute<JSKeyframeEffect>::set<setJSKeyframeEffectCompositeSetter>(*state, thisValue, encodedValue, "composite" ); |
525 | } |
526 | |
527 | static inline JSC::EncodedJSValue jsKeyframeEffectPrototypeFunctionGetKeyframesBody(JSC::ExecState* state, typename IDLOperation<JSKeyframeEffect>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
528 | { |
529 | UNUSED_PARAM(state); |
530 | UNUSED_PARAM(throwScope); |
531 | auto& impl = castedThis->wrapped(); |
532 | return JSValue::encode(toJS<IDLSequence<IDLObject>>(*state, *castedThis->globalObject(), impl.getKeyframes(*state))); |
533 | } |
534 | |
535 | EncodedJSValue JSC_HOST_CALL jsKeyframeEffectPrototypeFunctionGetKeyframes(ExecState* state) |
536 | { |
537 | return IDLOperation<JSKeyframeEffect>::call<jsKeyframeEffectPrototypeFunctionGetKeyframesBody>(*state, "getKeyframes" ); |
538 | } |
539 | |
540 | static inline JSC::EncodedJSValue jsKeyframeEffectPrototypeFunctionSetKeyframesBody(JSC::ExecState* state, typename IDLOperation<JSKeyframeEffect>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
541 | { |
542 | UNUSED_PARAM(state); |
543 | UNUSED_PARAM(throwScope); |
544 | auto& impl = castedThis->wrapped(); |
545 | if (UNLIKELY(state->argumentCount() < 1)) |
546 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
547 | auto keyframes = convert<IDLNullable<IDLObject>>(*state, state->uncheckedArgument(0)); |
548 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
549 | propagateException(*state, throwScope, impl.setKeyframes(*state, WTFMove(keyframes))); |
550 | return JSValue::encode(jsUndefined()); |
551 | } |
552 | |
553 | EncodedJSValue JSC_HOST_CALL jsKeyframeEffectPrototypeFunctionSetKeyframes(ExecState* state) |
554 | { |
555 | return IDLOperation<JSKeyframeEffect>::call<jsKeyframeEffectPrototypeFunctionSetKeyframesBody>(*state, "setKeyframes" ); |
556 | } |
557 | |
558 | void JSKeyframeEffect::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
559 | { |
560 | auto* thisObject = jsCast<JSKeyframeEffect*>(cell); |
561 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
562 | if (thisObject->scriptExecutionContext()) |
563 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
564 | Base::heapSnapshot(cell, builder); |
565 | } |
566 | |
567 | #if ENABLE(BINDING_INTEGRITY) |
568 | #if PLATFORM(WIN) |
569 | #pragma warning(disable: 4483) |
570 | extern "C" { extern void (*const __identifier("??_7KeyframeEffect@WebCore@@6B@" )[])(); } |
571 | #else |
572 | extern "C" { extern void* _ZTVN7WebCore14KeyframeEffectE[]; } |
573 | #endif |
574 | #endif |
575 | |
576 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<KeyframeEffect>&& impl) |
577 | { |
578 | |
579 | #if ENABLE(BINDING_INTEGRITY) |
580 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
581 | #if PLATFORM(WIN) |
582 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7KeyframeEffect@WebCore@@6B@" )); |
583 | #else |
584 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore14KeyframeEffectE[2]); |
585 | #endif |
586 | |
587 | // If this fails KeyframeEffect does not have a vtable, so you need to add the |
588 | // ImplementationLacksVTable attribute to the interface definition |
589 | static_assert(std::is_polymorphic<KeyframeEffect>::value, "KeyframeEffect is not polymorphic" ); |
590 | |
591 | // If you hit this assertion you either have a use after free bug, or |
592 | // KeyframeEffect has subclasses. If KeyframeEffect has subclasses that get passed |
593 | // to toJS() we currently require KeyframeEffect you to opt out of binding hardening |
594 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
595 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
596 | #endif |
597 | return createWrapper<KeyframeEffect>(globalObject, WTFMove(impl)); |
598 | } |
599 | |
600 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, KeyframeEffect& impl) |
601 | { |
602 | return wrap(state, globalObject, impl); |
603 | } |
604 | |
605 | KeyframeEffect* JSKeyframeEffect::toWrapped(JSC::VM& vm, JSC::JSValue value) |
606 | { |
607 | if (auto* wrapper = jsDynamicCast<JSKeyframeEffect*>(vm, value)) |
608 | return &wrapper->wrapped(); |
609 | return nullptr; |
610 | } |
611 | |
612 | } |
613 | |