| 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 "JSSVGGeometryElement.h" |
| 23 | |
| 24 | #include "JSDOMAttribute.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructorNotConstructable.h" |
| 27 | #include "JSDOMConvertBoolean.h" |
| 28 | #include "JSDOMConvertDictionary.h" |
| 29 | #include "JSDOMConvertInterface.h" |
| 30 | #include "JSDOMConvertNumbers.h" |
| 31 | #include "JSDOMExceptionHandling.h" |
| 32 | #include "JSDOMGlobalObject.h" |
| 33 | #include "JSDOMOperation.h" |
| 34 | #include "JSDOMPointInit.h" |
| 35 | #include "JSDOMWrapperCache.h" |
| 36 | #include "JSSVGAnimatedNumber.h" |
| 37 | #include "JSSVGPoint.h" |
| 38 | #include "ScriptExecutionContext.h" |
| 39 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 40 | #include <JavaScriptCore/JSCInlines.h> |
| 41 | #include <wtf/GetPtr.h> |
| 42 | #include <wtf/PointerPreparations.h> |
| 43 | #include <wtf/URL.h> |
| 44 | |
| 45 | |
| 46 | namespace WebCore { |
| 47 | using namespace JSC; |
| 48 | |
| 49 | // Functions |
| 50 | |
| 51 | JSC::EncodedJSValue JSC_HOST_CALL jsSVGGeometryElementPrototypeFunctionIsPointInFill(JSC::ExecState*); |
| 52 | JSC::EncodedJSValue JSC_HOST_CALL jsSVGGeometryElementPrototypeFunctionIsPointInStroke(JSC::ExecState*); |
| 53 | JSC::EncodedJSValue JSC_HOST_CALL jsSVGGeometryElementPrototypeFunctionGetTotalLength(JSC::ExecState*); |
| 54 | JSC::EncodedJSValue JSC_HOST_CALL jsSVGGeometryElementPrototypeFunctionGetPointAtLength(JSC::ExecState*); |
| 55 | |
| 56 | // Attributes |
| 57 | |
| 58 | JSC::EncodedJSValue jsSVGGeometryElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 59 | bool setJSSVGGeometryElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 60 | JSC::EncodedJSValue jsSVGGeometryElementPathLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 61 | |
| 62 | class JSSVGGeometryElementPrototype : public JSC::JSNonFinalObject { |
| 63 | public: |
| 64 | using Base = JSC::JSNonFinalObject; |
| 65 | static JSSVGGeometryElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 66 | { |
| 67 | JSSVGGeometryElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSSVGGeometryElementPrototype>(vm.heap)) JSSVGGeometryElementPrototype(vm, globalObject, structure); |
| 68 | ptr->finishCreation(vm); |
| 69 | return ptr; |
| 70 | } |
| 71 | |
| 72 | DECLARE_INFO; |
| 73 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 74 | { |
| 75 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 76 | } |
| 77 | |
| 78 | private: |
| 79 | JSSVGGeometryElementPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 80 | : JSC::JSNonFinalObject(vm, structure) |
| 81 | { |
| 82 | } |
| 83 | |
| 84 | void finishCreation(JSC::VM&); |
| 85 | }; |
| 86 | |
| 87 | using JSSVGGeometryElementConstructor = JSDOMConstructorNotConstructable<JSSVGGeometryElement>; |
| 88 | |
| 89 | template<> JSValue JSSVGGeometryElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 90 | { |
| 91 | return JSSVGGraphicsElement::getConstructor(vm, &globalObject); |
| 92 | } |
| 93 | |
| 94 | template<> void JSSVGGeometryElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 95 | { |
| 96 | putDirect(vm, vm.propertyNames->prototype, JSSVGGeometryElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 97 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SVGGeometryElement"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 98 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 99 | } |
| 100 | |
| 101 | template<> const ClassInfo JSSVGGeometryElementConstructor::s_info = { "SVGGeometryElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGGeometryElementConstructor) }; |
| 102 | |
| 103 | /* Hash table for prototype */ |
| 104 | |
| 105 | static const HashTableValue JSSVGGeometryElementPrototypeTableValues[] = |
| 106 | { |
| 107 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGGeometryElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGGeometryElementConstructor) } }, |
| 108 | { "pathLength" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGGeometryElementPathLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 109 | { "isPointInFill" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGGeometryElementPrototypeFunctionIsPointInFill), (intptr_t) (0) } }, |
| 110 | { "isPointInStroke" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGGeometryElementPrototypeFunctionIsPointInStroke), (intptr_t) (0) } }, |
| 111 | { "getTotalLength" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGGeometryElementPrototypeFunctionGetTotalLength), (intptr_t) (0) } }, |
| 112 | { "getPointAtLength" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGGeometryElementPrototypeFunctionGetPointAtLength), (intptr_t) (1) } }, |
| 113 | }; |
| 114 | |
| 115 | const ClassInfo JSSVGGeometryElementPrototype::s_info = { "SVGGeometryElementPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGGeometryElementPrototype) }; |
| 116 | |
| 117 | void JSSVGGeometryElementPrototype::finishCreation(VM& vm) |
| 118 | { |
| 119 | Base::finishCreation(vm); |
| 120 | reifyStaticProperties(vm, JSSVGGeometryElement::info(), JSSVGGeometryElementPrototypeTableValues, *this); |
| 121 | } |
| 122 | |
| 123 | const ClassInfo JSSVGGeometryElement::s_info = { "SVGGeometryElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGGeometryElement) }; |
| 124 | |
| 125 | JSSVGGeometryElement::JSSVGGeometryElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SVGGeometryElement>&& impl) |
| 126 | : JSSVGGraphicsElement(structure, globalObject, WTFMove(impl)) |
| 127 | { |
| 128 | } |
| 129 | |
| 130 | void JSSVGGeometryElement::finishCreation(VM& vm) |
| 131 | { |
| 132 | Base::finishCreation(vm); |
| 133 | ASSERT(inherits(vm, info())); |
| 134 | |
| 135 | } |
| 136 | |
| 137 | JSObject* JSSVGGeometryElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 138 | { |
| 139 | return JSSVGGeometryElementPrototype::create(vm, &globalObject, JSSVGGeometryElementPrototype::createStructure(vm, &globalObject, JSSVGGraphicsElement::prototype(vm, globalObject))); |
| 140 | } |
| 141 | |
| 142 | JSObject* JSSVGGeometryElement::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 143 | { |
| 144 | return getDOMPrototype<JSSVGGeometryElement>(vm, globalObject); |
| 145 | } |
| 146 | |
| 147 | JSValue JSSVGGeometryElement::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 148 | { |
| 149 | return getDOMConstructor<JSSVGGeometryElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 150 | } |
| 151 | |
| 152 | template<> inline JSSVGGeometryElement* IDLAttribute<JSSVGGeometryElement>::cast(ExecState& state, EncodedJSValue thisValue) |
| 153 | { |
| 154 | return jsDynamicCast<JSSVGGeometryElement*>(state.vm(), JSValue::decode(thisValue)); |
| 155 | } |
| 156 | |
| 157 | template<> inline JSSVGGeometryElement* IDLOperation<JSSVGGeometryElement>::cast(ExecState& state) |
| 158 | { |
| 159 | return jsDynamicCast<JSSVGGeometryElement*>(state.vm(), state.thisValue()); |
| 160 | } |
| 161 | |
| 162 | EncodedJSValue jsSVGGeometryElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 163 | { |
| 164 | VM& vm = state->vm(); |
| 165 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 166 | auto* prototype = jsDynamicCast<JSSVGGeometryElementPrototype*>(vm, JSValue::decode(thisValue)); |
| 167 | if (UNLIKELY(!prototype)) |
| 168 | return throwVMTypeError(state, throwScope); |
| 169 | return JSValue::encode(JSSVGGeometryElement::getConstructor(state->vm(), prototype->globalObject())); |
| 170 | } |
| 171 | |
| 172 | bool setJSSVGGeometryElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 173 | { |
| 174 | VM& vm = state->vm(); |
| 175 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 176 | auto* prototype = jsDynamicCast<JSSVGGeometryElementPrototype*>(vm, JSValue::decode(thisValue)); |
| 177 | if (UNLIKELY(!prototype)) { |
| 178 | throwVMTypeError(state, throwScope); |
| 179 | return false; |
| 180 | } |
| 181 | // Shadowing a built-in constructor |
| 182 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 183 | } |
| 184 | |
| 185 | static inline JSValue jsSVGGeometryElementPathLengthGetter(ExecState& state, JSSVGGeometryElement& thisObject, ThrowScope& throwScope) |
| 186 | { |
| 187 | UNUSED_PARAM(throwScope); |
| 188 | UNUSED_PARAM(state); |
| 189 | auto& impl = thisObject.wrapped(); |
| 190 | JSValue result = toJS<IDLInterface<SVGAnimatedNumber>>(state, *thisObject.globalObject(), throwScope, impl.pathLengthAnimated()); |
| 191 | return result; |
| 192 | } |
| 193 | |
| 194 | EncodedJSValue jsSVGGeometryElementPathLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 195 | { |
| 196 | return IDLAttribute<JSSVGGeometryElement>::get<jsSVGGeometryElementPathLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pathLength" ); |
| 197 | } |
| 198 | |
| 199 | static inline JSC::EncodedJSValue jsSVGGeometryElementPrototypeFunctionIsPointInFillBody(JSC::ExecState* state, typename IDLOperation<JSSVGGeometryElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 200 | { |
| 201 | UNUSED_PARAM(state); |
| 202 | UNUSED_PARAM(throwScope); |
| 203 | auto& impl = castedThis->wrapped(); |
| 204 | auto point = convert<IDLDictionary<DOMPointInit>>(*state, state->argument(0)); |
| 205 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 206 | return JSValue::encode(toJS<IDLBoolean>(impl.isPointInFill(WTFMove(point)))); |
| 207 | } |
| 208 | |
| 209 | EncodedJSValue JSC_HOST_CALL jsSVGGeometryElementPrototypeFunctionIsPointInFill(ExecState* state) |
| 210 | { |
| 211 | return IDLOperation<JSSVGGeometryElement>::call<jsSVGGeometryElementPrototypeFunctionIsPointInFillBody>(*state, "isPointInFill" ); |
| 212 | } |
| 213 | |
| 214 | static inline JSC::EncodedJSValue jsSVGGeometryElementPrototypeFunctionIsPointInStrokeBody(JSC::ExecState* state, typename IDLOperation<JSSVGGeometryElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 215 | { |
| 216 | UNUSED_PARAM(state); |
| 217 | UNUSED_PARAM(throwScope); |
| 218 | auto& impl = castedThis->wrapped(); |
| 219 | auto point = convert<IDLDictionary<DOMPointInit>>(*state, state->argument(0)); |
| 220 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 221 | return JSValue::encode(toJS<IDLBoolean>(impl.isPointInStroke(WTFMove(point)))); |
| 222 | } |
| 223 | |
| 224 | EncodedJSValue JSC_HOST_CALL jsSVGGeometryElementPrototypeFunctionIsPointInStroke(ExecState* state) |
| 225 | { |
| 226 | return IDLOperation<JSSVGGeometryElement>::call<jsSVGGeometryElementPrototypeFunctionIsPointInStrokeBody>(*state, "isPointInStroke" ); |
| 227 | } |
| 228 | |
| 229 | static inline JSC::EncodedJSValue jsSVGGeometryElementPrototypeFunctionGetTotalLengthBody(JSC::ExecState* state, typename IDLOperation<JSSVGGeometryElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 230 | { |
| 231 | UNUSED_PARAM(state); |
| 232 | UNUSED_PARAM(throwScope); |
| 233 | auto& impl = castedThis->wrapped(); |
| 234 | return JSValue::encode(toJS<IDLUnrestrictedFloat>(impl.getTotalLength())); |
| 235 | } |
| 236 | |
| 237 | EncodedJSValue JSC_HOST_CALL jsSVGGeometryElementPrototypeFunctionGetTotalLength(ExecState* state) |
| 238 | { |
| 239 | return IDLOperation<JSSVGGeometryElement>::call<jsSVGGeometryElementPrototypeFunctionGetTotalLengthBody>(*state, "getTotalLength" ); |
| 240 | } |
| 241 | |
| 242 | static inline JSC::EncodedJSValue jsSVGGeometryElementPrototypeFunctionGetPointAtLengthBody(JSC::ExecState* state, typename IDLOperation<JSSVGGeometryElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 243 | { |
| 244 | UNUSED_PARAM(state); |
| 245 | UNUSED_PARAM(throwScope); |
| 246 | auto& impl = castedThis->wrapped(); |
| 247 | if (UNLIKELY(state->argumentCount() < 1)) |
| 248 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 249 | auto distance = convert<IDLFloat>(*state, state->uncheckedArgument(0)); |
| 250 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 251 | return JSValue::encode(toJSNewlyCreated<IDLInterface<SVGPoint>>(*state, *castedThis->globalObject(), impl.getPointAtLength(WTFMove(distance)))); |
| 252 | } |
| 253 | |
| 254 | EncodedJSValue JSC_HOST_CALL jsSVGGeometryElementPrototypeFunctionGetPointAtLength(ExecState* state) |
| 255 | { |
| 256 | return IDLOperation<JSSVGGeometryElement>::call<jsSVGGeometryElementPrototypeFunctionGetPointAtLengthBody>(*state, "getPointAtLength" ); |
| 257 | } |
| 258 | |
| 259 | void JSSVGGeometryElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 260 | { |
| 261 | auto* thisObject = jsCast<JSSVGGeometryElement*>(cell); |
| 262 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 263 | if (thisObject->scriptExecutionContext()) |
| 264 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 265 | Base::heapSnapshot(cell, builder); |
| 266 | } |
| 267 | |
| 268 | |
| 269 | } |
| 270 | |