| 1 | /* |
| 2 | This file is part of the WebKit open source project. |
| 3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Library General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Library General Public License |
| 16 | along with this library; see the file COPYING.LIB. If not, write to |
| 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | |
| 23 | #if ENABLE(ATTACHMENT_ELEMENT) |
| 24 | |
| 25 | #include "JSHTMLAttachmentElement.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructorNotConstructable.h" |
| 30 | #include "JSDOMConvertInterface.h" |
| 31 | #include "JSDOMConvertNullable.h" |
| 32 | #include "JSDOMConvertStrings.h" |
| 33 | #include "JSDOMExceptionHandling.h" |
| 34 | #include "JSDOMGlobalObject.h" |
| 35 | #include "JSDOMOperation.h" |
| 36 | #include "JSDOMWrapperCache.h" |
| 37 | #include "JSFile.h" |
| 38 | #include "JSHTMLImageElement.h" |
| 39 | #include "ScriptExecutionContext.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 jsHTMLAttachmentElementConstructorFunctionGetAttachmentIdentifier(JSC::ExecState*); |
| 53 | |
| 54 | // Attributes |
| 55 | |
| 56 | JSC::EncodedJSValue jsHTMLAttachmentElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 57 | bool setJSHTMLAttachmentElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 58 | JSC::EncodedJSValue jsHTMLAttachmentElementFile(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 59 | bool setJSHTMLAttachmentElementFile(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 60 | JSC::EncodedJSValue jsHTMLAttachmentElementUniqueIdentifier(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 61 | |
| 62 | class JSHTMLAttachmentElementPrototype : public JSC::JSNonFinalObject { |
| 63 | public: |
| 64 | using Base = JSC::JSNonFinalObject; |
| 65 | static JSHTMLAttachmentElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 66 | { |
| 67 | JSHTMLAttachmentElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLAttachmentElementPrototype>(vm.heap)) JSHTMLAttachmentElementPrototype(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 | JSHTMLAttachmentElementPrototype(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 JSHTMLAttachmentElementConstructor = JSDOMConstructorNotConstructable<JSHTMLAttachmentElement>; |
| 88 | |
| 89 | /* Hash table for constructor */ |
| 90 | |
| 91 | static const HashTableValue JSHTMLAttachmentElementConstructorTableValues[] = |
| 92 | { |
| 93 | { "getAttachmentIdentifier" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLAttachmentElementConstructorFunctionGetAttachmentIdentifier), (intptr_t) (1) } }, |
| 94 | }; |
| 95 | |
| 96 | template<> JSValue JSHTMLAttachmentElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 97 | { |
| 98 | return JSHTMLElement::getConstructor(vm, &globalObject); |
| 99 | } |
| 100 | |
| 101 | template<> void JSHTMLAttachmentElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 102 | { |
| 103 | putDirect(vm, vm.propertyNames->prototype, JSHTMLAttachmentElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 104 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HTMLAttachmentElement"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 105 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 106 | reifyStaticProperties(vm, JSHTMLAttachmentElement::info(), JSHTMLAttachmentElementConstructorTableValues, *this); |
| 107 | } |
| 108 | |
| 109 | template<> const ClassInfo JSHTMLAttachmentElementConstructor::s_info = { "HTMLAttachmentElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLAttachmentElementConstructor) }; |
| 110 | |
| 111 | /* Hash table for prototype */ |
| 112 | |
| 113 | static const HashTableValue JSHTMLAttachmentElementPrototypeTableValues[] = |
| 114 | { |
| 115 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLAttachmentElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLAttachmentElementConstructor) } }, |
| 116 | { "file" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLAttachmentElementFile), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLAttachmentElementFile) } }, |
| 117 | { "uniqueIdentifier" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLAttachmentElementUniqueIdentifier), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 118 | }; |
| 119 | |
| 120 | const ClassInfo JSHTMLAttachmentElementPrototype::s_info = { "HTMLAttachmentElementPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLAttachmentElementPrototype) }; |
| 121 | |
| 122 | void JSHTMLAttachmentElementPrototype::finishCreation(VM& vm) |
| 123 | { |
| 124 | Base::finishCreation(vm); |
| 125 | reifyStaticProperties(vm, JSHTMLAttachmentElement::info(), JSHTMLAttachmentElementPrototypeTableValues, *this); |
| 126 | } |
| 127 | |
| 128 | const ClassInfo JSHTMLAttachmentElement::s_info = { "HTMLAttachmentElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLAttachmentElement) }; |
| 129 | |
| 130 | JSHTMLAttachmentElement::JSHTMLAttachmentElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLAttachmentElement>&& impl) |
| 131 | : JSHTMLElement(structure, globalObject, WTFMove(impl)) |
| 132 | { |
| 133 | } |
| 134 | |
| 135 | void JSHTMLAttachmentElement::finishCreation(VM& vm) |
| 136 | { |
| 137 | Base::finishCreation(vm); |
| 138 | ASSERT(inherits(vm, info())); |
| 139 | |
| 140 | } |
| 141 | |
| 142 | JSObject* JSHTMLAttachmentElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 143 | { |
| 144 | return JSHTMLAttachmentElementPrototype::create(vm, &globalObject, JSHTMLAttachmentElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject))); |
| 145 | } |
| 146 | |
| 147 | JSObject* JSHTMLAttachmentElement::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 148 | { |
| 149 | return getDOMPrototype<JSHTMLAttachmentElement>(vm, globalObject); |
| 150 | } |
| 151 | |
| 152 | JSValue JSHTMLAttachmentElement::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 153 | { |
| 154 | return getDOMConstructor<JSHTMLAttachmentElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 155 | } |
| 156 | |
| 157 | template<> inline JSHTMLAttachmentElement* IDLAttribute<JSHTMLAttachmentElement>::cast(ExecState& state, EncodedJSValue thisValue) |
| 158 | { |
| 159 | return jsDynamicCast<JSHTMLAttachmentElement*>(state.vm(), JSValue::decode(thisValue)); |
| 160 | } |
| 161 | |
| 162 | template<> inline JSHTMLAttachmentElement* IDLOperation<JSHTMLAttachmentElement>::cast(ExecState& state) |
| 163 | { |
| 164 | return jsDynamicCast<JSHTMLAttachmentElement*>(state.vm(), state.thisValue()); |
| 165 | } |
| 166 | |
| 167 | EncodedJSValue jsHTMLAttachmentElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 168 | { |
| 169 | VM& vm = state->vm(); |
| 170 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 171 | auto* prototype = jsDynamicCast<JSHTMLAttachmentElementPrototype*>(vm, JSValue::decode(thisValue)); |
| 172 | if (UNLIKELY(!prototype)) |
| 173 | return throwVMTypeError(state, throwScope); |
| 174 | return JSValue::encode(JSHTMLAttachmentElement::getConstructor(state->vm(), prototype->globalObject())); |
| 175 | } |
| 176 | |
| 177 | bool setJSHTMLAttachmentElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 178 | { |
| 179 | VM& vm = state->vm(); |
| 180 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 181 | auto* prototype = jsDynamicCast<JSHTMLAttachmentElementPrototype*>(vm, JSValue::decode(thisValue)); |
| 182 | if (UNLIKELY(!prototype)) { |
| 183 | throwVMTypeError(state, throwScope); |
| 184 | return false; |
| 185 | } |
| 186 | // Shadowing a built-in constructor |
| 187 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 188 | } |
| 189 | |
| 190 | static inline JSValue jsHTMLAttachmentElementFileGetter(ExecState& state, JSHTMLAttachmentElement& thisObject, ThrowScope& throwScope) |
| 191 | { |
| 192 | UNUSED_PARAM(throwScope); |
| 193 | UNUSED_PARAM(state); |
| 194 | auto& impl = thisObject.wrapped(); |
| 195 | JSValue result = toJS<IDLNullable<IDLInterface<File>>>(state, *thisObject.globalObject(), throwScope, impl.file()); |
| 196 | return result; |
| 197 | } |
| 198 | |
| 199 | EncodedJSValue jsHTMLAttachmentElementFile(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 200 | { |
| 201 | return IDLAttribute<JSHTMLAttachmentElement>::get<jsHTMLAttachmentElementFileGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "file" ); |
| 202 | } |
| 203 | |
| 204 | static inline bool setJSHTMLAttachmentElementFileSetter(ExecState& state, JSHTMLAttachmentElement& thisObject, JSValue value, ThrowScope& throwScope) |
| 205 | { |
| 206 | UNUSED_PARAM(throwScope); |
| 207 | auto& impl = thisObject.wrapped(); |
| 208 | auto nativeValue = convert<IDLNullable<IDLInterface<File>>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "HTMLAttachmentElement" , "file" , "File" ); }); |
| 209 | RETURN_IF_EXCEPTION(throwScope, false); |
| 210 | AttributeSetter::call(state, throwScope, [&] { |
| 211 | return impl.setFile(WTFMove(nativeValue)); |
| 212 | }); |
| 213 | return true; |
| 214 | } |
| 215 | |
| 216 | bool setJSHTMLAttachmentElementFile(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 217 | { |
| 218 | return IDLAttribute<JSHTMLAttachmentElement>::set<setJSHTMLAttachmentElementFileSetter>(*state, thisValue, encodedValue, "file" ); |
| 219 | } |
| 220 | |
| 221 | static inline JSValue jsHTMLAttachmentElementUniqueIdentifierGetter(ExecState& state, JSHTMLAttachmentElement& thisObject, ThrowScope& throwScope) |
| 222 | { |
| 223 | UNUSED_PARAM(throwScope); |
| 224 | UNUSED_PARAM(state); |
| 225 | auto& impl = thisObject.wrapped(); |
| 226 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.uniqueIdentifier()); |
| 227 | return result; |
| 228 | } |
| 229 | |
| 230 | EncodedJSValue jsHTMLAttachmentElementUniqueIdentifier(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 231 | { |
| 232 | return IDLAttribute<JSHTMLAttachmentElement>::get<jsHTMLAttachmentElementUniqueIdentifierGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "uniqueIdentifier" ); |
| 233 | } |
| 234 | |
| 235 | static inline JSC::EncodedJSValue jsHTMLAttachmentElementConstructorFunctionGetAttachmentIdentifierBody(JSC::ExecState* state, JSC::ThrowScope& throwScope) |
| 236 | { |
| 237 | UNUSED_PARAM(state); |
| 238 | UNUSED_PARAM(throwScope); |
| 239 | if (UNLIKELY(state->argumentCount() < 1)) |
| 240 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 241 | auto imageElement = convert<IDLInterface<HTMLImageElement>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "imageElement" , "HTMLAttachmentElement" , "getAttachmentIdentifier" , "HTMLImageElement" ); }); |
| 242 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 243 | return JSValue::encode(toJS<IDLDOMString>(*state, HTMLAttachmentElement::getAttachmentIdentifier(*imageElement))); |
| 244 | } |
| 245 | |
| 246 | EncodedJSValue JSC_HOST_CALL jsHTMLAttachmentElementConstructorFunctionGetAttachmentIdentifier(ExecState* state) |
| 247 | { |
| 248 | return IDLOperation<JSHTMLAttachmentElement>::callStatic<jsHTMLAttachmentElementConstructorFunctionGetAttachmentIdentifierBody>(*state, "getAttachmentIdentifier" ); |
| 249 | } |
| 250 | |
| 251 | void JSHTMLAttachmentElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 252 | { |
| 253 | auto* thisObject = jsCast<JSHTMLAttachmentElement*>(cell); |
| 254 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 255 | if (thisObject->scriptExecutionContext()) |
| 256 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 257 | Base::heapSnapshot(cell, builder); |
| 258 | } |
| 259 | |
| 260 | |
| 261 | } |
| 262 | |
| 263 | #endif // ENABLE(ATTACHMENT_ELEMENT) |
| 264 | |