| 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(TOUCH_EVENTS) |
| 24 | |
| 25 | #include "JSTouchEvent.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 "JSDOMGlobalObject.h" |
| 37 | #include "JSDOMOperation.h" |
| 38 | #include "JSDOMWrapperCache.h" |
| 39 | #include "JSTouchList.h" |
| 40 | #include "JSWindowProxy.h" |
| 41 | #include "ScriptExecutionContext.h" |
| 42 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 43 | #include <JavaScriptCore/JSCInlines.h> |
| 44 | #include <wtf/GetPtr.h> |
| 45 | #include <wtf/PointerPreparations.h> |
| 46 | #include <wtf/URL.h> |
| 47 | |
| 48 | |
| 49 | namespace WebCore { |
| 50 | using namespace JSC; |
| 51 | |
| 52 | template<> TouchEvent::Init convertDictionary<TouchEvent::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 | TouchEvent::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 changedTouchesValue; |
| 124 | if (isNullOrUndefined) |
| 125 | changedTouchesValue = jsUndefined(); |
| 126 | else { |
| 127 | changedTouchesValue = object->get(&state, Identifier::fromString(&state, "changedTouches" )); |
| 128 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 129 | } |
| 130 | if (!changedTouchesValue.isUndefined()) { |
| 131 | result.changedTouches = convert<IDLNullable<IDLInterface<TouchList>>>(state, changedTouchesValue); |
| 132 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 133 | } else |
| 134 | result.changedTouches = nullptr; |
| 135 | JSValue targetTouchesValue; |
| 136 | if (isNullOrUndefined) |
| 137 | targetTouchesValue = jsUndefined(); |
| 138 | else { |
| 139 | targetTouchesValue = object->get(&state, Identifier::fromString(&state, "targetTouches" )); |
| 140 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 141 | } |
| 142 | if (!targetTouchesValue.isUndefined()) { |
| 143 | result.targetTouches = convert<IDLNullable<IDLInterface<TouchList>>>(state, targetTouchesValue); |
| 144 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 145 | } else |
| 146 | result.targetTouches = nullptr; |
| 147 | JSValue touchesValue; |
| 148 | if (isNullOrUndefined) |
| 149 | touchesValue = jsUndefined(); |
| 150 | else { |
| 151 | touchesValue = object->get(&state, Identifier::fromString(&state, "touches" )); |
| 152 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 153 | } |
| 154 | if (!touchesValue.isUndefined()) { |
| 155 | result.touches = convert<IDLNullable<IDLInterface<TouchList>>>(state, touchesValue); |
| 156 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 157 | } else |
| 158 | result.touches = nullptr; |
| 159 | return result; |
| 160 | } |
| 161 | |
| 162 | // Functions |
| 163 | |
| 164 | JSC::EncodedJSValue JSC_HOST_CALL jsTouchEventPrototypeFunctionInitTouchEvent(JSC::ExecState*); |
| 165 | |
| 166 | // Attributes |
| 167 | |
| 168 | JSC::EncodedJSValue jsTouchEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 169 | bool setJSTouchEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 170 | JSC::EncodedJSValue jsTouchEventTouches(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 171 | JSC::EncodedJSValue jsTouchEventTargetTouches(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 172 | JSC::EncodedJSValue jsTouchEventChangedTouches(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 173 | JSC::EncodedJSValue jsTouchEventCtrlKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 174 | JSC::EncodedJSValue jsTouchEventShiftKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 175 | JSC::EncodedJSValue jsTouchEventAltKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 176 | JSC::EncodedJSValue jsTouchEventMetaKey(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 177 | |
| 178 | class JSTouchEventPrototype : public JSC::JSNonFinalObject { |
| 179 | public: |
| 180 | using Base = JSC::JSNonFinalObject; |
| 181 | static JSTouchEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 182 | { |
| 183 | JSTouchEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSTouchEventPrototype>(vm.heap)) JSTouchEventPrototype(vm, globalObject, structure); |
| 184 | ptr->finishCreation(vm); |
| 185 | return ptr; |
| 186 | } |
| 187 | |
| 188 | DECLARE_INFO; |
| 189 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 190 | { |
| 191 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 192 | } |
| 193 | |
| 194 | private: |
| 195 | JSTouchEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 196 | : JSC::JSNonFinalObject(vm, structure) |
| 197 | { |
| 198 | } |
| 199 | |
| 200 | void finishCreation(JSC::VM&); |
| 201 | }; |
| 202 | |
| 203 | using JSTouchEventConstructor = JSDOMConstructor<JSTouchEvent>; |
| 204 | |
| 205 | template<> EncodedJSValue JSC_HOST_CALL JSTouchEventConstructor::construct(ExecState* state) |
| 206 | { |
| 207 | VM& vm = state->vm(); |
| 208 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 209 | UNUSED_PARAM(throwScope); |
| 210 | auto* castedThis = jsCast<JSTouchEventConstructor*>(state->jsCallee()); |
| 211 | ASSERT(castedThis); |
| 212 | if (UNLIKELY(state->argumentCount() < 1)) |
| 213 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 214 | auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 215 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 216 | auto eventInitDict = convert<IDLDictionary<TouchEvent::Init>>(*state, state->argument(1)); |
| 217 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 218 | auto object = TouchEvent::create(WTFMove(type), WTFMove(eventInitDict)); |
| 219 | return JSValue::encode(toJSNewlyCreated<IDLInterface<TouchEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 220 | } |
| 221 | |
| 222 | template<> JSValue JSTouchEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 223 | { |
| 224 | return JSUIEvent::getConstructor(vm, &globalObject); |
| 225 | } |
| 226 | |
| 227 | template<> void JSTouchEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 228 | { |
| 229 | putDirect(vm, vm.propertyNames->prototype, JSTouchEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 230 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TouchEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 231 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 232 | } |
| 233 | |
| 234 | template<> const ClassInfo JSTouchEventConstructor::s_info = { "TouchEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTouchEventConstructor) }; |
| 235 | |
| 236 | /* Hash table for prototype */ |
| 237 | |
| 238 | static const HashTableValue JSTouchEventPrototypeTableValues[] = |
| 239 | { |
| 240 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTouchEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTouchEventConstructor) } }, |
| 241 | { "touches" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTouchEventTouches), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 242 | { "targetTouches" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTouchEventTargetTouches), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 243 | { "changedTouches" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTouchEventChangedTouches), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 244 | { "ctrlKey" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTouchEventCtrlKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 245 | { "shiftKey" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTouchEventShiftKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 246 | { "altKey" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTouchEventAltKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 247 | { "metaKey" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTouchEventMetaKey), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 248 | { "initTouchEvent" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTouchEventPrototypeFunctionInitTouchEvent), (intptr_t) (0) } }, |
| 249 | }; |
| 250 | |
| 251 | const ClassInfo JSTouchEventPrototype::s_info = { "TouchEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTouchEventPrototype) }; |
| 252 | |
| 253 | void JSTouchEventPrototype::finishCreation(VM& vm) |
| 254 | { |
| 255 | Base::finishCreation(vm); |
| 256 | reifyStaticProperties(vm, JSTouchEvent::info(), JSTouchEventPrototypeTableValues, *this); |
| 257 | } |
| 258 | |
| 259 | const ClassInfo JSTouchEvent::s_info = { "TouchEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTouchEvent) }; |
| 260 | |
| 261 | JSTouchEvent::JSTouchEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TouchEvent>&& impl) |
| 262 | : JSUIEvent(structure, globalObject, WTFMove(impl)) |
| 263 | { |
| 264 | } |
| 265 | |
| 266 | void JSTouchEvent::finishCreation(VM& vm) |
| 267 | { |
| 268 | Base::finishCreation(vm); |
| 269 | ASSERT(inherits(vm, info())); |
| 270 | |
| 271 | } |
| 272 | |
| 273 | JSObject* JSTouchEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 274 | { |
| 275 | return JSTouchEventPrototype::create(vm, &globalObject, JSTouchEventPrototype::createStructure(vm, &globalObject, JSUIEvent::prototype(vm, globalObject))); |
| 276 | } |
| 277 | |
| 278 | JSObject* JSTouchEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 279 | { |
| 280 | return getDOMPrototype<JSTouchEvent>(vm, globalObject); |
| 281 | } |
| 282 | |
| 283 | JSValue JSTouchEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 284 | { |
| 285 | return getDOMConstructor<JSTouchEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 286 | } |
| 287 | |
| 288 | template<> inline JSTouchEvent* IDLAttribute<JSTouchEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
| 289 | { |
| 290 | return jsDynamicCast<JSTouchEvent*>(state.vm(), JSValue::decode(thisValue)); |
| 291 | } |
| 292 | |
| 293 | template<> inline JSTouchEvent* IDLOperation<JSTouchEvent>::cast(ExecState& state) |
| 294 | { |
| 295 | return jsDynamicCast<JSTouchEvent*>(state.vm(), state.thisValue()); |
| 296 | } |
| 297 | |
| 298 | EncodedJSValue jsTouchEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 299 | { |
| 300 | VM& vm = state->vm(); |
| 301 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 302 | auto* prototype = jsDynamicCast<JSTouchEventPrototype*>(vm, JSValue::decode(thisValue)); |
| 303 | if (UNLIKELY(!prototype)) |
| 304 | return throwVMTypeError(state, throwScope); |
| 305 | return JSValue::encode(JSTouchEvent::getConstructor(state->vm(), prototype->globalObject())); |
| 306 | } |
| 307 | |
| 308 | bool setJSTouchEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 309 | { |
| 310 | VM& vm = state->vm(); |
| 311 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 312 | auto* prototype = jsDynamicCast<JSTouchEventPrototype*>(vm, JSValue::decode(thisValue)); |
| 313 | if (UNLIKELY(!prototype)) { |
| 314 | throwVMTypeError(state, throwScope); |
| 315 | return false; |
| 316 | } |
| 317 | // Shadowing a built-in constructor |
| 318 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 319 | } |
| 320 | |
| 321 | static inline JSValue jsTouchEventTouchesGetter(ExecState& state, JSTouchEvent& thisObject, ThrowScope& throwScope) |
| 322 | { |
| 323 | UNUSED_PARAM(throwScope); |
| 324 | UNUSED_PARAM(state); |
| 325 | auto& impl = thisObject.wrapped(); |
| 326 | JSValue result = toJS<IDLInterface<TouchList>>(state, *thisObject.globalObject(), throwScope, impl.touches()); |
| 327 | return result; |
| 328 | } |
| 329 | |
| 330 | EncodedJSValue jsTouchEventTouches(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 331 | { |
| 332 | return IDLAttribute<JSTouchEvent>::get<jsTouchEventTouchesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "touches" ); |
| 333 | } |
| 334 | |
| 335 | static inline JSValue jsTouchEventTargetTouchesGetter(ExecState& state, JSTouchEvent& thisObject, ThrowScope& throwScope) |
| 336 | { |
| 337 | UNUSED_PARAM(throwScope); |
| 338 | UNUSED_PARAM(state); |
| 339 | auto& impl = thisObject.wrapped(); |
| 340 | JSValue result = toJS<IDLInterface<TouchList>>(state, *thisObject.globalObject(), throwScope, impl.targetTouches()); |
| 341 | return result; |
| 342 | } |
| 343 | |
| 344 | EncodedJSValue jsTouchEventTargetTouches(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 345 | { |
| 346 | return IDLAttribute<JSTouchEvent>::get<jsTouchEventTargetTouchesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "targetTouches" ); |
| 347 | } |
| 348 | |
| 349 | static inline JSValue jsTouchEventChangedTouchesGetter(ExecState& state, JSTouchEvent& thisObject, ThrowScope& throwScope) |
| 350 | { |
| 351 | UNUSED_PARAM(throwScope); |
| 352 | UNUSED_PARAM(state); |
| 353 | auto& impl = thisObject.wrapped(); |
| 354 | JSValue result = toJS<IDLInterface<TouchList>>(state, *thisObject.globalObject(), throwScope, impl.changedTouches()); |
| 355 | return result; |
| 356 | } |
| 357 | |
| 358 | EncodedJSValue jsTouchEventChangedTouches(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 359 | { |
| 360 | return IDLAttribute<JSTouchEvent>::get<jsTouchEventChangedTouchesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "changedTouches" ); |
| 361 | } |
| 362 | |
| 363 | static inline JSValue jsTouchEventCtrlKeyGetter(ExecState& state, JSTouchEvent& thisObject, ThrowScope& throwScope) |
| 364 | { |
| 365 | UNUSED_PARAM(throwScope); |
| 366 | UNUSED_PARAM(state); |
| 367 | auto& impl = thisObject.wrapped(); |
| 368 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.ctrlKey()); |
| 369 | return result; |
| 370 | } |
| 371 | |
| 372 | EncodedJSValue jsTouchEventCtrlKey(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 373 | { |
| 374 | return IDLAttribute<JSTouchEvent>::get<jsTouchEventCtrlKeyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "ctrlKey" ); |
| 375 | } |
| 376 | |
| 377 | static inline JSValue jsTouchEventShiftKeyGetter(ExecState& state, JSTouchEvent& thisObject, ThrowScope& throwScope) |
| 378 | { |
| 379 | UNUSED_PARAM(throwScope); |
| 380 | UNUSED_PARAM(state); |
| 381 | auto& impl = thisObject.wrapped(); |
| 382 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.shiftKey()); |
| 383 | return result; |
| 384 | } |
| 385 | |
| 386 | EncodedJSValue jsTouchEventShiftKey(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 387 | { |
| 388 | return IDLAttribute<JSTouchEvent>::get<jsTouchEventShiftKeyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "shiftKey" ); |
| 389 | } |
| 390 | |
| 391 | static inline JSValue jsTouchEventAltKeyGetter(ExecState& state, JSTouchEvent& thisObject, ThrowScope& throwScope) |
| 392 | { |
| 393 | UNUSED_PARAM(throwScope); |
| 394 | UNUSED_PARAM(state); |
| 395 | auto& impl = thisObject.wrapped(); |
| 396 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.altKey()); |
| 397 | return result; |
| 398 | } |
| 399 | |
| 400 | EncodedJSValue jsTouchEventAltKey(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 401 | { |
| 402 | return IDLAttribute<JSTouchEvent>::get<jsTouchEventAltKeyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "altKey" ); |
| 403 | } |
| 404 | |
| 405 | static inline JSValue jsTouchEventMetaKeyGetter(ExecState& state, JSTouchEvent& thisObject, ThrowScope& throwScope) |
| 406 | { |
| 407 | UNUSED_PARAM(throwScope); |
| 408 | UNUSED_PARAM(state); |
| 409 | auto& impl = thisObject.wrapped(); |
| 410 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.metaKey()); |
| 411 | return result; |
| 412 | } |
| 413 | |
| 414 | EncodedJSValue jsTouchEventMetaKey(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 415 | { |
| 416 | return IDLAttribute<JSTouchEvent>::get<jsTouchEventMetaKeyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "metaKey" ); |
| 417 | } |
| 418 | |
| 419 | static inline JSC::EncodedJSValue jsTouchEventPrototypeFunctionInitTouchEventBody(JSC::ExecState* state, typename IDLOperation<JSTouchEvent>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 420 | { |
| 421 | UNUSED_PARAM(state); |
| 422 | UNUSED_PARAM(throwScope); |
| 423 | auto& impl = castedThis->wrapped(); |
| 424 | auto touches = convert<IDLNullable<IDLInterface<TouchList>>>(*state, state->argument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "touches" , "TouchEvent" , "initTouchEvent" , "TouchList" ); }); |
| 425 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 426 | auto targetTouches = convert<IDLNullable<IDLInterface<TouchList>>>(*state, state->argument(1), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 1, "targetTouches" , "TouchEvent" , "initTouchEvent" , "TouchList" ); }); |
| 427 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 428 | auto changedTouches = convert<IDLNullable<IDLInterface<TouchList>>>(*state, state->argument(2), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 2, "changedTouches" , "TouchEvent" , "initTouchEvent" , "TouchList" ); }); |
| 429 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 430 | auto type = convert<IDLDOMString>(*state, state->argument(3)); |
| 431 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 432 | auto view = convert<IDLNullable<IDLInterface<WindowProxy>>>(*state, state->argument(4), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 4, "view" , "TouchEvent" , "initTouchEvent" , "WindowProxy" ); }); |
| 433 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 434 | auto screenX = convert<IDLLong>(*state, state->argument(5)); |
| 435 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 436 | auto screenY = convert<IDLLong>(*state, state->argument(6)); |
| 437 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 438 | auto clientX = convert<IDLLong>(*state, state->argument(7)); |
| 439 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 440 | auto clientY = convert<IDLLong>(*state, state->argument(8)); |
| 441 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 442 | auto ctrlKey = convert<IDLBoolean>(*state, state->argument(9)); |
| 443 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 444 | auto altKey = convert<IDLBoolean>(*state, state->argument(10)); |
| 445 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 446 | auto shiftKey = convert<IDLBoolean>(*state, state->argument(11)); |
| 447 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 448 | auto metaKey = convert<IDLBoolean>(*state, state->argument(12)); |
| 449 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 450 | impl.initTouchEvent(WTFMove(touches), WTFMove(targetTouches), WTFMove(changedTouches), WTFMove(type), WTFMove(view), WTFMove(screenX), WTFMove(screenY), WTFMove(clientX), WTFMove(clientY), WTFMove(ctrlKey), WTFMove(altKey), WTFMove(shiftKey), WTFMove(metaKey)); |
| 451 | return JSValue::encode(jsUndefined()); |
| 452 | } |
| 453 | |
| 454 | EncodedJSValue JSC_HOST_CALL jsTouchEventPrototypeFunctionInitTouchEvent(ExecState* state) |
| 455 | { |
| 456 | return IDLOperation<JSTouchEvent>::call<jsTouchEventPrototypeFunctionInitTouchEventBody>(*state, "initTouchEvent" ); |
| 457 | } |
| 458 | |
| 459 | void JSTouchEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 460 | { |
| 461 | auto* thisObject = jsCast<JSTouchEvent*>(cell); |
| 462 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 463 | if (thisObject->scriptExecutionContext()) |
| 464 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 465 | Base::heapSnapshot(cell, builder); |
| 466 | } |
| 467 | |
| 468 | #if ENABLE(BINDING_INTEGRITY) |
| 469 | #if PLATFORM(WIN) |
| 470 | #pragma warning(disable: 4483) |
| 471 | extern "C" { extern void (*const __identifier("??_7TouchEvent@WebCore@@6B@" )[])(); } |
| 472 | #else |
| 473 | extern "C" { extern void* _ZTVN7WebCore10TouchEventE[]; } |
| 474 | #endif |
| 475 | #endif |
| 476 | |
| 477 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TouchEvent>&& impl) |
| 478 | { |
| 479 | |
| 480 | #if ENABLE(BINDING_INTEGRITY) |
| 481 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 482 | #if PLATFORM(WIN) |
| 483 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TouchEvent@WebCore@@6B@" )); |
| 484 | #else |
| 485 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore10TouchEventE[2]); |
| 486 | #endif |
| 487 | |
| 488 | // If this fails TouchEvent does not have a vtable, so you need to add the |
| 489 | // ImplementationLacksVTable attribute to the interface definition |
| 490 | static_assert(std::is_polymorphic<TouchEvent>::value, "TouchEvent is not polymorphic" ); |
| 491 | |
| 492 | // If you hit this assertion you either have a use after free bug, or |
| 493 | // TouchEvent has subclasses. If TouchEvent has subclasses that get passed |
| 494 | // to toJS() we currently require TouchEvent you to opt out of binding hardening |
| 495 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 496 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 497 | #endif |
| 498 | return createWrapper<TouchEvent>(globalObject, WTFMove(impl)); |
| 499 | } |
| 500 | |
| 501 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TouchEvent& impl) |
| 502 | { |
| 503 | return wrap(state, globalObject, impl); |
| 504 | } |
| 505 | |
| 506 | |
| 507 | } |
| 508 | |
| 509 | #endif // ENABLE(TOUCH_EVENTS) |
| 510 | |