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 "JSWebKitAnimationEvent.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructor.h"
27#include "JSDOMConvertBoolean.h"
28#include "JSDOMConvertInterface.h"
29#include "JSDOMConvertNumbers.h"
30#include "JSDOMConvertStrings.h"
31#include "JSDOMExceptionHandling.h"
32#include "JSDOMWrapperCache.h"
33#include "ScriptExecutionContext.h"
34#include <JavaScriptCore/HeapSnapshotBuilder.h>
35#include <JavaScriptCore/JSCInlines.h>
36#include <wtf/GetPtr.h>
37#include <wtf/PointerPreparations.h>
38#include <wtf/URL.h>
39
40
41namespace WebCore {
42using namespace JSC;
43
44template<> WebKitAnimationEvent::Init convertDictionary<WebKitAnimationEvent::Init>(ExecState& state, JSValue value)
45{
46 VM& vm = state.vm();
47 auto throwScope = DECLARE_THROW_SCOPE(vm);
48 bool isNullOrUndefined = value.isUndefinedOrNull();
49 auto* object = isNullOrUndefined ? nullptr : value.getObject();
50 if (UNLIKELY(!isNullOrUndefined && !object)) {
51 throwTypeError(&state, throwScope);
52 return { };
53 }
54 WebKitAnimationEvent::Init result;
55 JSValue bubblesValue;
56 if (isNullOrUndefined)
57 bubblesValue = jsUndefined();
58 else {
59 bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles"));
60 RETURN_IF_EXCEPTION(throwScope, { });
61 }
62 if (!bubblesValue.isUndefined()) {
63 result.bubbles = convert<IDLBoolean>(state, bubblesValue);
64 RETURN_IF_EXCEPTION(throwScope, { });
65 } else
66 result.bubbles = false;
67 JSValue cancelableValue;
68 if (isNullOrUndefined)
69 cancelableValue = jsUndefined();
70 else {
71 cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable"));
72 RETURN_IF_EXCEPTION(throwScope, { });
73 }
74 if (!cancelableValue.isUndefined()) {
75 result.cancelable = convert<IDLBoolean>(state, cancelableValue);
76 RETURN_IF_EXCEPTION(throwScope, { });
77 } else
78 result.cancelable = false;
79 JSValue composedValue;
80 if (isNullOrUndefined)
81 composedValue = jsUndefined();
82 else {
83 composedValue = object->get(&state, Identifier::fromString(&state, "composed"));
84 RETURN_IF_EXCEPTION(throwScope, { });
85 }
86 if (!composedValue.isUndefined()) {
87 result.composed = convert<IDLBoolean>(state, composedValue);
88 RETURN_IF_EXCEPTION(throwScope, { });
89 } else
90 result.composed = false;
91 JSValue animationNameValue;
92 if (isNullOrUndefined)
93 animationNameValue = jsUndefined();
94 else {
95 animationNameValue = object->get(&state, Identifier::fromString(&state, "animationName"));
96 RETURN_IF_EXCEPTION(throwScope, { });
97 }
98 if (!animationNameValue.isUndefined()) {
99 result.animationName = convert<IDLDOMString>(state, animationNameValue);
100 RETURN_IF_EXCEPTION(throwScope, { });
101 } else
102 result.animationName = emptyString();
103 JSValue elapsedTimeValue;
104 if (isNullOrUndefined)
105 elapsedTimeValue = jsUndefined();
106 else {
107 elapsedTimeValue = object->get(&state, Identifier::fromString(&state, "elapsedTime"));
108 RETURN_IF_EXCEPTION(throwScope, { });
109 }
110 if (!elapsedTimeValue.isUndefined()) {
111 result.elapsedTime = convert<IDLDouble>(state, elapsedTimeValue);
112 RETURN_IF_EXCEPTION(throwScope, { });
113 } else
114 result.elapsedTime = 0;
115 return result;
116}
117
118// Attributes
119
120JSC::EncodedJSValue jsWebKitAnimationEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
121bool setJSWebKitAnimationEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
122JSC::EncodedJSValue jsWebKitAnimationEventAnimationName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
123JSC::EncodedJSValue jsWebKitAnimationEventElapsedTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
124
125class JSWebKitAnimationEventPrototype : public JSC::JSNonFinalObject {
126public:
127 using Base = JSC::JSNonFinalObject;
128 static JSWebKitAnimationEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
129 {
130 JSWebKitAnimationEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebKitAnimationEventPrototype>(vm.heap)) JSWebKitAnimationEventPrototype(vm, globalObject, structure);
131 ptr->finishCreation(vm);
132 return ptr;
133 }
134
135 DECLARE_INFO;
136 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
137 {
138 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
139 }
140
141private:
142 JSWebKitAnimationEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
143 : JSC::JSNonFinalObject(vm, structure)
144 {
145 }
146
147 void finishCreation(JSC::VM&);
148};
149
150using JSWebKitAnimationEventConstructor = JSDOMConstructor<JSWebKitAnimationEvent>;
151
152template<> EncodedJSValue JSC_HOST_CALL JSWebKitAnimationEventConstructor::construct(ExecState* state)
153{
154 VM& vm = state->vm();
155 auto throwScope = DECLARE_THROW_SCOPE(vm);
156 UNUSED_PARAM(throwScope);
157 auto* castedThis = jsCast<JSWebKitAnimationEventConstructor*>(state->jsCallee());
158 ASSERT(castedThis);
159 if (UNLIKELY(state->argumentCount() < 1))
160 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
161 auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
162 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
163 auto eventInitDict = convert<IDLDictionary<WebKitAnimationEvent::Init>>(*state, state->argument(1));
164 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
165 auto object = WebKitAnimationEvent::create(WTFMove(type), WTFMove(eventInitDict));
166 return JSValue::encode(toJSNewlyCreated<IDLInterface<WebKitAnimationEvent>>(*state, *castedThis->globalObject(), WTFMove(object)));
167}
168
169template<> JSValue JSWebKitAnimationEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
170{
171 return JSEvent::getConstructor(vm, &globalObject);
172}
173
174template<> void JSWebKitAnimationEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
175{
176 putDirect(vm, vm.propertyNames->prototype, JSWebKitAnimationEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
177 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("WebKitAnimationEvent"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
178 putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
179}
180
181template<> const ClassInfo JSWebKitAnimationEventConstructor::s_info = { "WebKitAnimationEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebKitAnimationEventConstructor) };
182
183/* Hash table for prototype */
184
185static const HashTableValue JSWebKitAnimationEventPrototypeTableValues[] =
186{
187 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebKitAnimationEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebKitAnimationEventConstructor) } },
188 { "animationName", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebKitAnimationEventAnimationName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
189 { "elapsedTime", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebKitAnimationEventElapsedTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
190};
191
192const ClassInfo JSWebKitAnimationEventPrototype::s_info = { "WebKitAnimationEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebKitAnimationEventPrototype) };
193
194void JSWebKitAnimationEventPrototype::finishCreation(VM& vm)
195{
196 Base::finishCreation(vm);
197 reifyStaticProperties(vm, JSWebKitAnimationEvent::info(), JSWebKitAnimationEventPrototypeTableValues, *this);
198}
199
200const ClassInfo JSWebKitAnimationEvent::s_info = { "WebKitAnimationEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebKitAnimationEvent) };
201
202JSWebKitAnimationEvent::JSWebKitAnimationEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebKitAnimationEvent>&& impl)
203 : JSEvent(structure, globalObject, WTFMove(impl))
204{
205}
206
207void JSWebKitAnimationEvent::finishCreation(VM& vm)
208{
209 Base::finishCreation(vm);
210 ASSERT(inherits(vm, info()));
211
212}
213
214JSObject* JSWebKitAnimationEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
215{
216 return JSWebKitAnimationEventPrototype::create(vm, &globalObject, JSWebKitAnimationEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject)));
217}
218
219JSObject* JSWebKitAnimationEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
220{
221 return getDOMPrototype<JSWebKitAnimationEvent>(vm, globalObject);
222}
223
224JSValue JSWebKitAnimationEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
225{
226 return getDOMConstructor<JSWebKitAnimationEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
227}
228
229template<> inline JSWebKitAnimationEvent* IDLAttribute<JSWebKitAnimationEvent>::cast(ExecState& state, EncodedJSValue thisValue)
230{
231 return jsDynamicCast<JSWebKitAnimationEvent*>(state.vm(), JSValue::decode(thisValue));
232}
233
234EncodedJSValue jsWebKitAnimationEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
235{
236 VM& vm = state->vm();
237 auto throwScope = DECLARE_THROW_SCOPE(vm);
238 auto* prototype = jsDynamicCast<JSWebKitAnimationEventPrototype*>(vm, JSValue::decode(thisValue));
239 if (UNLIKELY(!prototype))
240 return throwVMTypeError(state, throwScope);
241 return JSValue::encode(JSWebKitAnimationEvent::getConstructor(state->vm(), prototype->globalObject()));
242}
243
244bool setJSWebKitAnimationEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
245{
246 VM& vm = state->vm();
247 auto throwScope = DECLARE_THROW_SCOPE(vm);
248 auto* prototype = jsDynamicCast<JSWebKitAnimationEventPrototype*>(vm, JSValue::decode(thisValue));
249 if (UNLIKELY(!prototype)) {
250 throwVMTypeError(state, throwScope);
251 return false;
252 }
253 // Shadowing a built-in constructor
254 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
255}
256
257static inline JSValue jsWebKitAnimationEventAnimationNameGetter(ExecState& state, JSWebKitAnimationEvent& thisObject, ThrowScope& throwScope)
258{
259 UNUSED_PARAM(throwScope);
260 UNUSED_PARAM(state);
261 auto& impl = thisObject.wrapped();
262 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.animationName());
263 return result;
264}
265
266EncodedJSValue jsWebKitAnimationEventAnimationName(ExecState* state, EncodedJSValue thisValue, PropertyName)
267{
268 return IDLAttribute<JSWebKitAnimationEvent>::get<jsWebKitAnimationEventAnimationNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "animationName");
269}
270
271static inline JSValue jsWebKitAnimationEventElapsedTimeGetter(ExecState& state, JSWebKitAnimationEvent& thisObject, ThrowScope& throwScope)
272{
273 UNUSED_PARAM(throwScope);
274 UNUSED_PARAM(state);
275 auto& impl = thisObject.wrapped();
276 JSValue result = toJS<IDLDouble>(state, throwScope, impl.elapsedTime());
277 return result;
278}
279
280EncodedJSValue jsWebKitAnimationEventElapsedTime(ExecState* state, EncodedJSValue thisValue, PropertyName)
281{
282 return IDLAttribute<JSWebKitAnimationEvent>::get<jsWebKitAnimationEventElapsedTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "elapsedTime");
283}
284
285void JSWebKitAnimationEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
286{
287 auto* thisObject = jsCast<JSWebKitAnimationEvent*>(cell);
288 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
289 if (thisObject->scriptExecutionContext())
290 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
291 Base::heapSnapshot(cell, builder);
292}
293
294#if ENABLE(BINDING_INTEGRITY)
295#if PLATFORM(WIN)
296#pragma warning(disable: 4483)
297extern "C" { extern void (*const __identifier("??_7WebKitAnimationEvent@WebCore@@6B@")[])(); }
298#else
299extern "C" { extern void* _ZTVN7WebCore20WebKitAnimationEventE[]; }
300#endif
301#endif
302
303JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebKitAnimationEvent>&& impl)
304{
305
306#if ENABLE(BINDING_INTEGRITY)
307 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
308#if PLATFORM(WIN)
309 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7WebKitAnimationEvent@WebCore@@6B@"));
310#else
311 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore20WebKitAnimationEventE[2]);
312#endif
313
314 // If this fails WebKitAnimationEvent does not have a vtable, so you need to add the
315 // ImplementationLacksVTable attribute to the interface definition
316 static_assert(std::is_polymorphic<WebKitAnimationEvent>::value, "WebKitAnimationEvent is not polymorphic");
317
318 // If you hit this assertion you either have a use after free bug, or
319 // WebKitAnimationEvent has subclasses. If WebKitAnimationEvent has subclasses that get passed
320 // to toJS() we currently require WebKitAnimationEvent you to opt out of binding hardening
321 // by adding the SkipVTableValidation attribute to the interface IDL definition
322 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
323#endif
324 return createWrapper<WebKitAnimationEvent>(globalObject, WTFMove(impl));
325}
326
327JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebKitAnimationEvent& impl)
328{
329 return wrap(state, globalObject, impl);
330}
331
332
333}
334