| 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 "JSHTMLBaseElement.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 jsHTMLBaseElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 46 | bool setJSHTMLBaseElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 47 | JSC::EncodedJSValue jsHTMLBaseElementHref(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 48 | bool setJSHTMLBaseElementHref(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 49 | JSC::EncodedJSValue jsHTMLBaseElementTarget(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 50 | bool setJSHTMLBaseElementTarget(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 51 | |
| 52 | class JSHTMLBaseElementPrototype : public JSC::JSNonFinalObject { |
| 53 | public: |
| 54 | using Base = JSC::JSNonFinalObject; |
| 55 | static JSHTMLBaseElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 56 | { |
| 57 | JSHTMLBaseElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLBaseElementPrototype>(vm.heap)) JSHTMLBaseElementPrototype(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 | JSHTMLBaseElementPrototype(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 JSHTMLBaseElementConstructor = JSDOMConstructorNotConstructable<JSHTMLBaseElement>; |
| 78 | |
| 79 | template<> JSValue JSHTMLBaseElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 80 | { |
| 81 | return JSHTMLElement::getConstructor(vm, &globalObject); |
| 82 | } |
| 83 | |
| 84 | template<> void JSHTMLBaseElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 85 | { |
| 86 | putDirect(vm, vm.propertyNames->prototype, JSHTMLBaseElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 87 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HTMLBaseElement"_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 JSHTMLBaseElementConstructor::s_info = { "HTMLBaseElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLBaseElementConstructor) }; |
| 92 | |
| 93 | /* Hash table for prototype */ |
| 94 | |
| 95 | static const HashTableValue JSHTMLBaseElementPrototypeTableValues[] = |
| 96 | { |
| 97 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLBaseElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLBaseElementConstructor) } }, |
| 98 | { "href" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLBaseElementHref), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLBaseElementHref) } }, |
| 99 | { "target" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLBaseElementTarget), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLBaseElementTarget) } }, |
| 100 | }; |
| 101 | |
| 102 | const ClassInfo JSHTMLBaseElementPrototype::s_info = { "HTMLBaseElementPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLBaseElementPrototype) }; |
| 103 | |
| 104 | void JSHTMLBaseElementPrototype::finishCreation(VM& vm) |
| 105 | { |
| 106 | Base::finishCreation(vm); |
| 107 | reifyStaticProperties(vm, JSHTMLBaseElement::info(), JSHTMLBaseElementPrototypeTableValues, *this); |
| 108 | } |
| 109 | |
| 110 | const ClassInfo JSHTMLBaseElement::s_info = { "HTMLBaseElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLBaseElement) }; |
| 111 | |
| 112 | JSHTMLBaseElement::JSHTMLBaseElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLBaseElement>&& impl) |
| 113 | : JSHTMLElement(structure, globalObject, WTFMove(impl)) |
| 114 | { |
| 115 | } |
| 116 | |
| 117 | void JSHTMLBaseElement::finishCreation(VM& vm) |
| 118 | { |
| 119 | Base::finishCreation(vm); |
| 120 | ASSERT(inherits(vm, info())); |
| 121 | |
| 122 | } |
| 123 | |
| 124 | JSObject* JSHTMLBaseElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 125 | { |
| 126 | return JSHTMLBaseElementPrototype::create(vm, &globalObject, JSHTMLBaseElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject))); |
| 127 | } |
| 128 | |
| 129 | JSObject* JSHTMLBaseElement::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 130 | { |
| 131 | return getDOMPrototype<JSHTMLBaseElement>(vm, globalObject); |
| 132 | } |
| 133 | |
| 134 | JSValue JSHTMLBaseElement::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 135 | { |
| 136 | return getDOMConstructor<JSHTMLBaseElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 137 | } |
| 138 | |
| 139 | template<> inline JSHTMLBaseElement* IDLAttribute<JSHTMLBaseElement>::cast(ExecState& state, EncodedJSValue thisValue) |
| 140 | { |
| 141 | return jsDynamicCast<JSHTMLBaseElement*>(state.vm(), JSValue::decode(thisValue)); |
| 142 | } |
| 143 | |
| 144 | EncodedJSValue jsHTMLBaseElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 145 | { |
| 146 | VM& vm = state->vm(); |
| 147 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 148 | auto* prototype = jsDynamicCast<JSHTMLBaseElementPrototype*>(vm, JSValue::decode(thisValue)); |
| 149 | if (UNLIKELY(!prototype)) |
| 150 | return throwVMTypeError(state, throwScope); |
| 151 | return JSValue::encode(JSHTMLBaseElement::getConstructor(state->vm(), prototype->globalObject())); |
| 152 | } |
| 153 | |
| 154 | bool setJSHTMLBaseElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 155 | { |
| 156 | VM& vm = state->vm(); |
| 157 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 158 | auto* prototype = jsDynamicCast<JSHTMLBaseElementPrototype*>(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 jsHTMLBaseElementHrefGetter(ExecState& state, JSHTMLBaseElement& 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.href()); |
| 173 | return result; |
| 174 | } |
| 175 | |
| 176 | EncodedJSValue jsHTMLBaseElementHref(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 177 | { |
| 178 | return IDLAttribute<JSHTMLBaseElement>::get<jsHTMLBaseElementHrefGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "href" ); |
| 179 | } |
| 180 | |
| 181 | static inline bool setJSHTMLBaseElementHrefSetter(ExecState& state, JSHTMLBaseElement& 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.setHref(WTFMove(nativeValue)); |
| 190 | }); |
| 191 | return true; |
| 192 | } |
| 193 | |
| 194 | bool setJSHTMLBaseElementHref(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 195 | { |
| 196 | return IDLAttribute<JSHTMLBaseElement>::set<setJSHTMLBaseElementHrefSetter>(*state, thisValue, encodedValue, "href" ); |
| 197 | } |
| 198 | |
| 199 | static inline JSValue jsHTMLBaseElementTargetGetter(ExecState& state, JSHTMLBaseElement& 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::targetAttr)); |
| 205 | return result; |
| 206 | } |
| 207 | |
| 208 | EncodedJSValue jsHTMLBaseElementTarget(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 209 | { |
| 210 | return IDLAttribute<JSHTMLBaseElement>::get<jsHTMLBaseElementTargetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "target" ); |
| 211 | } |
| 212 | |
| 213 | static inline bool setJSHTMLBaseElementTargetSetter(ExecState& state, JSHTMLBaseElement& 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::targetAttr, WTFMove(nativeValue)); |
| 222 | }); |
| 223 | return true; |
| 224 | } |
| 225 | |
| 226 | bool setJSHTMLBaseElementTarget(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 227 | { |
| 228 | return IDLAttribute<JSHTMLBaseElement>::set<setJSHTMLBaseElementTargetSetter>(*state, thisValue, encodedValue, "target" ); |
| 229 | } |
| 230 | |
| 231 | void JSHTMLBaseElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 232 | { |
| 233 | auto* thisObject = jsCast<JSHTMLBaseElement*>(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 | |