| /* |
| This file is part of the WebKit open source project. |
| This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| |
| This library is free software; you can redistribute it and/or |
| modify it under the terms of the GNU Library General Public |
| License as published by the Free Software Foundation; either |
| version 2 of the License, or (at your option) any later version. |
| |
| This library is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| Library General Public License for more details. |
| |
| You should have received a copy of the GNU Library General Public License |
| along with this library; see the file COPYING.LIB. If not, write to |
| the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| Boston, MA 02110-1301, USA. |
| */ |
| |
| #include "config.h" |
| #include "JSDOMPath.h" |
| |
| #include "ExceptionCode.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSDOMConvert.h" |
| #include "JSDOMPath.h" |
| #include <runtime/Error.h> |
| #include <runtime/FunctionPrototype.h> |
| #include <wtf/GetPtr.h> |
| |
| #if ENABLE(CANVAS_PATH) |
| #include "JSSVGMatrix.h" |
| #endif |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Functions |
| |
| #if ENABLE(CANVAS_PATH) |
| JSC::EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionAddPath(JSC::ExecState*); |
| #endif |
| JSC::EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionClosePath(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionMoveTo(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionLineTo(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionQuadraticCurveTo(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionBezierCurveTo(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionArcTo(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionRect(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionArc(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionEllipse(JSC::ExecState*); |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsDOMPathConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSDOMPathConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSDOMPathPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSDOMPathPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSDOMPathPrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMPathPrototype>(vm.heap)) JSDOMPathPrototype(vm, globalObject, structure); |
| ptr->finishCreation(vm); |
| return ptr; |
| } |
| |
| DECLARE_INFO; |
| static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| { |
| return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| } |
| |
| private: |
| JSDOMPathPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSDOMPath> JSDOMPathConstructor; |
| |
| static inline EncodedJSValue constructJSDOMPath1(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| auto* castedThis = jsCast<JSDOMPathConstructor*>(state->callee()); |
| ASSERT(castedThis); |
| auto object = DOMPath::create(); |
| return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))); |
| } |
| |
| static inline EncodedJSValue constructJSDOMPath2(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| auto* castedThis = jsCast<JSDOMPathConstructor*>(state->callee()); |
| ASSERT(castedThis); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto path = JSDOMPath::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!path)) |
| return throwArgumentTypeError(*state, throwScope, 0, "path", "Path2D", nullptr, "DOMPath"); |
| auto object = DOMPath::create(*path); |
| return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))); |
| } |
| |
| static inline EncodedJSValue constructJSDOMPath3(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| auto* castedThis = jsCast<JSDOMPathConstructor*>(state->callee()); |
| ASSERT(castedThis); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto text = state->uncheckedArgument(0).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto object = DOMPath::create(WTFMove(text)); |
| return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))); |
| } |
| |
| template<> EncodedJSValue JSC_HOST_CALL JSDOMPathConstructor::construct(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| size_t argsCount = std::min<size_t>(1, state->argumentCount()); |
| if (argsCount == 0) { |
| return constructJSDOMPath1(state); |
| } |
| if (argsCount == 1) { |
| JSValue distinguishingArg = state->uncheckedArgument(0); |
| if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSDOMPath::info())) |
| return constructJSDOMPath2(state); |
| return constructJSDOMPath3(state); |
| } |
| return throwVMTypeError(state, throwScope); |
| } |
| |
| template<> JSValue JSDOMPathConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| UNUSED_PARAM(vm); |
| return globalObject.functionPrototype(); |
| } |
| |
| template<> void JSDOMPathConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSDOMPath::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("Path2D"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSDOMPathConstructor::s_info = { "Path2D", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDOMPathConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSDOMPathPrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPathConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMPathConstructor) } }, |
| #if ENABLE(CANVAS_PATH) |
| { "addPath", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMPathPrototypeFunctionAddPath), (intptr_t) (1) } }, |
| #else |
| { 0, 0, NoIntrinsic, { 0, 0 } }, |
| #endif |
| { "closePath", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMPathPrototypeFunctionClosePath), (intptr_t) (0) } }, |
| { "moveTo", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMPathPrototypeFunctionMoveTo), (intptr_t) (2) } }, |
| { "lineTo", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMPathPrototypeFunctionLineTo), (intptr_t) (2) } }, |
| { "quadraticCurveTo", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMPathPrototypeFunctionQuadraticCurveTo), (intptr_t) (4) } }, |
| { "bezierCurveTo", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMPathPrototypeFunctionBezierCurveTo), (intptr_t) (6) } }, |
| { "arcTo", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMPathPrototypeFunctionArcTo), (intptr_t) (5) } }, |
| { "rect", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMPathPrototypeFunctionRect), (intptr_t) (4) } }, |
| { "arc", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMPathPrototypeFunctionArc), (intptr_t) (5) } }, |
| { "ellipse", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMPathPrototypeFunctionEllipse), (intptr_t) (7) } }, |
| }; |
| |
| const ClassInfo JSDOMPathPrototype::s_info = { "Path2DPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDOMPathPrototype) }; |
| |
| void JSDOMPathPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSDOMPathPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSDOMPath::s_info = { "Path2D", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDOMPath) }; |
| |
| JSDOMPath::JSDOMPath(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMPath>&& impl) |
| : JSDOMWrapper<DOMPath>(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSDOMPath::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSDOMPathPrototype::create(vm, globalObject, JSDOMPathPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); |
| } |
| |
| JSObject* JSDOMPath::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSDOMPath>(vm, globalObject); |
| } |
| |
| void JSDOMPath::destroy(JSC::JSCell* cell) |
| { |
| JSDOMPath* thisObject = static_cast<JSDOMPath*>(cell); |
| thisObject->JSDOMPath::~JSDOMPath(); |
| } |
| |
| EncodedJSValue jsDOMPathConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSDOMPathPrototype* domObject = jsDynamicCast<JSDOMPathPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSDOMPath::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSDOMPathConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSDOMPathPrototype* domObject = jsDynamicCast<JSDOMPathPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) { |
| throwVMTypeError(state, throwScope); |
| return false; |
| } |
| // Shadowing a built-in constructor |
| return domObject->putDirect(state->vm(), state->propertyNames().constructor, value); |
| } |
| |
| JSValue JSDOMPath::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSDOMPathConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| #if ENABLE(CANVAS_PATH) |
| static inline EncodedJSValue jsDOMPathPrototypeFunctionAddPath1(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMPath*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "Path2D", "addPath"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMPath::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| DOMPath* path = nullptr; |
| if (!state->uncheckedArgument(0).isUndefinedOrNull()) { |
| path = JSDOMPath::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!path)) |
| return throwArgumentTypeError(*state, throwScope, 0, "path", "Path2D", "addPath", "DOMPath"); |
| } |
| impl.addPath(WTFMove(path)); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| #endif |
| |
| #if ENABLE(CANVAS_PATH) |
| static inline EncodedJSValue jsDOMPathPrototypeFunctionAddPath2(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMPath*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "Path2D", "addPath"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMPath::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 2)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| DOMPath* path = nullptr; |
| if (!state->uncheckedArgument(0).isUndefinedOrNull()) { |
| path = JSDOMPath::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!path)) |
| return throwArgumentTypeError(*state, throwScope, 0, "path", "Path2D", "addPath", "DOMPath"); |
| } |
| auto transform = JSSVGMatrix::toWrapped(state->uncheckedArgument(1)); |
| if (UNLIKELY(!transform)) |
| return throwArgumentTypeError(*state, throwScope, 1, "transform", "Path2D", "addPath", "SVGMatrix"); |
| impl.addPath(WTFMove(path), transform->propertyReference()); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| #endif |
| |
| #if ENABLE(CANVAS_PATH) |
| EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionAddPath(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| size_t argsCount = std::min<size_t>(2, state->argumentCount()); |
| if (argsCount == 1) { |
| #if ENABLE(CANVAS_PATH) |
| return jsDOMPathPrototypeFunctionAddPath1(state); |
| #endif |
| } |
| if (argsCount == 2) { |
| #if ENABLE(CANVAS_PATH) |
| return jsDOMPathPrototypeFunctionAddPath2(state); |
| #endif |
| } |
| return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope); |
| } |
| #endif |
| |
| EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionClosePath(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMPath*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "Path2D", "closePath"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMPath::info()); |
| auto& impl = castedThis->wrapped(); |
| impl.closePath(); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionMoveTo(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMPath*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "Path2D", "moveTo"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMPath::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 2)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto x = convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto y = convert<double>(*state, state->uncheckedArgument(1), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.moveTo(WTFMove(x), WTFMove(y)); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionLineTo(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMPath*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "Path2D", "lineTo"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMPath::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 2)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto x = convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto y = convert<double>(*state, state->uncheckedArgument(1), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.lineTo(WTFMove(x), WTFMove(y)); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionQuadraticCurveTo(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMPath*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "Path2D", "quadraticCurveTo"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMPath::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 4)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto cpx = convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto cpy = convert<double>(*state, state->uncheckedArgument(1), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto x = convert<double>(*state, state->uncheckedArgument(2), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto y = convert<double>(*state, state->uncheckedArgument(3), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.quadraticCurveTo(WTFMove(cpx), WTFMove(cpy), WTFMove(x), WTFMove(y)); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionBezierCurveTo(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMPath*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "Path2D", "bezierCurveTo"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMPath::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 6)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto cp1x = convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto cp1y = convert<double>(*state, state->uncheckedArgument(1), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto cp2x = convert<double>(*state, state->uncheckedArgument(2), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto cp2y = convert<double>(*state, state->uncheckedArgument(3), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto x = convert<double>(*state, state->uncheckedArgument(4), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto y = convert<double>(*state, state->uncheckedArgument(5), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.bezierCurveTo(WTFMove(cp1x), WTFMove(cp1y), WTFMove(cp2x), WTFMove(cp2y), WTFMove(x), WTFMove(y)); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionArcTo(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMPath*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "Path2D", "arcTo"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMPath::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 5)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCode ec = 0; |
| auto x1 = convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto y1 = convert<double>(*state, state->uncheckedArgument(1), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto x2 = convert<double>(*state, state->uncheckedArgument(2), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto y2 = convert<double>(*state, state->uncheckedArgument(3), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto radius = convert<double>(*state, state->uncheckedArgument(4), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.arcTo(WTFMove(x1), WTFMove(y1), WTFMove(x2), WTFMove(y2), WTFMove(radius), ec); |
| setDOMException(state, throwScope, ec); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionRect(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMPath*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "Path2D", "rect"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMPath::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 4)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto x = convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto y = convert<double>(*state, state->uncheckedArgument(1), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto w = convert<double>(*state, state->uncheckedArgument(2), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto h = convert<double>(*state, state->uncheckedArgument(3), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.rect(WTFMove(x), WTFMove(y), WTFMove(w), WTFMove(h)); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionArc(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMPath*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "Path2D", "arc"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMPath::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 5)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCode ec = 0; |
| auto x = convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto y = convert<double>(*state, state->uncheckedArgument(1), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto radius = convert<double>(*state, state->uncheckedArgument(2), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto startAngle = convert<double>(*state, state->uncheckedArgument(3), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto endAngle = convert<double>(*state, state->uncheckedArgument(4), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto anticlockwise = state->argument(5).toBoolean(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.arc(WTFMove(x), WTFMove(y), WTFMove(radius), WTFMove(startAngle), WTFMove(endAngle), WTFMove(anticlockwise), ec); |
| setDOMException(state, throwScope, ec); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsDOMPathPrototypeFunctionEllipse(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMPath*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "Path2D", "ellipse"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMPath::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 7)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCode ec = 0; |
| auto x = convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto y = convert<double>(*state, state->uncheckedArgument(1), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto radiusX = convert<double>(*state, state->uncheckedArgument(2), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto radiusY = convert<double>(*state, state->uncheckedArgument(3), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto rotation = convert<double>(*state, state->uncheckedArgument(4), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto startAngle = convert<double>(*state, state->uncheckedArgument(5), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto endAngle = convert<double>(*state, state->uncheckedArgument(6), ShouldAllowNonFinite::Yes); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto anticlockwise = state->argument(7).toBoolean(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.ellipse(WTFMove(x), WTFMove(y), WTFMove(radiusX), WTFMove(radiusY), WTFMove(rotation), WTFMove(startAngle), WTFMove(endAngle), WTFMove(anticlockwise), ec); |
| setDOMException(state, throwScope, ec); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| bool JSDOMPathOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) |
| { |
| UNUSED_PARAM(handle); |
| UNUSED_PARAM(visitor); |
| return false; |
| } |
| |
| void JSDOMPathOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| { |
| auto* jsDOMPath = jsCast<JSDOMPath*>(handle.slot()->asCell()); |
| auto& world = *static_cast<DOMWrapperWorld*>(context); |
| uncacheWrapper(world, &jsDOMPath->wrapped(), jsDOMPath); |
| } |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| #if PLATFORM(WIN) |
| #pragma warning(disable: 4483) |
| extern "C" { extern void (*const __identifier("??_7DOMPath@WebCore@@6B@")[])(); } |
| #else |
| extern "C" { extern void* _ZTVN7WebCore7DOMPathE[]; } |
| #endif |
| #endif |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMPath>&& impl) |
| { |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| #if PLATFORM(WIN) |
| void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7DOMPath@WebCore@@6B@")); |
| #else |
| void* expectedVTablePointer = &_ZTVN7WebCore7DOMPathE[2]; |
| #if COMPILER(CLANG) |
| // If this fails DOMPath does not have a vtable, so you need to add the |
| // ImplementationLacksVTable attribute to the interface definition |
| static_assert(__is_polymorphic(DOMPath), "DOMPath is not polymorphic"); |
| #endif |
| #endif |
| // If you hit this assertion you either have a use after free bug, or |
| // DOMPath has subclasses. If DOMPath has subclasses that get passed |
| // to toJS() we currently require DOMPath you to opt out of binding hardening |
| // by adding the SkipVTableValidation attribute to the interface IDL definition |
| RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| #endif |
| return createWrapper<DOMPath>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMPath& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| DOMPath* JSDOMPath::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSDOMPath*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |