| 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 "JSPath2D.h" |
| 23 | |
| 24 | #include "JSDOMAttribute.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructor.h" |
| 27 | #include "JSDOMConvertBoolean.h" |
| 28 | #include "JSDOMConvertDictionary.h" |
| 29 | #include "JSDOMConvertInterface.h" |
| 30 | #include "JSDOMConvertNumbers.h" |
| 31 | #include "JSDOMConvertStrings.h" |
| 32 | #include "JSDOMExceptionHandling.h" |
| 33 | #include "JSDOMMatrix2DInit.h" |
| 34 | #include "JSDOMOperation.h" |
| 35 | #include "JSDOMWrapperCache.h" |
| 36 | #include "JSPath2D.h" |
| 37 | #include "RuntimeEnabledFeatures.h" |
| 38 | #include "ScriptExecutionContext.h" |
| 39 | #include <JavaScriptCore/FunctionPrototype.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 | |
| 47 | namespace WebCore { |
| 48 | using namespace JSC; |
| 49 | |
| 50 | // Functions |
| 51 | |
| 52 | JSC::EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionAddPath(JSC::ExecState*); |
| 53 | JSC::EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionClosePath(JSC::ExecState*); |
| 54 | JSC::EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionMoveTo(JSC::ExecState*); |
| 55 | JSC::EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionLineTo(JSC::ExecState*); |
| 56 | JSC::EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionQuadraticCurveTo(JSC::ExecState*); |
| 57 | JSC::EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionBezierCurveTo(JSC::ExecState*); |
| 58 | JSC::EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionArcTo(JSC::ExecState*); |
| 59 | JSC::EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionRect(JSC::ExecState*); |
| 60 | JSC::EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionArc(JSC::ExecState*); |
| 61 | JSC::EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionEllipse(JSC::ExecState*); |
| 62 | |
| 63 | // Attributes |
| 64 | |
| 65 | JSC::EncodedJSValue jsPath2DConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 66 | bool setJSPath2DConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 67 | JSC::EncodedJSValue jsPath2DCurrentX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 68 | JSC::EncodedJSValue jsPath2DCurrentY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 69 | |
| 70 | class JSPath2DPrototype : public JSC::JSNonFinalObject { |
| 71 | public: |
| 72 | using Base = JSC::JSNonFinalObject; |
| 73 | static JSPath2DPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 74 | { |
| 75 | JSPath2DPrototype* ptr = new (NotNull, JSC::allocateCell<JSPath2DPrototype>(vm.heap)) JSPath2DPrototype(vm, globalObject, structure); |
| 76 | ptr->finishCreation(vm); |
| 77 | return ptr; |
| 78 | } |
| 79 | |
| 80 | DECLARE_INFO; |
| 81 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 82 | { |
| 83 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 84 | } |
| 85 | |
| 86 | private: |
| 87 | JSPath2DPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 88 | : JSC::JSNonFinalObject(vm, structure) |
| 89 | { |
| 90 | } |
| 91 | |
| 92 | void finishCreation(JSC::VM&); |
| 93 | }; |
| 94 | |
| 95 | using JSPath2DConstructor = JSDOMConstructor<JSPath2D>; |
| 96 | |
| 97 | static inline EncodedJSValue constructJSPath2D1(ExecState* state) |
| 98 | { |
| 99 | VM& vm = state->vm(); |
| 100 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 101 | UNUSED_PARAM(throwScope); |
| 102 | auto* castedThis = jsCast<JSPath2DConstructor*>(state->jsCallee()); |
| 103 | ASSERT(castedThis); |
| 104 | auto object = Path2D::create(); |
| 105 | return JSValue::encode(toJSNewlyCreated<IDLInterface<Path2D>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 106 | } |
| 107 | |
| 108 | static inline EncodedJSValue constructJSPath2D2(ExecState* state) |
| 109 | { |
| 110 | VM& vm = state->vm(); |
| 111 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 112 | UNUSED_PARAM(throwScope); |
| 113 | auto* castedThis = jsCast<JSPath2DConstructor*>(state->jsCallee()); |
| 114 | ASSERT(castedThis); |
| 115 | auto path = convert<IDLInterface<Path2D>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "path" , "Path2D" , nullptr, "Path2D" ); }); |
| 116 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 117 | auto object = Path2D::create(*path); |
| 118 | return JSValue::encode(toJSNewlyCreated<IDLInterface<Path2D>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 119 | } |
| 120 | |
| 121 | static inline EncodedJSValue constructJSPath2D3(ExecState* state) |
| 122 | { |
| 123 | VM& vm = state->vm(); |
| 124 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 125 | UNUSED_PARAM(throwScope); |
| 126 | auto* castedThis = jsCast<JSPath2DConstructor*>(state->jsCallee()); |
| 127 | ASSERT(castedThis); |
| 128 | auto d = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 129 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 130 | auto object = Path2D::create(WTFMove(d)); |
| 131 | return JSValue::encode(toJSNewlyCreated<IDLInterface<Path2D>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 132 | } |
| 133 | |
| 134 | template<> EncodedJSValue JSC_HOST_CALL JSPath2DConstructor::construct(ExecState* state) |
| 135 | { |
| 136 | VM& vm = state->vm(); |
| 137 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 138 | UNUSED_PARAM(throwScope); |
| 139 | size_t argsCount = std::min<size_t>(1, state->argumentCount()); |
| 140 | if (argsCount == 0) { |
| 141 | return constructJSPath2D1(state); |
| 142 | } |
| 143 | if (argsCount == 1) { |
| 144 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 145 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSPath2D>(vm)) |
| 146 | return constructJSPath2D2(state); |
| 147 | return constructJSPath2D3(state); |
| 148 | } |
| 149 | return throwVMTypeError(state, throwScope); |
| 150 | } |
| 151 | |
| 152 | template<> JSValue JSPath2DConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 153 | { |
| 154 | UNUSED_PARAM(vm); |
| 155 | return globalObject.functionPrototype(); |
| 156 | } |
| 157 | |
| 158 | template<> void JSPath2DConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 159 | { |
| 160 | putDirect(vm, vm.propertyNames->prototype, JSPath2D::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 161 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Path2D"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 162 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 163 | } |
| 164 | |
| 165 | template<> const ClassInfo JSPath2DConstructor::s_info = { "Path2D" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPath2DConstructor) }; |
| 166 | |
| 167 | /* Hash table for prototype */ |
| 168 | |
| 169 | static const HashTableValue JSPath2DPrototypeTableValues[] = |
| 170 | { |
| 171 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPath2DConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSPath2DConstructor) } }, |
| 172 | { "currentX" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPath2DCurrentX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 173 | { "currentY" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPath2DCurrentY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 174 | { "addPath" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPath2DPrototypeFunctionAddPath), (intptr_t) (1) } }, |
| 175 | { "closePath" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPath2DPrototypeFunctionClosePath), (intptr_t) (0) } }, |
| 176 | { "moveTo" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPath2DPrototypeFunctionMoveTo), (intptr_t) (2) } }, |
| 177 | { "lineTo" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPath2DPrototypeFunctionLineTo), (intptr_t) (2) } }, |
| 178 | { "quadraticCurveTo" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPath2DPrototypeFunctionQuadraticCurveTo), (intptr_t) (4) } }, |
| 179 | { "bezierCurveTo" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPath2DPrototypeFunctionBezierCurveTo), (intptr_t) (6) } }, |
| 180 | { "arcTo" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPath2DPrototypeFunctionArcTo), (intptr_t) (5) } }, |
| 181 | { "rect" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPath2DPrototypeFunctionRect), (intptr_t) (4) } }, |
| 182 | { "arc" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPath2DPrototypeFunctionArc), (intptr_t) (5) } }, |
| 183 | { "ellipse" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsPath2DPrototypeFunctionEllipse), (intptr_t) (7) } }, |
| 184 | }; |
| 185 | |
| 186 | const ClassInfo JSPath2DPrototype::s_info = { "Path2DPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPath2DPrototype) }; |
| 187 | |
| 188 | void JSPath2DPrototype::finishCreation(VM& vm) |
| 189 | { |
| 190 | Base::finishCreation(vm); |
| 191 | reifyStaticProperties(vm, JSPath2D::info(), JSPath2DPrototypeTableValues, *this); |
| 192 | bool hasDisabledRuntimeProperties = false; |
| 193 | if (!RuntimeEnabledFeatures::sharedFeatures().inspectorAdditionsEnabled()) { |
| 194 | hasDisabledRuntimeProperties = true; |
| 195 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("currentX" ), strlen("currentX" )); |
| 196 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 197 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 198 | } |
| 199 | if (!RuntimeEnabledFeatures::sharedFeatures().inspectorAdditionsEnabled()) { |
| 200 | hasDisabledRuntimeProperties = true; |
| 201 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("currentY" ), strlen("currentY" )); |
| 202 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 203 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 204 | } |
| 205 | if (hasDisabledRuntimeProperties && structure()->isDictionary()) |
| 206 | flattenDictionaryObject(vm); |
| 207 | } |
| 208 | |
| 209 | const ClassInfo JSPath2D::s_info = { "Path2D" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPath2D) }; |
| 210 | |
| 211 | JSPath2D::JSPath2D(Structure* structure, JSDOMGlobalObject& globalObject, Ref<Path2D>&& impl) |
| 212 | : JSDOMWrapper<Path2D>(structure, globalObject, WTFMove(impl)) |
| 213 | { |
| 214 | } |
| 215 | |
| 216 | void JSPath2D::finishCreation(VM& vm) |
| 217 | { |
| 218 | Base::finishCreation(vm); |
| 219 | ASSERT(inherits(vm, info())); |
| 220 | |
| 221 | } |
| 222 | |
| 223 | JSObject* JSPath2D::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 224 | { |
| 225 | return JSPath2DPrototype::create(vm, &globalObject, JSPath2DPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 226 | } |
| 227 | |
| 228 | JSObject* JSPath2D::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 229 | { |
| 230 | return getDOMPrototype<JSPath2D>(vm, globalObject); |
| 231 | } |
| 232 | |
| 233 | JSValue JSPath2D::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 234 | { |
| 235 | return getDOMConstructor<JSPath2DConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 236 | } |
| 237 | |
| 238 | void JSPath2D::destroy(JSC::JSCell* cell) |
| 239 | { |
| 240 | JSPath2D* thisObject = static_cast<JSPath2D*>(cell); |
| 241 | thisObject->JSPath2D::~JSPath2D(); |
| 242 | } |
| 243 | |
| 244 | template<> inline JSPath2D* IDLAttribute<JSPath2D>::cast(ExecState& state, EncodedJSValue thisValue) |
| 245 | { |
| 246 | return jsDynamicCast<JSPath2D*>(state.vm(), JSValue::decode(thisValue)); |
| 247 | } |
| 248 | |
| 249 | template<> inline JSPath2D* IDLOperation<JSPath2D>::cast(ExecState& state) |
| 250 | { |
| 251 | return jsDynamicCast<JSPath2D*>(state.vm(), state.thisValue()); |
| 252 | } |
| 253 | |
| 254 | EncodedJSValue jsPath2DConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 255 | { |
| 256 | VM& vm = state->vm(); |
| 257 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 258 | auto* prototype = jsDynamicCast<JSPath2DPrototype*>(vm, JSValue::decode(thisValue)); |
| 259 | if (UNLIKELY(!prototype)) |
| 260 | return throwVMTypeError(state, throwScope); |
| 261 | return JSValue::encode(JSPath2D::getConstructor(state->vm(), prototype->globalObject())); |
| 262 | } |
| 263 | |
| 264 | bool setJSPath2DConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 265 | { |
| 266 | VM& vm = state->vm(); |
| 267 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 268 | auto* prototype = jsDynamicCast<JSPath2DPrototype*>(vm, JSValue::decode(thisValue)); |
| 269 | if (UNLIKELY(!prototype)) { |
| 270 | throwVMTypeError(state, throwScope); |
| 271 | return false; |
| 272 | } |
| 273 | // Shadowing a built-in constructor |
| 274 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 275 | } |
| 276 | |
| 277 | static inline JSValue jsPath2DCurrentXGetter(ExecState& state, JSPath2D& thisObject, ThrowScope& throwScope) |
| 278 | { |
| 279 | UNUSED_PARAM(throwScope); |
| 280 | UNUSED_PARAM(state); |
| 281 | auto& impl = thisObject.wrapped(); |
| 282 | JSValue result = toJS<IDLFloat>(state, throwScope, impl.currentX()); |
| 283 | return result; |
| 284 | } |
| 285 | |
| 286 | EncodedJSValue jsPath2DCurrentX(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 287 | { |
| 288 | return IDLAttribute<JSPath2D>::get<jsPath2DCurrentXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "currentX" ); |
| 289 | } |
| 290 | |
| 291 | static inline JSValue jsPath2DCurrentYGetter(ExecState& state, JSPath2D& thisObject, ThrowScope& throwScope) |
| 292 | { |
| 293 | UNUSED_PARAM(throwScope); |
| 294 | UNUSED_PARAM(state); |
| 295 | auto& impl = thisObject.wrapped(); |
| 296 | JSValue result = toJS<IDLFloat>(state, throwScope, impl.currentY()); |
| 297 | return result; |
| 298 | } |
| 299 | |
| 300 | EncodedJSValue jsPath2DCurrentY(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 301 | { |
| 302 | return IDLAttribute<JSPath2D>::get<jsPath2DCurrentYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "currentY" ); |
| 303 | } |
| 304 | |
| 305 | static inline JSC::EncodedJSValue jsPath2DPrototypeFunctionAddPathBody(JSC::ExecState* state, typename IDLOperation<JSPath2D>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 306 | { |
| 307 | UNUSED_PARAM(state); |
| 308 | UNUSED_PARAM(throwScope); |
| 309 | auto& impl = castedThis->wrapped(); |
| 310 | if (UNLIKELY(state->argumentCount() < 1)) |
| 311 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 312 | auto path = convert<IDLInterface<Path2D>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "path" , "Path2D" , "addPath" , "Path2D" ); }); |
| 313 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 314 | auto transform = convert<IDLDictionary<DOMMatrix2DInit>>(*state, state->argument(1)); |
| 315 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 316 | propagateException(*state, throwScope, impl.addPath(*path, WTFMove(transform))); |
| 317 | return JSValue::encode(jsUndefined()); |
| 318 | } |
| 319 | |
| 320 | EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionAddPath(ExecState* state) |
| 321 | { |
| 322 | return IDLOperation<JSPath2D>::call<jsPath2DPrototypeFunctionAddPathBody>(*state, "addPath" ); |
| 323 | } |
| 324 | |
| 325 | static inline JSC::EncodedJSValue jsPath2DPrototypeFunctionClosePathBody(JSC::ExecState* state, typename IDLOperation<JSPath2D>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 326 | { |
| 327 | UNUSED_PARAM(state); |
| 328 | UNUSED_PARAM(throwScope); |
| 329 | auto& impl = castedThis->wrapped(); |
| 330 | impl.closePath(); |
| 331 | return JSValue::encode(jsUndefined()); |
| 332 | } |
| 333 | |
| 334 | EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionClosePath(ExecState* state) |
| 335 | { |
| 336 | return IDLOperation<JSPath2D>::call<jsPath2DPrototypeFunctionClosePathBody>(*state, "closePath" ); |
| 337 | } |
| 338 | |
| 339 | static inline JSC::EncodedJSValue jsPath2DPrototypeFunctionMoveToBody(JSC::ExecState* state, typename IDLOperation<JSPath2D>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 340 | { |
| 341 | UNUSED_PARAM(state); |
| 342 | UNUSED_PARAM(throwScope); |
| 343 | auto& impl = castedThis->wrapped(); |
| 344 | if (UNLIKELY(state->argumentCount() < 2)) |
| 345 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 346 | auto x = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
| 347 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 348 | auto y = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
| 349 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 350 | impl.moveTo(WTFMove(x), WTFMove(y)); |
| 351 | return JSValue::encode(jsUndefined()); |
| 352 | } |
| 353 | |
| 354 | EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionMoveTo(ExecState* state) |
| 355 | { |
| 356 | return IDLOperation<JSPath2D>::call<jsPath2DPrototypeFunctionMoveToBody>(*state, "moveTo" ); |
| 357 | } |
| 358 | |
| 359 | static inline JSC::EncodedJSValue jsPath2DPrototypeFunctionLineToBody(JSC::ExecState* state, typename IDLOperation<JSPath2D>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 360 | { |
| 361 | UNUSED_PARAM(state); |
| 362 | UNUSED_PARAM(throwScope); |
| 363 | auto& impl = castedThis->wrapped(); |
| 364 | if (UNLIKELY(state->argumentCount() < 2)) |
| 365 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 366 | auto x = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
| 367 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 368 | auto y = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
| 369 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 370 | impl.lineTo(WTFMove(x), WTFMove(y)); |
| 371 | return JSValue::encode(jsUndefined()); |
| 372 | } |
| 373 | |
| 374 | EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionLineTo(ExecState* state) |
| 375 | { |
| 376 | return IDLOperation<JSPath2D>::call<jsPath2DPrototypeFunctionLineToBody>(*state, "lineTo" ); |
| 377 | } |
| 378 | |
| 379 | static inline JSC::EncodedJSValue jsPath2DPrototypeFunctionQuadraticCurveToBody(JSC::ExecState* state, typename IDLOperation<JSPath2D>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 380 | { |
| 381 | UNUSED_PARAM(state); |
| 382 | UNUSED_PARAM(throwScope); |
| 383 | auto& impl = castedThis->wrapped(); |
| 384 | if (UNLIKELY(state->argumentCount() < 4)) |
| 385 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 386 | auto cpx = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
| 387 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 388 | auto cpy = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
| 389 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 390 | auto x = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(2)); |
| 391 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 392 | auto y = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(3)); |
| 393 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 394 | impl.quadraticCurveTo(WTFMove(cpx), WTFMove(cpy), WTFMove(x), WTFMove(y)); |
| 395 | return JSValue::encode(jsUndefined()); |
| 396 | } |
| 397 | |
| 398 | EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionQuadraticCurveTo(ExecState* state) |
| 399 | { |
| 400 | return IDLOperation<JSPath2D>::call<jsPath2DPrototypeFunctionQuadraticCurveToBody>(*state, "quadraticCurveTo" ); |
| 401 | } |
| 402 | |
| 403 | static inline JSC::EncodedJSValue jsPath2DPrototypeFunctionBezierCurveToBody(JSC::ExecState* state, typename IDLOperation<JSPath2D>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 404 | { |
| 405 | UNUSED_PARAM(state); |
| 406 | UNUSED_PARAM(throwScope); |
| 407 | auto& impl = castedThis->wrapped(); |
| 408 | if (UNLIKELY(state->argumentCount() < 6)) |
| 409 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 410 | auto cp1x = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
| 411 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 412 | auto cp1y = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
| 413 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 414 | auto cp2x = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(2)); |
| 415 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 416 | auto cp2y = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(3)); |
| 417 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 418 | auto x = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(4)); |
| 419 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 420 | auto y = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(5)); |
| 421 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 422 | impl.bezierCurveTo(WTFMove(cp1x), WTFMove(cp1y), WTFMove(cp2x), WTFMove(cp2y), WTFMove(x), WTFMove(y)); |
| 423 | return JSValue::encode(jsUndefined()); |
| 424 | } |
| 425 | |
| 426 | EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionBezierCurveTo(ExecState* state) |
| 427 | { |
| 428 | return IDLOperation<JSPath2D>::call<jsPath2DPrototypeFunctionBezierCurveToBody>(*state, "bezierCurveTo" ); |
| 429 | } |
| 430 | |
| 431 | static inline JSC::EncodedJSValue jsPath2DPrototypeFunctionArcToBody(JSC::ExecState* state, typename IDLOperation<JSPath2D>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 432 | { |
| 433 | UNUSED_PARAM(state); |
| 434 | UNUSED_PARAM(throwScope); |
| 435 | auto& impl = castedThis->wrapped(); |
| 436 | if (UNLIKELY(state->argumentCount() < 5)) |
| 437 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 438 | auto x1 = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
| 439 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 440 | auto y1 = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
| 441 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 442 | auto x2 = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(2)); |
| 443 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 444 | auto y2 = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(3)); |
| 445 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 446 | auto radius = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(4)); |
| 447 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 448 | propagateException(*state, throwScope, impl.arcTo(WTFMove(x1), WTFMove(y1), WTFMove(x2), WTFMove(y2), WTFMove(radius))); |
| 449 | return JSValue::encode(jsUndefined()); |
| 450 | } |
| 451 | |
| 452 | EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionArcTo(ExecState* state) |
| 453 | { |
| 454 | return IDLOperation<JSPath2D>::call<jsPath2DPrototypeFunctionArcToBody>(*state, "arcTo" ); |
| 455 | } |
| 456 | |
| 457 | static inline JSC::EncodedJSValue jsPath2DPrototypeFunctionRectBody(JSC::ExecState* state, typename IDLOperation<JSPath2D>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 458 | { |
| 459 | UNUSED_PARAM(state); |
| 460 | UNUSED_PARAM(throwScope); |
| 461 | auto& impl = castedThis->wrapped(); |
| 462 | if (UNLIKELY(state->argumentCount() < 4)) |
| 463 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 464 | auto x = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
| 465 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 466 | auto y = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
| 467 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 468 | auto w = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(2)); |
| 469 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 470 | auto h = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(3)); |
| 471 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 472 | impl.rect(WTFMove(x), WTFMove(y), WTFMove(w), WTFMove(h)); |
| 473 | return JSValue::encode(jsUndefined()); |
| 474 | } |
| 475 | |
| 476 | EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionRect(ExecState* state) |
| 477 | { |
| 478 | return IDLOperation<JSPath2D>::call<jsPath2DPrototypeFunctionRectBody>(*state, "rect" ); |
| 479 | } |
| 480 | |
| 481 | static inline JSC::EncodedJSValue jsPath2DPrototypeFunctionArcBody(JSC::ExecState* state, typename IDLOperation<JSPath2D>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 482 | { |
| 483 | UNUSED_PARAM(state); |
| 484 | UNUSED_PARAM(throwScope); |
| 485 | auto& impl = castedThis->wrapped(); |
| 486 | if (UNLIKELY(state->argumentCount() < 5)) |
| 487 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 488 | auto x = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
| 489 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 490 | auto y = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
| 491 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 492 | auto radius = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(2)); |
| 493 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 494 | auto startAngle = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(3)); |
| 495 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 496 | auto endAngle = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(4)); |
| 497 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 498 | auto anticlockwise = convert<IDLBoolean>(*state, state->argument(5)); |
| 499 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 500 | propagateException(*state, throwScope, impl.arc(WTFMove(x), WTFMove(y), WTFMove(radius), WTFMove(startAngle), WTFMove(endAngle), WTFMove(anticlockwise))); |
| 501 | return JSValue::encode(jsUndefined()); |
| 502 | } |
| 503 | |
| 504 | EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionArc(ExecState* state) |
| 505 | { |
| 506 | return IDLOperation<JSPath2D>::call<jsPath2DPrototypeFunctionArcBody>(*state, "arc" ); |
| 507 | } |
| 508 | |
| 509 | static inline JSC::EncodedJSValue jsPath2DPrototypeFunctionEllipseBody(JSC::ExecState* state, typename IDLOperation<JSPath2D>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 510 | { |
| 511 | UNUSED_PARAM(state); |
| 512 | UNUSED_PARAM(throwScope); |
| 513 | auto& impl = castedThis->wrapped(); |
| 514 | if (UNLIKELY(state->argumentCount() < 7)) |
| 515 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 516 | auto x = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
| 517 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 518 | auto y = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
| 519 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 520 | auto radiusX = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(2)); |
| 521 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 522 | auto radiusY = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(3)); |
| 523 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 524 | auto rotation = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(4)); |
| 525 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 526 | auto startAngle = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(5)); |
| 527 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 528 | auto endAngle = convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(6)); |
| 529 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 530 | auto anticlockwise = convert<IDLBoolean>(*state, state->argument(7)); |
| 531 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 532 | propagateException(*state, throwScope, impl.ellipse(WTFMove(x), WTFMove(y), WTFMove(radiusX), WTFMove(radiusY), WTFMove(rotation), WTFMove(startAngle), WTFMove(endAngle), WTFMove(anticlockwise))); |
| 533 | return JSValue::encode(jsUndefined()); |
| 534 | } |
| 535 | |
| 536 | EncodedJSValue JSC_HOST_CALL jsPath2DPrototypeFunctionEllipse(ExecState* state) |
| 537 | { |
| 538 | return IDLOperation<JSPath2D>::call<jsPath2DPrototypeFunctionEllipseBody>(*state, "ellipse" ); |
| 539 | } |
| 540 | |
| 541 | void JSPath2D::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 542 | { |
| 543 | auto* thisObject = jsCast<JSPath2D*>(cell); |
| 544 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 545 | if (thisObject->scriptExecutionContext()) |
| 546 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 547 | Base::heapSnapshot(cell, builder); |
| 548 | } |
| 549 | |
| 550 | bool JSPath2DOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 551 | { |
| 552 | UNUSED_PARAM(handle); |
| 553 | UNUSED_PARAM(visitor); |
| 554 | UNUSED_PARAM(reason); |
| 555 | return false; |
| 556 | } |
| 557 | |
| 558 | void JSPath2DOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 559 | { |
| 560 | auto* jsPath2D = static_cast<JSPath2D*>(handle.slot()->asCell()); |
| 561 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 562 | uncacheWrapper(world, &jsPath2D->wrapped(), jsPath2D); |
| 563 | } |
| 564 | |
| 565 | #if ENABLE(BINDING_INTEGRITY) |
| 566 | #if PLATFORM(WIN) |
| 567 | #pragma warning(disable: 4483) |
| 568 | extern "C" { extern void (*const __identifier("??_7Path2D@WebCore@@6B@" )[])(); } |
| 569 | #else |
| 570 | extern "C" { extern void* _ZTVN7WebCore6Path2DE[]; } |
| 571 | #endif |
| 572 | #endif |
| 573 | |
| 574 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<Path2D>&& impl) |
| 575 | { |
| 576 | |
| 577 | #if ENABLE(BINDING_INTEGRITY) |
| 578 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 579 | #if PLATFORM(WIN) |
| 580 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7Path2D@WebCore@@6B@" )); |
| 581 | #else |
| 582 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore6Path2DE[2]); |
| 583 | #endif |
| 584 | |
| 585 | // If this fails Path2D does not have a vtable, so you need to add the |
| 586 | // ImplementationLacksVTable attribute to the interface definition |
| 587 | static_assert(std::is_polymorphic<Path2D>::value, "Path2D is not polymorphic" ); |
| 588 | |
| 589 | // If you hit this assertion you either have a use after free bug, or |
| 590 | // Path2D has subclasses. If Path2D has subclasses that get passed |
| 591 | // to toJS() we currently require Path2D you to opt out of binding hardening |
| 592 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 593 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 594 | #endif |
| 595 | return createWrapper<Path2D>(globalObject, WTFMove(impl)); |
| 596 | } |
| 597 | |
| 598 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, Path2D& impl) |
| 599 | { |
| 600 | return wrap(state, globalObject, impl); |
| 601 | } |
| 602 | |
| 603 | Path2D* JSPath2D::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 604 | { |
| 605 | if (auto* wrapper = jsDynamicCast<JSPath2D*>(vm, value)) |
| 606 | return &wrapper->wrapped(); |
| 607 | return nullptr; |
| 608 | } |
| 609 | |
| 610 | } |
| 611 | |