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 | |
23 | #if ENABLE(CSS_PAINTING_API) |
24 | |
25 | #include "JSWorkletGlobalScope.h" |
26 | |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConstructorNotConstructable.h" |
30 | #include "JSDOMExceptionHandling.h" |
31 | #include "JSDOMWrapperCache.h" |
32 | #include "RuntimeEnabledFeatures.h" |
33 | #include "ScriptExecutionContext.h" |
34 | #include "WebCoreJSClientData.h" |
35 | #include "WorkletGlobalScope.h" |
36 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
37 | #include <JavaScriptCore/JSCInlines.h> |
38 | #include <wtf/GetPtr.h> |
39 | #include <wtf/PointerPreparations.h> |
40 | #include <wtf/URL.h> |
41 | |
42 | #if ENABLE(CSS_PAINTING_API) |
43 | #include "JSWorkletGlobalScope.h" |
44 | #endif |
45 | |
46 | |
47 | namespace WebCore { |
48 | using namespace JSC; |
49 | |
50 | // Attributes |
51 | |
52 | JSC::EncodedJSValue jsWorkletGlobalScopeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
53 | bool setJSWorkletGlobalScopeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
54 | #if ENABLE(CSS_PAINTING_API) |
55 | JSC::EncodedJSValue jsWorkletGlobalScopeWorkletGlobalScopeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
56 | bool setJSWorkletGlobalScopeWorkletGlobalScopeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
57 | #endif |
58 | |
59 | using JSWorkletGlobalScopeConstructor = JSDOMConstructorNotConstructable<JSWorkletGlobalScope>; |
60 | |
61 | template<> JSValue JSWorkletGlobalScopeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
62 | { |
63 | return JSEventTarget::getConstructor(vm, &globalObject); |
64 | } |
65 | |
66 | template<> void JSWorkletGlobalScopeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
67 | { |
68 | putDirect(vm, vm.propertyNames->prototype, JSWorkletGlobalScope::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
69 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("WorkletGlobalScope"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
70 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
71 | } |
72 | |
73 | template<> const ClassInfo JSWorkletGlobalScopeConstructor::s_info = { "WorkletGlobalScope" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWorkletGlobalScopeConstructor) }; |
74 | |
75 | /* Hash table for prototype */ |
76 | |
77 | static const struct CompactHashIndex JSWorkletGlobalScopePrototypeTableIndex[2] = { |
78 | { -1, -1 }, |
79 | { 0, -1 }, |
80 | }; |
81 | |
82 | |
83 | static const HashTableValue JSWorkletGlobalScopePrototypeTableValues[] = |
84 | { |
85 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkletGlobalScopeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWorkletGlobalScopeConstructor) } }, |
86 | }; |
87 | |
88 | static const HashTable JSWorkletGlobalScopePrototypeTable = { 1, 1, true, JSWorkletGlobalScope::info(), JSWorkletGlobalScopePrototypeTableValues, JSWorkletGlobalScopePrototypeTableIndex }; |
89 | const ClassInfo JSWorkletGlobalScopePrototype::s_info = { "WorkletGlobalScopePrototype" , &Base::s_info, &JSWorkletGlobalScopePrototypeTable, nullptr, CREATE_METHOD_TABLE(JSWorkletGlobalScopePrototype) }; |
90 | |
91 | const ClassInfo JSWorkletGlobalScope::s_info = { "WorkletGlobalScope" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWorkletGlobalScope) }; |
92 | |
93 | JSWorkletGlobalScope::JSWorkletGlobalScope(VM& vm, Structure* structure, Ref<WorkletGlobalScope>&& impl) |
94 | : JSWorkletGlobalScopeBase(vm, structure, WTFMove(impl)) |
95 | { |
96 | } |
97 | |
98 | void JSWorkletGlobalScope::finishCreation(VM& vm, JSProxy* proxy) |
99 | { |
100 | Base::finishCreation(vm, proxy); |
101 | |
102 | #if ENABLE(CSS_PAINTING_API) |
103 | if (RuntimeEnabledFeatures::sharedFeatures().cssPaintingAPIEnabled()) |
104 | putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WorkletGlobalScopePublicName(), CustomGetterSetter::create(vm, jsWorkletGlobalScopeWorkletGlobalScopeConstructor, setJSWorkletGlobalScopeWorkletGlobalScopeConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); |
105 | #endif |
106 | } |
107 | |
108 | JSObject* JSWorkletGlobalScope::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
109 | { |
110 | return JSWorkletGlobalScopePrototype::create(vm, &globalObject, JSWorkletGlobalScopePrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
111 | } |
112 | |
113 | JSObject* JSWorkletGlobalScope::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
114 | { |
115 | return getDOMPrototype<JSWorkletGlobalScope>(vm, globalObject); |
116 | } |
117 | |
118 | JSValue JSWorkletGlobalScope::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
119 | { |
120 | return getDOMConstructor<JSWorkletGlobalScopeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
121 | } |
122 | |
123 | template<> inline JSWorkletGlobalScope* IDLAttribute<JSWorkletGlobalScope>::cast(ExecState& state, EncodedJSValue thisValue) |
124 | { |
125 | auto decodedThisValue = JSValue::decode(thisValue); |
126 | if (decodedThisValue.isUndefinedOrNull()) |
127 | decodedThisValue = state.thisValue().toThis(&state, NotStrictMode); |
128 | return toJSWorkletGlobalScope(state.vm(), decodedThisValue);} |
129 | |
130 | EncodedJSValue jsWorkletGlobalScopeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
131 | { |
132 | VM& vm = state->vm(); |
133 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
134 | auto* prototype = jsDynamicCast<JSWorkletGlobalScopePrototype*>(vm, JSValue::decode(thisValue)); |
135 | if (UNLIKELY(!prototype)) |
136 | return throwVMTypeError(state, throwScope); |
137 | return JSValue::encode(JSWorkletGlobalScope::getConstructor(state->vm(), prototype->globalObject())); |
138 | } |
139 | |
140 | bool setJSWorkletGlobalScopeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
141 | { |
142 | VM& vm = state->vm(); |
143 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
144 | auto* prototype = jsDynamicCast<JSWorkletGlobalScopePrototype*>(vm, JSValue::decode(thisValue)); |
145 | if (UNLIKELY(!prototype)) { |
146 | throwVMTypeError(state, throwScope); |
147 | return false; |
148 | } |
149 | // Shadowing a built-in constructor |
150 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
151 | } |
152 | |
153 | #if ENABLE(CSS_PAINTING_API) |
154 | static inline JSValue jsWorkletGlobalScopeWorkletGlobalScopeConstructorGetter(ExecState& state, JSWorkletGlobalScope& thisObject, ThrowScope& throwScope) |
155 | { |
156 | UNUSED_PARAM(throwScope); |
157 | UNUSED_PARAM(state); |
158 | return JSWorkletGlobalScope::getConstructor(state.vm(), thisObject.globalObject()); |
159 | } |
160 | |
161 | EncodedJSValue jsWorkletGlobalScopeWorkletGlobalScopeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
162 | { |
163 | return IDLAttribute<JSWorkletGlobalScope>::get<jsWorkletGlobalScopeWorkletGlobalScopeConstructorGetter>(*state, thisValue, "WorkletGlobalScope" ); |
164 | } |
165 | |
166 | #endif |
167 | |
168 | #if ENABLE(CSS_PAINTING_API) |
169 | static inline bool setJSWorkletGlobalScopeWorkletGlobalScopeConstructorSetter(ExecState& state, JSWorkletGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
170 | { |
171 | UNUSED_PARAM(throwScope); |
172 | // Shadowing a built-in constructor. |
173 | return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("WorkletGlobalScope" ), strlen("WorkletGlobalScope" )), value); |
174 | } |
175 | |
176 | bool setJSWorkletGlobalScopeWorkletGlobalScopeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
177 | { |
178 | return IDLAttribute<JSWorkletGlobalScope>::set<setJSWorkletGlobalScopeWorkletGlobalScopeConstructorSetter>(*state, thisValue, encodedValue, "WorkletGlobalScope" ); |
179 | } |
180 | |
181 | #endif |
182 | |
183 | void JSWorkletGlobalScope::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
184 | { |
185 | auto* thisObject = jsCast<JSWorkletGlobalScope*>(cell); |
186 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
187 | if (thisObject->scriptExecutionContext()) |
188 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
189 | Base::heapSnapshot(cell, builder); |
190 | } |
191 | |
192 | WorkletGlobalScope* JSWorkletGlobalScope::toWrapped(JSC::VM& vm, JSC::JSValue value) |
193 | { |
194 | if (auto* wrapper = jsDynamicCast<JSWorkletGlobalScope*>(vm, value)) |
195 | return &wrapper->wrapped(); |
196 | return nullptr; |
197 | } |
198 | |
199 | } |
200 | |
201 | #endif // ENABLE(CSS_PAINTING_API) |
202 | |