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(SERVICE_WORKER) |
24 | |
25 | #include "JSServiceWorkerWindowClient.h" |
26 | |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConstructorNotConstructable.h" |
30 | #include "JSDOMConvertBoolean.h" |
31 | #include "JSDOMConvertEnumeration.h" |
32 | #include "JSDOMConvertStrings.h" |
33 | #include "JSDOMExceptionHandling.h" |
34 | #include "JSDOMOperation.h" |
35 | #include "JSDOMOperationReturningPromise.h" |
36 | #include "JSDOMWrapperCache.h" |
37 | #include "JSVisibilityState.h" |
38 | #include "ScriptExecutionContext.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 | |
46 | namespace WebCore { |
47 | using namespace JSC; |
48 | |
49 | // Functions |
50 | |
51 | JSC::EncodedJSValue JSC_HOST_CALL jsServiceWorkerWindowClientPrototypeFunctionFocus(JSC::ExecState*); |
52 | JSC::EncodedJSValue JSC_HOST_CALL jsServiceWorkerWindowClientPrototypeFunctionNavigate(JSC::ExecState*); |
53 | |
54 | // Attributes |
55 | |
56 | JSC::EncodedJSValue jsServiceWorkerWindowClientConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
57 | bool setJSServiceWorkerWindowClientConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
58 | JSC::EncodedJSValue jsServiceWorkerWindowClientVisibilityState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
59 | JSC::EncodedJSValue jsServiceWorkerWindowClientFocused(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
60 | |
61 | class JSServiceWorkerWindowClientPrototype : public JSC::JSNonFinalObject { |
62 | public: |
63 | using Base = JSC::JSNonFinalObject; |
64 | static JSServiceWorkerWindowClientPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
65 | { |
66 | JSServiceWorkerWindowClientPrototype* ptr = new (NotNull, JSC::allocateCell<JSServiceWorkerWindowClientPrototype>(vm.heap)) JSServiceWorkerWindowClientPrototype(vm, globalObject, structure); |
67 | ptr->finishCreation(vm); |
68 | return ptr; |
69 | } |
70 | |
71 | DECLARE_INFO; |
72 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
73 | { |
74 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
75 | } |
76 | |
77 | private: |
78 | JSServiceWorkerWindowClientPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
79 | : JSC::JSNonFinalObject(vm, structure) |
80 | { |
81 | } |
82 | |
83 | void finishCreation(JSC::VM&); |
84 | }; |
85 | |
86 | using JSServiceWorkerWindowClientConstructor = JSDOMConstructorNotConstructable<JSServiceWorkerWindowClient>; |
87 | |
88 | template<> JSValue JSServiceWorkerWindowClientConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
89 | { |
90 | return JSServiceWorkerClient::getConstructor(vm, &globalObject); |
91 | } |
92 | |
93 | template<> void JSServiceWorkerWindowClientConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
94 | { |
95 | putDirect(vm, vm.propertyNames->prototype, JSServiceWorkerWindowClient::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
96 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("WindowClient"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
97 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
98 | } |
99 | |
100 | template<> const ClassInfo JSServiceWorkerWindowClientConstructor::s_info = { "WindowClient" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSServiceWorkerWindowClientConstructor) }; |
101 | |
102 | /* Hash table for prototype */ |
103 | |
104 | static const HashTableValue JSServiceWorkerWindowClientPrototypeTableValues[] = |
105 | { |
106 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsServiceWorkerWindowClientConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSServiceWorkerWindowClientConstructor) } }, |
107 | { "visibilityState" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsServiceWorkerWindowClientVisibilityState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
108 | { "focused" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsServiceWorkerWindowClientFocused), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
109 | { "focus" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsServiceWorkerWindowClientPrototypeFunctionFocus), (intptr_t) (0) } }, |
110 | { "navigate" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsServiceWorkerWindowClientPrototypeFunctionNavigate), (intptr_t) (1) } }, |
111 | }; |
112 | |
113 | const ClassInfo JSServiceWorkerWindowClientPrototype::s_info = { "WindowClientPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSServiceWorkerWindowClientPrototype) }; |
114 | |
115 | void JSServiceWorkerWindowClientPrototype::finishCreation(VM& vm) |
116 | { |
117 | Base::finishCreation(vm); |
118 | reifyStaticProperties(vm, JSServiceWorkerWindowClient::info(), JSServiceWorkerWindowClientPrototypeTableValues, *this); |
119 | } |
120 | |
121 | const ClassInfo JSServiceWorkerWindowClient::s_info = { "WindowClient" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSServiceWorkerWindowClient) }; |
122 | |
123 | JSServiceWorkerWindowClient::JSServiceWorkerWindowClient(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ServiceWorkerWindowClient>&& impl) |
124 | : JSServiceWorkerClient(structure, globalObject, WTFMove(impl)) |
125 | { |
126 | } |
127 | |
128 | void JSServiceWorkerWindowClient::finishCreation(VM& vm) |
129 | { |
130 | Base::finishCreation(vm); |
131 | ASSERT(inherits(vm, info())); |
132 | |
133 | } |
134 | |
135 | JSObject* JSServiceWorkerWindowClient::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
136 | { |
137 | return JSServiceWorkerWindowClientPrototype::create(vm, &globalObject, JSServiceWorkerWindowClientPrototype::createStructure(vm, &globalObject, JSServiceWorkerClient::prototype(vm, globalObject))); |
138 | } |
139 | |
140 | JSObject* JSServiceWorkerWindowClient::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
141 | { |
142 | return getDOMPrototype<JSServiceWorkerWindowClient>(vm, globalObject); |
143 | } |
144 | |
145 | JSValue JSServiceWorkerWindowClient::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
146 | { |
147 | return getDOMConstructor<JSServiceWorkerWindowClientConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
148 | } |
149 | |
150 | template<> inline JSServiceWorkerWindowClient* IDLAttribute<JSServiceWorkerWindowClient>::cast(ExecState& state, EncodedJSValue thisValue) |
151 | { |
152 | return jsDynamicCast<JSServiceWorkerWindowClient*>(state.vm(), JSValue::decode(thisValue)); |
153 | } |
154 | |
155 | template<> inline JSServiceWorkerWindowClient* IDLOperation<JSServiceWorkerWindowClient>::cast(ExecState& state) |
156 | { |
157 | return jsDynamicCast<JSServiceWorkerWindowClient*>(state.vm(), state.thisValue()); |
158 | } |
159 | |
160 | EncodedJSValue jsServiceWorkerWindowClientConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
161 | { |
162 | VM& vm = state->vm(); |
163 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
164 | auto* prototype = jsDynamicCast<JSServiceWorkerWindowClientPrototype*>(vm, JSValue::decode(thisValue)); |
165 | if (UNLIKELY(!prototype)) |
166 | return throwVMTypeError(state, throwScope); |
167 | return JSValue::encode(JSServiceWorkerWindowClient::getConstructor(state->vm(), prototype->globalObject())); |
168 | } |
169 | |
170 | bool setJSServiceWorkerWindowClientConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
171 | { |
172 | VM& vm = state->vm(); |
173 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
174 | auto* prototype = jsDynamicCast<JSServiceWorkerWindowClientPrototype*>(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 JSValue jsServiceWorkerWindowClientVisibilityStateGetter(ExecState& state, JSServiceWorkerWindowClient& thisObject, ThrowScope& throwScope) |
184 | { |
185 | UNUSED_PARAM(throwScope); |
186 | UNUSED_PARAM(state); |
187 | auto& impl = thisObject.wrapped(); |
188 | JSValue result = toJS<IDLEnumeration<VisibilityState>>(state, throwScope, impl.visibilityState()); |
189 | return result; |
190 | } |
191 | |
192 | EncodedJSValue jsServiceWorkerWindowClientVisibilityState(ExecState* state, EncodedJSValue thisValue, PropertyName) |
193 | { |
194 | return IDLAttribute<JSServiceWorkerWindowClient>::get<jsServiceWorkerWindowClientVisibilityStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "visibilityState" ); |
195 | } |
196 | |
197 | static inline JSValue jsServiceWorkerWindowClientFocusedGetter(ExecState& state, JSServiceWorkerWindowClient& thisObject, ThrowScope& throwScope) |
198 | { |
199 | UNUSED_PARAM(throwScope); |
200 | UNUSED_PARAM(state); |
201 | auto& impl = thisObject.wrapped(); |
202 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.isFocused()); |
203 | return result; |
204 | } |
205 | |
206 | EncodedJSValue jsServiceWorkerWindowClientFocused(ExecState* state, EncodedJSValue thisValue, PropertyName) |
207 | { |
208 | return IDLAttribute<JSServiceWorkerWindowClient>::get<jsServiceWorkerWindowClientFocusedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "focused" ); |
209 | } |
210 | |
211 | static inline JSC::EncodedJSValue jsServiceWorkerWindowClientPrototypeFunctionFocusBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSServiceWorkerWindowClient>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
212 | { |
213 | UNUSED_PARAM(state); |
214 | UNUSED_PARAM(throwScope); |
215 | auto& impl = castedThis->wrapped(); |
216 | impl.focus(WTFMove(promise)); |
217 | return JSValue::encode(jsUndefined()); |
218 | } |
219 | |
220 | EncodedJSValue JSC_HOST_CALL jsServiceWorkerWindowClientPrototypeFunctionFocus(ExecState* state) |
221 | { |
222 | return IDLOperationReturningPromise<JSServiceWorkerWindowClient>::call<jsServiceWorkerWindowClientPrototypeFunctionFocusBody, PromiseExecutionScope::WindowOrWorker>(*state, "focus" ); |
223 | } |
224 | |
225 | static inline JSC::EncodedJSValue jsServiceWorkerWindowClientPrototypeFunctionNavigateBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSServiceWorkerWindowClient>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
226 | { |
227 | UNUSED_PARAM(state); |
228 | UNUSED_PARAM(throwScope); |
229 | auto& impl = castedThis->wrapped(); |
230 | if (UNLIKELY(state->argumentCount() < 1)) |
231 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
232 | auto url = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
233 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
234 | impl.navigate(WTFMove(url), WTFMove(promise)); |
235 | return JSValue::encode(jsUndefined()); |
236 | } |
237 | |
238 | EncodedJSValue JSC_HOST_CALL jsServiceWorkerWindowClientPrototypeFunctionNavigate(ExecState* state) |
239 | { |
240 | return IDLOperationReturningPromise<JSServiceWorkerWindowClient>::call<jsServiceWorkerWindowClientPrototypeFunctionNavigateBody, PromiseExecutionScope::WindowOrWorker>(*state, "navigate" ); |
241 | } |
242 | |
243 | void JSServiceWorkerWindowClient::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
244 | { |
245 | auto* thisObject = jsCast<JSServiceWorkerWindowClient*>(cell); |
246 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
247 | if (thisObject->scriptExecutionContext()) |
248 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
249 | Base::heapSnapshot(cell, builder); |
250 | } |
251 | |
252 | |
253 | } |
254 | |
255 | #endif // ENABLE(SERVICE_WORKER) |
256 | |