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 "JSDOMCSSNamespace.h" |
23 | |
24 | #include "DOMCSSRegisterCustomProperty.h" |
25 | #include "Document.h" |
26 | #include "JSDOMAttribute.h" |
27 | #include "JSDOMBinding.h" |
28 | #include "JSDOMCSSCustomPropertyDescriptor.h" |
29 | #include "JSDOMConstructorNotConstructable.h" |
30 | #include "JSDOMConvertBoolean.h" |
31 | #include "JSDOMConvertDictionary.h" |
32 | #include "JSDOMConvertStrings.h" |
33 | #include "JSDOMExceptionHandling.h" |
34 | #include "JSDOMOperation.h" |
35 | #include "JSDOMWrapperCache.h" |
36 | #include "RuntimeEnabledFeatures.h" |
37 | #include "ScriptExecutionContext.h" |
38 | #include <JavaScriptCore/FunctionPrototype.h> |
39 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
40 | #include <JavaScriptCore/JSCInlines.h> |
41 | #include <wtf/GetPtr.h> |
42 | #include <wtf/PointerPreparations.h> |
43 | #include <wtf/URL.h> |
44 | |
45 | #if ENABLE(CSS_PAINTING_API) |
46 | #include "DOMCSSPaintWorklet.h" |
47 | #include "JSDOMConvertInterface.h" |
48 | #include "JSDOMGlobalObject.h" |
49 | #include "JSWorklet.h" |
50 | #endif |
51 | |
52 | |
53 | namespace WebCore { |
54 | using namespace JSC; |
55 | |
56 | // Functions |
57 | |
58 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMCSSNamespaceConstructorFunctionSupports(JSC::ExecState*); |
59 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMCSSNamespaceConstructorFunctionEscape(JSC::ExecState*); |
60 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMCSSNamespaceConstructorFunctionRegisterProperty(JSC::ExecState*); |
61 | |
62 | // Attributes |
63 | |
64 | JSC::EncodedJSValue jsDOMCSSNamespaceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
65 | bool setJSDOMCSSNamespaceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
66 | #if ENABLE(CSS_PAINTING_API) |
67 | JSC::EncodedJSValue jsDOMCSSNamespaceConstructorPaintWorklet(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
68 | #endif |
69 | |
70 | class JSDOMCSSNamespacePrototype : public JSC::JSNonFinalObject { |
71 | public: |
72 | using Base = JSC::JSNonFinalObject; |
73 | static JSDOMCSSNamespacePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
74 | { |
75 | JSDOMCSSNamespacePrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMCSSNamespacePrototype>(vm.heap)) JSDOMCSSNamespacePrototype(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 | JSDOMCSSNamespacePrototype(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 JSDOMCSSNamespaceConstructor = JSDOMConstructorNotConstructable<JSDOMCSSNamespace>; |
96 | |
97 | /* Hash table for constructor */ |
98 | |
99 | static const HashTableValue JSDOMCSSNamespaceConstructorTableValues[] = |
100 | { |
101 | #if ENABLE(CSS_PAINTING_API) |
102 | { "paintWorklet" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMCSSNamespaceConstructorPaintWorklet), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
103 | #else |
104 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
105 | #endif |
106 | { "supports" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMCSSNamespaceConstructorFunctionSupports), (intptr_t) (1) } }, |
107 | { "escape" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMCSSNamespaceConstructorFunctionEscape), (intptr_t) (1) } }, |
108 | { "registerProperty" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMCSSNamespaceConstructorFunctionRegisterProperty), (intptr_t) (1) } }, |
109 | }; |
110 | |
111 | template<> JSValue JSDOMCSSNamespaceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
112 | { |
113 | UNUSED_PARAM(vm); |
114 | return globalObject.functionPrototype(); |
115 | } |
116 | |
117 | template<> void JSDOMCSSNamespaceConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
118 | { |
119 | putDirect(vm, vm.propertyNames->prototype, JSDOMCSSNamespace::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
120 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("CSS"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
121 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
122 | reifyStaticProperties(vm, JSDOMCSSNamespace::info(), JSDOMCSSNamespaceConstructorTableValues, *this); |
123 | #if ENABLE(CSS_PAINTING_API) |
124 | if (!RuntimeEnabledFeatures::sharedFeatures().cssPaintingAPIEnabled()) { |
125 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("paintWorklet" ), strlen("paintWorklet" )); |
126 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
127 | JSObject::deleteProperty(this, globalObject.globalExec(), propertyName); |
128 | } |
129 | #endif |
130 | if (!RuntimeEnabledFeatures::sharedFeatures().cssCustomPropertiesAndValuesEnabled()) { |
131 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("registerProperty" ), strlen("registerProperty" )); |
132 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
133 | JSObject::deleteProperty(this, globalObject.globalExec(), propertyName); |
134 | } |
135 | } |
136 | |
137 | template<> const ClassInfo JSDOMCSSNamespaceConstructor::s_info = { "CSS" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMCSSNamespaceConstructor) }; |
138 | |
139 | /* Hash table for prototype */ |
140 | |
141 | static const HashTableValue JSDOMCSSNamespacePrototypeTableValues[] = |
142 | { |
143 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMCSSNamespaceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMCSSNamespaceConstructor) } }, |
144 | }; |
145 | |
146 | const ClassInfo JSDOMCSSNamespacePrototype::s_info = { "CSSPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMCSSNamespacePrototype) }; |
147 | |
148 | void JSDOMCSSNamespacePrototype::finishCreation(VM& vm) |
149 | { |
150 | Base::finishCreation(vm); |
151 | reifyStaticProperties(vm, JSDOMCSSNamespace::info(), JSDOMCSSNamespacePrototypeTableValues, *this); |
152 | } |
153 | |
154 | const ClassInfo JSDOMCSSNamespace::s_info = { "CSS" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMCSSNamespace) }; |
155 | |
156 | JSDOMCSSNamespace::JSDOMCSSNamespace(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMCSSNamespace>&& impl) |
157 | : JSDOMWrapper<DOMCSSNamespace>(structure, globalObject, WTFMove(impl)) |
158 | { |
159 | } |
160 | |
161 | void JSDOMCSSNamespace::finishCreation(VM& vm) |
162 | { |
163 | Base::finishCreation(vm); |
164 | ASSERT(inherits(vm, info())); |
165 | |
166 | } |
167 | |
168 | JSObject* JSDOMCSSNamespace::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
169 | { |
170 | return JSDOMCSSNamespacePrototype::create(vm, &globalObject, JSDOMCSSNamespacePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
171 | } |
172 | |
173 | JSObject* JSDOMCSSNamespace::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
174 | { |
175 | return getDOMPrototype<JSDOMCSSNamespace>(vm, globalObject); |
176 | } |
177 | |
178 | JSValue JSDOMCSSNamespace::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
179 | { |
180 | return getDOMConstructor<JSDOMCSSNamespaceConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
181 | } |
182 | |
183 | void JSDOMCSSNamespace::destroy(JSC::JSCell* cell) |
184 | { |
185 | JSDOMCSSNamespace* thisObject = static_cast<JSDOMCSSNamespace*>(cell); |
186 | thisObject->JSDOMCSSNamespace::~JSDOMCSSNamespace(); |
187 | } |
188 | |
189 | template<> inline JSDOMCSSNamespace* IDLAttribute<JSDOMCSSNamespace>::cast(ExecState& state, EncodedJSValue thisValue) |
190 | { |
191 | return jsDynamicCast<JSDOMCSSNamespace*>(state.vm(), JSValue::decode(thisValue)); |
192 | } |
193 | |
194 | template<> inline JSDOMCSSNamespace* IDLOperation<JSDOMCSSNamespace>::cast(ExecState& state) |
195 | { |
196 | return jsDynamicCast<JSDOMCSSNamespace*>(state.vm(), state.thisValue()); |
197 | } |
198 | |
199 | EncodedJSValue jsDOMCSSNamespaceConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
200 | { |
201 | VM& vm = state->vm(); |
202 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
203 | auto* prototype = jsDynamicCast<JSDOMCSSNamespacePrototype*>(vm, JSValue::decode(thisValue)); |
204 | if (UNLIKELY(!prototype)) |
205 | return throwVMTypeError(state, throwScope); |
206 | return JSValue::encode(JSDOMCSSNamespace::getConstructor(state->vm(), prototype->globalObject())); |
207 | } |
208 | |
209 | bool setJSDOMCSSNamespaceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
210 | { |
211 | VM& vm = state->vm(); |
212 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
213 | auto* prototype = jsDynamicCast<JSDOMCSSNamespacePrototype*>(vm, JSValue::decode(thisValue)); |
214 | if (UNLIKELY(!prototype)) { |
215 | throwVMTypeError(state, throwScope); |
216 | return false; |
217 | } |
218 | // Shadowing a built-in constructor |
219 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
220 | } |
221 | |
222 | #if ENABLE(CSS_PAINTING_API) |
223 | static inline JSValue jsDOMCSSNamespaceConstructorPaintWorkletGetter(ExecState& state, ThrowScope& throwScope) |
224 | { |
225 | UNUSED_PARAM(throwScope); |
226 | UNUSED_PARAM(state); |
227 | auto* context = jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->scriptExecutionContext(); |
228 | if (UNLIKELY(!context)) |
229 | return jsUndefined(); |
230 | ASSERT(context->isDocument()); |
231 | auto& document = downcast<Document>(*context); |
232 | JSValue result = toJS<IDLInterface<Worklet>>(state, *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject()), throwScope, WebCore::DOMCSSPaintWorklet::ensurePaintWorklet(document)); |
233 | return result; |
234 | } |
235 | |
236 | EncodedJSValue jsDOMCSSNamespaceConstructorPaintWorklet(ExecState* state, EncodedJSValue thisValue, PropertyName) |
237 | { |
238 | return IDLAttribute<JSDOMCSSNamespace>::getStatic<jsDOMCSSNamespaceConstructorPaintWorkletGetter>(*state, thisValue, "paintWorklet" ); |
239 | } |
240 | |
241 | #endif |
242 | |
243 | static inline JSC::EncodedJSValue jsDOMCSSNamespaceConstructorFunctionSupports1Body(JSC::ExecState* state, JSC::ThrowScope& throwScope) |
244 | { |
245 | UNUSED_PARAM(state); |
246 | UNUSED_PARAM(throwScope); |
247 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
248 | if (UNLIKELY(!context)) |
249 | return JSValue::encode(jsUndefined()); |
250 | ASSERT(context->isDocument()); |
251 | auto& document = downcast<Document>(*context); |
252 | auto property = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
253 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
254 | auto value = convert<IDLDOMString>(*state, state->uncheckedArgument(1)); |
255 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
256 | return JSValue::encode(toJS<IDLBoolean>(DOMCSSNamespace::supports(document, WTFMove(property), WTFMove(value)))); |
257 | } |
258 | |
259 | static inline JSC::EncodedJSValue jsDOMCSSNamespaceConstructorFunctionSupports2Body(JSC::ExecState* state, JSC::ThrowScope& throwScope) |
260 | { |
261 | UNUSED_PARAM(state); |
262 | UNUSED_PARAM(throwScope); |
263 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
264 | if (UNLIKELY(!context)) |
265 | return JSValue::encode(jsUndefined()); |
266 | ASSERT(context->isDocument()); |
267 | auto& document = downcast<Document>(*context); |
268 | auto conditionText = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
269 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
270 | return JSValue::encode(toJS<IDLBoolean>(DOMCSSNamespace::supports(document, WTFMove(conditionText)))); |
271 | } |
272 | |
273 | static inline JSC::EncodedJSValue jsDOMCSSNamespaceConstructorFunctionSupportsOverloadDispatcher(JSC::ExecState* state, JSC::ThrowScope& throwScope) |
274 | { |
275 | UNUSED_PARAM(state); |
276 | UNUSED_PARAM(throwScope); |
277 | VM& vm = state->vm(); |
278 | UNUSED_PARAM(vm); |
279 | size_t argsCount = std::min<size_t>(2, state->argumentCount()); |
280 | if (argsCount == 1) { |
281 | return jsDOMCSSNamespaceConstructorFunctionSupports2Body(state, throwScope); |
282 | } |
283 | if (argsCount == 2) { |
284 | return jsDOMCSSNamespaceConstructorFunctionSupports1Body(state, throwScope); |
285 | } |
286 | return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope); |
287 | } |
288 | |
289 | EncodedJSValue JSC_HOST_CALL jsDOMCSSNamespaceConstructorFunctionSupports(ExecState* state) |
290 | { |
291 | return IDLOperation<JSDOMCSSNamespace>::callStatic<jsDOMCSSNamespaceConstructorFunctionSupportsOverloadDispatcher>(*state, "supports" ); |
292 | } |
293 | |
294 | static inline JSC::EncodedJSValue jsDOMCSSNamespaceConstructorFunctionEscapeBody(JSC::ExecState* state, JSC::ThrowScope& throwScope) |
295 | { |
296 | UNUSED_PARAM(state); |
297 | UNUSED_PARAM(throwScope); |
298 | if (UNLIKELY(state->argumentCount() < 1)) |
299 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
300 | auto ident = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
301 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
302 | return JSValue::encode(toJS<IDLDOMString>(*state, DOMCSSNamespace::escape(WTFMove(ident)))); |
303 | } |
304 | |
305 | EncodedJSValue JSC_HOST_CALL jsDOMCSSNamespaceConstructorFunctionEscape(ExecState* state) |
306 | { |
307 | return IDLOperation<JSDOMCSSNamespace>::callStatic<jsDOMCSSNamespaceConstructorFunctionEscapeBody>(*state, "escape" ); |
308 | } |
309 | |
310 | static inline JSC::EncodedJSValue jsDOMCSSNamespaceConstructorFunctionRegisterPropertyBody(JSC::ExecState* state, JSC::ThrowScope& throwScope) |
311 | { |
312 | UNUSED_PARAM(state); |
313 | UNUSED_PARAM(throwScope); |
314 | if (UNLIKELY(state->argumentCount() < 1)) |
315 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
316 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
317 | if (UNLIKELY(!context)) |
318 | return JSValue::encode(jsUndefined()); |
319 | ASSERT(context->isDocument()); |
320 | auto& document = downcast<Document>(*context); |
321 | auto descriptor = convert<IDLDictionary<DOMCSSCustomPropertyDescriptor>>(*state, state->uncheckedArgument(0)); |
322 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
323 | propagateException(*state, throwScope, WebCore::DOMCSSRegisterCustomProperty::registerProperty(document, WTFMove(descriptor))); |
324 | return JSValue::encode(jsUndefined()); |
325 | } |
326 | |
327 | EncodedJSValue JSC_HOST_CALL jsDOMCSSNamespaceConstructorFunctionRegisterProperty(ExecState* state) |
328 | { |
329 | return IDLOperation<JSDOMCSSNamespace>::callStatic<jsDOMCSSNamespaceConstructorFunctionRegisterPropertyBody>(*state, "registerProperty" ); |
330 | } |
331 | |
332 | void JSDOMCSSNamespace::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
333 | { |
334 | auto* thisObject = jsCast<JSDOMCSSNamespace*>(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 JSDOMCSSNamespaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
342 | { |
343 | UNUSED_PARAM(handle); |
344 | UNUSED_PARAM(visitor); |
345 | UNUSED_PARAM(reason); |
346 | return false; |
347 | } |
348 | |
349 | void JSDOMCSSNamespaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
350 | { |
351 | auto* jsDOMCSSNamespace = static_cast<JSDOMCSSNamespace*>(handle.slot()->asCell()); |
352 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
353 | uncacheWrapper(world, &jsDOMCSSNamespace->wrapped(), jsDOMCSSNamespace); |
354 | } |
355 | |
356 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMCSSNamespace>&& impl) |
357 | { |
358 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
359 | // attribute. You should remove that attribute. If the class has subclasses |
360 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
361 | // attribute to DOMCSSNamespace. |
362 | static_assert(!std::is_polymorphic<DOMCSSNamespace>::value, "DOMCSSNamespace is polymorphic but the IDL claims it is not" ); |
363 | return createWrapper<DOMCSSNamespace>(globalObject, WTFMove(impl)); |
364 | } |
365 | |
366 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMCSSNamespace& impl) |
367 | { |
368 | return wrap(state, globalObject, impl); |
369 | } |
370 | |
371 | DOMCSSNamespace* JSDOMCSSNamespace::toWrapped(JSC::VM& vm, JSC::JSValue value) |
372 | { |
373 | if (auto* wrapper = jsDynamicCast<JSDOMCSSNamespace*>(vm, value)) |
374 | return &wrapper->wrapped(); |
375 | return nullptr; |
376 | } |
377 | |
378 | } |
379 | |