| 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 "JSDocumentFragment.h" |
| 23 | |
| 24 | #include "CustomElementReactionQueue.h" |
| 25 | #include "DOMJITAbstractHeapRepository.h" |
| 26 | #include "DOMJITIDLConvert.h" |
| 27 | #include "DOMJITIDLType.h" |
| 28 | #include "DOMJITIDLTypeFilter.h" |
| 29 | #include "Document.h" |
| 30 | #include "JSDOMAttribute.h" |
| 31 | #include "JSDOMBinding.h" |
| 32 | #include "JSDOMConstructor.h" |
| 33 | #include "JSDOMConvertInterface.h" |
| 34 | #include "JSDOMConvertNullable.h" |
| 35 | #include "JSDOMConvertNumbers.h" |
| 36 | #include "JSDOMConvertStrings.h" |
| 37 | #include "JSDOMConvertUnion.h" |
| 38 | #include "JSDOMConvertVariadic.h" |
| 39 | #include "JSDOMExceptionHandling.h" |
| 40 | #include "JSDOMGlobalObject.h" |
| 41 | #include "JSDOMOperation.h" |
| 42 | #include "JSDOMWrapperCache.h" |
| 43 | #include "JSElement.h" |
| 44 | #include "JSHTMLCollection.h" |
| 45 | #include "JSNodeList.h" |
| 46 | #include "ScriptExecutionContext.h" |
| 47 | #include <JavaScriptCore/FrameTracers.h> |
| 48 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 49 | #include <JavaScriptCore/JSCInlines.h> |
| 50 | #include <JavaScriptCore/ObjectConstructor.h> |
| 51 | #include <wtf/GetPtr.h> |
| 52 | #include <wtf/PointerPreparations.h> |
| 53 | #include <wtf/URL.h> |
| 54 | #include <wtf/Variant.h> |
| 55 | |
| 56 | |
| 57 | namespace WebCore { |
| 58 | using namespace JSC; |
| 59 | |
| 60 | // Functions |
| 61 | |
| 62 | JSC::EncodedJSValue JSC_HOST_CALL jsDocumentFragmentPrototypeFunctionGetElementById(JSC::ExecState*); |
| 63 | JSC::EncodedJSValue JIT_OPERATION unsafeJsDocumentFragmentPrototypeFunctionGetElementById(JSC::ExecState*, JSDocumentFragment*, DOMJIT::IDLJSArgumentType<IDLRequiresExistingAtomicStringAdaptor<IDLDOMString>>); |
| 64 | JSC::EncodedJSValue JSC_HOST_CALL jsDocumentFragmentPrototypeFunctionPrepend(JSC::ExecState*); |
| 65 | JSC::EncodedJSValue JSC_HOST_CALL jsDocumentFragmentPrototypeFunctionAppend(JSC::ExecState*); |
| 66 | JSC::EncodedJSValue JSC_HOST_CALL jsDocumentFragmentPrototypeFunctionQuerySelector(JSC::ExecState*); |
| 67 | JSC::EncodedJSValue JSC_HOST_CALL jsDocumentFragmentPrototypeFunctionQuerySelectorAll(JSC::ExecState*); |
| 68 | |
| 69 | // Attributes |
| 70 | |
| 71 | JSC::EncodedJSValue jsDocumentFragmentConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 72 | bool setJSDocumentFragmentConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 73 | JSC::EncodedJSValue jsDocumentFragmentChildren(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 74 | JSC::EncodedJSValue jsDocumentFragmentFirstElementChild(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 75 | JSC::EncodedJSValue jsDocumentFragmentLastElementChild(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 76 | JSC::EncodedJSValue jsDocumentFragmentChildElementCount(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 77 | |
| 78 | static const JSC::DOMJIT::Signature DOMJITSignatureForDocumentFragmentGetElementById((uintptr_t)unsafeJsDocumentFragmentPrototypeFunctionGetElementById, JSDocumentFragment::info(), JSC::DOMJIT::Effect::forRead(DOMJIT::AbstractHeapRepository::DOM), DOMJIT::IDLResultTypeFilter<IDLNullable<IDLInterface<Element>>>::value, DOMJIT::IDLArgumentTypeFilter<IDLRequiresExistingAtomicStringAdaptor<IDLDOMString>>::value); |
| 79 | |
| 80 | class JSDocumentFragmentPrototype : public JSC::JSNonFinalObject { |
| 81 | public: |
| 82 | using Base = JSC::JSNonFinalObject; |
| 83 | static JSDocumentFragmentPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 84 | { |
| 85 | JSDocumentFragmentPrototype* ptr = new (NotNull, JSC::allocateCell<JSDocumentFragmentPrototype>(vm.heap)) JSDocumentFragmentPrototype(vm, globalObject, structure); |
| 86 | ptr->finishCreation(vm); |
| 87 | return ptr; |
| 88 | } |
| 89 | |
| 90 | DECLARE_INFO; |
| 91 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 92 | { |
| 93 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 94 | } |
| 95 | |
| 96 | private: |
| 97 | JSDocumentFragmentPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 98 | : JSC::JSNonFinalObject(vm, structure) |
| 99 | { |
| 100 | } |
| 101 | |
| 102 | void finishCreation(JSC::VM&); |
| 103 | }; |
| 104 | |
| 105 | using JSDocumentFragmentConstructor = JSDOMConstructor<JSDocumentFragment>; |
| 106 | |
| 107 | template<> EncodedJSValue JSC_HOST_CALL JSDocumentFragmentConstructor::construct(ExecState* state) |
| 108 | { |
| 109 | VM& vm = state->vm(); |
| 110 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 111 | UNUSED_PARAM(throwScope); |
| 112 | auto* castedThis = jsCast<JSDocumentFragmentConstructor*>(state->jsCallee()); |
| 113 | ASSERT(castedThis); |
| 114 | auto* context = castedThis->scriptExecutionContext(); |
| 115 | if (UNLIKELY(!context)) |
| 116 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "DocumentFragment" ); |
| 117 | ASSERT(context->isDocument()); |
| 118 | auto& document = downcast<Document>(*context); |
| 119 | auto object = DocumentFragment::create(document); |
| 120 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DocumentFragment>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 121 | } |
| 122 | |
| 123 | template<> JSValue JSDocumentFragmentConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 124 | { |
| 125 | return JSNode::getConstructor(vm, &globalObject); |
| 126 | } |
| 127 | |
| 128 | template<> void JSDocumentFragmentConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 129 | { |
| 130 | putDirect(vm, vm.propertyNames->prototype, JSDocumentFragment::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 131 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("DocumentFragment"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 132 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 133 | } |
| 134 | |
| 135 | template<> const ClassInfo JSDocumentFragmentConstructor::s_info = { "DocumentFragment" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDocumentFragmentConstructor) }; |
| 136 | |
| 137 | /* Hash table for prototype */ |
| 138 | |
| 139 | static const HashTableValue JSDocumentFragmentPrototypeTableValues[] = |
| 140 | { |
| 141 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentFragmentConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDocumentFragmentConstructor) } }, |
| 142 | { "children" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentFragmentChildren), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 143 | { "firstElementChild" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentFragmentFirstElementChild), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 144 | { "lastElementChild" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentFragmentLastElementChild), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 145 | { "childElementCount" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentFragmentChildElementCount), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 146 | { "getElementById" , static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDocumentFragmentPrototypeFunctionGetElementById), (intptr_t) static_cast<const JSC::DOMJIT::Signature*>(&DOMJITSignatureForDocumentFragmentGetElementById) } }, |
| 147 | { "prepend" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDocumentFragmentPrototypeFunctionPrepend), (intptr_t) (0) } }, |
| 148 | { "append" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDocumentFragmentPrototypeFunctionAppend), (intptr_t) (0) } }, |
| 149 | { "querySelector" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDocumentFragmentPrototypeFunctionQuerySelector), (intptr_t) (1) } }, |
| 150 | { "querySelectorAll" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDocumentFragmentPrototypeFunctionQuerySelectorAll), (intptr_t) (1) } }, |
| 151 | }; |
| 152 | |
| 153 | const ClassInfo JSDocumentFragmentPrototype::s_info = { "DocumentFragmentPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDocumentFragmentPrototype) }; |
| 154 | |
| 155 | void JSDocumentFragmentPrototype::finishCreation(VM& vm) |
| 156 | { |
| 157 | Base::finishCreation(vm); |
| 158 | reifyStaticProperties(vm, JSDocumentFragment::info(), JSDocumentFragmentPrototypeTableValues, *this); |
| 159 | JSObject& unscopables = *constructEmptyObject(globalObject()->globalExec(), globalObject()->nullPrototypeObjectStructure()); |
| 160 | unscopables.putDirect(vm, Identifier::fromString(&vm, "prepend" ), jsBoolean(true)); |
| 161 | unscopables.putDirect(vm, Identifier::fromString(&vm, "append" ), jsBoolean(true)); |
| 162 | putDirectWithoutTransition(vm, vm.propertyNames->unscopablesSymbol, &unscopables, JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly); |
| 163 | } |
| 164 | |
| 165 | const ClassInfo JSDocumentFragment::s_info = { "DocumentFragment" , &Base::s_info, nullptr |
| 166 | #if ENABLE(JIT) |
| 167 | , &checkSubClassSnippetForJSDocumentFragment |
| 168 | #else |
| 169 | , nullptr |
| 170 | #endif |
| 171 | , CREATE_METHOD_TABLE(JSDocumentFragment) }; |
| 172 | |
| 173 | JSDocumentFragment::JSDocumentFragment(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DocumentFragment>&& impl) |
| 174 | : JSNode(structure, globalObject, WTFMove(impl)) |
| 175 | { |
| 176 | } |
| 177 | |
| 178 | void JSDocumentFragment::finishCreation(VM& vm) |
| 179 | { |
| 180 | Base::finishCreation(vm); |
| 181 | ASSERT(inherits(vm, info())); |
| 182 | |
| 183 | } |
| 184 | |
| 185 | JSObject* JSDocumentFragment::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 186 | { |
| 187 | return JSDocumentFragmentPrototype::create(vm, &globalObject, JSDocumentFragmentPrototype::createStructure(vm, &globalObject, JSNode::prototype(vm, globalObject))); |
| 188 | } |
| 189 | |
| 190 | JSObject* JSDocumentFragment::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 191 | { |
| 192 | return getDOMPrototype<JSDocumentFragment>(vm, globalObject); |
| 193 | } |
| 194 | |
| 195 | JSValue JSDocumentFragment::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 196 | { |
| 197 | return getDOMConstructor<JSDocumentFragmentConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 198 | } |
| 199 | |
| 200 | template<> inline JSDocumentFragment* IDLAttribute<JSDocumentFragment>::cast(ExecState& state, EncodedJSValue thisValue) |
| 201 | { |
| 202 | return jsDynamicCast<JSDocumentFragment*>(state.vm(), JSValue::decode(thisValue)); |
| 203 | } |
| 204 | |
| 205 | template<> inline JSDocumentFragment* IDLOperation<JSDocumentFragment>::cast(ExecState& state) |
| 206 | { |
| 207 | return jsDynamicCast<JSDocumentFragment*>(state.vm(), state.thisValue()); |
| 208 | } |
| 209 | |
| 210 | EncodedJSValue jsDocumentFragmentConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 211 | { |
| 212 | VM& vm = state->vm(); |
| 213 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 214 | auto* prototype = jsDynamicCast<JSDocumentFragmentPrototype*>(vm, JSValue::decode(thisValue)); |
| 215 | if (UNLIKELY(!prototype)) |
| 216 | return throwVMTypeError(state, throwScope); |
| 217 | return JSValue::encode(JSDocumentFragment::getConstructor(state->vm(), prototype->globalObject())); |
| 218 | } |
| 219 | |
| 220 | bool setJSDocumentFragmentConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 221 | { |
| 222 | VM& vm = state->vm(); |
| 223 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 224 | auto* prototype = jsDynamicCast<JSDocumentFragmentPrototype*>(vm, JSValue::decode(thisValue)); |
| 225 | if (UNLIKELY(!prototype)) { |
| 226 | throwVMTypeError(state, throwScope); |
| 227 | return false; |
| 228 | } |
| 229 | // Shadowing a built-in constructor |
| 230 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 231 | } |
| 232 | |
| 233 | static inline JSValue jsDocumentFragmentChildrenGetter(ExecState& state, JSDocumentFragment& thisObject, ThrowScope& throwScope) |
| 234 | { |
| 235 | UNUSED_PARAM(throwScope); |
| 236 | UNUSED_PARAM(state); |
| 237 | auto& impl = thisObject.wrapped(); |
| 238 | JSValue result = toJS<IDLInterface<HTMLCollection>>(state, *thisObject.globalObject(), throwScope, impl.children()); |
| 239 | return result; |
| 240 | } |
| 241 | |
| 242 | EncodedJSValue jsDocumentFragmentChildren(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 243 | { |
| 244 | return IDLAttribute<JSDocumentFragment>::get<jsDocumentFragmentChildrenGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "children" ); |
| 245 | } |
| 246 | |
| 247 | static inline JSValue jsDocumentFragmentFirstElementChildGetter(ExecState& state, JSDocumentFragment& thisObject, ThrowScope& throwScope) |
| 248 | { |
| 249 | UNUSED_PARAM(throwScope); |
| 250 | UNUSED_PARAM(state); |
| 251 | auto& impl = thisObject.wrapped(); |
| 252 | JSValue result = toJS<IDLNullable<IDLInterface<Element>>>(state, *thisObject.globalObject(), throwScope, impl.firstElementChild()); |
| 253 | return result; |
| 254 | } |
| 255 | |
| 256 | EncodedJSValue jsDocumentFragmentFirstElementChild(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 257 | { |
| 258 | return IDLAttribute<JSDocumentFragment>::get<jsDocumentFragmentFirstElementChildGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "firstElementChild" ); |
| 259 | } |
| 260 | |
| 261 | static inline JSValue jsDocumentFragmentLastElementChildGetter(ExecState& state, JSDocumentFragment& thisObject, ThrowScope& throwScope) |
| 262 | { |
| 263 | UNUSED_PARAM(throwScope); |
| 264 | UNUSED_PARAM(state); |
| 265 | auto& impl = thisObject.wrapped(); |
| 266 | JSValue result = toJS<IDLNullable<IDLInterface<Element>>>(state, *thisObject.globalObject(), throwScope, impl.lastElementChild()); |
| 267 | return result; |
| 268 | } |
| 269 | |
| 270 | EncodedJSValue jsDocumentFragmentLastElementChild(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 271 | { |
| 272 | return IDLAttribute<JSDocumentFragment>::get<jsDocumentFragmentLastElementChildGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "lastElementChild" ); |
| 273 | } |
| 274 | |
| 275 | static inline JSValue jsDocumentFragmentChildElementCountGetter(ExecState& state, JSDocumentFragment& thisObject, ThrowScope& throwScope) |
| 276 | { |
| 277 | UNUSED_PARAM(throwScope); |
| 278 | UNUSED_PARAM(state); |
| 279 | auto& impl = thisObject.wrapped(); |
| 280 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.childElementCount()); |
| 281 | return result; |
| 282 | } |
| 283 | |
| 284 | EncodedJSValue jsDocumentFragmentChildElementCount(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 285 | { |
| 286 | return IDLAttribute<JSDocumentFragment>::get<jsDocumentFragmentChildElementCountGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "childElementCount" ); |
| 287 | } |
| 288 | |
| 289 | static inline JSC::EncodedJSValue jsDocumentFragmentPrototypeFunctionGetElementByIdBody(JSC::ExecState* state, typename IDLOperation<JSDocumentFragment>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 290 | { |
| 291 | UNUSED_PARAM(state); |
| 292 | UNUSED_PARAM(throwScope); |
| 293 | auto& impl = castedThis->wrapped(); |
| 294 | if (UNLIKELY(state->argumentCount() < 1)) |
| 295 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 296 | auto elementId = convert<IDLRequiresExistingAtomicStringAdaptor<IDLDOMString>>(*state, state->uncheckedArgument(0)); |
| 297 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 298 | return JSValue::encode(toJS<IDLNullable<IDLInterface<Element>>>(*state, *castedThis->globalObject(), impl.getElementById(WTFMove(elementId)))); |
| 299 | } |
| 300 | |
| 301 | EncodedJSValue JSC_HOST_CALL jsDocumentFragmentPrototypeFunctionGetElementById(ExecState* state) |
| 302 | { |
| 303 | return IDLOperation<JSDocumentFragment>::call<jsDocumentFragmentPrototypeFunctionGetElementByIdBody>(*state, "getElementById" ); |
| 304 | } |
| 305 | |
| 306 | JSC::EncodedJSValue JIT_OPERATION unsafeJsDocumentFragmentPrototypeFunctionGetElementById(JSC::ExecState* state, JSDocumentFragment* castedThis, DOMJIT::IDLJSArgumentType<IDLRequiresExistingAtomicStringAdaptor<IDLDOMString>> encodedElementId) |
| 307 | { |
| 308 | UNUSED_PARAM(state); |
| 309 | VM& vm = state->vm(); |
| 310 | JSC::NativeCallFrameTracer tracer(&vm, state); |
| 311 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 312 | UNUSED_PARAM(throwScope); |
| 313 | auto& impl = castedThis->wrapped(); |
| 314 | auto elementId = DOMJIT::DirectConverter<IDLRequiresExistingAtomicStringAdaptor<IDLDOMString>>::directConvert(*state, encodedElementId); |
| 315 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 316 | return JSValue::encode(toJS<IDLNullable<IDLInterface<Element>>>(*state, *castedThis->globalObject(), impl.getElementById(WTFMove(elementId)))); |
| 317 | } |
| 318 | |
| 319 | static inline JSC::EncodedJSValue jsDocumentFragmentPrototypeFunctionPrependBody(JSC::ExecState* state, typename IDLOperation<JSDocumentFragment>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 320 | { |
| 321 | UNUSED_PARAM(state); |
| 322 | UNUSED_PARAM(throwScope); |
| 323 | CustomElementReactionStack customElementReactionStack(*state); |
| 324 | auto& impl = castedThis->wrapped(); |
| 325 | auto nodes = convertVariadicArguments<IDLUnion<IDLInterface<Node>, IDLDOMString>>(*state, 0); |
| 326 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 327 | propagateException(*state, throwScope, impl.prepend(WTFMove(nodes))); |
| 328 | return JSValue::encode(jsUndefined()); |
| 329 | } |
| 330 | |
| 331 | EncodedJSValue JSC_HOST_CALL jsDocumentFragmentPrototypeFunctionPrepend(ExecState* state) |
| 332 | { |
| 333 | return IDLOperation<JSDocumentFragment>::call<jsDocumentFragmentPrototypeFunctionPrependBody>(*state, "prepend" ); |
| 334 | } |
| 335 | |
| 336 | static inline JSC::EncodedJSValue jsDocumentFragmentPrototypeFunctionAppendBody(JSC::ExecState* state, typename IDLOperation<JSDocumentFragment>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 337 | { |
| 338 | UNUSED_PARAM(state); |
| 339 | UNUSED_PARAM(throwScope); |
| 340 | CustomElementReactionStack customElementReactionStack(*state); |
| 341 | auto& impl = castedThis->wrapped(); |
| 342 | auto nodes = convertVariadicArguments<IDLUnion<IDLInterface<Node>, IDLDOMString>>(*state, 0); |
| 343 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 344 | propagateException(*state, throwScope, impl.append(WTFMove(nodes))); |
| 345 | return JSValue::encode(jsUndefined()); |
| 346 | } |
| 347 | |
| 348 | EncodedJSValue JSC_HOST_CALL jsDocumentFragmentPrototypeFunctionAppend(ExecState* state) |
| 349 | { |
| 350 | return IDLOperation<JSDocumentFragment>::call<jsDocumentFragmentPrototypeFunctionAppendBody>(*state, "append" ); |
| 351 | } |
| 352 | |
| 353 | static inline JSC::EncodedJSValue jsDocumentFragmentPrototypeFunctionQuerySelectorBody(JSC::ExecState* state, typename IDLOperation<JSDocumentFragment>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 354 | { |
| 355 | UNUSED_PARAM(state); |
| 356 | UNUSED_PARAM(throwScope); |
| 357 | auto& impl = castedThis->wrapped(); |
| 358 | if (UNLIKELY(state->argumentCount() < 1)) |
| 359 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 360 | auto selectors = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 361 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 362 | return JSValue::encode(toJS<IDLNullable<IDLInterface<Element>>>(*state, *castedThis->globalObject(), throwScope, impl.querySelector(WTFMove(selectors)))); |
| 363 | } |
| 364 | |
| 365 | EncodedJSValue JSC_HOST_CALL jsDocumentFragmentPrototypeFunctionQuerySelector(ExecState* state) |
| 366 | { |
| 367 | return IDLOperation<JSDocumentFragment>::call<jsDocumentFragmentPrototypeFunctionQuerySelectorBody>(*state, "querySelector" ); |
| 368 | } |
| 369 | |
| 370 | static inline JSC::EncodedJSValue jsDocumentFragmentPrototypeFunctionQuerySelectorAllBody(JSC::ExecState* state, typename IDLOperation<JSDocumentFragment>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 371 | { |
| 372 | UNUSED_PARAM(state); |
| 373 | UNUSED_PARAM(throwScope); |
| 374 | auto& impl = castedThis->wrapped(); |
| 375 | if (UNLIKELY(state->argumentCount() < 1)) |
| 376 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 377 | auto selectors = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 378 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 379 | return JSValue::encode(toJSNewlyCreated<IDLInterface<NodeList>>(*state, *castedThis->globalObject(), throwScope, impl.querySelectorAll(WTFMove(selectors)))); |
| 380 | } |
| 381 | |
| 382 | EncodedJSValue JSC_HOST_CALL jsDocumentFragmentPrototypeFunctionQuerySelectorAll(ExecState* state) |
| 383 | { |
| 384 | return IDLOperation<JSDocumentFragment>::call<jsDocumentFragmentPrototypeFunctionQuerySelectorAllBody>(*state, "querySelectorAll" ); |
| 385 | } |
| 386 | |
| 387 | void JSDocumentFragment::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 388 | { |
| 389 | auto* thisObject = jsCast<JSDocumentFragment*>(cell); |
| 390 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 391 | if (thisObject->scriptExecutionContext()) |
| 392 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 393 | Base::heapSnapshot(cell, builder); |
| 394 | } |
| 395 | |
| 396 | |
| 397 | } |
| 398 | |