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
23#if ENABLE(POINTER_EVENTS)
24
25#include "JSPointerEvent.h"
26
27#include "JSDOMAttribute.h"
28#include "JSDOMBinding.h"
29#include "JSDOMConstructor.h"
30#include "JSDOMConvertBoolean.h"
31#include "JSDOMConvertInterface.h"
32#include "JSDOMConvertNullable.h"
33#include "JSDOMConvertNumbers.h"
34#include "JSDOMConvertStrings.h"
35#include "JSDOMExceptionHandling.h"
36#include "JSDOMWrapperCache.h"
37#include "JSEventTarget.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
50template<> PointerEvent::Init convertDictionary<PointerEvent::Init>(ExecState& state, JSValue value)
51{
52 VM& vm = state.vm();
53 auto throwScope = DECLARE_THROW_SCOPE(vm);
54 bool isNullOrUndefined = value.isUndefinedOrNull();
55 auto* object = isNullOrUndefined ? nullptr : value.getObject();
56 if (UNLIKELY(!isNullOrUndefined && !object)) {
57 throwTypeError(&state, throwScope);
58 return { };
59 }
60 PointerEvent::Init result;
61 JSValue bubblesValue;
62 if (isNullOrUndefined)
63 bubblesValue = jsUndefined();
64 else {
65 bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles"));
66 RETURN_IF_EXCEPTION(throwScope, { });
67 }
68 if (!bubblesValue.isUndefined()) {
69 result.bubbles = convert<IDLBoolean>(state, bubblesValue);
70 RETURN_IF_EXCEPTION(throwScope, { });
71 } else
72 result.bubbles = false;
73 JSValue cancelableValue;
74 if (isNullOrUndefined)
75 cancelableValue = jsUndefined();
76 else {
77 cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable"));
78 RETURN_IF_EXCEPTION(throwScope, { });
79 }
80 if (!cancelableValue.isUndefined()) {
81 result.cancelable = convert<IDLBoolean>(state, cancelableValue);
82 RETURN_IF_EXCEPTION(throwScope, { });
83 } else
84 result.cancelable = false;
85 JSValue composedValue;
86 if (isNullOrUndefined)
87 composedValue = jsUndefined();
88 else {
89 composedValue = object->get(&state, Identifier::fromString(&state, "composed"));
90 RETURN_IF_EXCEPTION(throwScope, { });
91 }
92 if (!composedValue.isUndefined()) {
93 result.composed = convert<IDLBoolean>(state, composedValue);
94 RETURN_IF_EXCEPTION(throwScope, { });
95 } else
96 result.composed = false;
97 JSValue detailValue;
98 if (isNullOrUndefined)
99 detailValue = jsUndefined();
100 else {
101 detailValue = object->get(&state, Identifier::fromString(&state, "detail"));
102 RETURN_IF_EXCEPTION(throwScope, { });
103 }
104 if (!detailValue.isUndefined()) {
105 result.detail = convert<IDLLong>(state, detailValue);
106 RETURN_IF_EXCEPTION(throwScope, { });
107 } else
108 result.detail = 0;
109 JSValue viewValue;
110 if (isNullOrUndefined)
111 viewValue = jsUndefined();
112 else {
113 viewValue = object->get(&state, Identifier::fromString(&state, "view"));
114 RETURN_IF_EXCEPTION(throwScope, { });
115 }
116 if (!viewValue.isUndefined()) {
117 result.view = convert<IDLNullable<IDLInterface<WindowProxy>>>(state, viewValue);
118 RETURN_IF_EXCEPTION(throwScope, { });
119 } else
120 result.view = nullptr;
121 JSValue altKeyValue;
122 if (isNullOrUndefined)
123 altKeyValue = jsUndefined();
124 else {
125 altKeyValue = object->get(&state, Identifier::fromString(&state, "altKey"));
126 RETURN_IF_EXCEPTION(throwScope, { });
127 }
128 if (!altKeyValue.isUndefined()) {
129 result.altKey = convert<IDLBoolean>(state, altKeyValue);
130 RETURN_IF_EXCEPTION(throwScope, { });
131 } else
132 result.altKey = false;
133 JSValue ctrlKeyValue;
134 if (isNullOrUndefined)
135 ctrlKeyValue = jsUndefined();
136 else {
137 ctrlKeyValue = object->get(&state, Identifier::fromString(&state, "ctrlKey"));
138 RETURN_IF_EXCEPTION(throwScope, { });
139 }
140 if (!ctrlKeyValue.isUndefined()) {
141 result.ctrlKey = convert<IDLBoolean>(state, ctrlKeyValue);
142 RETURN_IF_EXCEPTION(throwScope, { });
143 } else
144 result.ctrlKey = false;
145 JSValue metaKeyValue;
146 if (isNullOrUndefined)
147 metaKeyValue = jsUndefined();
148 else {
149 metaKeyValue = object->get(&state, Identifier::fromString(&state, "metaKey"));
150 RETURN_IF_EXCEPTION(throwScope, { });
151 }
152 if (!metaKeyValue.isUndefined()) {
153 result.metaKey = convert<IDLBoolean>(state, metaKeyValue);
154 RETURN_IF_EXCEPTION(throwScope, { });
155 } else
156 result.metaKey = false;
157 JSValue modifierAltGraphValue;
158 if (isNullOrUndefined)
159 modifierAltGraphValue = jsUndefined();
160 else {
161 modifierAltGraphValue = object->get(&state, Identifier::fromString(&state, "modifierAltGraph"));
162 RETURN_IF_EXCEPTION(throwScope, { });
163 }
164 if (!modifierAltGraphValue.isUndefined()) {
165 result.modifierAltGraph = convert<IDLBoolean>(state, modifierAltGraphValue);
166 RETURN_IF_EXCEPTION(throwScope, { });
167 } else
168 result.modifierAltGraph = false;
169 JSValue modifierCapsLockValue;
170 if (isNullOrUndefined)
171 modifierCapsLockValue = jsUndefined();
172 else {
173 modifierCapsLockValue = object->get(&state, Identifier::fromString(&state, "modifierCapsLock"));
174 RETURN_IF_EXCEPTION(throwScope, { });
175 }
176 if (!modifierCapsLockValue.isUndefined()) {
177 result.modifierCapsLock = convert<IDLBoolean>(state, modifierCapsLockValue);
178 RETURN_IF_EXCEPTION(throwScope, { });
179 } else
180 result.modifierCapsLock = false;
181 JSValue shiftKeyValue;
182 if (isNullOrUndefined)
183 shiftKeyValue = jsUndefined();
184 else {
185 shiftKeyValue = object->get(&state, Identifier::fromString(&state, "shiftKey"));
186 RETURN_IF_EXCEPTION(throwScope, { });
187 }
188 if (!shiftKeyValue.isUndefined()) {
189 result.shiftKey = convert<IDLBoolean>(state, shiftKeyValue);
190 RETURN_IF_EXCEPTION(throwScope, { });
191 } else
192 result.shiftKey = false;
193 JSValue buttonValue;
194 if (isNullOrUndefined)
195 buttonValue = jsUndefined();
196 else {
197 buttonValue = object->get(&state, Identifier::fromString(&state, "button"));
198 RETURN_IF_EXCEPTION(throwScope, { });
199 }
200 if (!buttonValue.isUndefined()) {
201 result.button = convert<IDLUnsignedShort>(state, buttonValue);
202 RETURN_IF_EXCEPTION(throwScope, { });
203 } else
204 result.button = 0;
205 JSValue buttonsValue;
206 if (isNullOrUndefined)
207 buttonsValue = jsUndefined();
208 else {
209 buttonsValue = object->get(&state, Identifier::fromString(&state, "buttons"));
210 RETURN_IF_EXCEPTION(throwScope, { });
211 }
212 if (!buttonsValue.isUndefined()) {
213 result.buttons = convert<IDLUnsignedShort>(state, buttonsValue);
214 RETURN_IF_EXCEPTION(throwScope, { });
215 } else
216 result.buttons = 0;
217 JSValue clientXValue;
218 if (isNullOrUndefined)
219 clientXValue = jsUndefined();
220 else {
221 clientXValue = object->get(&state, Identifier::fromString(&state, "clientX"));
222 RETURN_IF_EXCEPTION(throwScope, { });
223 }
224 if (!clientXValue.isUndefined()) {
225 result.clientX = convert<IDLLong>(state, clientXValue);
226 RETURN_IF_EXCEPTION(throwScope, { });
227 } else
228 result.clientX = 0;
229 JSValue clientYValue;
230 if (isNullOrUndefined)
231 clientYValue = jsUndefined();
232 else {
233 clientYValue = object->get(&state, Identifier::fromString(&state, "clientY"));
234 RETURN_IF_EXCEPTION(throwScope, { });
235 }
236 if (!clientYValue.isUndefined()) {
237 result.clientY = convert<IDLLong>(state, clientYValue);
238 RETURN_IF_EXCEPTION(throwScope, { });
239 } else
240 result.clientY = 0;
241 JSValue relatedTargetValue;
242 if (isNullOrUndefined)
243 relatedTargetValue = jsUndefined();
244 else {
245 relatedTargetValue = object->get(&state, Identifier::fromString(&state, "relatedTarget"));
246 RETURN_IF_EXCEPTION(throwScope, { });
247 }
248 if (!relatedTargetValue.isUndefined()) {
249 result.relatedTarget = convert<IDLNullable<IDLInterface<EventTarget>>>(state, relatedTargetValue);
250 RETURN_IF_EXCEPTION(throwScope, { });
251 } else
252 result.relatedTarget = nullptr;
253 JSValue screenXValue;
254 if (isNullOrUndefined)
255 screenXValue = jsUndefined();
256 else {
257 screenXValue = object->get(&state, Identifier::fromString(&state, "screenX"));
258 RETURN_IF_EXCEPTION(throwScope, { });
259 }
260 if (!screenXValue.isUndefined()) {
261 result.screenX = convert<IDLLong>(state, screenXValue);
262 RETURN_IF_EXCEPTION(throwScope, { });
263 } else
264 result.screenX = 0;
265 JSValue screenYValue;
266 if (isNullOrUndefined)
267 screenYValue = jsUndefined();
268 else {
269 screenYValue = object->get(&state, Identifier::fromString(&state, "screenY"));
270 RETURN_IF_EXCEPTION(throwScope, { });
271 }
272 if (!screenYValue.isUndefined()) {
273 result.screenY = convert<IDLLong>(state, screenYValue);
274 RETURN_IF_EXCEPTION(throwScope, { });
275 } else
276 result.screenY = 0;
277 JSValue heightValue;
278 if (isNullOrUndefined)
279 heightValue = jsUndefined();
280 else {
281 heightValue = object->get(&state, Identifier::fromString(&state, "height"));
282 RETURN_IF_EXCEPTION(throwScope, { });
283 }
284 if (!heightValue.isUndefined()) {
285 result.height = convert<IDLDouble>(state, heightValue);
286 RETURN_IF_EXCEPTION(throwScope, { });
287 } else
288 result.height = 1;
289 JSValue isPrimaryValue;
290 if (isNullOrUndefined)
291 isPrimaryValue = jsUndefined();
292 else {
293 isPrimaryValue = object->get(&state, Identifier::fromString(&state, "isPrimary"));
294 RETURN_IF_EXCEPTION(throwScope, { });
295 }
296 if (!isPrimaryValue.isUndefined()) {
297 result.isPrimary = convert<IDLBoolean>(state, isPrimaryValue);
298 RETURN_IF_EXCEPTION(throwScope, { });
299 } else
300 result.isPrimary = false;
301 JSValue pointerIdValue;
302 if (isNullOrUndefined)
303 pointerIdValue = jsUndefined();
304 else {
305 pointerIdValue = object->get(&state, Identifier::fromString(&state, "pointerId"));
306 RETURN_IF_EXCEPTION(throwScope, { });
307 }
308 if (!pointerIdValue.isUndefined()) {
309 result.pointerId = convert<IDLLong>(state, pointerIdValue);
310 RETURN_IF_EXCEPTION(throwScope, { });
311 } else
312 result.pointerId = 0;
313 JSValue pointerTypeValue;
314 if (isNullOrUndefined)
315 pointerTypeValue = jsUndefined();
316 else {
317 pointerTypeValue = object->get(&state, Identifier::fromString(&state, "pointerType"));
318 RETURN_IF_EXCEPTION(throwScope, { });
319 }
320 if (!pointerTypeValue.isUndefined()) {
321 result.pointerType = convert<IDLDOMString>(state, pointerTypeValue);
322 RETURN_IF_EXCEPTION(throwScope, { });
323 } else
324 result.pointerType = emptyString();
325 JSValue pressureValue;
326 if (isNullOrUndefined)
327 pressureValue = jsUndefined();
328 else {
329 pressureValue = object->get(&state, Identifier::fromString(&state, "pressure"));
330 RETURN_IF_EXCEPTION(throwScope, { });
331 }
332 if (!pressureValue.isUndefined()) {
333 result.pressure = convert<IDLFloat>(state, pressureValue);
334 RETURN_IF_EXCEPTION(throwScope, { });
335 } else
336 result.pressure = 0;
337 JSValue tangentialPressureValue;
338 if (isNullOrUndefined)
339 tangentialPressureValue = jsUndefined();
340 else {
341 tangentialPressureValue = object->get(&state, Identifier::fromString(&state, "tangentialPressure"));
342 RETURN_IF_EXCEPTION(throwScope, { });
343 }
344 if (!tangentialPressureValue.isUndefined()) {
345 result.tangentialPressure = convert<IDLFloat>(state, tangentialPressureValue);
346 RETURN_IF_EXCEPTION(throwScope, { });
347 } else
348 result.tangentialPressure = 0;
349 JSValue tiltXValue;
350 if (isNullOrUndefined)
351 tiltXValue = jsUndefined();
352 else {
353 tiltXValue = object->get(&state, Identifier::fromString(&state, "tiltX"));
354 RETURN_IF_EXCEPTION(throwScope, { });
355 }
356 if (!tiltXValue.isUndefined()) {
357 result.tiltX = convert<IDLLong>(state, tiltXValue);
358 RETURN_IF_EXCEPTION(throwScope, { });
359 } else
360 result.tiltX = 0;
361 JSValue tiltYValue;
362 if (isNullOrUndefined)
363 tiltYValue = jsUndefined();
364 else {
365 tiltYValue = object->get(&state, Identifier::fromString(&state, "tiltY"));
366 RETURN_IF_EXCEPTION(throwScope, { });
367 }
368 if (!tiltYValue.isUndefined()) {
369 result.tiltY = convert<IDLLong>(state, tiltYValue);
370 RETURN_IF_EXCEPTION(throwScope, { });
371 } else
372 result.tiltY = 0;
373 JSValue twistValue;
374 if (isNullOrUndefined)
375 twistValue = jsUndefined();
376 else {
377 twistValue = object->get(&state, Identifier::fromString(&state, "twist"));
378 RETURN_IF_EXCEPTION(throwScope, { });
379 }
380 if (!twistValue.isUndefined()) {
381 result.twist = convert<IDLLong>(state, twistValue);
382 RETURN_IF_EXCEPTION(throwScope, { });
383 } else
384 result.twist = 0;
385 JSValue widthValue;
386 if (isNullOrUndefined)
387 widthValue = jsUndefined();
388 else {
389 widthValue = object->get(&state, Identifier::fromString(&state, "width"));
390 RETURN_IF_EXCEPTION(throwScope, { });
391 }
392 if (!widthValue.isUndefined()) {
393 result.width = convert<IDLDouble>(state, widthValue);
394 RETURN_IF_EXCEPTION(throwScope, { });
395 } else
396 result.width = 1;
397 return result;
398}
399
400// Attributes
401
402JSC::EncodedJSValue jsPointerEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
403bool setJSPointerEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
404JSC::EncodedJSValue jsPointerEventPointerId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
405JSC::EncodedJSValue jsPointerEventWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
406JSC::EncodedJSValue jsPointerEventHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
407JSC::EncodedJSValue jsPointerEventPressure(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
408JSC::EncodedJSValue jsPointerEventTangentialPressure(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
409JSC::EncodedJSValue jsPointerEventTiltX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
410JSC::EncodedJSValue jsPointerEventTiltY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
411JSC::EncodedJSValue jsPointerEventTwist(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
412JSC::EncodedJSValue jsPointerEventPointerType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
413JSC::EncodedJSValue jsPointerEventIsPrimary(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
414
415class JSPointerEventPrototype : public JSC::JSNonFinalObject {
416public:
417 using Base = JSC::JSNonFinalObject;
418 static JSPointerEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
419 {
420 JSPointerEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSPointerEventPrototype>(vm.heap)) JSPointerEventPrototype(vm, globalObject, structure);
421 ptr->finishCreation(vm);
422 return ptr;
423 }
424
425 DECLARE_INFO;
426 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
427 {
428 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
429 }
430
431private:
432 JSPointerEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
433 : JSC::JSNonFinalObject(vm, structure)
434 {
435 }
436
437 void finishCreation(JSC::VM&);
438};
439
440using JSPointerEventConstructor = JSDOMConstructor<JSPointerEvent>;
441
442template<> EncodedJSValue JSC_HOST_CALL JSPointerEventConstructor::construct(ExecState* state)
443{
444 VM& vm = state->vm();
445 auto throwScope = DECLARE_THROW_SCOPE(vm);
446 UNUSED_PARAM(throwScope);
447 auto* castedThis = jsCast<JSPointerEventConstructor*>(state->jsCallee());
448 ASSERT(castedThis);
449 if (UNLIKELY(state->argumentCount() < 1))
450 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
451 auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
452 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
453 auto eventInitDict = convert<IDLDictionary<PointerEvent::Init>>(*state, state->argument(1));
454 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
455 auto object = PointerEvent::create(WTFMove(type), WTFMove(eventInitDict));
456 return JSValue::encode(toJSNewlyCreated<IDLInterface<PointerEvent>>(*state, *castedThis->globalObject(), WTFMove(object)));
457}
458
459template<> JSValue JSPointerEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
460{
461 return JSMouseEvent::getConstructor(vm, &globalObject);
462}
463
464template<> void JSPointerEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
465{
466 putDirect(vm, vm.propertyNames->prototype, JSPointerEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
467 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("PointerEvent"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
468 putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
469}
470
471template<> const ClassInfo JSPointerEventConstructor::s_info = { "PointerEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPointerEventConstructor) };
472
473/* Hash table for prototype */
474
475static const HashTableValue JSPointerEventPrototypeTableValues[] =
476{
477 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPointerEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSPointerEventConstructor) } },
478 { "pointerId", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPointerEventPointerId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
479 { "width", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPointerEventWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
480 { "height", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPointerEventHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
481 { "pressure", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPointerEventPressure), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
482 { "tangentialPressure", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPointerEventTangentialPressure), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
483 { "tiltX", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPointerEventTiltX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
484 { "tiltY", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPointerEventTiltY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
485 { "twist", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPointerEventTwist), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
486 { "pointerType", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPointerEventPointerType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
487 { "isPrimary", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPointerEventIsPrimary), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
488};
489
490const ClassInfo JSPointerEventPrototype::s_info = { "PointerEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPointerEventPrototype) };
491
492void JSPointerEventPrototype::finishCreation(VM& vm)
493{
494 Base::finishCreation(vm);
495 reifyStaticProperties(vm, JSPointerEvent::info(), JSPointerEventPrototypeTableValues, *this);
496}
497
498const ClassInfo JSPointerEvent::s_info = { "PointerEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPointerEvent) };
499
500JSPointerEvent::JSPointerEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<PointerEvent>&& impl)
501 : JSMouseEvent(structure, globalObject, WTFMove(impl))
502{
503}
504
505void JSPointerEvent::finishCreation(VM& vm)
506{
507 Base::finishCreation(vm);
508 ASSERT(inherits(vm, info()));
509
510}
511
512JSObject* JSPointerEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
513{
514 return JSPointerEventPrototype::create(vm, &globalObject, JSPointerEventPrototype::createStructure(vm, &globalObject, JSMouseEvent::prototype(vm, globalObject)));
515}
516
517JSObject* JSPointerEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
518{
519 return getDOMPrototype<JSPointerEvent>(vm, globalObject);
520}
521
522JSValue JSPointerEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
523{
524 return getDOMConstructor<JSPointerEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
525}
526
527template<> inline JSPointerEvent* IDLAttribute<JSPointerEvent>::cast(ExecState& state, EncodedJSValue thisValue)
528{
529 return jsDynamicCast<JSPointerEvent*>(state.vm(), JSValue::decode(thisValue));
530}
531
532EncodedJSValue jsPointerEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
533{
534 VM& vm = state->vm();
535 auto throwScope = DECLARE_THROW_SCOPE(vm);
536 auto* prototype = jsDynamicCast<JSPointerEventPrototype*>(vm, JSValue::decode(thisValue));
537 if (UNLIKELY(!prototype))
538 return throwVMTypeError(state, throwScope);
539 return JSValue::encode(JSPointerEvent::getConstructor(state->vm(), prototype->globalObject()));
540}
541
542bool setJSPointerEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
543{
544 VM& vm = state->vm();
545 auto throwScope = DECLARE_THROW_SCOPE(vm);
546 auto* prototype = jsDynamicCast<JSPointerEventPrototype*>(vm, JSValue::decode(thisValue));
547 if (UNLIKELY(!prototype)) {
548 throwVMTypeError(state, throwScope);
549 return false;
550 }
551 // Shadowing a built-in constructor
552 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
553}
554
555static inline JSValue jsPointerEventPointerIdGetter(ExecState& state, JSPointerEvent& thisObject, ThrowScope& throwScope)
556{
557 UNUSED_PARAM(throwScope);
558 UNUSED_PARAM(state);
559 auto& impl = thisObject.wrapped();
560 JSValue result = toJS<IDLLong>(state, throwScope, impl.pointerId());
561 return result;
562}
563
564EncodedJSValue jsPointerEventPointerId(ExecState* state, EncodedJSValue thisValue, PropertyName)
565{
566 return IDLAttribute<JSPointerEvent>::get<jsPointerEventPointerIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pointerId");
567}
568
569static inline JSValue jsPointerEventWidthGetter(ExecState& state, JSPointerEvent& thisObject, ThrowScope& throwScope)
570{
571 UNUSED_PARAM(throwScope);
572 UNUSED_PARAM(state);
573 auto& impl = thisObject.wrapped();
574 JSValue result = toJS<IDLDouble>(state, throwScope, impl.width());
575 return result;
576}
577
578EncodedJSValue jsPointerEventWidth(ExecState* state, EncodedJSValue thisValue, PropertyName)
579{
580 return IDLAttribute<JSPointerEvent>::get<jsPointerEventWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "width");
581}
582
583static inline JSValue jsPointerEventHeightGetter(ExecState& state, JSPointerEvent& thisObject, ThrowScope& throwScope)
584{
585 UNUSED_PARAM(throwScope);
586 UNUSED_PARAM(state);
587 auto& impl = thisObject.wrapped();
588 JSValue result = toJS<IDLDouble>(state, throwScope, impl.height());
589 return result;
590}
591
592EncodedJSValue jsPointerEventHeight(ExecState* state, EncodedJSValue thisValue, PropertyName)
593{
594 return IDLAttribute<JSPointerEvent>::get<jsPointerEventHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "height");
595}
596
597static inline JSValue jsPointerEventPressureGetter(ExecState& state, JSPointerEvent& thisObject, ThrowScope& throwScope)
598{
599 UNUSED_PARAM(throwScope);
600 UNUSED_PARAM(state);
601 auto& impl = thisObject.wrapped();
602 JSValue result = toJS<IDLFloat>(state, throwScope, impl.pressure());
603 return result;
604}
605
606EncodedJSValue jsPointerEventPressure(ExecState* state, EncodedJSValue thisValue, PropertyName)
607{
608 return IDLAttribute<JSPointerEvent>::get<jsPointerEventPressureGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pressure");
609}
610
611static inline JSValue jsPointerEventTangentialPressureGetter(ExecState& state, JSPointerEvent& thisObject, ThrowScope& throwScope)
612{
613 UNUSED_PARAM(throwScope);
614 UNUSED_PARAM(state);
615 auto& impl = thisObject.wrapped();
616 JSValue result = toJS<IDLFloat>(state, throwScope, impl.tangentialPressure());
617 return result;
618}
619
620EncodedJSValue jsPointerEventTangentialPressure(ExecState* state, EncodedJSValue thisValue, PropertyName)
621{
622 return IDLAttribute<JSPointerEvent>::get<jsPointerEventTangentialPressureGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "tangentialPressure");
623}
624
625static inline JSValue jsPointerEventTiltXGetter(ExecState& state, JSPointerEvent& thisObject, ThrowScope& throwScope)
626{
627 UNUSED_PARAM(throwScope);
628 UNUSED_PARAM(state);
629 auto& impl = thisObject.wrapped();
630 JSValue result = toJS<IDLLong>(state, throwScope, impl.tiltX());
631 return result;
632}
633
634EncodedJSValue jsPointerEventTiltX(ExecState* state, EncodedJSValue thisValue, PropertyName)
635{
636 return IDLAttribute<JSPointerEvent>::get<jsPointerEventTiltXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "tiltX");
637}
638
639static inline JSValue jsPointerEventTiltYGetter(ExecState& state, JSPointerEvent& thisObject, ThrowScope& throwScope)
640{
641 UNUSED_PARAM(throwScope);
642 UNUSED_PARAM(state);
643 auto& impl = thisObject.wrapped();
644 JSValue result = toJS<IDLLong>(state, throwScope, impl.tiltY());
645 return result;
646}
647
648EncodedJSValue jsPointerEventTiltY(ExecState* state, EncodedJSValue thisValue, PropertyName)
649{
650 return IDLAttribute<JSPointerEvent>::get<jsPointerEventTiltYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "tiltY");
651}
652
653static inline JSValue jsPointerEventTwistGetter(ExecState& state, JSPointerEvent& thisObject, ThrowScope& throwScope)
654{
655 UNUSED_PARAM(throwScope);
656 UNUSED_PARAM(state);
657 auto& impl = thisObject.wrapped();
658 JSValue result = toJS<IDLLong>(state, throwScope, impl.twist());
659 return result;
660}
661
662EncodedJSValue jsPointerEventTwist(ExecState* state, EncodedJSValue thisValue, PropertyName)
663{
664 return IDLAttribute<JSPointerEvent>::get<jsPointerEventTwistGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "twist");
665}
666
667static inline JSValue jsPointerEventPointerTypeGetter(ExecState& state, JSPointerEvent& thisObject, ThrowScope& throwScope)
668{
669 UNUSED_PARAM(throwScope);
670 UNUSED_PARAM(state);
671 auto& impl = thisObject.wrapped();
672 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.pointerType());
673 return result;
674}
675
676EncodedJSValue jsPointerEventPointerType(ExecState* state, EncodedJSValue thisValue, PropertyName)
677{
678 return IDLAttribute<JSPointerEvent>::get<jsPointerEventPointerTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pointerType");
679}
680
681static inline JSValue jsPointerEventIsPrimaryGetter(ExecState& state, JSPointerEvent& thisObject, ThrowScope& throwScope)
682{
683 UNUSED_PARAM(throwScope);
684 UNUSED_PARAM(state);
685 auto& impl = thisObject.wrapped();
686 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.isPrimary());
687 return result;
688}
689
690EncodedJSValue jsPointerEventIsPrimary(ExecState* state, EncodedJSValue thisValue, PropertyName)
691{
692 return IDLAttribute<JSPointerEvent>::get<jsPointerEventIsPrimaryGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "isPrimary");
693}
694
695void JSPointerEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
696{
697 auto* thisObject = jsCast<JSPointerEvent*>(cell);
698 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
699 if (thisObject->scriptExecutionContext())
700 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
701 Base::heapSnapshot(cell, builder);
702}
703
704#if ENABLE(BINDING_INTEGRITY)
705#if PLATFORM(WIN)
706#pragma warning(disable: 4483)
707extern "C" { extern void (*const __identifier("??_7PointerEvent@WebCore@@6B@")[])(); }
708#else
709extern "C" { extern void* _ZTVN7WebCore12PointerEventE[]; }
710#endif
711#endif
712
713JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<PointerEvent>&& impl)
714{
715
716#if ENABLE(BINDING_INTEGRITY)
717 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
718#if PLATFORM(WIN)
719 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7PointerEvent@WebCore@@6B@"));
720#else
721 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore12PointerEventE[2]);
722#endif
723
724 // If this fails PointerEvent does not have a vtable, so you need to add the
725 // ImplementationLacksVTable attribute to the interface definition
726 static_assert(std::is_polymorphic<PointerEvent>::value, "PointerEvent is not polymorphic");
727
728 // If you hit this assertion you either have a use after free bug, or
729 // PointerEvent has subclasses. If PointerEvent has subclasses that get passed
730 // to toJS() we currently require PointerEvent you to opt out of binding hardening
731 // by adding the SkipVTableValidation attribute to the interface IDL definition
732 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
733#endif
734 return createWrapper<PointerEvent>(globalObject, WTFMove(impl));
735}
736
737JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, PointerEvent& impl)
738{
739 return wrap(state, globalObject, impl);
740}
741
742
743}
744
745#endif // ENABLE(POINTER_EVENTS)
746