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