| 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 "JSIDBRequest.h" |
| 26 | |
| 27 | #include "EventNames.h" |
| 28 | #include "JSDOMAttribute.h" |
| 29 | #include "JSDOMBinding.h" |
| 30 | #include "JSDOMConstructorNotConstructable.h" |
| 31 | #include "JSDOMConvertInterface.h" |
| 32 | #include "JSDOMConvertNullable.h" |
| 33 | #include "JSDOMConvertUnion.h" |
| 34 | #include "JSDOMException.h" |
| 35 | #include "JSDOMExceptionHandling.h" |
| 36 | #include "JSDOMGlobalObject.h" |
| 37 | #include "JSDOMWrapperCache.h" |
| 38 | #include "JSEventListener.h" |
| 39 | #include "JSIDBCursor.h" |
| 40 | #include "JSIDBIndex.h" |
| 41 | #include "JSIDBObjectStore.h" |
| 42 | #include "JSIDBTransaction.h" |
| 43 | #include "ScriptExecutionContext.h" |
| 44 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 45 | #include <JavaScriptCore/JSCInlines.h> |
| 46 | #include <JavaScriptCore/JSString.h> |
| 47 | #include <wtf/GetPtr.h> |
| 48 | #include <wtf/PointerPreparations.h> |
| 49 | #include <wtf/URL.h> |
| 50 | #include <wtf/Variant.h> |
| 51 | |
| 52 | |
| 53 | namespace WebCore { |
| 54 | using namespace JSC; |
| 55 | |
| 56 | String convertEnumerationToString(IDBRequest::ReadyState enumerationValue) |
| 57 | { |
| 58 | static const NeverDestroyed<String> values[] = { |
| 59 | MAKE_STATIC_STRING_IMPL("pending" ), |
| 60 | MAKE_STATIC_STRING_IMPL("done" ), |
| 61 | }; |
| 62 | static_assert(static_cast<size_t>(IDBRequest::ReadyState::Pending) == 0, "IDBRequest::ReadyState::Pending is not 0 as expected" ); |
| 63 | static_assert(static_cast<size_t>(IDBRequest::ReadyState::Done) == 1, "IDBRequest::ReadyState::Done is not 1 as expected" ); |
| 64 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| 65 | return values[static_cast<size_t>(enumerationValue)]; |
| 66 | } |
| 67 | |
| 68 | template<> JSString* convertEnumerationToJS(ExecState& state, IDBRequest::ReadyState enumerationValue) |
| 69 | { |
| 70 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
| 71 | } |
| 72 | |
| 73 | template<> Optional<IDBRequest::ReadyState> parseEnumeration<IDBRequest::ReadyState>(ExecState& state, JSValue value) |
| 74 | { |
| 75 | auto stringValue = value.toWTFString(&state); |
| 76 | if (stringValue == "pending" ) |
| 77 | return IDBRequest::ReadyState::Pending; |
| 78 | if (stringValue == "done" ) |
| 79 | return IDBRequest::ReadyState::Done; |
| 80 | return WTF::nullopt; |
| 81 | } |
| 82 | |
| 83 | template<> const char* expectedEnumerationValues<IDBRequest::ReadyState>() |
| 84 | { |
| 85 | return "\"pending\", \"done\"" ; |
| 86 | } |
| 87 | |
| 88 | // Attributes |
| 89 | |
| 90 | JSC::EncodedJSValue jsIDBRequestConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 91 | bool setJSIDBRequestConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 92 | JSC::EncodedJSValue jsIDBRequestResult(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 93 | JSC::EncodedJSValue jsIDBRequestError(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 94 | JSC::EncodedJSValue jsIDBRequestSource(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 95 | JSC::EncodedJSValue jsIDBRequestTransaction(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 96 | JSC::EncodedJSValue jsIDBRequestReadyState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 97 | JSC::EncodedJSValue jsIDBRequestOnsuccess(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 98 | bool setJSIDBRequestOnsuccess(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 99 | JSC::EncodedJSValue jsIDBRequestOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 100 | bool setJSIDBRequestOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 101 | |
| 102 | class JSIDBRequestPrototype : public JSC::JSNonFinalObject { |
| 103 | public: |
| 104 | using Base = JSC::JSNonFinalObject; |
| 105 | static JSIDBRequestPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 106 | { |
| 107 | JSIDBRequestPrototype* ptr = new (NotNull, JSC::allocateCell<JSIDBRequestPrototype>(vm.heap)) JSIDBRequestPrototype(vm, globalObject, structure); |
| 108 | ptr->finishCreation(vm); |
| 109 | return ptr; |
| 110 | } |
| 111 | |
| 112 | DECLARE_INFO; |
| 113 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 114 | { |
| 115 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 116 | } |
| 117 | |
| 118 | private: |
| 119 | JSIDBRequestPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 120 | : JSC::JSNonFinalObject(vm, structure) |
| 121 | { |
| 122 | } |
| 123 | |
| 124 | void finishCreation(JSC::VM&); |
| 125 | }; |
| 126 | |
| 127 | using JSIDBRequestConstructor = JSDOMConstructorNotConstructable<JSIDBRequest>; |
| 128 | |
| 129 | template<> JSValue JSIDBRequestConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 130 | { |
| 131 | return JSEventTarget::getConstructor(vm, &globalObject); |
| 132 | } |
| 133 | |
| 134 | template<> void JSIDBRequestConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 135 | { |
| 136 | putDirect(vm, vm.propertyNames->prototype, JSIDBRequest::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 137 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("IDBRequest"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 138 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 139 | } |
| 140 | |
| 141 | template<> const ClassInfo JSIDBRequestConstructor::s_info = { "IDBRequest" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBRequestConstructor) }; |
| 142 | |
| 143 | /* Hash table for prototype */ |
| 144 | |
| 145 | static const HashTableValue JSIDBRequestPrototypeTableValues[] = |
| 146 | { |
| 147 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBRequestConstructor) } }, |
| 148 | { "result" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestResult), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 149 | { "error" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestError), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 150 | { "source" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestSource), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 151 | { "transaction" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestTransaction), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 152 | { "readyState" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestReadyState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 153 | { "onsuccess" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestOnsuccess), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBRequestOnsuccess) } }, |
| 154 | { "onerror" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestOnerror), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBRequestOnerror) } }, |
| 155 | }; |
| 156 | |
| 157 | const ClassInfo JSIDBRequestPrototype::s_info = { "IDBRequestPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBRequestPrototype) }; |
| 158 | |
| 159 | void JSIDBRequestPrototype::finishCreation(VM& vm) |
| 160 | { |
| 161 | Base::finishCreation(vm); |
| 162 | reifyStaticProperties(vm, JSIDBRequest::info(), JSIDBRequestPrototypeTableValues, *this); |
| 163 | } |
| 164 | |
| 165 | const ClassInfo JSIDBRequest::s_info = { "IDBRequest" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBRequest) }; |
| 166 | |
| 167 | JSIDBRequest::JSIDBRequest(Structure* structure, JSDOMGlobalObject& globalObject, Ref<IDBRequest>&& impl) |
| 168 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| 169 | { |
| 170 | } |
| 171 | |
| 172 | void JSIDBRequest::finishCreation(VM& vm) |
| 173 | { |
| 174 | Base::finishCreation(vm); |
| 175 | ASSERT(inherits(vm, info())); |
| 176 | |
| 177 | } |
| 178 | |
| 179 | JSObject* JSIDBRequest::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 180 | { |
| 181 | return JSIDBRequestPrototype::create(vm, &globalObject, JSIDBRequestPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
| 182 | } |
| 183 | |
| 184 | JSObject* JSIDBRequest::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 185 | { |
| 186 | return getDOMPrototype<JSIDBRequest>(vm, globalObject); |
| 187 | } |
| 188 | |
| 189 | JSValue JSIDBRequest::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 190 | { |
| 191 | return getDOMConstructor<JSIDBRequestConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 192 | } |
| 193 | |
| 194 | template<> inline JSIDBRequest* IDLAttribute<JSIDBRequest>::cast(ExecState& state, EncodedJSValue thisValue) |
| 195 | { |
| 196 | return jsDynamicCast<JSIDBRequest*>(state.vm(), JSValue::decode(thisValue)); |
| 197 | } |
| 198 | |
| 199 | EncodedJSValue jsIDBRequestConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 200 | { |
| 201 | VM& vm = state->vm(); |
| 202 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 203 | auto* prototype = jsDynamicCast<JSIDBRequestPrototype*>(vm, JSValue::decode(thisValue)); |
| 204 | if (UNLIKELY(!prototype)) |
| 205 | return throwVMTypeError(state, throwScope); |
| 206 | return JSValue::encode(JSIDBRequest::getConstructor(state->vm(), prototype->globalObject())); |
| 207 | } |
| 208 | |
| 209 | bool setJSIDBRequestConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 210 | { |
| 211 | VM& vm = state->vm(); |
| 212 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 213 | auto* prototype = jsDynamicCast<JSIDBRequestPrototype*>(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 | static inline JSValue jsIDBRequestResultGetter(ExecState& state, JSIDBRequest& thisObject, ThrowScope& throwScope) |
| 223 | { |
| 224 | UNUSED_PARAM(throwScope); |
| 225 | UNUSED_PARAM(state); |
| 226 | return thisObject.result(state); |
| 227 | } |
| 228 | |
| 229 | EncodedJSValue jsIDBRequestResult(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 230 | { |
| 231 | return IDLAttribute<JSIDBRequest>::get<jsIDBRequestResultGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "result" ); |
| 232 | } |
| 233 | |
| 234 | static inline JSValue jsIDBRequestErrorGetter(ExecState& state, JSIDBRequest& thisObject, ThrowScope& throwScope) |
| 235 | { |
| 236 | UNUSED_PARAM(throwScope); |
| 237 | UNUSED_PARAM(state); |
| 238 | auto& impl = thisObject.wrapped(); |
| 239 | JSValue result = toJS<IDLNullable<IDLInterface<DOMException>>>(state, *thisObject.globalObject(), throwScope, impl.error()); |
| 240 | return result; |
| 241 | } |
| 242 | |
| 243 | EncodedJSValue jsIDBRequestError(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 244 | { |
| 245 | return IDLAttribute<JSIDBRequest>::get<jsIDBRequestErrorGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "error" ); |
| 246 | } |
| 247 | |
| 248 | static inline JSValue jsIDBRequestSourceGetter(ExecState& state, JSIDBRequest& thisObject, ThrowScope& throwScope) |
| 249 | { |
| 250 | UNUSED_PARAM(throwScope); |
| 251 | UNUSED_PARAM(state); |
| 252 | auto& impl = thisObject.wrapped(); |
| 253 | JSValue result = toJS<IDLNullable<IDLUnion<IDLInterface<IDBObjectStore>, IDLInterface<IDBIndex>, IDLInterface<IDBCursor>>>>(state, *thisObject.globalObject(), throwScope, impl.source()); |
| 254 | return result; |
| 255 | } |
| 256 | |
| 257 | EncodedJSValue jsIDBRequestSource(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 258 | { |
| 259 | return IDLAttribute<JSIDBRequest>::get<jsIDBRequestSourceGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "source" ); |
| 260 | } |
| 261 | |
| 262 | static inline JSValue jsIDBRequestTransactionGetter(ExecState& state, JSIDBRequest& thisObject, ThrowScope& throwScope) |
| 263 | { |
| 264 | UNUSED_PARAM(throwScope); |
| 265 | UNUSED_PARAM(state); |
| 266 | auto& impl = thisObject.wrapped(); |
| 267 | JSValue result = toJS<IDLInterface<IDBTransaction>>(state, *thisObject.globalObject(), throwScope, impl.transaction()); |
| 268 | return result; |
| 269 | } |
| 270 | |
| 271 | EncodedJSValue jsIDBRequestTransaction(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 272 | { |
| 273 | return IDLAttribute<JSIDBRequest>::get<jsIDBRequestTransactionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "transaction" ); |
| 274 | } |
| 275 | |
| 276 | static inline JSValue jsIDBRequestReadyStateGetter(ExecState& state, JSIDBRequest& thisObject, ThrowScope& throwScope) |
| 277 | { |
| 278 | UNUSED_PARAM(throwScope); |
| 279 | UNUSED_PARAM(state); |
| 280 | auto& impl = thisObject.wrapped(); |
| 281 | JSValue result = toJS<IDLEnumeration<IDBRequest::ReadyState>>(state, throwScope, impl.readyState()); |
| 282 | return result; |
| 283 | } |
| 284 | |
| 285 | EncodedJSValue jsIDBRequestReadyState(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 286 | { |
| 287 | return IDLAttribute<JSIDBRequest>::get<jsIDBRequestReadyStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "readyState" ); |
| 288 | } |
| 289 | |
| 290 | static inline JSValue jsIDBRequestOnsuccessGetter(ExecState& state, JSIDBRequest& thisObject, ThrowScope& throwScope) |
| 291 | { |
| 292 | UNUSED_PARAM(throwScope); |
| 293 | UNUSED_PARAM(state); |
| 294 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().successEvent, worldForDOMObject(thisObject)); |
| 295 | } |
| 296 | |
| 297 | EncodedJSValue jsIDBRequestOnsuccess(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 298 | { |
| 299 | return IDLAttribute<JSIDBRequest>::get<jsIDBRequestOnsuccessGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onsuccess" ); |
| 300 | } |
| 301 | |
| 302 | static inline bool setJSIDBRequestOnsuccessSetter(ExecState& state, JSIDBRequest& thisObject, JSValue value, ThrowScope& throwScope) |
| 303 | { |
| 304 | UNUSED_PARAM(throwScope); |
| 305 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().successEvent, value); |
| 306 | return true; |
| 307 | } |
| 308 | |
| 309 | bool setJSIDBRequestOnsuccess(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 310 | { |
| 311 | return IDLAttribute<JSIDBRequest>::set<setJSIDBRequestOnsuccessSetter>(*state, thisValue, encodedValue, "onsuccess" ); |
| 312 | } |
| 313 | |
| 314 | static inline JSValue jsIDBRequestOnerrorGetter(ExecState& state, JSIDBRequest& thisObject, ThrowScope& throwScope) |
| 315 | { |
| 316 | UNUSED_PARAM(throwScope); |
| 317 | UNUSED_PARAM(state); |
| 318 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().errorEvent, worldForDOMObject(thisObject)); |
| 319 | } |
| 320 | |
| 321 | EncodedJSValue jsIDBRequestOnerror(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 322 | { |
| 323 | return IDLAttribute<JSIDBRequest>::get<jsIDBRequestOnerrorGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onerror" ); |
| 324 | } |
| 325 | |
| 326 | static inline bool setJSIDBRequestOnerrorSetter(ExecState& state, JSIDBRequest& thisObject, JSValue value, ThrowScope& throwScope) |
| 327 | { |
| 328 | UNUSED_PARAM(throwScope); |
| 329 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().errorEvent, value); |
| 330 | return true; |
| 331 | } |
| 332 | |
| 333 | bool setJSIDBRequestOnerror(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 334 | { |
| 335 | return IDLAttribute<JSIDBRequest>::set<setJSIDBRequestOnerrorSetter>(*state, thisValue, encodedValue, "onerror" ); |
| 336 | } |
| 337 | |
| 338 | void JSIDBRequest::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 339 | { |
| 340 | auto* thisObject = jsCast<JSIDBRequest*>(cell); |
| 341 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 342 | Base::visitChildren(thisObject, visitor); |
| 343 | thisObject->visitAdditionalChildren(visitor); |
| 344 | } |
| 345 | |
| 346 | void JSIDBRequest::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
| 347 | { |
| 348 | auto* thisObject = jsCast<JSIDBRequest*>(cell); |
| 349 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 350 | Base::visitOutputConstraints(thisObject, visitor); |
| 351 | thisObject->visitAdditionalChildren(visitor); |
| 352 | } |
| 353 | |
| 354 | void JSIDBRequest::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 355 | { |
| 356 | auto* thisObject = jsCast<JSIDBRequest*>(cell); |
| 357 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 358 | if (thisObject->scriptExecutionContext()) |
| 359 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 360 | Base::heapSnapshot(cell, builder); |
| 361 | } |
| 362 | |
| 363 | bool JSIDBRequestOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 364 | { |
| 365 | auto* jsIDBRequest = jsCast<JSIDBRequest*>(handle.slot()->asCell()); |
| 366 | if (jsIDBRequest->wrapped().hasPendingActivity()) { |
| 367 | if (UNLIKELY(reason)) |
| 368 | *reason = "ActiveDOMObject with pending activity" ; |
| 369 | return true; |
| 370 | } |
| 371 | if (jsIDBRequest->wrapped().isFiringEventListeners()) { |
| 372 | if (UNLIKELY(reason)) |
| 373 | *reason = "EventTarget firing event listeners" ; |
| 374 | return true; |
| 375 | } |
| 376 | IDBRequest* root = &jsIDBRequest->wrapped(); |
| 377 | if (UNLIKELY(reason)) |
| 378 | *reason = "Reachable from IDBRequest" ; |
| 379 | return visitor.containsOpaqueRoot(root); |
| 380 | } |
| 381 | |
| 382 | void JSIDBRequestOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 383 | { |
| 384 | auto* jsIDBRequest = static_cast<JSIDBRequest*>(handle.slot()->asCell()); |
| 385 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 386 | uncacheWrapper(world, &jsIDBRequest->wrapped(), jsIDBRequest); |
| 387 | } |
| 388 | |
| 389 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<IDBRequest>&& impl) |
| 390 | { |
| 391 | return createWrapper<IDBRequest>(globalObject, WTFMove(impl)); |
| 392 | } |
| 393 | |
| 394 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, IDBRequest& impl) |
| 395 | { |
| 396 | return wrap(state, globalObject, impl); |
| 397 | } |
| 398 | |
| 399 | IDBRequest* JSIDBRequest::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 400 | { |
| 401 | if (auto* wrapper = jsDynamicCast<JSIDBRequest*>(vm, value)) |
| 402 | return &wrapper->wrapped(); |
| 403 | return nullptr; |
| 404 | } |
| 405 | |
| 406 | } |
| 407 | |
| 408 | #endif // ENABLE(INDEXED_DATABASE) |
| 409 | |