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(INDEXED_DATABASE) |
24 | |
25 | #include "JSIDBOpenDBRequest.h" |
26 | |
27 | #include "EventNames.h" |
28 | #include "JSDOMAttribute.h" |
29 | #include "JSDOMBinding.h" |
30 | #include "JSDOMConstructorNotConstructable.h" |
31 | #include "JSDOMExceptionHandling.h" |
32 | #include "JSDOMWrapperCache.h" |
33 | #include "JSEventListener.h" |
34 | #include "ScriptExecutionContext.h" |
35 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
36 | #include <JavaScriptCore/JSCInlines.h> |
37 | #include <wtf/GetPtr.h> |
38 | #include <wtf/PointerPreparations.h> |
39 | #include <wtf/URL.h> |
40 | |
41 | |
42 | namespace WebCore { |
43 | using namespace JSC; |
44 | |
45 | // Attributes |
46 | |
47 | JSC::EncodedJSValue jsIDBOpenDBRequestConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
48 | bool setJSIDBOpenDBRequestConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
49 | JSC::EncodedJSValue jsIDBOpenDBRequestOnblocked(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
50 | bool setJSIDBOpenDBRequestOnblocked(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
51 | JSC::EncodedJSValue jsIDBOpenDBRequestOnupgradeneeded(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
52 | bool setJSIDBOpenDBRequestOnupgradeneeded(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
53 | |
54 | class JSIDBOpenDBRequestPrototype : public JSC::JSNonFinalObject { |
55 | public: |
56 | using Base = JSC::JSNonFinalObject; |
57 | static JSIDBOpenDBRequestPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
58 | { |
59 | JSIDBOpenDBRequestPrototype* ptr = new (NotNull, JSC::allocateCell<JSIDBOpenDBRequestPrototype>(vm.heap)) JSIDBOpenDBRequestPrototype(vm, globalObject, structure); |
60 | ptr->finishCreation(vm); |
61 | return ptr; |
62 | } |
63 | |
64 | DECLARE_INFO; |
65 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
66 | { |
67 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
68 | } |
69 | |
70 | private: |
71 | JSIDBOpenDBRequestPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
72 | : JSC::JSNonFinalObject(vm, structure) |
73 | { |
74 | } |
75 | |
76 | void finishCreation(JSC::VM&); |
77 | }; |
78 | |
79 | using JSIDBOpenDBRequestConstructor = JSDOMConstructorNotConstructable<JSIDBOpenDBRequest>; |
80 | |
81 | template<> JSValue JSIDBOpenDBRequestConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
82 | { |
83 | return JSIDBRequest::getConstructor(vm, &globalObject); |
84 | } |
85 | |
86 | template<> void JSIDBOpenDBRequestConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
87 | { |
88 | putDirect(vm, vm.propertyNames->prototype, JSIDBOpenDBRequest::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
89 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("IDBOpenDBRequest"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
90 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
91 | } |
92 | |
93 | template<> const ClassInfo JSIDBOpenDBRequestConstructor::s_info = { "IDBOpenDBRequest" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBOpenDBRequestConstructor) }; |
94 | |
95 | /* Hash table for prototype */ |
96 | |
97 | static const HashTableValue JSIDBOpenDBRequestPrototypeTableValues[] = |
98 | { |
99 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBOpenDBRequestConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBOpenDBRequestConstructor) } }, |
100 | { "onblocked" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBOpenDBRequestOnblocked), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBOpenDBRequestOnblocked) } }, |
101 | { "onupgradeneeded" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBOpenDBRequestOnupgradeneeded), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBOpenDBRequestOnupgradeneeded) } }, |
102 | }; |
103 | |
104 | const ClassInfo JSIDBOpenDBRequestPrototype::s_info = { "IDBOpenDBRequestPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBOpenDBRequestPrototype) }; |
105 | |
106 | void JSIDBOpenDBRequestPrototype::finishCreation(VM& vm) |
107 | { |
108 | Base::finishCreation(vm); |
109 | reifyStaticProperties(vm, JSIDBOpenDBRequest::info(), JSIDBOpenDBRequestPrototypeTableValues, *this); |
110 | } |
111 | |
112 | const ClassInfo JSIDBOpenDBRequest::s_info = { "IDBOpenDBRequest" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBOpenDBRequest) }; |
113 | |
114 | JSIDBOpenDBRequest::JSIDBOpenDBRequest(Structure* structure, JSDOMGlobalObject& globalObject, Ref<IDBOpenDBRequest>&& impl) |
115 | : JSIDBRequest(structure, globalObject, WTFMove(impl)) |
116 | { |
117 | } |
118 | |
119 | void JSIDBOpenDBRequest::finishCreation(VM& vm) |
120 | { |
121 | Base::finishCreation(vm); |
122 | ASSERT(inherits(vm, info())); |
123 | |
124 | } |
125 | |
126 | JSObject* JSIDBOpenDBRequest::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
127 | { |
128 | return JSIDBOpenDBRequestPrototype::create(vm, &globalObject, JSIDBOpenDBRequestPrototype::createStructure(vm, &globalObject, JSIDBRequest::prototype(vm, globalObject))); |
129 | } |
130 | |
131 | JSObject* JSIDBOpenDBRequest::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
132 | { |
133 | return getDOMPrototype<JSIDBOpenDBRequest>(vm, globalObject); |
134 | } |
135 | |
136 | JSValue JSIDBOpenDBRequest::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
137 | { |
138 | return getDOMConstructor<JSIDBOpenDBRequestConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
139 | } |
140 | |
141 | template<> inline JSIDBOpenDBRequest* IDLAttribute<JSIDBOpenDBRequest>::cast(ExecState& state, EncodedJSValue thisValue) |
142 | { |
143 | return jsDynamicCast<JSIDBOpenDBRequest*>(state.vm(), JSValue::decode(thisValue)); |
144 | } |
145 | |
146 | EncodedJSValue jsIDBOpenDBRequestConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
147 | { |
148 | VM& vm = state->vm(); |
149 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
150 | auto* prototype = jsDynamicCast<JSIDBOpenDBRequestPrototype*>(vm, JSValue::decode(thisValue)); |
151 | if (UNLIKELY(!prototype)) |
152 | return throwVMTypeError(state, throwScope); |
153 | return JSValue::encode(JSIDBOpenDBRequest::getConstructor(state->vm(), prototype->globalObject())); |
154 | } |
155 | |
156 | bool setJSIDBOpenDBRequestConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
157 | { |
158 | VM& vm = state->vm(); |
159 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
160 | auto* prototype = jsDynamicCast<JSIDBOpenDBRequestPrototype*>(vm, JSValue::decode(thisValue)); |
161 | if (UNLIKELY(!prototype)) { |
162 | throwVMTypeError(state, throwScope); |
163 | return false; |
164 | } |
165 | // Shadowing a built-in constructor |
166 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
167 | } |
168 | |
169 | static inline JSValue jsIDBOpenDBRequestOnblockedGetter(ExecState& state, JSIDBOpenDBRequest& thisObject, ThrowScope& throwScope) |
170 | { |
171 | UNUSED_PARAM(throwScope); |
172 | UNUSED_PARAM(state); |
173 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().blockedEvent, worldForDOMObject(thisObject)); |
174 | } |
175 | |
176 | EncodedJSValue jsIDBOpenDBRequestOnblocked(ExecState* state, EncodedJSValue thisValue, PropertyName) |
177 | { |
178 | return IDLAttribute<JSIDBOpenDBRequest>::get<jsIDBOpenDBRequestOnblockedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onblocked" ); |
179 | } |
180 | |
181 | static inline bool setJSIDBOpenDBRequestOnblockedSetter(ExecState& state, JSIDBOpenDBRequest& thisObject, JSValue value, ThrowScope& throwScope) |
182 | { |
183 | UNUSED_PARAM(throwScope); |
184 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().blockedEvent, value); |
185 | return true; |
186 | } |
187 | |
188 | bool setJSIDBOpenDBRequestOnblocked(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
189 | { |
190 | return IDLAttribute<JSIDBOpenDBRequest>::set<setJSIDBOpenDBRequestOnblockedSetter>(*state, thisValue, encodedValue, "onblocked" ); |
191 | } |
192 | |
193 | static inline JSValue jsIDBOpenDBRequestOnupgradeneededGetter(ExecState& state, JSIDBOpenDBRequest& thisObject, ThrowScope& throwScope) |
194 | { |
195 | UNUSED_PARAM(throwScope); |
196 | UNUSED_PARAM(state); |
197 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().upgradeneededEvent, worldForDOMObject(thisObject)); |
198 | } |
199 | |
200 | EncodedJSValue jsIDBOpenDBRequestOnupgradeneeded(ExecState* state, EncodedJSValue thisValue, PropertyName) |
201 | { |
202 | return IDLAttribute<JSIDBOpenDBRequest>::get<jsIDBOpenDBRequestOnupgradeneededGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onupgradeneeded" ); |
203 | } |
204 | |
205 | static inline bool setJSIDBOpenDBRequestOnupgradeneededSetter(ExecState& state, JSIDBOpenDBRequest& thisObject, JSValue value, ThrowScope& throwScope) |
206 | { |
207 | UNUSED_PARAM(throwScope); |
208 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().upgradeneededEvent, value); |
209 | return true; |
210 | } |
211 | |
212 | bool setJSIDBOpenDBRequestOnupgradeneeded(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
213 | { |
214 | return IDLAttribute<JSIDBOpenDBRequest>::set<setJSIDBOpenDBRequestOnupgradeneededSetter>(*state, thisValue, encodedValue, "onupgradeneeded" ); |
215 | } |
216 | |
217 | void JSIDBOpenDBRequest::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
218 | { |
219 | auto* thisObject = jsCast<JSIDBOpenDBRequest*>(cell); |
220 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
221 | if (thisObject->scriptExecutionContext()) |
222 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
223 | Base::heapSnapshot(cell, builder); |
224 | } |
225 | |
226 | bool JSIDBOpenDBRequestOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
227 | { |
228 | auto* jsIDBOpenDBRequest = jsCast<JSIDBOpenDBRequest*>(handle.slot()->asCell()); |
229 | if (jsIDBOpenDBRequest->wrapped().hasPendingActivity()) { |
230 | if (UNLIKELY(reason)) |
231 | *reason = "ActiveDOMObject with pending activity" ; |
232 | return true; |
233 | } |
234 | if (jsIDBOpenDBRequest->wrapped().isFiringEventListeners()) { |
235 | if (UNLIKELY(reason)) |
236 | *reason = "EventTarget firing event listeners" ; |
237 | return true; |
238 | } |
239 | UNUSED_PARAM(visitor); |
240 | UNUSED_PARAM(reason); |
241 | return false; |
242 | } |
243 | |
244 | void JSIDBOpenDBRequestOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
245 | { |
246 | auto* jsIDBOpenDBRequest = static_cast<JSIDBOpenDBRequest*>(handle.slot()->asCell()); |
247 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
248 | uncacheWrapper(world, &jsIDBOpenDBRequest->wrapped(), jsIDBOpenDBRequest); |
249 | } |
250 | |
251 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<IDBOpenDBRequest>&& impl) |
252 | { |
253 | return createWrapper<IDBOpenDBRequest>(globalObject, WTFMove(impl)); |
254 | } |
255 | |
256 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, IDBOpenDBRequest& impl) |
257 | { |
258 | return wrap(state, globalObject, impl); |
259 | } |
260 | |
261 | IDBOpenDBRequest* JSIDBOpenDBRequest::toWrapped(JSC::VM& vm, JSC::JSValue value) |
262 | { |
263 | if (auto* wrapper = jsDynamicCast<JSIDBOpenDBRequest*>(vm, value)) |
264 | return &wrapper->wrapped(); |
265 | return nullptr; |
266 | } |
267 | |
268 | } |
269 | |
270 | #endif // ENABLE(INDEXED_DATABASE) |
271 | |