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