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