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 "JSMouseEvent.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructor.h"
27#include "JSDOMConvertAny.h"
28#include "JSDOMConvertBoolean.h"
29#include "JSDOMConvertDictionary.h"
30#include "JSDOMConvertInterface.h"
31#include "JSDOMConvertNullable.h"
32#include "JSDOMConvertNumbers.h"
33#include "JSDOMConvertStrings.h"
34#include "JSDOMExceptionHandling.h"
35#include "JSDOMGlobalObject.h"
36#include "JSDOMOperation.h"
37#include "JSDOMWrapperCache.h"
38#include "JSDataTransfer.h"
39#include "JSEventTarget.h"
40#include "JSMouseEventInit.h"
41#include "JSNode.h"
42#include "JSWindowProxy.h"
43#include "ScriptExecutionContext.h"
44#include <JavaScriptCore/HeapSnapshotBuilder.h>
45#include <JavaScriptCore/JSCInlines.h>
46#include <wtf/GetPtr.h>
47#include <wtf/PointerPreparations.h>
48#include <wtf/URL.h>
49
50
51namespace WebCore {
52using namespace JSC;
53
54// Functions
55
56JSC::EncodedJSValue JSC_HOST_CALL jsMouseEventPrototypeFunctionGetModifierState(JSC::ExecState*);
57JSC::EncodedJSValue JSC_HOST_CALL jsMouseEventPrototypeFunctionInitMouseEvent(JSC::ExecState*);
58
59// Attributes
60
61JSC::EncodedJSValue jsMouseEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
62bool setJSMouseEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
63JSC::EncodedJSValue jsMouseEventScreenX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
64JSC::EncodedJSValue jsMouseEventScreenY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
65JSC::EncodedJSValue jsMouseEventClientX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
66JSC::EncodedJSValue jsMouseEventClientY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
67JSC::EncodedJSValue jsMouseEventCtrlKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
68JSC::EncodedJSValue jsMouseEventShiftKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
69JSC::EncodedJSValue jsMouseEventAltKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
70JSC::EncodedJSValue jsMouseEventMetaKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
71JSC::EncodedJSValue jsMouseEventButton(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
72JSC::EncodedJSValue jsMouseEventButtons(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
73JSC::EncodedJSValue jsMouseEventRelatedTarget(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
74#if ENABLE(POINTER_LOCK)
75JSC::EncodedJSValue jsMouseEventMovementX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
76#endif
77#if ENABLE(POINTER_LOCK)
78JSC::EncodedJSValue jsMouseEventMovementY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
79#endif
80#if ENABLE(MOUSE_FORCE_EVENTS)
81JSC::EncodedJSValue jsMouseEventWebkitForce(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
82#endif
83JSC::EncodedJSValue jsMouseEventOffsetX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
84JSC::EncodedJSValue jsMouseEventOffsetY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
85JSC::EncodedJSValue jsMouseEventX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
86JSC::EncodedJSValue jsMouseEventY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
87JSC::EncodedJSValue jsMouseEventFromElement(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
88JSC::EncodedJSValue jsMouseEventToElement(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
89JSC::EncodedJSValue jsMouseEventDataTransfer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
90
91class JSMouseEventPrototype : public JSC::JSNonFinalObject {
92public:
93 using Base = JSC::JSNonFinalObject;
94 static JSMouseEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
95 {
96 JSMouseEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSMouseEventPrototype>(vm.heap)) JSMouseEventPrototype(vm, globalObject, structure);
97 ptr->finishCreation(vm);
98 return ptr;
99 }
100
101 DECLARE_INFO;
102 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
103 {
104 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
105 }
106
107private:
108 JSMouseEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
109 : JSC::JSNonFinalObject(vm, structure)
110 {
111 }
112
113 void finishCreation(JSC::VM&);
114};
115
116using JSMouseEventConstructor = JSDOMConstructor<JSMouseEvent>;
117
118/* Hash table for constructor */
119
120static const HashTableValue JSMouseEventConstructorTableValues[] =
121{
122#if ENABLE(MOUSE_FORCE_EVENTS)
123 { "WEBKIT_FORCE_AT_MOUSE_DOWN", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
124#else
125 { 0, 0, NoIntrinsic, { 0, 0 } },
126#endif
127#if ENABLE(MOUSE_FORCE_EVENTS)
128 { "WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
129#else
130 { 0, 0, NoIntrinsic, { 0, 0 } },
131#endif
132};
133
134template<> EncodedJSValue JSC_HOST_CALL JSMouseEventConstructor::construct(ExecState* state)
135{
136 VM& vm = state->vm();
137 auto throwScope = DECLARE_THROW_SCOPE(vm);
138 UNUSED_PARAM(throwScope);
139 auto* castedThis = jsCast<JSMouseEventConstructor*>(state->jsCallee());
140 ASSERT(castedThis);
141 if (UNLIKELY(state->argumentCount() < 1))
142 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
143 auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
144 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
145 auto eventInitDict = convert<IDLDictionary<MouseEventInit>>(*state, state->argument(1));
146 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
147 auto object = MouseEvent::create(WTFMove(type), WTFMove(eventInitDict));
148 return JSValue::encode(toJSNewlyCreated<IDLInterface<MouseEvent>>(*state, *castedThis->globalObject(), WTFMove(object)));
149}
150
151template<> JSValue JSMouseEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
152{
153 return JSUIEvent::getConstructor(vm, &globalObject);
154}
155
156template<> void JSMouseEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
157{
158 putDirect(vm, vm.propertyNames->prototype, JSMouseEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
159 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MouseEvent"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
160 putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
161 reifyStaticProperties(vm, JSMouseEvent::info(), JSMouseEventConstructorTableValues, *this);
162}
163
164template<> const ClassInfo JSMouseEventConstructor::s_info = { "MouseEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMouseEventConstructor) };
165
166/* Hash table for prototype */
167
168static const HashTableValue JSMouseEventPrototypeTableValues[] =
169{
170 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMouseEventConstructor) } },
171 { "screenX", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventScreenX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
172 { "screenY", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventScreenY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
173 { "clientX", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventClientX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
174 { "clientY", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventClientY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
175 { "ctrlKey", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventCtrlKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
176 { "shiftKey", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventShiftKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
177 { "altKey", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventAltKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
178 { "metaKey", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventMetaKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
179 { "button", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventButton), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
180 { "buttons", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventButtons), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
181 { "relatedTarget", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventRelatedTarget), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
182#if ENABLE(POINTER_LOCK)
183 { "movementX", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventMovementX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
184#else
185 { 0, 0, NoIntrinsic, { 0, 0 } },
186#endif
187#if ENABLE(POINTER_LOCK)
188 { "movementY", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventMovementY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
189#else
190 { 0, 0, NoIntrinsic, { 0, 0 } },
191#endif
192#if ENABLE(MOUSE_FORCE_EVENTS)
193 { "webkitForce", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventWebkitForce), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
194#else
195 { 0, 0, NoIntrinsic, { 0, 0 } },
196#endif
197 { "offsetX", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventOffsetX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
198 { "offsetY", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventOffsetY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
199 { "x", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
200 { "y", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
201 { "fromElement", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventFromElement), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
202 { "toElement", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventToElement), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
203 { "dataTransfer", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMouseEventDataTransfer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
204 { "getModifierState", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMouseEventPrototypeFunctionGetModifierState), (intptr_t) (1) } },
205 { "initMouseEvent", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMouseEventPrototypeFunctionInitMouseEvent), (intptr_t) (0) } },
206#if ENABLE(MOUSE_FORCE_EVENTS)
207 { "WEBKIT_FORCE_AT_MOUSE_DOWN", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
208#else
209 { 0, 0, NoIntrinsic, { 0, 0 } },
210#endif
211#if ENABLE(MOUSE_FORCE_EVENTS)
212 { "WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
213#else
214 { 0, 0, NoIntrinsic, { 0, 0 } },
215#endif
216};
217
218const ClassInfo JSMouseEventPrototype::s_info = { "MouseEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMouseEventPrototype) };
219
220void JSMouseEventPrototype::finishCreation(VM& vm)
221{
222 Base::finishCreation(vm);
223 reifyStaticProperties(vm, JSMouseEvent::info(), JSMouseEventPrototypeTableValues, *this);
224}
225
226const ClassInfo JSMouseEvent::s_info = { "MouseEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMouseEvent) };
227
228JSMouseEvent::JSMouseEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MouseEvent>&& impl)
229 : JSUIEvent(structure, globalObject, WTFMove(impl))
230{
231}
232
233void JSMouseEvent::finishCreation(VM& vm)
234{
235 Base::finishCreation(vm);
236 ASSERT(inherits(vm, info()));
237
238}
239
240JSObject* JSMouseEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
241{
242 return JSMouseEventPrototype::create(vm, &globalObject, JSMouseEventPrototype::createStructure(vm, &globalObject, JSUIEvent::prototype(vm, globalObject)));
243}
244
245JSObject* JSMouseEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
246{
247 return getDOMPrototype<JSMouseEvent>(vm, globalObject);
248}
249
250JSValue JSMouseEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
251{
252 return getDOMConstructor<JSMouseEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
253}
254
255template<> inline JSMouseEvent* IDLAttribute<JSMouseEvent>::cast(ExecState& state, EncodedJSValue thisValue)
256{
257 return jsDynamicCast<JSMouseEvent*>(state.vm(), JSValue::decode(thisValue));
258}
259
260template<> inline JSMouseEvent* IDLOperation<JSMouseEvent>::cast(ExecState& state)
261{
262 return jsDynamicCast<JSMouseEvent*>(state.vm(), state.thisValue());
263}
264
265EncodedJSValue jsMouseEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
266{
267 VM& vm = state->vm();
268 auto throwScope = DECLARE_THROW_SCOPE(vm);
269 auto* prototype = jsDynamicCast<JSMouseEventPrototype*>(vm, JSValue::decode(thisValue));
270 if (UNLIKELY(!prototype))
271 return throwVMTypeError(state, throwScope);
272 return JSValue::encode(JSMouseEvent::getConstructor(state->vm(), prototype->globalObject()));
273}
274
275bool setJSMouseEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
276{
277 VM& vm = state->vm();
278 auto throwScope = DECLARE_THROW_SCOPE(vm);
279 auto* prototype = jsDynamicCast<JSMouseEventPrototype*>(vm, JSValue::decode(thisValue));
280 if (UNLIKELY(!prototype)) {
281 throwVMTypeError(state, throwScope);
282 return false;
283 }
284 // Shadowing a built-in constructor
285 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
286}
287
288static inline JSValue jsMouseEventScreenXGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
289{
290 UNUSED_PARAM(throwScope);
291 UNUSED_PARAM(state);
292 auto& impl = thisObject.wrapped();
293 JSValue result = toJS<IDLLong>(state, throwScope, impl.screenX());
294 return result;
295}
296
297EncodedJSValue jsMouseEventScreenX(ExecState* state, EncodedJSValue thisValue, PropertyName)
298{
299 return IDLAttribute<JSMouseEvent>::get<jsMouseEventScreenXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "screenX");
300}
301
302static inline JSValue jsMouseEventScreenYGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
303{
304 UNUSED_PARAM(throwScope);
305 UNUSED_PARAM(state);
306 auto& impl = thisObject.wrapped();
307 JSValue result = toJS<IDLLong>(state, throwScope, impl.screenY());
308 return result;
309}
310
311EncodedJSValue jsMouseEventScreenY(ExecState* state, EncodedJSValue thisValue, PropertyName)
312{
313 return IDLAttribute<JSMouseEvent>::get<jsMouseEventScreenYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "screenY");
314}
315
316static inline JSValue jsMouseEventClientXGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
317{
318 UNUSED_PARAM(throwScope);
319 UNUSED_PARAM(state);
320 auto& impl = thisObject.wrapped();
321 JSValue result = toJS<IDLLong>(state, throwScope, impl.clientX());
322 return result;
323}
324
325EncodedJSValue jsMouseEventClientX(ExecState* state, EncodedJSValue thisValue, PropertyName)
326{
327 return IDLAttribute<JSMouseEvent>::get<jsMouseEventClientXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "clientX");
328}
329
330static inline JSValue jsMouseEventClientYGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
331{
332 UNUSED_PARAM(throwScope);
333 UNUSED_PARAM(state);
334 auto& impl = thisObject.wrapped();
335 JSValue result = toJS<IDLLong>(state, throwScope, impl.clientY());
336 return result;
337}
338
339EncodedJSValue jsMouseEventClientY(ExecState* state, EncodedJSValue thisValue, PropertyName)
340{
341 return IDLAttribute<JSMouseEvent>::get<jsMouseEventClientYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "clientY");
342}
343
344static inline JSValue jsMouseEventCtrlKeyGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
345{
346 UNUSED_PARAM(throwScope);
347 UNUSED_PARAM(state);
348 auto& impl = thisObject.wrapped();
349 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.ctrlKey());
350 return result;
351}
352
353EncodedJSValue jsMouseEventCtrlKey(ExecState* state, EncodedJSValue thisValue, PropertyName)
354{
355 return IDLAttribute<JSMouseEvent>::get<jsMouseEventCtrlKeyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "ctrlKey");
356}
357
358static inline JSValue jsMouseEventShiftKeyGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
359{
360 UNUSED_PARAM(throwScope);
361 UNUSED_PARAM(state);
362 auto& impl = thisObject.wrapped();
363 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.shiftKey());
364 return result;
365}
366
367EncodedJSValue jsMouseEventShiftKey(ExecState* state, EncodedJSValue thisValue, PropertyName)
368{
369 return IDLAttribute<JSMouseEvent>::get<jsMouseEventShiftKeyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "shiftKey");
370}
371
372static inline JSValue jsMouseEventAltKeyGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
373{
374 UNUSED_PARAM(throwScope);
375 UNUSED_PARAM(state);
376 auto& impl = thisObject.wrapped();
377 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.altKey());
378 return result;
379}
380
381EncodedJSValue jsMouseEventAltKey(ExecState* state, EncodedJSValue thisValue, PropertyName)
382{
383 return IDLAttribute<JSMouseEvent>::get<jsMouseEventAltKeyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "altKey");
384}
385
386static inline JSValue jsMouseEventMetaKeyGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
387{
388 UNUSED_PARAM(throwScope);
389 UNUSED_PARAM(state);
390 auto& impl = thisObject.wrapped();
391 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.metaKey());
392 return result;
393}
394
395EncodedJSValue jsMouseEventMetaKey(ExecState* state, EncodedJSValue thisValue, PropertyName)
396{
397 return IDLAttribute<JSMouseEvent>::get<jsMouseEventMetaKeyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "metaKey");
398}
399
400static inline JSValue jsMouseEventButtonGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
401{
402 UNUSED_PARAM(throwScope);
403 UNUSED_PARAM(state);
404 auto& impl = thisObject.wrapped();
405 JSValue result = toJS<IDLUnsignedShort>(state, throwScope, impl.button());
406 return result;
407}
408
409EncodedJSValue jsMouseEventButton(ExecState* state, EncodedJSValue thisValue, PropertyName)
410{
411 return IDLAttribute<JSMouseEvent>::get<jsMouseEventButtonGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "button");
412}
413
414static inline JSValue jsMouseEventButtonsGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
415{
416 UNUSED_PARAM(throwScope);
417 UNUSED_PARAM(state);
418 auto& impl = thisObject.wrapped();
419 JSValue result = toJS<IDLUnsignedShort>(state, throwScope, impl.buttons());
420 return result;
421}
422
423EncodedJSValue jsMouseEventButtons(ExecState* state, EncodedJSValue thisValue, PropertyName)
424{
425 return IDLAttribute<JSMouseEvent>::get<jsMouseEventButtonsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "buttons");
426}
427
428static inline JSValue jsMouseEventRelatedTargetGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
429{
430 UNUSED_PARAM(throwScope);
431 UNUSED_PARAM(state);
432 auto& impl = thisObject.wrapped();
433 JSValue result = toJS<IDLNullable<IDLInterface<EventTarget>>>(state, *thisObject.globalObject(), throwScope, impl.relatedTarget());
434 return result;
435}
436
437EncodedJSValue jsMouseEventRelatedTarget(ExecState* state, EncodedJSValue thisValue, PropertyName)
438{
439 return IDLAttribute<JSMouseEvent>::get<jsMouseEventRelatedTargetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "relatedTarget");
440}
441
442#if ENABLE(POINTER_LOCK)
443static inline JSValue jsMouseEventMovementXGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
444{
445 UNUSED_PARAM(throwScope);
446 UNUSED_PARAM(state);
447 auto& impl = thisObject.wrapped();
448 JSValue result = toJS<IDLLong>(state, throwScope, impl.movementX());
449 return result;
450}
451
452EncodedJSValue jsMouseEventMovementX(ExecState* state, EncodedJSValue thisValue, PropertyName)
453{
454 return IDLAttribute<JSMouseEvent>::get<jsMouseEventMovementXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "movementX");
455}
456
457#endif
458
459#if ENABLE(POINTER_LOCK)
460static inline JSValue jsMouseEventMovementYGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
461{
462 UNUSED_PARAM(throwScope);
463 UNUSED_PARAM(state);
464 auto& impl = thisObject.wrapped();
465 JSValue result = toJS<IDLLong>(state, throwScope, impl.movementY());
466 return result;
467}
468
469EncodedJSValue jsMouseEventMovementY(ExecState* state, EncodedJSValue thisValue, PropertyName)
470{
471 return IDLAttribute<JSMouseEvent>::get<jsMouseEventMovementYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "movementY");
472}
473
474#endif
475
476#if ENABLE(MOUSE_FORCE_EVENTS)
477static inline JSValue jsMouseEventWebkitForceGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
478{
479 UNUSED_PARAM(throwScope);
480 UNUSED_PARAM(state);
481 auto& impl = thisObject.wrapped();
482 JSValue result = toJS<IDLDouble>(state, throwScope, impl.force());
483 return result;
484}
485
486EncodedJSValue jsMouseEventWebkitForce(ExecState* state, EncodedJSValue thisValue, PropertyName)
487{
488 return IDLAttribute<JSMouseEvent>::get<jsMouseEventWebkitForceGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "webkitForce");
489}
490
491#endif
492
493static inline JSValue jsMouseEventOffsetXGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
494{
495 UNUSED_PARAM(throwScope);
496 UNUSED_PARAM(state);
497 auto& impl = thisObject.wrapped();
498 JSValue result = toJS<IDLLong>(state, throwScope, impl.offsetX());
499 return result;
500}
501
502EncodedJSValue jsMouseEventOffsetX(ExecState* state, EncodedJSValue thisValue, PropertyName)
503{
504 return IDLAttribute<JSMouseEvent>::get<jsMouseEventOffsetXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "offsetX");
505}
506
507static inline JSValue jsMouseEventOffsetYGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
508{
509 UNUSED_PARAM(throwScope);
510 UNUSED_PARAM(state);
511 auto& impl = thisObject.wrapped();
512 JSValue result = toJS<IDLLong>(state, throwScope, impl.offsetY());
513 return result;
514}
515
516EncodedJSValue jsMouseEventOffsetY(ExecState* state, EncodedJSValue thisValue, PropertyName)
517{
518 return IDLAttribute<JSMouseEvent>::get<jsMouseEventOffsetYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "offsetY");
519}
520
521static inline JSValue jsMouseEventXGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
522{
523 UNUSED_PARAM(throwScope);
524 UNUSED_PARAM(state);
525 auto& impl = thisObject.wrapped();
526 JSValue result = toJS<IDLLong>(state, throwScope, impl.x());
527 return result;
528}
529
530EncodedJSValue jsMouseEventX(ExecState* state, EncodedJSValue thisValue, PropertyName)
531{
532 return IDLAttribute<JSMouseEvent>::get<jsMouseEventXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "x");
533}
534
535static inline JSValue jsMouseEventYGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
536{
537 UNUSED_PARAM(throwScope);
538 UNUSED_PARAM(state);
539 auto& impl = thisObject.wrapped();
540 JSValue result = toJS<IDLLong>(state, throwScope, impl.y());
541 return result;
542}
543
544EncodedJSValue jsMouseEventY(ExecState* state, EncodedJSValue thisValue, PropertyName)
545{
546 return IDLAttribute<JSMouseEvent>::get<jsMouseEventYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "y");
547}
548
549static inline JSValue jsMouseEventFromElementGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
550{
551 UNUSED_PARAM(throwScope);
552 UNUSED_PARAM(state);
553 auto& impl = thisObject.wrapped();
554 JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.fromElement());
555 return result;
556}
557
558EncodedJSValue jsMouseEventFromElement(ExecState* state, EncodedJSValue thisValue, PropertyName)
559{
560 return IDLAttribute<JSMouseEvent>::get<jsMouseEventFromElementGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "fromElement");
561}
562
563static inline JSValue jsMouseEventToElementGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
564{
565 UNUSED_PARAM(throwScope);
566 UNUSED_PARAM(state);
567 auto& impl = thisObject.wrapped();
568 JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.toElement());
569 return result;
570}
571
572EncodedJSValue jsMouseEventToElement(ExecState* state, EncodedJSValue thisValue, PropertyName)
573{
574 return IDLAttribute<JSMouseEvent>::get<jsMouseEventToElementGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "toElement");
575}
576
577static inline JSValue jsMouseEventDataTransferGetter(ExecState& state, JSMouseEvent& thisObject, ThrowScope& throwScope)
578{
579 UNUSED_PARAM(throwScope);
580 UNUSED_PARAM(state);
581 auto& impl = thisObject.wrapped();
582 JSValue result = toJS<IDLInterface<DataTransfer>>(state, *thisObject.globalObject(), throwScope, impl.dataTransfer());
583 return result;
584}
585
586EncodedJSValue jsMouseEventDataTransfer(ExecState* state, EncodedJSValue thisValue, PropertyName)
587{
588 return IDLAttribute<JSMouseEvent>::get<jsMouseEventDataTransferGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "dataTransfer");
589}
590
591static inline JSC::EncodedJSValue jsMouseEventPrototypeFunctionGetModifierStateBody(JSC::ExecState* state, typename IDLOperation<JSMouseEvent>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
592{
593 UNUSED_PARAM(state);
594 UNUSED_PARAM(throwScope);
595 auto& impl = castedThis->wrapped();
596 if (UNLIKELY(state->argumentCount() < 1))
597 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
598 auto keyArg = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
599 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
600 return JSValue::encode(toJS<IDLBoolean>(impl.getModifierState(WTFMove(keyArg))));
601}
602
603EncodedJSValue JSC_HOST_CALL jsMouseEventPrototypeFunctionGetModifierState(ExecState* state)
604{
605 return IDLOperation<JSMouseEvent>::call<jsMouseEventPrototypeFunctionGetModifierStateBody>(*state, "getModifierState");
606}
607
608static inline JSC::EncodedJSValue jsMouseEventPrototypeFunctionInitMouseEventBody(JSC::ExecState* state, typename IDLOperation<JSMouseEvent>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
609{
610 UNUSED_PARAM(state);
611 UNUSED_PARAM(throwScope);
612 auto& impl = castedThis->wrapped();
613 auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
614 if (UNLIKELY(!context))
615 return JSValue::encode(jsUndefined());
616 auto type = convert<IDLDOMString>(*state, state->argument(0));
617 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
618 auto canBubble = convert<IDLBoolean>(*state, state->argument(1));
619 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
620 auto cancelable = convert<IDLBoolean>(*state, state->argument(2));
621 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
622 auto view = convert<IDLNullable<IDLInterface<WindowProxy>>>(*state, state->argument(3), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 3, "view", "MouseEvent", "initMouseEvent", "WindowProxy"); });
623 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
624 auto detail = convert<IDLLong>(*state, state->argument(4));
625 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
626 auto screenX = convert<IDLLong>(*state, state->argument(5));
627 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
628 auto screenY = convert<IDLLong>(*state, state->argument(6));
629 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
630 auto clientX = convert<IDLLong>(*state, state->argument(7));
631 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
632 auto clientY = convert<IDLLong>(*state, state->argument(8));
633 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
634 auto ctrlKey = convert<IDLBoolean>(*state, state->argument(9));
635 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
636 auto altKey = convert<IDLBoolean>(*state, state->argument(10));
637 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
638 auto shiftKey = convert<IDLBoolean>(*state, state->argument(11));
639 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
640 auto metaKey = convert<IDLBoolean>(*state, state->argument(12));
641 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
642 auto button = convert<IDLUnsignedShort>(*state, state->argument(13));
643 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
644 auto relatedTarget = state->argument(14).isUndefined() ? jsNull() : convert<IDLAny>(*state, state->uncheckedArgument(14));
645 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
646 impl.initMouseEventQuirk(*state, *context, WTFMove(type), WTFMove(canBubble), WTFMove(cancelable), WTFMove(view), WTFMove(detail), WTFMove(screenX), WTFMove(screenY), WTFMove(clientX), WTFMove(clientY), WTFMove(ctrlKey), WTFMove(altKey), WTFMove(shiftKey), WTFMove(metaKey), WTFMove(button), WTFMove(relatedTarget));
647 return JSValue::encode(jsUndefined());
648}
649
650EncodedJSValue JSC_HOST_CALL jsMouseEventPrototypeFunctionInitMouseEvent(ExecState* state)
651{
652 return IDLOperation<JSMouseEvent>::call<jsMouseEventPrototypeFunctionInitMouseEventBody>(*state, "initMouseEvent");
653}
654
655void JSMouseEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
656{
657 auto* thisObject = jsCast<JSMouseEvent*>(cell);
658 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
659 if (thisObject->scriptExecutionContext())
660 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
661 Base::heapSnapshot(cell, builder);
662}
663
664#if ENABLE(BINDING_INTEGRITY)
665#if PLATFORM(WIN)
666#pragma warning(disable: 4483)
667extern "C" { extern void (*const __identifier("??_7MouseEvent@WebCore@@6B@")[])(); }
668#else
669extern "C" { extern void* _ZTVN7WebCore10MouseEventE[]; }
670#endif
671#endif
672
673JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MouseEvent>&& impl)
674{
675
676#if ENABLE(BINDING_INTEGRITY)
677 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
678#if PLATFORM(WIN)
679 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7MouseEvent@WebCore@@6B@"));
680#else
681 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore10MouseEventE[2]);
682#endif
683
684 // If this fails MouseEvent does not have a vtable, so you need to add the
685 // ImplementationLacksVTable attribute to the interface definition
686 static_assert(std::is_polymorphic<MouseEvent>::value, "MouseEvent is not polymorphic");
687
688 // If you hit this assertion you either have a use after free bug, or
689 // MouseEvent has subclasses. If MouseEvent has subclasses that get passed
690 // to toJS() we currently require MouseEvent you to opt out of binding hardening
691 // by adding the SkipVTableValidation attribute to the interface IDL definition
692 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
693#endif
694 return createWrapper<MouseEvent>(globalObject, WTFMove(impl));
695}
696
697JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MouseEvent& impl)
698{
699 return wrap(state, globalObject, impl);
700}
701
702
703}
704