| 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 "JSHTMLSlotElement.h" |
| 23 | |
| 24 | #include "CustomElementReactionQueue.h" |
| 25 | #include "HTMLNames.h" |
| 26 | #include "JSDOMAttribute.h" |
| 27 | #include "JSDOMBinding.h" |
| 28 | #include "JSDOMConstructorNotConstructable.h" |
| 29 | #include "JSDOMConvertBoolean.h" |
| 30 | #include "JSDOMConvertInterface.h" |
| 31 | #include "JSDOMConvertSequences.h" |
| 32 | #include "JSDOMConvertStrings.h" |
| 33 | #include "JSDOMExceptionHandling.h" |
| 34 | #include "JSDOMGlobalObject.h" |
| 35 | #include "JSDOMOperation.h" |
| 36 | #include "JSDOMWrapperCache.h" |
| 37 | #include "JSElement.h" |
| 38 | #include "JSNode.h" |
| 39 | #include "ScriptExecutionContext.h" |
| 40 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 41 | #include <JavaScriptCore/JSArray.h> |
| 42 | #include <JavaScriptCore/JSCInlines.h> |
| 43 | #include <wtf/GetPtr.h> |
| 44 | #include <wtf/PointerPreparations.h> |
| 45 | #include <wtf/URL.h> |
| 46 | |
| 47 | |
| 48 | namespace WebCore { |
| 49 | using namespace JSC; |
| 50 | |
| 51 | template<> HTMLSlotElement::AssignedNodesOptions convertDictionary<HTMLSlotElement::AssignedNodesOptions>(ExecState& state, JSValue value) |
| 52 | { |
| 53 | VM& vm = state.vm(); |
| 54 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 55 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 56 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 57 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 58 | throwTypeError(&state, throwScope); |
| 59 | return { }; |
| 60 | } |
| 61 | HTMLSlotElement::AssignedNodesOptions result; |
| 62 | JSValue flattenValue; |
| 63 | if (isNullOrUndefined) |
| 64 | flattenValue = jsUndefined(); |
| 65 | else { |
| 66 | flattenValue = object->get(&state, Identifier::fromString(&state, "flatten" )); |
| 67 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 68 | } |
| 69 | if (!flattenValue.isUndefined()) { |
| 70 | result.flatten = convert<IDLBoolean>(state, flattenValue); |
| 71 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 72 | } else |
| 73 | result.flatten = false; |
| 74 | return result; |
| 75 | } |
| 76 | |
| 77 | // Functions |
| 78 | |
| 79 | JSC::EncodedJSValue JSC_HOST_CALL jsHTMLSlotElementPrototypeFunctionAssignedNodes(JSC::ExecState*); |
| 80 | JSC::EncodedJSValue JSC_HOST_CALL jsHTMLSlotElementPrototypeFunctionAssignedElements(JSC::ExecState*); |
| 81 | |
| 82 | // Attributes |
| 83 | |
| 84 | JSC::EncodedJSValue jsHTMLSlotElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 85 | bool setJSHTMLSlotElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 86 | JSC::EncodedJSValue jsHTMLSlotElementName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 87 | bool setJSHTMLSlotElementName(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 88 | |
| 89 | class JSHTMLSlotElementPrototype : public JSC::JSNonFinalObject { |
| 90 | public: |
| 91 | using Base = JSC::JSNonFinalObject; |
| 92 | static JSHTMLSlotElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 93 | { |
| 94 | JSHTMLSlotElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLSlotElementPrototype>(vm.heap)) JSHTMLSlotElementPrototype(vm, globalObject, structure); |
| 95 | ptr->finishCreation(vm); |
| 96 | return ptr; |
| 97 | } |
| 98 | |
| 99 | DECLARE_INFO; |
| 100 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 101 | { |
| 102 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 103 | } |
| 104 | |
| 105 | private: |
| 106 | JSHTMLSlotElementPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 107 | : JSC::JSNonFinalObject(vm, structure) |
| 108 | { |
| 109 | } |
| 110 | |
| 111 | void finishCreation(JSC::VM&); |
| 112 | }; |
| 113 | |
| 114 | using JSHTMLSlotElementConstructor = JSDOMConstructorNotConstructable<JSHTMLSlotElement>; |
| 115 | |
| 116 | template<> JSValue JSHTMLSlotElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 117 | { |
| 118 | return JSHTMLElement::getConstructor(vm, &globalObject); |
| 119 | } |
| 120 | |
| 121 | template<> void JSHTMLSlotElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 122 | { |
| 123 | putDirect(vm, vm.propertyNames->prototype, JSHTMLSlotElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 124 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HTMLSlotElement"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 125 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 126 | } |
| 127 | |
| 128 | template<> const ClassInfo JSHTMLSlotElementConstructor::s_info = { "HTMLSlotElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSlotElementConstructor) }; |
| 129 | |
| 130 | /* Hash table for prototype */ |
| 131 | |
| 132 | static const HashTableValue JSHTMLSlotElementPrototypeTableValues[] = |
| 133 | { |
| 134 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSlotElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSlotElementConstructor) } }, |
| 135 | { "name" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSlotElementName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSlotElementName) } }, |
| 136 | { "assignedNodes" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLSlotElementPrototypeFunctionAssignedNodes), (intptr_t) (0) } }, |
| 137 | { "assignedElements" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLSlotElementPrototypeFunctionAssignedElements), (intptr_t) (0) } }, |
| 138 | }; |
| 139 | |
| 140 | const ClassInfo JSHTMLSlotElementPrototype::s_info = { "HTMLSlotElementPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSlotElementPrototype) }; |
| 141 | |
| 142 | void JSHTMLSlotElementPrototype::finishCreation(VM& vm) |
| 143 | { |
| 144 | Base::finishCreation(vm); |
| 145 | reifyStaticProperties(vm, JSHTMLSlotElement::info(), JSHTMLSlotElementPrototypeTableValues, *this); |
| 146 | } |
| 147 | |
| 148 | const ClassInfo JSHTMLSlotElement::s_info = { "HTMLSlotElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSlotElement) }; |
| 149 | |
| 150 | JSHTMLSlotElement::JSHTMLSlotElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLSlotElement>&& impl) |
| 151 | : JSHTMLElement(structure, globalObject, WTFMove(impl)) |
| 152 | { |
| 153 | } |
| 154 | |
| 155 | void JSHTMLSlotElement::finishCreation(VM& vm) |
| 156 | { |
| 157 | Base::finishCreation(vm); |
| 158 | ASSERT(inherits(vm, info())); |
| 159 | |
| 160 | } |
| 161 | |
| 162 | JSObject* JSHTMLSlotElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 163 | { |
| 164 | return JSHTMLSlotElementPrototype::create(vm, &globalObject, JSHTMLSlotElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject))); |
| 165 | } |
| 166 | |
| 167 | JSObject* JSHTMLSlotElement::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 168 | { |
| 169 | return getDOMPrototype<JSHTMLSlotElement>(vm, globalObject); |
| 170 | } |
| 171 | |
| 172 | JSValue JSHTMLSlotElement::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 173 | { |
| 174 | return getDOMConstructor<JSHTMLSlotElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 175 | } |
| 176 | |
| 177 | template<> inline JSHTMLSlotElement* IDLAttribute<JSHTMLSlotElement>::cast(ExecState& state, EncodedJSValue thisValue) |
| 178 | { |
| 179 | return jsDynamicCast<JSHTMLSlotElement*>(state.vm(), JSValue::decode(thisValue)); |
| 180 | } |
| 181 | |
| 182 | template<> inline JSHTMLSlotElement* IDLOperation<JSHTMLSlotElement>::cast(ExecState& state) |
| 183 | { |
| 184 | return jsDynamicCast<JSHTMLSlotElement*>(state.vm(), state.thisValue()); |
| 185 | } |
| 186 | |
| 187 | EncodedJSValue jsHTMLSlotElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 188 | { |
| 189 | VM& vm = state->vm(); |
| 190 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 191 | auto* prototype = jsDynamicCast<JSHTMLSlotElementPrototype*>(vm, JSValue::decode(thisValue)); |
| 192 | if (UNLIKELY(!prototype)) |
| 193 | return throwVMTypeError(state, throwScope); |
| 194 | return JSValue::encode(JSHTMLSlotElement::getConstructor(state->vm(), prototype->globalObject())); |
| 195 | } |
| 196 | |
| 197 | bool setJSHTMLSlotElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 198 | { |
| 199 | VM& vm = state->vm(); |
| 200 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 201 | auto* prototype = jsDynamicCast<JSHTMLSlotElementPrototype*>(vm, JSValue::decode(thisValue)); |
| 202 | if (UNLIKELY(!prototype)) { |
| 203 | throwVMTypeError(state, throwScope); |
| 204 | return false; |
| 205 | } |
| 206 | // Shadowing a built-in constructor |
| 207 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 208 | } |
| 209 | |
| 210 | static inline JSValue jsHTMLSlotElementNameGetter(ExecState& state, JSHTMLSlotElement& thisObject, ThrowScope& throwScope) |
| 211 | { |
| 212 | UNUSED_PARAM(throwScope); |
| 213 | UNUSED_PARAM(state); |
| 214 | auto& impl = thisObject.wrapped(); |
| 215 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.getNameAttribute()); |
| 216 | return result; |
| 217 | } |
| 218 | |
| 219 | EncodedJSValue jsHTMLSlotElementName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 220 | { |
| 221 | return IDLAttribute<JSHTMLSlotElement>::get<jsHTMLSlotElementNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "name" ); |
| 222 | } |
| 223 | |
| 224 | static inline bool setJSHTMLSlotElementNameSetter(ExecState& state, JSHTMLSlotElement& thisObject, JSValue value, ThrowScope& throwScope) |
| 225 | { |
| 226 | UNUSED_PARAM(throwScope); |
| 227 | CustomElementReactionDisallowedScope customElementReactionDisallowedScope; |
| 228 | auto& impl = thisObject.wrapped(); |
| 229 | auto nativeValue = convert<IDLDOMString>(state, value); |
| 230 | RETURN_IF_EXCEPTION(throwScope, false); |
| 231 | AttributeSetter::call(state, throwScope, [&] { |
| 232 | return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::nameAttr, WTFMove(nativeValue)); |
| 233 | }); |
| 234 | return true; |
| 235 | } |
| 236 | |
| 237 | bool setJSHTMLSlotElementName(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 238 | { |
| 239 | return IDLAttribute<JSHTMLSlotElement>::set<setJSHTMLSlotElementNameSetter>(*state, thisValue, encodedValue, "name" ); |
| 240 | } |
| 241 | |
| 242 | static inline JSC::EncodedJSValue jsHTMLSlotElementPrototypeFunctionAssignedNodesBody(JSC::ExecState* state, typename IDLOperation<JSHTMLSlotElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 243 | { |
| 244 | UNUSED_PARAM(state); |
| 245 | UNUSED_PARAM(throwScope); |
| 246 | auto& impl = castedThis->wrapped(); |
| 247 | auto options = convert<IDLDictionary<HTMLSlotElement::AssignedNodesOptions>>(*state, state->argument(0)); |
| 248 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 249 | return JSValue::encode(toJS<IDLSequence<IDLInterface<Node>>>(*state, *castedThis->globalObject(), impl.assignedNodes(WTFMove(options)))); |
| 250 | } |
| 251 | |
| 252 | EncodedJSValue JSC_HOST_CALL jsHTMLSlotElementPrototypeFunctionAssignedNodes(ExecState* state) |
| 253 | { |
| 254 | return IDLOperation<JSHTMLSlotElement>::call<jsHTMLSlotElementPrototypeFunctionAssignedNodesBody>(*state, "assignedNodes" ); |
| 255 | } |
| 256 | |
| 257 | static inline JSC::EncodedJSValue jsHTMLSlotElementPrototypeFunctionAssignedElementsBody(JSC::ExecState* state, typename IDLOperation<JSHTMLSlotElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 258 | { |
| 259 | UNUSED_PARAM(state); |
| 260 | UNUSED_PARAM(throwScope); |
| 261 | auto& impl = castedThis->wrapped(); |
| 262 | auto options = convert<IDLDictionary<HTMLSlotElement::AssignedNodesOptions>>(*state, state->argument(0)); |
| 263 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 264 | return JSValue::encode(toJS<IDLSequence<IDLInterface<Element>>>(*state, *castedThis->globalObject(), impl.assignedElements(WTFMove(options)))); |
| 265 | } |
| 266 | |
| 267 | EncodedJSValue JSC_HOST_CALL jsHTMLSlotElementPrototypeFunctionAssignedElements(ExecState* state) |
| 268 | { |
| 269 | return IDLOperation<JSHTMLSlotElement>::call<jsHTMLSlotElementPrototypeFunctionAssignedElementsBody>(*state, "assignedElements" ); |
| 270 | } |
| 271 | |
| 272 | void JSHTMLSlotElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 273 | { |
| 274 | auto* thisObject = jsCast<JSHTMLSlotElement*>(cell); |
| 275 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 276 | if (thisObject->scriptExecutionContext()) |
| 277 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 278 | Base::heapSnapshot(cell, builder); |
| 279 | } |
| 280 | |
| 281 | HTMLSlotElement* JSHTMLSlotElement::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 282 | { |
| 283 | if (auto* wrapper = jsDynamicCast<JSHTMLSlotElement*>(vm, value)) |
| 284 | return &wrapper->wrapped(); |
| 285 | return nullptr; |
| 286 | } |
| 287 | |
| 288 | } |
| 289 | |