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 "JSTransitionEvent.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<> TransitionEvent::Init convertDictionary<TransitionEvent::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 | TransitionEvent::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 elapsedTimeValue; |
92 | if (isNullOrUndefined) |
93 | elapsedTimeValue = jsUndefined(); |
94 | else { |
95 | elapsedTimeValue = object->get(&state, Identifier::fromString(&state, "elapsedTime" )); |
96 | RETURN_IF_EXCEPTION(throwScope, { }); |
97 | } |
98 | if (!elapsedTimeValue.isUndefined()) { |
99 | result.elapsedTime = convert<IDLDouble>(state, elapsedTimeValue); |
100 | RETURN_IF_EXCEPTION(throwScope, { }); |
101 | } else |
102 | result.elapsedTime = 0.0; |
103 | JSValue propertyNameValue; |
104 | if (isNullOrUndefined) |
105 | propertyNameValue = jsUndefined(); |
106 | else { |
107 | propertyNameValue = object->get(&state, Identifier::fromString(&state, "propertyName" )); |
108 | RETURN_IF_EXCEPTION(throwScope, { }); |
109 | } |
110 | if (!propertyNameValue.isUndefined()) { |
111 | result.propertyName = convert<IDLDOMString>(state, propertyNameValue); |
112 | RETURN_IF_EXCEPTION(throwScope, { }); |
113 | } else |
114 | result.propertyName = emptyString(); |
115 | JSValue pseudoElementValue; |
116 | if (isNullOrUndefined) |
117 | pseudoElementValue = jsUndefined(); |
118 | else { |
119 | pseudoElementValue = object->get(&state, Identifier::fromString(&state, "pseudoElement" )); |
120 | RETURN_IF_EXCEPTION(throwScope, { }); |
121 | } |
122 | if (!pseudoElementValue.isUndefined()) { |
123 | result.pseudoElement = convert<IDLDOMString>(state, pseudoElementValue); |
124 | RETURN_IF_EXCEPTION(throwScope, { }); |
125 | } else |
126 | result.pseudoElement = emptyString(); |
127 | return result; |
128 | } |
129 | |
130 | // Attributes |
131 | |
132 | JSC::EncodedJSValue jsTransitionEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
133 | bool setJSTransitionEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
134 | JSC::EncodedJSValue jsTransitionEventPropertyName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
135 | JSC::EncodedJSValue jsTransitionEventElapsedTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
136 | JSC::EncodedJSValue jsTransitionEventPseudoElement(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
137 | |
138 | class JSTransitionEventPrototype : public JSC::JSNonFinalObject { |
139 | public: |
140 | using Base = JSC::JSNonFinalObject; |
141 | static JSTransitionEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
142 | { |
143 | JSTransitionEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSTransitionEventPrototype>(vm.heap)) JSTransitionEventPrototype(vm, globalObject, structure); |
144 | ptr->finishCreation(vm); |
145 | return ptr; |
146 | } |
147 | |
148 | DECLARE_INFO; |
149 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
150 | { |
151 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
152 | } |
153 | |
154 | private: |
155 | JSTransitionEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
156 | : JSC::JSNonFinalObject(vm, structure) |
157 | { |
158 | } |
159 | |
160 | void finishCreation(JSC::VM&); |
161 | }; |
162 | |
163 | using JSTransitionEventConstructor = JSDOMConstructor<JSTransitionEvent>; |
164 | |
165 | template<> EncodedJSValue JSC_HOST_CALL JSTransitionEventConstructor::construct(ExecState* state) |
166 | { |
167 | VM& vm = state->vm(); |
168 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
169 | UNUSED_PARAM(throwScope); |
170 | auto* castedThis = jsCast<JSTransitionEventConstructor*>(state->jsCallee()); |
171 | ASSERT(castedThis); |
172 | if (UNLIKELY(state->argumentCount() < 1)) |
173 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
174 | auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
175 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
176 | auto transitionEventInitDict = convert<IDLDictionary<TransitionEvent::Init>>(*state, state->argument(1)); |
177 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
178 | auto object = TransitionEvent::create(WTFMove(type), WTFMove(transitionEventInitDict)); |
179 | return JSValue::encode(toJSNewlyCreated<IDLInterface<TransitionEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
180 | } |
181 | |
182 | template<> JSValue JSTransitionEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
183 | { |
184 | return JSEvent::getConstructor(vm, &globalObject); |
185 | } |
186 | |
187 | template<> void JSTransitionEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
188 | { |
189 | putDirect(vm, vm.propertyNames->prototype, JSTransitionEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
190 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TransitionEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
191 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
192 | } |
193 | |
194 | template<> const ClassInfo JSTransitionEventConstructor::s_info = { "TransitionEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTransitionEventConstructor) }; |
195 | |
196 | /* Hash table for prototype */ |
197 | |
198 | static const HashTableValue JSTransitionEventPrototypeTableValues[] = |
199 | { |
200 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTransitionEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTransitionEventConstructor) } }, |
201 | { "propertyName" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTransitionEventPropertyName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
202 | { "elapsedTime" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTransitionEventElapsedTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
203 | { "pseudoElement" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTransitionEventPseudoElement), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
204 | }; |
205 | |
206 | const ClassInfo JSTransitionEventPrototype::s_info = { "TransitionEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTransitionEventPrototype) }; |
207 | |
208 | void JSTransitionEventPrototype::finishCreation(VM& vm) |
209 | { |
210 | Base::finishCreation(vm); |
211 | reifyStaticProperties(vm, JSTransitionEvent::info(), JSTransitionEventPrototypeTableValues, *this); |
212 | } |
213 | |
214 | const ClassInfo JSTransitionEvent::s_info = { "TransitionEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTransitionEvent) }; |
215 | |
216 | JSTransitionEvent::JSTransitionEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TransitionEvent>&& impl) |
217 | : JSEvent(structure, globalObject, WTFMove(impl)) |
218 | { |
219 | } |
220 | |
221 | void JSTransitionEvent::finishCreation(VM& vm) |
222 | { |
223 | Base::finishCreation(vm); |
224 | ASSERT(inherits(vm, info())); |
225 | |
226 | } |
227 | |
228 | JSObject* JSTransitionEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
229 | { |
230 | return JSTransitionEventPrototype::create(vm, &globalObject, JSTransitionEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
231 | } |
232 | |
233 | JSObject* JSTransitionEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
234 | { |
235 | return getDOMPrototype<JSTransitionEvent>(vm, globalObject); |
236 | } |
237 | |
238 | JSValue JSTransitionEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
239 | { |
240 | return getDOMConstructor<JSTransitionEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
241 | } |
242 | |
243 | template<> inline JSTransitionEvent* IDLAttribute<JSTransitionEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
244 | { |
245 | return jsDynamicCast<JSTransitionEvent*>(state.vm(), JSValue::decode(thisValue)); |
246 | } |
247 | |
248 | EncodedJSValue jsTransitionEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
249 | { |
250 | VM& vm = state->vm(); |
251 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
252 | auto* prototype = jsDynamicCast<JSTransitionEventPrototype*>(vm, JSValue::decode(thisValue)); |
253 | if (UNLIKELY(!prototype)) |
254 | return throwVMTypeError(state, throwScope); |
255 | return JSValue::encode(JSTransitionEvent::getConstructor(state->vm(), prototype->globalObject())); |
256 | } |
257 | |
258 | bool setJSTransitionEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
259 | { |
260 | VM& vm = state->vm(); |
261 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
262 | auto* prototype = jsDynamicCast<JSTransitionEventPrototype*>(vm, JSValue::decode(thisValue)); |
263 | if (UNLIKELY(!prototype)) { |
264 | throwVMTypeError(state, throwScope); |
265 | return false; |
266 | } |
267 | // Shadowing a built-in constructor |
268 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
269 | } |
270 | |
271 | static inline JSValue jsTransitionEventPropertyNameGetter(ExecState& state, JSTransitionEvent& thisObject, ThrowScope& throwScope) |
272 | { |
273 | UNUSED_PARAM(throwScope); |
274 | UNUSED_PARAM(state); |
275 | auto& impl = thisObject.wrapped(); |
276 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.propertyName()); |
277 | return result; |
278 | } |
279 | |
280 | EncodedJSValue jsTransitionEventPropertyName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
281 | { |
282 | return IDLAttribute<JSTransitionEvent>::get<jsTransitionEventPropertyNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "propertyName" ); |
283 | } |
284 | |
285 | static inline JSValue jsTransitionEventElapsedTimeGetter(ExecState& state, JSTransitionEvent& thisObject, ThrowScope& throwScope) |
286 | { |
287 | UNUSED_PARAM(throwScope); |
288 | UNUSED_PARAM(state); |
289 | auto& impl = thisObject.wrapped(); |
290 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.elapsedTime()); |
291 | return result; |
292 | } |
293 | |
294 | EncodedJSValue jsTransitionEventElapsedTime(ExecState* state, EncodedJSValue thisValue, PropertyName) |
295 | { |
296 | return IDLAttribute<JSTransitionEvent>::get<jsTransitionEventElapsedTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "elapsedTime" ); |
297 | } |
298 | |
299 | static inline JSValue jsTransitionEventPseudoElementGetter(ExecState& state, JSTransitionEvent& thisObject, ThrowScope& throwScope) |
300 | { |
301 | UNUSED_PARAM(throwScope); |
302 | UNUSED_PARAM(state); |
303 | auto& impl = thisObject.wrapped(); |
304 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.pseudoElement()); |
305 | return result; |
306 | } |
307 | |
308 | EncodedJSValue jsTransitionEventPseudoElement(ExecState* state, EncodedJSValue thisValue, PropertyName) |
309 | { |
310 | return IDLAttribute<JSTransitionEvent>::get<jsTransitionEventPseudoElementGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pseudoElement" ); |
311 | } |
312 | |
313 | void JSTransitionEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
314 | { |
315 | auto* thisObject = jsCast<JSTransitionEvent*>(cell); |
316 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
317 | if (thisObject->scriptExecutionContext()) |
318 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
319 | Base::heapSnapshot(cell, builder); |
320 | } |
321 | |
322 | #if ENABLE(BINDING_INTEGRITY) |
323 | #if PLATFORM(WIN) |
324 | #pragma warning(disable: 4483) |
325 | extern "C" { extern void (*const __identifier("??_7TransitionEvent@WebCore@@6B@" )[])(); } |
326 | #else |
327 | extern "C" { extern void* _ZTVN7WebCore15TransitionEventE[]; } |
328 | #endif |
329 | #endif |
330 | |
331 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TransitionEvent>&& impl) |
332 | { |
333 | |
334 | #if ENABLE(BINDING_INTEGRITY) |
335 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
336 | #if PLATFORM(WIN) |
337 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TransitionEvent@WebCore@@6B@" )); |
338 | #else |
339 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore15TransitionEventE[2]); |
340 | #endif |
341 | |
342 | // If this fails TransitionEvent does not have a vtable, so you need to add the |
343 | // ImplementationLacksVTable attribute to the interface definition |
344 | static_assert(std::is_polymorphic<TransitionEvent>::value, "TransitionEvent is not polymorphic" ); |
345 | |
346 | // If you hit this assertion you either have a use after free bug, or |
347 | // TransitionEvent has subclasses. If TransitionEvent has subclasses that get passed |
348 | // to toJS() we currently require TransitionEvent you to opt out of binding hardening |
349 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
350 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
351 | #endif |
352 | return createWrapper<TransitionEvent>(globalObject, WTFMove(impl)); |
353 | } |
354 | |
355 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TransitionEvent& impl) |
356 | { |
357 | return wrap(state, globalObject, impl); |
358 | } |
359 | |
360 | |
361 | } |
362 | |