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 "JSCustomElementRegistry.h" |
23 | |
24 | #include "CustomElementReactionQueue.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructorNotConstructable.h" |
27 | #include "JSDOMConvertAny.h" |
28 | #include "JSDOMConvertInterface.h" |
29 | #include "JSDOMConvertStrings.h" |
30 | #include "JSDOMExceptionHandling.h" |
31 | #include "JSDOMOperation.h" |
32 | #include "JSDOMOperationReturningPromise.h" |
33 | #include "JSDOMWrapperCache.h" |
34 | #include "JSNode.h" |
35 | #include "ScriptExecutionContext.h" |
36 | #include <JavaScriptCore/FunctionPrototype.h> |
37 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
38 | #include <JavaScriptCore/JSCInlines.h> |
39 | #include <wtf/GetPtr.h> |
40 | #include <wtf/PointerPreparations.h> |
41 | #include <wtf/URL.h> |
42 | |
43 | |
44 | namespace WebCore { |
45 | using namespace JSC; |
46 | |
47 | // Functions |
48 | |
49 | JSC::EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionDefine(JSC::ExecState*); |
50 | JSC::EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionGet(JSC::ExecState*); |
51 | JSC::EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionWhenDefined(JSC::ExecState*); |
52 | JSC::EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionUpgrade(JSC::ExecState*); |
53 | |
54 | // Attributes |
55 | |
56 | JSC::EncodedJSValue jsCustomElementRegistryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
57 | bool setJSCustomElementRegistryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
58 | |
59 | class JSCustomElementRegistryPrototype : public JSC::JSNonFinalObject { |
60 | public: |
61 | using Base = JSC::JSNonFinalObject; |
62 | static JSCustomElementRegistryPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
63 | { |
64 | JSCustomElementRegistryPrototype* ptr = new (NotNull, JSC::allocateCell<JSCustomElementRegistryPrototype>(vm.heap)) JSCustomElementRegistryPrototype(vm, globalObject, structure); |
65 | ptr->finishCreation(vm); |
66 | return ptr; |
67 | } |
68 | |
69 | DECLARE_INFO; |
70 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
71 | { |
72 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
73 | } |
74 | |
75 | private: |
76 | JSCustomElementRegistryPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
77 | : JSC::JSNonFinalObject(vm, structure) |
78 | { |
79 | } |
80 | |
81 | void finishCreation(JSC::VM&); |
82 | }; |
83 | |
84 | using JSCustomElementRegistryConstructor = JSDOMConstructorNotConstructable<JSCustomElementRegistry>; |
85 | |
86 | template<> JSValue JSCustomElementRegistryConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
87 | { |
88 | UNUSED_PARAM(vm); |
89 | return globalObject.functionPrototype(); |
90 | } |
91 | |
92 | template<> void JSCustomElementRegistryConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
93 | { |
94 | putDirect(vm, vm.propertyNames->prototype, JSCustomElementRegistry::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
95 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("CustomElementRegistry"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
96 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
97 | } |
98 | |
99 | template<> const ClassInfo JSCustomElementRegistryConstructor::s_info = { "CustomElementRegistry" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCustomElementRegistryConstructor) }; |
100 | |
101 | /* Hash table for prototype */ |
102 | |
103 | static const HashTableValue JSCustomElementRegistryPrototypeTableValues[] = |
104 | { |
105 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCustomElementRegistryConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCustomElementRegistryConstructor) } }, |
106 | { "define" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCustomElementRegistryPrototypeFunctionDefine), (intptr_t) (2) } }, |
107 | { "get" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCustomElementRegistryPrototypeFunctionGet), (intptr_t) (1) } }, |
108 | { "whenDefined" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCustomElementRegistryPrototypeFunctionWhenDefined), (intptr_t) (1) } }, |
109 | { "upgrade" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCustomElementRegistryPrototypeFunctionUpgrade), (intptr_t) (1) } }, |
110 | }; |
111 | |
112 | const ClassInfo JSCustomElementRegistryPrototype::s_info = { "CustomElementRegistryPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCustomElementRegistryPrototype) }; |
113 | |
114 | void JSCustomElementRegistryPrototype::finishCreation(VM& vm) |
115 | { |
116 | Base::finishCreation(vm); |
117 | reifyStaticProperties(vm, JSCustomElementRegistry::info(), JSCustomElementRegistryPrototypeTableValues, *this); |
118 | } |
119 | |
120 | const ClassInfo JSCustomElementRegistry::s_info = { "CustomElementRegistry" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCustomElementRegistry) }; |
121 | |
122 | JSCustomElementRegistry::JSCustomElementRegistry(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CustomElementRegistry>&& impl) |
123 | : JSDOMWrapper<CustomElementRegistry>(structure, globalObject, WTFMove(impl)) |
124 | { |
125 | } |
126 | |
127 | void JSCustomElementRegistry::finishCreation(VM& vm) |
128 | { |
129 | Base::finishCreation(vm); |
130 | ASSERT(inherits(vm, info())); |
131 | |
132 | } |
133 | |
134 | JSObject* JSCustomElementRegistry::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
135 | { |
136 | return JSCustomElementRegistryPrototype::create(vm, &globalObject, JSCustomElementRegistryPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
137 | } |
138 | |
139 | JSObject* JSCustomElementRegistry::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
140 | { |
141 | return getDOMPrototype<JSCustomElementRegistry>(vm, globalObject); |
142 | } |
143 | |
144 | JSValue JSCustomElementRegistry::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
145 | { |
146 | return getDOMConstructor<JSCustomElementRegistryConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
147 | } |
148 | |
149 | void JSCustomElementRegistry::destroy(JSC::JSCell* cell) |
150 | { |
151 | JSCustomElementRegistry* thisObject = static_cast<JSCustomElementRegistry*>(cell); |
152 | thisObject->JSCustomElementRegistry::~JSCustomElementRegistry(); |
153 | } |
154 | |
155 | template<> inline JSCustomElementRegistry* IDLOperation<JSCustomElementRegistry>::cast(ExecState& state) |
156 | { |
157 | return jsDynamicCast<JSCustomElementRegistry*>(state.vm(), state.thisValue()); |
158 | } |
159 | |
160 | EncodedJSValue jsCustomElementRegistryConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
161 | { |
162 | VM& vm = state->vm(); |
163 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
164 | auto* prototype = jsDynamicCast<JSCustomElementRegistryPrototype*>(vm, JSValue::decode(thisValue)); |
165 | if (UNLIKELY(!prototype)) |
166 | return throwVMTypeError(state, throwScope); |
167 | return JSValue::encode(JSCustomElementRegistry::getConstructor(state->vm(), prototype->globalObject())); |
168 | } |
169 | |
170 | bool setJSCustomElementRegistryConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
171 | { |
172 | VM& vm = state->vm(); |
173 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
174 | auto* prototype = jsDynamicCast<JSCustomElementRegistryPrototype*>(vm, JSValue::decode(thisValue)); |
175 | if (UNLIKELY(!prototype)) { |
176 | throwVMTypeError(state, throwScope); |
177 | return false; |
178 | } |
179 | // Shadowing a built-in constructor |
180 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
181 | } |
182 | |
183 | static inline JSC::EncodedJSValue jsCustomElementRegistryPrototypeFunctionDefineBody(JSC::ExecState* state, typename IDLOperation<JSCustomElementRegistry>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
184 | { |
185 | UNUSED_PARAM(state); |
186 | UNUSED_PARAM(throwScope); |
187 | CustomElementReactionStack customElementReactionStack(*state); |
188 | return JSValue::encode(castedThis->define(*state)); |
189 | } |
190 | |
191 | EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionDefine(ExecState* state) |
192 | { |
193 | return IDLOperation<JSCustomElementRegistry>::call<jsCustomElementRegistryPrototypeFunctionDefineBody>(*state, "define" ); |
194 | } |
195 | |
196 | static inline JSC::EncodedJSValue jsCustomElementRegistryPrototypeFunctionGetBody(JSC::ExecState* state, typename IDLOperation<JSCustomElementRegistry>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
197 | { |
198 | UNUSED_PARAM(state); |
199 | UNUSED_PARAM(throwScope); |
200 | auto& impl = castedThis->wrapped(); |
201 | if (UNLIKELY(state->argumentCount() < 1)) |
202 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
203 | auto name = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
204 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
205 | return JSValue::encode(toJS<IDLAny>(impl.get(WTFMove(name)))); |
206 | } |
207 | |
208 | EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionGet(ExecState* state) |
209 | { |
210 | return IDLOperation<JSCustomElementRegistry>::call<jsCustomElementRegistryPrototypeFunctionGetBody>(*state, "get" ); |
211 | } |
212 | |
213 | static inline JSC::EncodedJSValue jsCustomElementRegistryPrototypeFunctionWhenDefinedBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSCustomElementRegistry>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
214 | { |
215 | UNUSED_PARAM(state); |
216 | UNUSED_PARAM(throwScope); |
217 | return JSValue::encode(castedThis->whenDefined(*state)); |
218 | } |
219 | |
220 | EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionWhenDefined(ExecState* state) |
221 | { |
222 | return IDLOperationReturningPromise<JSCustomElementRegistry>::callReturningOwnPromise<jsCustomElementRegistryPrototypeFunctionWhenDefinedBody>(*state, "whenDefined" ); |
223 | } |
224 | |
225 | static inline JSC::EncodedJSValue jsCustomElementRegistryPrototypeFunctionUpgradeBody(JSC::ExecState* state, typename IDLOperation<JSCustomElementRegistry>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
226 | { |
227 | UNUSED_PARAM(state); |
228 | UNUSED_PARAM(throwScope); |
229 | CustomElementReactionStack customElementReactionStack(*state); |
230 | auto& impl = castedThis->wrapped(); |
231 | if (UNLIKELY(state->argumentCount() < 1)) |
232 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
233 | auto root = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "root" , "CustomElementRegistry" , "upgrade" , "Node" ); }); |
234 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
235 | impl.upgrade(*root); |
236 | return JSValue::encode(jsUndefined()); |
237 | } |
238 | |
239 | EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionUpgrade(ExecState* state) |
240 | { |
241 | return IDLOperation<JSCustomElementRegistry>::call<jsCustomElementRegistryPrototypeFunctionUpgradeBody>(*state, "upgrade" ); |
242 | } |
243 | |
244 | void JSCustomElementRegistry::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
245 | { |
246 | auto* thisObject = jsCast<JSCustomElementRegistry*>(cell); |
247 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
248 | if (thisObject->scriptExecutionContext()) |
249 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
250 | Base::heapSnapshot(cell, builder); |
251 | } |
252 | |
253 | bool JSCustomElementRegistryOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
254 | { |
255 | auto* jsCustomElementRegistry = jsCast<JSCustomElementRegistry*>(handle.slot()->asCell()); |
256 | ScriptExecutionContext* root = WTF::getPtr(jsCustomElementRegistry->wrapped().scriptExecutionContext()); |
257 | if (!root) |
258 | return false; |
259 | if (UNLIKELY(reason)) |
260 | *reason = "Reachable from ScriptExecutionContext" ; |
261 | return visitor.containsOpaqueRoot(root); |
262 | } |
263 | |
264 | void JSCustomElementRegistryOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
265 | { |
266 | auto* jsCustomElementRegistry = static_cast<JSCustomElementRegistry*>(handle.slot()->asCell()); |
267 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
268 | uncacheWrapper(world, &jsCustomElementRegistry->wrapped(), jsCustomElementRegistry); |
269 | } |
270 | |
271 | #if ENABLE(BINDING_INTEGRITY) |
272 | #if PLATFORM(WIN) |
273 | #pragma warning(disable: 4483) |
274 | extern "C" { extern void (*const __identifier("??_7CustomElementRegistry@WebCore@@6B@" )[])(); } |
275 | #else |
276 | extern "C" { extern void* _ZTVN7WebCore21CustomElementRegistryE[]; } |
277 | #endif |
278 | #endif |
279 | |
280 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<CustomElementRegistry>&& impl) |
281 | { |
282 | |
283 | #if ENABLE(BINDING_INTEGRITY) |
284 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
285 | #if PLATFORM(WIN) |
286 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7CustomElementRegistry@WebCore@@6B@" )); |
287 | #else |
288 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore21CustomElementRegistryE[2]); |
289 | #endif |
290 | |
291 | // If this fails CustomElementRegistry does not have a vtable, so you need to add the |
292 | // ImplementationLacksVTable attribute to the interface definition |
293 | static_assert(std::is_polymorphic<CustomElementRegistry>::value, "CustomElementRegistry is not polymorphic" ); |
294 | |
295 | // If you hit this assertion you either have a use after free bug, or |
296 | // CustomElementRegistry has subclasses. If CustomElementRegistry has subclasses that get passed |
297 | // to toJS() we currently require CustomElementRegistry you to opt out of binding hardening |
298 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
299 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
300 | #endif |
301 | return createWrapper<CustomElementRegistry>(globalObject, WTFMove(impl)); |
302 | } |
303 | |
304 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, CustomElementRegistry& impl) |
305 | { |
306 | return wrap(state, globalObject, impl); |
307 | } |
308 | |
309 | CustomElementRegistry* JSCustomElementRegistry::toWrapped(JSC::VM& vm, JSC::JSValue value) |
310 | { |
311 | if (auto* wrapper = jsDynamicCast<JSCustomElementRegistry*>(vm, value)) |
312 | return &wrapper->wrapped(); |
313 | return nullptr; |
314 | } |
315 | |
316 | } |
317 | |