| 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 "JSSVGImageElement.h" |
| 23 | |
| 24 | #include "JSDOMAttribute.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructorNotConstructable.h" |
| 27 | #include "JSDOMConvertInterface.h" |
| 28 | #include "JSDOMExceptionHandling.h" |
| 29 | #include "JSDOMGlobalObject.h" |
| 30 | #include "JSDOMWrapperCache.h" |
| 31 | #include "JSSVGAnimatedBoolean.h" |
| 32 | #include "JSSVGAnimatedLength.h" |
| 33 | #include "JSSVGAnimatedPreserveAspectRatio.h" |
| 34 | #include "JSSVGAnimatedString.h" |
| 35 | #include "ScriptExecutionContext.h" |
| 36 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 37 | #include <JavaScriptCore/JSCInlines.h> |
| 38 | #include <wtf/GetPtr.h> |
| 39 | #include <wtf/PointerPreparations.h> |
| 40 | #include <wtf/URL.h> |
| 41 | |
| 42 | |
| 43 | namespace WebCore { |
| 44 | using namespace JSC; |
| 45 | |
| 46 | // Attributes |
| 47 | |
| 48 | JSC::EncodedJSValue jsSVGImageElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 49 | bool setJSSVGImageElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 50 | JSC::EncodedJSValue jsSVGImageElementX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 51 | JSC::EncodedJSValue jsSVGImageElementY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 52 | JSC::EncodedJSValue jsSVGImageElementWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 53 | JSC::EncodedJSValue jsSVGImageElementHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 54 | JSC::EncodedJSValue jsSVGImageElementPreserveAspectRatio(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 55 | JSC::EncodedJSValue jsSVGImageElementExternalResourcesRequired(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 56 | JSC::EncodedJSValue jsSVGImageElementHref(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 57 | |
| 58 | class JSSVGImageElementPrototype : public JSC::JSNonFinalObject { |
| 59 | public: |
| 60 | using Base = JSC::JSNonFinalObject; |
| 61 | static JSSVGImageElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 62 | { |
| 63 | JSSVGImageElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSSVGImageElementPrototype>(vm.heap)) JSSVGImageElementPrototype(vm, globalObject, structure); |
| 64 | ptr->finishCreation(vm); |
| 65 | return ptr; |
| 66 | } |
| 67 | |
| 68 | DECLARE_INFO; |
| 69 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 70 | { |
| 71 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 72 | } |
| 73 | |
| 74 | private: |
| 75 | JSSVGImageElementPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 76 | : JSC::JSNonFinalObject(vm, structure) |
| 77 | { |
| 78 | } |
| 79 | |
| 80 | void finishCreation(JSC::VM&); |
| 81 | }; |
| 82 | |
| 83 | using JSSVGImageElementConstructor = JSDOMConstructorNotConstructable<JSSVGImageElement>; |
| 84 | |
| 85 | template<> JSValue JSSVGImageElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 86 | { |
| 87 | return JSSVGGraphicsElement::getConstructor(vm, &globalObject); |
| 88 | } |
| 89 | |
| 90 | template<> void JSSVGImageElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 91 | { |
| 92 | putDirect(vm, vm.propertyNames->prototype, JSSVGImageElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 93 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SVGImageElement"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 94 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 95 | } |
| 96 | |
| 97 | template<> const ClassInfo JSSVGImageElementConstructor::s_info = { "SVGImageElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGImageElementConstructor) }; |
| 98 | |
| 99 | /* Hash table for prototype */ |
| 100 | |
| 101 | static const HashTableValue JSSVGImageElementPrototypeTableValues[] = |
| 102 | { |
| 103 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGImageElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGImageElementConstructor) } }, |
| 104 | { "x" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGImageElementX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 105 | { "y" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGImageElementY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 106 | { "width" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGImageElementWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 107 | { "height" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGImageElementHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 108 | { "preserveAspectRatio" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGImageElementPreserveAspectRatio), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 109 | { "externalResourcesRequired" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGImageElementExternalResourcesRequired), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 110 | { "href" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGImageElementHref), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 111 | }; |
| 112 | |
| 113 | const ClassInfo JSSVGImageElementPrototype::s_info = { "SVGImageElementPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGImageElementPrototype) }; |
| 114 | |
| 115 | void JSSVGImageElementPrototype::finishCreation(VM& vm) |
| 116 | { |
| 117 | Base::finishCreation(vm); |
| 118 | reifyStaticProperties(vm, JSSVGImageElement::info(), JSSVGImageElementPrototypeTableValues, *this); |
| 119 | } |
| 120 | |
| 121 | const ClassInfo JSSVGImageElement::s_info = { "SVGImageElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGImageElement) }; |
| 122 | |
| 123 | JSSVGImageElement::JSSVGImageElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SVGImageElement>&& impl) |
| 124 | : JSSVGGraphicsElement(structure, globalObject, WTFMove(impl)) |
| 125 | { |
| 126 | } |
| 127 | |
| 128 | void JSSVGImageElement::finishCreation(VM& vm) |
| 129 | { |
| 130 | Base::finishCreation(vm); |
| 131 | ASSERT(inherits(vm, info())); |
| 132 | |
| 133 | } |
| 134 | |
| 135 | JSObject* JSSVGImageElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 136 | { |
| 137 | return JSSVGImageElementPrototype::create(vm, &globalObject, JSSVGImageElementPrototype::createStructure(vm, &globalObject, JSSVGGraphicsElement::prototype(vm, globalObject))); |
| 138 | } |
| 139 | |
| 140 | JSObject* JSSVGImageElement::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 141 | { |
| 142 | return getDOMPrototype<JSSVGImageElement>(vm, globalObject); |
| 143 | } |
| 144 | |
| 145 | JSValue JSSVGImageElement::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 146 | { |
| 147 | return getDOMConstructor<JSSVGImageElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 148 | } |
| 149 | |
| 150 | template<> inline JSSVGImageElement* IDLAttribute<JSSVGImageElement>::cast(ExecState& state, EncodedJSValue thisValue) |
| 151 | { |
| 152 | return jsDynamicCast<JSSVGImageElement*>(state.vm(), JSValue::decode(thisValue)); |
| 153 | } |
| 154 | |
| 155 | EncodedJSValue jsSVGImageElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 156 | { |
| 157 | VM& vm = state->vm(); |
| 158 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 159 | auto* prototype = jsDynamicCast<JSSVGImageElementPrototype*>(vm, JSValue::decode(thisValue)); |
| 160 | if (UNLIKELY(!prototype)) |
| 161 | return throwVMTypeError(state, throwScope); |
| 162 | return JSValue::encode(JSSVGImageElement::getConstructor(state->vm(), prototype->globalObject())); |
| 163 | } |
| 164 | |
| 165 | bool setJSSVGImageElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 166 | { |
| 167 | VM& vm = state->vm(); |
| 168 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 169 | auto* prototype = jsDynamicCast<JSSVGImageElementPrototype*>(vm, JSValue::decode(thisValue)); |
| 170 | if (UNLIKELY(!prototype)) { |
| 171 | throwVMTypeError(state, throwScope); |
| 172 | return false; |
| 173 | } |
| 174 | // Shadowing a built-in constructor |
| 175 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 176 | } |
| 177 | |
| 178 | static inline JSValue jsSVGImageElementXGetter(ExecState& state, JSSVGImageElement& thisObject, ThrowScope& throwScope) |
| 179 | { |
| 180 | UNUSED_PARAM(throwScope); |
| 181 | UNUSED_PARAM(state); |
| 182 | auto& impl = thisObject.wrapped(); |
| 183 | JSValue result = toJS<IDLInterface<SVGAnimatedLength>>(state, *thisObject.globalObject(), throwScope, impl.xAnimated()); |
| 184 | return result; |
| 185 | } |
| 186 | |
| 187 | EncodedJSValue jsSVGImageElementX(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 188 | { |
| 189 | return IDLAttribute<JSSVGImageElement>::get<jsSVGImageElementXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "x" ); |
| 190 | } |
| 191 | |
| 192 | static inline JSValue jsSVGImageElementYGetter(ExecState& state, JSSVGImageElement& thisObject, ThrowScope& throwScope) |
| 193 | { |
| 194 | UNUSED_PARAM(throwScope); |
| 195 | UNUSED_PARAM(state); |
| 196 | auto& impl = thisObject.wrapped(); |
| 197 | JSValue result = toJS<IDLInterface<SVGAnimatedLength>>(state, *thisObject.globalObject(), throwScope, impl.yAnimated()); |
| 198 | return result; |
| 199 | } |
| 200 | |
| 201 | EncodedJSValue jsSVGImageElementY(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 202 | { |
| 203 | return IDLAttribute<JSSVGImageElement>::get<jsSVGImageElementYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "y" ); |
| 204 | } |
| 205 | |
| 206 | static inline JSValue jsSVGImageElementWidthGetter(ExecState& state, JSSVGImageElement& thisObject, ThrowScope& throwScope) |
| 207 | { |
| 208 | UNUSED_PARAM(throwScope); |
| 209 | UNUSED_PARAM(state); |
| 210 | auto& impl = thisObject.wrapped(); |
| 211 | JSValue result = toJS<IDLInterface<SVGAnimatedLength>>(state, *thisObject.globalObject(), throwScope, impl.widthAnimated()); |
| 212 | return result; |
| 213 | } |
| 214 | |
| 215 | EncodedJSValue jsSVGImageElementWidth(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 216 | { |
| 217 | return IDLAttribute<JSSVGImageElement>::get<jsSVGImageElementWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "width" ); |
| 218 | } |
| 219 | |
| 220 | static inline JSValue jsSVGImageElementHeightGetter(ExecState& state, JSSVGImageElement& thisObject, ThrowScope& throwScope) |
| 221 | { |
| 222 | UNUSED_PARAM(throwScope); |
| 223 | UNUSED_PARAM(state); |
| 224 | auto& impl = thisObject.wrapped(); |
| 225 | JSValue result = toJS<IDLInterface<SVGAnimatedLength>>(state, *thisObject.globalObject(), throwScope, impl.heightAnimated()); |
| 226 | return result; |
| 227 | } |
| 228 | |
| 229 | EncodedJSValue jsSVGImageElementHeight(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 230 | { |
| 231 | return IDLAttribute<JSSVGImageElement>::get<jsSVGImageElementHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "height" ); |
| 232 | } |
| 233 | |
| 234 | static inline JSValue jsSVGImageElementPreserveAspectRatioGetter(ExecState& state, JSSVGImageElement& thisObject, ThrowScope& throwScope) |
| 235 | { |
| 236 | UNUSED_PARAM(throwScope); |
| 237 | UNUSED_PARAM(state); |
| 238 | auto& impl = thisObject.wrapped(); |
| 239 | JSValue result = toJS<IDLInterface<SVGAnimatedPreserveAspectRatio>>(state, *thisObject.globalObject(), throwScope, impl.preserveAspectRatioAnimated()); |
| 240 | return result; |
| 241 | } |
| 242 | |
| 243 | EncodedJSValue jsSVGImageElementPreserveAspectRatio(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 244 | { |
| 245 | return IDLAttribute<JSSVGImageElement>::get<jsSVGImageElementPreserveAspectRatioGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "preserveAspectRatio" ); |
| 246 | } |
| 247 | |
| 248 | static inline JSValue jsSVGImageElementExternalResourcesRequiredGetter(ExecState& state, JSSVGImageElement& thisObject, ThrowScope& throwScope) |
| 249 | { |
| 250 | UNUSED_PARAM(throwScope); |
| 251 | UNUSED_PARAM(state); |
| 252 | auto& impl = thisObject.wrapped(); |
| 253 | JSValue result = toJS<IDLInterface<SVGAnimatedBoolean>>(state, *thisObject.globalObject(), throwScope, impl.externalResourcesRequiredAnimated()); |
| 254 | return result; |
| 255 | } |
| 256 | |
| 257 | EncodedJSValue jsSVGImageElementExternalResourcesRequired(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 258 | { |
| 259 | return IDLAttribute<JSSVGImageElement>::get<jsSVGImageElementExternalResourcesRequiredGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "externalResourcesRequired" ); |
| 260 | } |
| 261 | |
| 262 | static inline JSValue jsSVGImageElementHrefGetter(ExecState& state, JSSVGImageElement& thisObject, ThrowScope& throwScope) |
| 263 | { |
| 264 | UNUSED_PARAM(throwScope); |
| 265 | UNUSED_PARAM(state); |
| 266 | auto& impl = thisObject.wrapped(); |
| 267 | JSValue result = toJS<IDLInterface<SVGAnimatedString>>(state, *thisObject.globalObject(), throwScope, impl.hrefAnimated()); |
| 268 | return result; |
| 269 | } |
| 270 | |
| 271 | EncodedJSValue jsSVGImageElementHref(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 272 | { |
| 273 | return IDLAttribute<JSSVGImageElement>::get<jsSVGImageElementHrefGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "href" ); |
| 274 | } |
| 275 | |
| 276 | void JSSVGImageElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 277 | { |
| 278 | auto* thisObject = jsCast<JSSVGImageElement*>(cell); |
| 279 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 280 | if (thisObject->scriptExecutionContext()) |
| 281 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 282 | Base::heapSnapshot(cell, builder); |
| 283 | } |
| 284 | |
| 285 | |
| 286 | } |
| 287 | |