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 "JSAnimationEvent.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 | |
41 | namespace WebCore { |
42 | using namespace JSC; |
43 | |
44 | template<> AnimationEvent::Init convertDictionary<AnimationEvent::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 | AnimationEvent::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.0; |
115 | return result; |
116 | } |
117 | |
118 | // Attributes |
119 | |
120 | JSC::EncodedJSValue jsAnimationEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
121 | bool setJSAnimationEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
122 | JSC::EncodedJSValue jsAnimationEventAnimationName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
123 | JSC::EncodedJSValue jsAnimationEventElapsedTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
124 | |
125 | class JSAnimationEventPrototype : public JSC::JSNonFinalObject { |
126 | public: |
127 | using Base = JSC::JSNonFinalObject; |
128 | static JSAnimationEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
129 | { |
130 | JSAnimationEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSAnimationEventPrototype>(vm.heap)) JSAnimationEventPrototype(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 | |
141 | private: |
142 | JSAnimationEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
143 | : JSC::JSNonFinalObject(vm, structure) |
144 | { |
145 | } |
146 | |
147 | void finishCreation(JSC::VM&); |
148 | }; |
149 | |
150 | using JSAnimationEventConstructor = JSDOMConstructor<JSAnimationEvent>; |
151 | |
152 | template<> EncodedJSValue JSC_HOST_CALL JSAnimationEventConstructor::construct(ExecState* state) |
153 | { |
154 | VM& vm = state->vm(); |
155 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
156 | UNUSED_PARAM(throwScope); |
157 | auto* castedThis = jsCast<JSAnimationEventConstructor*>(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 animationEventInitDict = convert<IDLDictionary<AnimationEvent::Init>>(*state, state->argument(1)); |
164 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
165 | auto object = AnimationEvent::create(WTFMove(type), WTFMove(animationEventInitDict)); |
166 | return JSValue::encode(toJSNewlyCreated<IDLInterface<AnimationEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
167 | } |
168 | |
169 | template<> JSValue JSAnimationEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
170 | { |
171 | return JSEvent::getConstructor(vm, &globalObject); |
172 | } |
173 | |
174 | template<> void JSAnimationEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
175 | { |
176 | putDirect(vm, vm.propertyNames->prototype, JSAnimationEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
177 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("AnimationEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
178 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
179 | } |
180 | |
181 | template<> const ClassInfo JSAnimationEventConstructor::s_info = { "AnimationEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAnimationEventConstructor) }; |
182 | |
183 | /* Hash table for prototype */ |
184 | |
185 | static const HashTableValue JSAnimationEventPrototypeTableValues[] = |
186 | { |
187 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAnimationEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAnimationEventConstructor) } }, |
188 | { "animationName" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAnimationEventAnimationName), (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>(jsAnimationEventElapsedTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
190 | }; |
191 | |
192 | const ClassInfo JSAnimationEventPrototype::s_info = { "AnimationEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAnimationEventPrototype) }; |
193 | |
194 | void JSAnimationEventPrototype::finishCreation(VM& vm) |
195 | { |
196 | Base::finishCreation(vm); |
197 | reifyStaticProperties(vm, JSAnimationEvent::info(), JSAnimationEventPrototypeTableValues, *this); |
198 | } |
199 | |
200 | const ClassInfo JSAnimationEvent::s_info = { "AnimationEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAnimationEvent) }; |
201 | |
202 | JSAnimationEvent::JSAnimationEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<AnimationEvent>&& impl) |
203 | : JSEvent(structure, globalObject, WTFMove(impl)) |
204 | { |
205 | } |
206 | |
207 | void JSAnimationEvent::finishCreation(VM& vm) |
208 | { |
209 | Base::finishCreation(vm); |
210 | ASSERT(inherits(vm, info())); |
211 | |
212 | } |
213 | |
214 | JSObject* JSAnimationEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
215 | { |
216 | return JSAnimationEventPrototype::create(vm, &globalObject, JSAnimationEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
217 | } |
218 | |
219 | JSObject* JSAnimationEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
220 | { |
221 | return getDOMPrototype<JSAnimationEvent>(vm, globalObject); |
222 | } |
223 | |
224 | JSValue JSAnimationEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
225 | { |
226 | return getDOMConstructor<JSAnimationEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
227 | } |
228 | |
229 | template<> inline JSAnimationEvent* IDLAttribute<JSAnimationEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
230 | { |
231 | return jsDynamicCast<JSAnimationEvent*>(state.vm(), JSValue::decode(thisValue)); |
232 | } |
233 | |
234 | EncodedJSValue jsAnimationEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
235 | { |
236 | VM& vm = state->vm(); |
237 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
238 | auto* prototype = jsDynamicCast<JSAnimationEventPrototype*>(vm, JSValue::decode(thisValue)); |
239 | if (UNLIKELY(!prototype)) |
240 | return throwVMTypeError(state, throwScope); |
241 | return JSValue::encode(JSAnimationEvent::getConstructor(state->vm(), prototype->globalObject())); |
242 | } |
243 | |
244 | bool setJSAnimationEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
245 | { |
246 | VM& vm = state->vm(); |
247 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
248 | auto* prototype = jsDynamicCast<JSAnimationEventPrototype*>(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 | |
257 | static inline JSValue jsAnimationEventAnimationNameGetter(ExecState& state, JSAnimationEvent& 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 | |
266 | EncodedJSValue jsAnimationEventAnimationName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
267 | { |
268 | return IDLAttribute<JSAnimationEvent>::get<jsAnimationEventAnimationNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "animationName" ); |
269 | } |
270 | |
271 | static inline JSValue jsAnimationEventElapsedTimeGetter(ExecState& state, JSAnimationEvent& 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 | |
280 | EncodedJSValue jsAnimationEventElapsedTime(ExecState* state, EncodedJSValue thisValue, PropertyName) |
281 | { |
282 | return IDLAttribute<JSAnimationEvent>::get<jsAnimationEventElapsedTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "elapsedTime" ); |
283 | } |
284 | |
285 | void JSAnimationEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
286 | { |
287 | auto* thisObject = jsCast<JSAnimationEvent*>(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) |
297 | extern "C" { extern void (*const __identifier("??_7AnimationEvent@WebCore@@6B@" )[])(); } |
298 | #else |
299 | extern "C" { extern void* _ZTVN7WebCore14AnimationEventE[]; } |
300 | #endif |
301 | #endif |
302 | |
303 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<AnimationEvent>&& 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("??_7AnimationEvent@WebCore@@6B@" )); |
310 | #else |
311 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore14AnimationEventE[2]); |
312 | #endif |
313 | |
314 | // If this fails AnimationEvent does not have a vtable, so you need to add the |
315 | // ImplementationLacksVTable attribute to the interface definition |
316 | static_assert(std::is_polymorphic<AnimationEvent>::value, "AnimationEvent is not polymorphic" ); |
317 | |
318 | // If you hit this assertion you either have a use after free bug, or |
319 | // AnimationEvent has subclasses. If AnimationEvent has subclasses that get passed |
320 | // to toJS() we currently require AnimationEvent 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<AnimationEvent>(globalObject, WTFMove(impl)); |
325 | } |
326 | |
327 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, AnimationEvent& impl) |
328 | { |
329 | return wrap(state, globalObject, impl); |
330 | } |
331 | |
332 | |
333 | } |
334 | |