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 "JSHTMLAllCollection.h" |
23 | |
24 | #include "Element.h" |
25 | #include "JSDOMAbstractOperations.h" |
26 | #include "JSDOMAttribute.h" |
27 | #include "JSDOMBinding.h" |
28 | #include "JSDOMConstructorNotConstructable.h" |
29 | #include "JSDOMConvertInterface.h" |
30 | #include "JSDOMConvertNullable.h" |
31 | #include "JSDOMConvertNumbers.h" |
32 | #include "JSDOMConvertStrings.h" |
33 | #include "JSDOMConvertUnion.h" |
34 | #include "JSDOMExceptionHandling.h" |
35 | #include "JSDOMGlobalObject.h" |
36 | #include "JSDOMOperation.h" |
37 | #include "JSDOMWrapperCache.h" |
38 | #include "JSElement.h" |
39 | #include "JSHTMLCollection.h" |
40 | #include "JSNode.h" |
41 | #include "JSNodeCustom.h" |
42 | #include "Node.h" |
43 | #include "ScriptExecutionContext.h" |
44 | #include <JavaScriptCore/ArrayPrototype.h> |
45 | #include <JavaScriptCore/BuiltinNames.h> |
46 | #include <JavaScriptCore/FunctionPrototype.h> |
47 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
48 | #include <JavaScriptCore/JSCInlines.h> |
49 | #include <JavaScriptCore/PropertyNameArray.h> |
50 | #include <wtf/GetPtr.h> |
51 | #include <wtf/PointerPreparations.h> |
52 | #include <wtf/URL.h> |
53 | #include <wtf/Variant.h> |
54 | |
55 | |
56 | namespace WebCore { |
57 | using namespace JSC; |
58 | |
59 | // Functions |
60 | |
61 | JSC::EncodedJSValue JSC_HOST_CALL jsHTMLAllCollectionPrototypeFunctionNamedItem(JSC::ExecState*); |
62 | JSC::EncodedJSValue JSC_HOST_CALL jsHTMLAllCollectionPrototypeFunctionItem(JSC::ExecState*); |
63 | |
64 | // Attributes |
65 | |
66 | JSC::EncodedJSValue jsHTMLAllCollectionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
67 | bool setJSHTMLAllCollectionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
68 | JSC::EncodedJSValue jsHTMLAllCollectionLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
69 | |
70 | class JSHTMLAllCollectionPrototype : public JSC::JSNonFinalObject { |
71 | public: |
72 | using Base = JSC::JSNonFinalObject; |
73 | static JSHTMLAllCollectionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
74 | { |
75 | JSHTMLAllCollectionPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLAllCollectionPrototype>(vm.heap)) JSHTMLAllCollectionPrototype(vm, globalObject, structure); |
76 | ptr->finishCreation(vm); |
77 | return ptr; |
78 | } |
79 | |
80 | DECLARE_INFO; |
81 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
82 | { |
83 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
84 | } |
85 | |
86 | private: |
87 | JSHTMLAllCollectionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
88 | : JSC::JSNonFinalObject(vm, structure) |
89 | { |
90 | } |
91 | |
92 | void finishCreation(JSC::VM&); |
93 | }; |
94 | |
95 | using JSHTMLAllCollectionConstructor = JSDOMConstructorNotConstructable<JSHTMLAllCollection>; |
96 | |
97 | template<> JSValue JSHTMLAllCollectionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
98 | { |
99 | UNUSED_PARAM(vm); |
100 | return globalObject.functionPrototype(); |
101 | } |
102 | |
103 | template<> void JSHTMLAllCollectionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
104 | { |
105 | putDirect(vm, vm.propertyNames->prototype, JSHTMLAllCollection::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
106 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HTMLAllCollection"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
107 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
108 | } |
109 | |
110 | template<> const ClassInfo JSHTMLAllCollectionConstructor::s_info = { "HTMLAllCollection" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLAllCollectionConstructor) }; |
111 | |
112 | /* Hash table for prototype */ |
113 | |
114 | static const HashTableValue JSHTMLAllCollectionPrototypeTableValues[] = |
115 | { |
116 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLAllCollectionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLAllCollectionConstructor) } }, |
117 | { "length" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLAllCollectionLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
118 | { "namedItem" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLAllCollectionPrototypeFunctionNamedItem), (intptr_t) (1) } }, |
119 | { "item" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLAllCollectionPrototypeFunctionItem), (intptr_t) (0) } }, |
120 | }; |
121 | |
122 | const ClassInfo JSHTMLAllCollectionPrototype::s_info = { "HTMLAllCollectionPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLAllCollectionPrototype) }; |
123 | |
124 | void JSHTMLAllCollectionPrototype::finishCreation(VM& vm) |
125 | { |
126 | Base::finishCreation(vm); |
127 | reifyStaticProperties(vm, JSHTMLAllCollection::info(), JSHTMLAllCollectionPrototypeTableValues, *this); |
128 | putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)); |
129 | } |
130 | |
131 | const ClassInfo JSHTMLAllCollection::s_info = { "HTMLAllCollection" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLAllCollection) }; |
132 | |
133 | JSHTMLAllCollection::JSHTMLAllCollection(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLAllCollection>&& impl) |
134 | : JSDOMWrapper<HTMLAllCollection>(structure, globalObject, WTFMove(impl)) |
135 | { |
136 | } |
137 | |
138 | void JSHTMLAllCollection::finishCreation(VM& vm) |
139 | { |
140 | Base::finishCreation(vm); |
141 | ASSERT(inherits(vm, info())); |
142 | |
143 | } |
144 | |
145 | JSObject* JSHTMLAllCollection::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
146 | { |
147 | return JSHTMLAllCollectionPrototype::create(vm, &globalObject, JSHTMLAllCollectionPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
148 | } |
149 | |
150 | JSObject* JSHTMLAllCollection::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
151 | { |
152 | return getDOMPrototype<JSHTMLAllCollection>(vm, globalObject); |
153 | } |
154 | |
155 | JSValue JSHTMLAllCollection::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
156 | { |
157 | return getDOMConstructor<JSHTMLAllCollectionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
158 | } |
159 | |
160 | void JSHTMLAllCollection::destroy(JSC::JSCell* cell) |
161 | { |
162 | JSHTMLAllCollection* thisObject = static_cast<JSHTMLAllCollection*>(cell); |
163 | thisObject->JSHTMLAllCollection::~JSHTMLAllCollection(); |
164 | } |
165 | |
166 | bool JSHTMLAllCollection::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot) |
167 | { |
168 | auto* thisObject = jsCast<JSHTMLAllCollection*>(object); |
169 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
170 | if (auto index = parseIndex(propertyName)) { |
171 | if (index.value() < thisObject->wrapped().length()) { |
172 | auto value = toJS<IDLNullable<IDLInterface<Element>>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index.value())); |
173 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
174 | return true; |
175 | } |
176 | return JSObject::getOwnPropertySlot(object, state, propertyName, slot); |
177 | } |
178 | using GetterIDLType = IDLUnion<IDLInterface<HTMLCollection>, IDLInterface<Element>>; |
179 | auto getterFunctor = [] (auto& thisObject, auto propertyName) -> Optional<typename GetterIDLType::ImplementationType> { |
180 | auto result = thisObject.wrapped().namedItemOrItems(propertyNameToAtomicString(propertyName)); |
181 | if (!GetterIDLType::isNullValue(result)) |
182 | return typename GetterIDLType::ImplementationType { GetterIDLType::extractValueFromNullable(result) }; |
183 | return WTF::nullopt; |
184 | }; |
185 | if (auto namedProperty = accessVisibleNamedProperty<OverrideBuiltins::No>(*state, *thisObject, propertyName, getterFunctor)) { |
186 | auto value = toJS<IDLNullable<IDLUnion<IDLInterface<HTMLCollection>, IDLInterface<Element>>>>(*state, *thisObject->globalObject(), WTFMove(namedProperty.value())); |
187 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), value); |
188 | return true; |
189 | } |
190 | return JSObject::getOwnPropertySlot(object, state, propertyName, slot); |
191 | } |
192 | |
193 | bool JSHTMLAllCollection::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot) |
194 | { |
195 | auto* thisObject = jsCast<JSHTMLAllCollection*>(object); |
196 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
197 | if (LIKELY(index <= MAX_ARRAY_INDEX)) { |
198 | if (index < thisObject->wrapped().length()) { |
199 | auto value = toJS<IDLNullable<IDLInterface<Element>>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index)); |
200 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
201 | return true; |
202 | } |
203 | return JSObject::getOwnPropertySlotByIndex(object, state, index, slot); |
204 | } |
205 | auto propertyName = Identifier::from(state, index); |
206 | using GetterIDLType = IDLUnion<IDLInterface<HTMLCollection>, IDLInterface<Element>>; |
207 | auto getterFunctor = [] (auto& thisObject, auto propertyName) -> Optional<typename GetterIDLType::ImplementationType> { |
208 | auto result = thisObject.wrapped().namedItemOrItems(propertyNameToAtomicString(propertyName)); |
209 | if (!GetterIDLType::isNullValue(result)) |
210 | return typename GetterIDLType::ImplementationType { GetterIDLType::extractValueFromNullable(result) }; |
211 | return WTF::nullopt; |
212 | }; |
213 | if (auto namedProperty = accessVisibleNamedProperty<OverrideBuiltins::No>(*state, *thisObject, propertyName, getterFunctor)) { |
214 | auto value = toJS<IDLNullable<IDLUnion<IDLInterface<HTMLCollection>, IDLInterface<Element>>>>(*state, *thisObject->globalObject(), WTFMove(namedProperty.value())); |
215 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), value); |
216 | return true; |
217 | } |
218 | return JSObject::getOwnPropertySlotByIndex(object, state, index, slot); |
219 | } |
220 | |
221 | void JSHTMLAllCollection::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode) |
222 | { |
223 | auto* thisObject = jsCast<JSHTMLAllCollection*>(object); |
224 | ASSERT_GC_OBJECT_INHERITS(object, info()); |
225 | for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i) |
226 | propertyNames.add(Identifier::from(state, i)); |
227 | if (mode.includeDontEnumProperties()) { |
228 | for (auto& propertyName : thisObject->wrapped().supportedPropertyNames()) |
229 | propertyNames.add(Identifier::fromString(state, propertyName)); |
230 | } |
231 | JSObject::getOwnPropertyNames(object, state, propertyNames, mode); |
232 | } |
233 | |
234 | static EncodedJSValue JSC_HOST_CALL callJSHTMLAllCollection(ExecState* state) |
235 | { |
236 | VM& vm = state->vm(); |
237 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
238 | UNUSED_PARAM(throwScope); |
239 | auto* castedThis = jsCast<JSHTMLAllCollection*>(state->jsCallee()); |
240 | ASSERT(castedThis); |
241 | auto& impl = castedThis->wrapped(); |
242 | auto nameOrIndex = state->argument(0).isUndefined() ? String() : convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
243 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
244 | return JSValue::encode(toJS<IDLNullable<IDLUnion<IDLInterface<HTMLCollection>, IDLInterface<Element>>>>(*state, *castedThis->globalObject(), impl.namedOrIndexedItemOrItems(WTFMove(nameOrIndex)))); |
245 | } |
246 | |
247 | CallType JSHTMLAllCollection::getCallData(JSCell*, CallData& callData) |
248 | { |
249 | callData.native.function = callJSHTMLAllCollection; |
250 | return CallType::Host; |
251 | } |
252 | |
253 | template<> inline JSHTMLAllCollection* IDLAttribute<JSHTMLAllCollection>::cast(ExecState& state, EncodedJSValue thisValue) |
254 | { |
255 | return jsDynamicCast<JSHTMLAllCollection*>(state.vm(), JSValue::decode(thisValue)); |
256 | } |
257 | |
258 | template<> inline JSHTMLAllCollection* IDLOperation<JSHTMLAllCollection>::cast(ExecState& state) |
259 | { |
260 | return jsDynamicCast<JSHTMLAllCollection*>(state.vm(), state.thisValue()); |
261 | } |
262 | |
263 | EncodedJSValue jsHTMLAllCollectionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
264 | { |
265 | VM& vm = state->vm(); |
266 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
267 | auto* prototype = jsDynamicCast<JSHTMLAllCollectionPrototype*>(vm, JSValue::decode(thisValue)); |
268 | if (UNLIKELY(!prototype)) |
269 | return throwVMTypeError(state, throwScope); |
270 | return JSValue::encode(JSHTMLAllCollection::getConstructor(state->vm(), prototype->globalObject())); |
271 | } |
272 | |
273 | bool setJSHTMLAllCollectionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
274 | { |
275 | VM& vm = state->vm(); |
276 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
277 | auto* prototype = jsDynamicCast<JSHTMLAllCollectionPrototype*>(vm, JSValue::decode(thisValue)); |
278 | if (UNLIKELY(!prototype)) { |
279 | throwVMTypeError(state, throwScope); |
280 | return false; |
281 | } |
282 | // Shadowing a built-in constructor |
283 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
284 | } |
285 | |
286 | static inline JSValue jsHTMLAllCollectionLengthGetter(ExecState& state, JSHTMLAllCollection& thisObject, ThrowScope& throwScope) |
287 | { |
288 | UNUSED_PARAM(throwScope); |
289 | UNUSED_PARAM(state); |
290 | auto& impl = thisObject.wrapped(); |
291 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length()); |
292 | return result; |
293 | } |
294 | |
295 | EncodedJSValue jsHTMLAllCollectionLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
296 | { |
297 | return IDLAttribute<JSHTMLAllCollection>::get<jsHTMLAllCollectionLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length" ); |
298 | } |
299 | |
300 | static inline JSC::EncodedJSValue jsHTMLAllCollectionPrototypeFunctionNamedItemBody(JSC::ExecState* state, typename IDLOperation<JSHTMLAllCollection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
301 | { |
302 | UNUSED_PARAM(state); |
303 | UNUSED_PARAM(throwScope); |
304 | auto& impl = castedThis->wrapped(); |
305 | if (UNLIKELY(state->argumentCount() < 1)) |
306 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
307 | auto name = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
308 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
309 | return JSValue::encode(toJS<IDLNullable<IDLUnion<IDLInterface<HTMLCollection>, IDLInterface<Element>>>>(*state, *castedThis->globalObject(), impl.namedItemOrItems(WTFMove(name)))); |
310 | } |
311 | |
312 | EncodedJSValue JSC_HOST_CALL jsHTMLAllCollectionPrototypeFunctionNamedItem(ExecState* state) |
313 | { |
314 | return IDLOperation<JSHTMLAllCollection>::call<jsHTMLAllCollectionPrototypeFunctionNamedItemBody>(*state, "namedItem" ); |
315 | } |
316 | |
317 | static inline JSC::EncodedJSValue jsHTMLAllCollectionPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSHTMLAllCollection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
318 | { |
319 | UNUSED_PARAM(state); |
320 | UNUSED_PARAM(throwScope); |
321 | auto& impl = castedThis->wrapped(); |
322 | auto nameOrIndex = state->argument(0).isUndefined() ? String() : convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
323 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
324 | return JSValue::encode(toJS<IDLNullable<IDLUnion<IDLInterface<HTMLCollection>, IDLInterface<Element>>>>(*state, *castedThis->globalObject(), impl.namedOrIndexedItemOrItems(WTFMove(nameOrIndex)))); |
325 | } |
326 | |
327 | EncodedJSValue JSC_HOST_CALL jsHTMLAllCollectionPrototypeFunctionItem(ExecState* state) |
328 | { |
329 | return IDLOperation<JSHTMLAllCollection>::call<jsHTMLAllCollectionPrototypeFunctionItemBody>(*state, "item" ); |
330 | } |
331 | |
332 | void JSHTMLAllCollection::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
333 | { |
334 | auto* thisObject = jsCast<JSHTMLAllCollection*>(cell); |
335 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
336 | if (thisObject->scriptExecutionContext()) |
337 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
338 | Base::heapSnapshot(cell, builder); |
339 | } |
340 | |
341 | bool JSHTMLAllCollectionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
342 | { |
343 | auto* jsHTMLAllCollection = jsCast<JSHTMLAllCollection*>(handle.slot()->asCell()); |
344 | void* root = WebCore::root(jsHTMLAllCollection->wrapped().ownerNode()); |
345 | if (UNLIKELY(reason)) |
346 | *reason = "Reachable from HTMLAllCollection ownerNode" ; |
347 | return visitor.containsOpaqueRoot(root); |
348 | } |
349 | |
350 | void JSHTMLAllCollectionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
351 | { |
352 | auto* jsHTMLAllCollection = static_cast<JSHTMLAllCollection*>(handle.slot()->asCell()); |
353 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
354 | uncacheWrapper(world, &jsHTMLAllCollection->wrapped(), jsHTMLAllCollection); |
355 | } |
356 | |
357 | #if ENABLE(BINDING_INTEGRITY) |
358 | #if PLATFORM(WIN) |
359 | #pragma warning(disable: 4483) |
360 | extern "C" { extern void (*const __identifier("??_7HTMLAllCollection@WebCore@@6B@" )[])(); } |
361 | #else |
362 | extern "C" { extern void* _ZTVN7WebCore17HTMLAllCollectionE[]; } |
363 | #endif |
364 | #endif |
365 | |
366 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<HTMLAllCollection>&& impl) |
367 | { |
368 | |
369 | #if ENABLE(BINDING_INTEGRITY) |
370 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
371 | #if PLATFORM(WIN) |
372 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7HTMLAllCollection@WebCore@@6B@" )); |
373 | #else |
374 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore17HTMLAllCollectionE[2]); |
375 | #endif |
376 | |
377 | // If this fails HTMLAllCollection does not have a vtable, so you need to add the |
378 | // ImplementationLacksVTable attribute to the interface definition |
379 | static_assert(std::is_polymorphic<HTMLAllCollection>::value, "HTMLAllCollection is not polymorphic" ); |
380 | |
381 | // If you hit this assertion you either have a use after free bug, or |
382 | // HTMLAllCollection has subclasses. If HTMLAllCollection has subclasses that get passed |
383 | // to toJS() we currently require HTMLAllCollection you to opt out of binding hardening |
384 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
385 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
386 | #endif |
387 | return createWrapper<HTMLAllCollection>(globalObject, WTFMove(impl)); |
388 | } |
389 | |
390 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, HTMLAllCollection& impl) |
391 | { |
392 | return wrap(state, globalObject, impl); |
393 | } |
394 | |
395 | HTMLAllCollection* JSHTMLAllCollection::toWrapped(JSC::VM& vm, JSC::JSValue value) |
396 | { |
397 | if (auto* wrapper = jsDynamicCast<JSHTMLAllCollection*>(vm, value)) |
398 | return &wrapper->wrapped(); |
399 | return nullptr; |
400 | } |
401 | |
402 | } |
403 | |