| 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 "JSHTMLModElement.h" |
| 23 | |
| 24 | #include "CustomElementReactionQueue.h" |
| 25 | #include "HTMLNames.h" |
| 26 | #include "JSDOMAttribute.h" |
| 27 | #include "JSDOMBinding.h" |
| 28 | #include "JSDOMConstructorNotConstructable.h" |
| 29 | #include "JSDOMConvertStrings.h" |
| 30 | #include "JSDOMExceptionHandling.h" |
| 31 | #include "JSDOMWrapperCache.h" |
| 32 | #include "ScriptExecutionContext.h" |
| 33 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 34 | #include <JavaScriptCore/JSCInlines.h> |
| 35 | #include <wtf/GetPtr.h> |
| 36 | #include <wtf/PointerPreparations.h> |
| 37 | #include <wtf/URL.h> |
| 38 | |
| 39 | |
| 40 | namespace WebCore { |
| 41 | using namespace JSC; |
| 42 | |
| 43 | // Attributes |
| 44 | |
| 45 | JSC::EncodedJSValue jsHTMLModElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 46 | bool setJSHTMLModElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 47 | JSC::EncodedJSValue jsHTMLModElementCite(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 48 | bool setJSHTMLModElementCite(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 49 | JSC::EncodedJSValue jsHTMLModElementDateTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 50 | bool setJSHTMLModElementDateTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 51 | |
| 52 | class JSHTMLModElementPrototype : public JSC::JSNonFinalObject { |
| 53 | public: |
| 54 | using Base = JSC::JSNonFinalObject; |
| 55 | static JSHTMLModElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 56 | { |
| 57 | JSHTMLModElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLModElementPrototype>(vm.heap)) JSHTMLModElementPrototype(vm, globalObject, structure); |
| 58 | ptr->finishCreation(vm); |
| 59 | return ptr; |
| 60 | } |
| 61 | |
| 62 | DECLARE_INFO; |
| 63 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 64 | { |
| 65 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 66 | } |
| 67 | |
| 68 | private: |
| 69 | JSHTMLModElementPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 70 | : JSC::JSNonFinalObject(vm, structure) |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | void finishCreation(JSC::VM&); |
| 75 | }; |
| 76 | |
| 77 | using JSHTMLModElementConstructor = JSDOMConstructorNotConstructable<JSHTMLModElement>; |
| 78 | |
| 79 | template<> JSValue JSHTMLModElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 80 | { |
| 81 | return JSHTMLElement::getConstructor(vm, &globalObject); |
| 82 | } |
| 83 | |
| 84 | template<> void JSHTMLModElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 85 | { |
| 86 | putDirect(vm, vm.propertyNames->prototype, JSHTMLModElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 87 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HTMLModElement"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 88 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 89 | } |
| 90 | |
| 91 | template<> const ClassInfo JSHTMLModElementConstructor::s_info = { "HTMLModElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLModElementConstructor) }; |
| 92 | |
| 93 | /* Hash table for prototype */ |
| 94 | |
| 95 | static const HashTableValue JSHTMLModElementPrototypeTableValues[] = |
| 96 | { |
| 97 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLModElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLModElementConstructor) } }, |
| 98 | { "cite" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLModElementCite), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLModElementCite) } }, |
| 99 | { "dateTime" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLModElementDateTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLModElementDateTime) } }, |
| 100 | }; |
| 101 | |
| 102 | const ClassInfo JSHTMLModElementPrototype::s_info = { "HTMLModElementPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLModElementPrototype) }; |
| 103 | |
| 104 | void JSHTMLModElementPrototype::finishCreation(VM& vm) |
| 105 | { |
| 106 | Base::finishCreation(vm); |
| 107 | reifyStaticProperties(vm, JSHTMLModElement::info(), JSHTMLModElementPrototypeTableValues, *this); |
| 108 | } |
| 109 | |
| 110 | const ClassInfo JSHTMLModElement::s_info = { "HTMLModElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLModElement) }; |
| 111 | |
| 112 | JSHTMLModElement::JSHTMLModElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLModElement>&& impl) |
| 113 | : JSHTMLElement(structure, globalObject, WTFMove(impl)) |
| 114 | { |
| 115 | } |
| 116 | |
| 117 | void JSHTMLModElement::finishCreation(VM& vm) |
| 118 | { |
| 119 | Base::finishCreation(vm); |
| 120 | ASSERT(inherits(vm, info())); |
| 121 | |
| 122 | } |
| 123 | |
| 124 | JSObject* JSHTMLModElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 125 | { |
| 126 | return JSHTMLModElementPrototype::create(vm, &globalObject, JSHTMLModElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject))); |
| 127 | } |
| 128 | |
| 129 | JSObject* JSHTMLModElement::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 130 | { |
| 131 | return getDOMPrototype<JSHTMLModElement>(vm, globalObject); |
| 132 | } |
| 133 | |
| 134 | JSValue JSHTMLModElement::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 135 | { |
| 136 | return getDOMConstructor<JSHTMLModElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 137 | } |
| 138 | |
| 139 | template<> inline JSHTMLModElement* IDLAttribute<JSHTMLModElement>::cast(ExecState& state, EncodedJSValue thisValue) |
| 140 | { |
| 141 | return jsDynamicCast<JSHTMLModElement*>(state.vm(), JSValue::decode(thisValue)); |
| 142 | } |
| 143 | |
| 144 | EncodedJSValue jsHTMLModElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 145 | { |
| 146 | VM& vm = state->vm(); |
| 147 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 148 | auto* prototype = jsDynamicCast<JSHTMLModElementPrototype*>(vm, JSValue::decode(thisValue)); |
| 149 | if (UNLIKELY(!prototype)) |
| 150 | return throwVMTypeError(state, throwScope); |
| 151 | return JSValue::encode(JSHTMLModElement::getConstructor(state->vm(), prototype->globalObject())); |
| 152 | } |
| 153 | |
| 154 | bool setJSHTMLModElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 155 | { |
| 156 | VM& vm = state->vm(); |
| 157 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 158 | auto* prototype = jsDynamicCast<JSHTMLModElementPrototype*>(vm, JSValue::decode(thisValue)); |
| 159 | if (UNLIKELY(!prototype)) { |
| 160 | throwVMTypeError(state, throwScope); |
| 161 | return false; |
| 162 | } |
| 163 | // Shadowing a built-in constructor |
| 164 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 165 | } |
| 166 | |
| 167 | static inline JSValue jsHTMLModElementCiteGetter(ExecState& state, JSHTMLModElement& thisObject, ThrowScope& throwScope) |
| 168 | { |
| 169 | UNUSED_PARAM(throwScope); |
| 170 | UNUSED_PARAM(state); |
| 171 | auto& impl = thisObject.wrapped(); |
| 172 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.getURLAttribute(WebCore::HTMLNames::citeAttr)); |
| 173 | return result; |
| 174 | } |
| 175 | |
| 176 | EncodedJSValue jsHTMLModElementCite(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 177 | { |
| 178 | return IDLAttribute<JSHTMLModElement>::get<jsHTMLModElementCiteGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "cite" ); |
| 179 | } |
| 180 | |
| 181 | static inline bool setJSHTMLModElementCiteSetter(ExecState& state, JSHTMLModElement& thisObject, JSValue value, ThrowScope& throwScope) |
| 182 | { |
| 183 | UNUSED_PARAM(throwScope); |
| 184 | CustomElementReactionDisallowedScope customElementReactionDisallowedScope; |
| 185 | auto& impl = thisObject.wrapped(); |
| 186 | auto nativeValue = convert<IDLUSVString>(state, value); |
| 187 | RETURN_IF_EXCEPTION(throwScope, false); |
| 188 | AttributeSetter::call(state, throwScope, [&] { |
| 189 | return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::citeAttr, WTFMove(nativeValue)); |
| 190 | }); |
| 191 | return true; |
| 192 | } |
| 193 | |
| 194 | bool setJSHTMLModElementCite(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 195 | { |
| 196 | return IDLAttribute<JSHTMLModElement>::set<setJSHTMLModElementCiteSetter>(*state, thisValue, encodedValue, "cite" ); |
| 197 | } |
| 198 | |
| 199 | static inline JSValue jsHTMLModElementDateTimeGetter(ExecState& state, JSHTMLModElement& thisObject, ThrowScope& throwScope) |
| 200 | { |
| 201 | UNUSED_PARAM(throwScope); |
| 202 | UNUSED_PARAM(state); |
| 203 | auto& impl = thisObject.wrapped(); |
| 204 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attributeWithoutSynchronization(WebCore::HTMLNames::datetimeAttr)); |
| 205 | return result; |
| 206 | } |
| 207 | |
| 208 | EncodedJSValue jsHTMLModElementDateTime(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 209 | { |
| 210 | return IDLAttribute<JSHTMLModElement>::get<jsHTMLModElementDateTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "dateTime" ); |
| 211 | } |
| 212 | |
| 213 | static inline bool setJSHTMLModElementDateTimeSetter(ExecState& state, JSHTMLModElement& thisObject, JSValue value, ThrowScope& throwScope) |
| 214 | { |
| 215 | UNUSED_PARAM(throwScope); |
| 216 | CustomElementReactionDisallowedScope customElementReactionDisallowedScope; |
| 217 | auto& impl = thisObject.wrapped(); |
| 218 | auto nativeValue = convert<IDLDOMString>(state, value); |
| 219 | RETURN_IF_EXCEPTION(throwScope, false); |
| 220 | AttributeSetter::call(state, throwScope, [&] { |
| 221 | return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::datetimeAttr, WTFMove(nativeValue)); |
| 222 | }); |
| 223 | return true; |
| 224 | } |
| 225 | |
| 226 | bool setJSHTMLModElementDateTime(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 227 | { |
| 228 | return IDLAttribute<JSHTMLModElement>::set<setJSHTMLModElementDateTimeSetter>(*state, thisValue, encodedValue, "dateTime" ); |
| 229 | } |
| 230 | |
| 231 | void JSHTMLModElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 232 | { |
| 233 | auto* thisObject = jsCast<JSHTMLModElement*>(cell); |
| 234 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 235 | if (thisObject->scriptExecutionContext()) |
| 236 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 237 | Base::heapSnapshot(cell, builder); |
| 238 | } |
| 239 | |
| 240 | |
| 241 | } |
| 242 | |