| 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 "JSIDBTransaction.h" |
| 26 | |
| 27 | #include "EventNames.h" |
| 28 | #include "JSDOMAttribute.h" |
| 29 | #include "JSDOMBinding.h" |
| 30 | #include "JSDOMConstructorNotConstructable.h" |
| 31 | #include "JSDOMConvertEnumeration.h" |
| 32 | #include "JSDOMConvertInterface.h" |
| 33 | #include "JSDOMConvertStrings.h" |
| 34 | #include "JSDOMException.h" |
| 35 | #include "JSDOMExceptionHandling.h" |
| 36 | #include "JSDOMGlobalObject.h" |
| 37 | #include "JSDOMOperation.h" |
| 38 | #include "JSDOMStringList.h" |
| 39 | #include "JSDOMWrapperCache.h" |
| 40 | #include "JSEventListener.h" |
| 41 | #include "JSIDBDatabase.h" |
| 42 | #include "JSIDBObjectStore.h" |
| 43 | #include "JSIDBTransactionMode.h" |
| 44 | #include "ScriptExecutionContext.h" |
| 45 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 46 | #include <JavaScriptCore/JSCInlines.h> |
| 47 | #include <wtf/GetPtr.h> |
| 48 | #include <wtf/PointerPreparations.h> |
| 49 | #include <wtf/URL.h> |
| 50 | |
| 51 | |
| 52 | namespace WebCore { |
| 53 | using namespace JSC; |
| 54 | |
| 55 | // Functions |
| 56 | |
| 57 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBTransactionPrototypeFunctionObjectStore(JSC::ExecState*); |
| 58 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBTransactionPrototypeFunctionAbort(JSC::ExecState*); |
| 59 | |
| 60 | // Attributes |
| 61 | |
| 62 | JSC::EncodedJSValue jsIDBTransactionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 63 | bool setJSIDBTransactionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 64 | JSC::EncodedJSValue jsIDBTransactionObjectStoreNames(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 65 | JSC::EncodedJSValue jsIDBTransactionMode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 66 | JSC::EncodedJSValue jsIDBTransactionDb(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 67 | JSC::EncodedJSValue jsIDBTransactionError(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 68 | JSC::EncodedJSValue jsIDBTransactionOnabort(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 69 | bool setJSIDBTransactionOnabort(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 70 | JSC::EncodedJSValue jsIDBTransactionOncomplete(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 71 | bool setJSIDBTransactionOncomplete(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 72 | JSC::EncodedJSValue jsIDBTransactionOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 73 | bool setJSIDBTransactionOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 74 | |
| 75 | class JSIDBTransactionPrototype : public JSC::JSNonFinalObject { |
| 76 | public: |
| 77 | using Base = JSC::JSNonFinalObject; |
| 78 | static JSIDBTransactionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 79 | { |
| 80 | JSIDBTransactionPrototype* ptr = new (NotNull, JSC::allocateCell<JSIDBTransactionPrototype>(vm.heap)) JSIDBTransactionPrototype(vm, globalObject, structure); |
| 81 | ptr->finishCreation(vm); |
| 82 | return ptr; |
| 83 | } |
| 84 | |
| 85 | DECLARE_INFO; |
| 86 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 87 | { |
| 88 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 89 | } |
| 90 | |
| 91 | private: |
| 92 | JSIDBTransactionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 93 | : JSC::JSNonFinalObject(vm, structure) |
| 94 | { |
| 95 | } |
| 96 | |
| 97 | void finishCreation(JSC::VM&); |
| 98 | }; |
| 99 | |
| 100 | using JSIDBTransactionConstructor = JSDOMConstructorNotConstructable<JSIDBTransaction>; |
| 101 | |
| 102 | template<> JSValue JSIDBTransactionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 103 | { |
| 104 | return JSEventTarget::getConstructor(vm, &globalObject); |
| 105 | } |
| 106 | |
| 107 | template<> void JSIDBTransactionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 108 | { |
| 109 | putDirect(vm, vm.propertyNames->prototype, JSIDBTransaction::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 110 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("IDBTransaction"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 111 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 112 | } |
| 113 | |
| 114 | template<> const ClassInfo JSIDBTransactionConstructor::s_info = { "IDBTransaction" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBTransactionConstructor) }; |
| 115 | |
| 116 | /* Hash table for prototype */ |
| 117 | |
| 118 | static const HashTableValue JSIDBTransactionPrototypeTableValues[] = |
| 119 | { |
| 120 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBTransactionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBTransactionConstructor) } }, |
| 121 | { "objectStoreNames" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBTransactionObjectStoreNames), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 122 | { "mode" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBTransactionMode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 123 | { "db" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBTransactionDb), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 124 | { "error" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBTransactionError), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 125 | { "onabort" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBTransactionOnabort), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBTransactionOnabort) } }, |
| 126 | { "oncomplete" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBTransactionOncomplete), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBTransactionOncomplete) } }, |
| 127 | { "onerror" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBTransactionOnerror), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBTransactionOnerror) } }, |
| 128 | { "objectStore" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBTransactionPrototypeFunctionObjectStore), (intptr_t) (1) } }, |
| 129 | { "abort" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBTransactionPrototypeFunctionAbort), (intptr_t) (0) } }, |
| 130 | }; |
| 131 | |
| 132 | const ClassInfo JSIDBTransactionPrototype::s_info = { "IDBTransactionPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBTransactionPrototype) }; |
| 133 | |
| 134 | void JSIDBTransactionPrototype::finishCreation(VM& vm) |
| 135 | { |
| 136 | Base::finishCreation(vm); |
| 137 | reifyStaticProperties(vm, JSIDBTransaction::info(), JSIDBTransactionPrototypeTableValues, *this); |
| 138 | } |
| 139 | |
| 140 | const ClassInfo JSIDBTransaction::s_info = { "IDBTransaction" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBTransaction) }; |
| 141 | |
| 142 | JSIDBTransaction::JSIDBTransaction(Structure* structure, JSDOMGlobalObject& globalObject, Ref<IDBTransaction>&& impl) |
| 143 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| 144 | { |
| 145 | } |
| 146 | |
| 147 | void JSIDBTransaction::finishCreation(VM& vm) |
| 148 | { |
| 149 | Base::finishCreation(vm); |
| 150 | ASSERT(inherits(vm, info())); |
| 151 | |
| 152 | } |
| 153 | |
| 154 | JSObject* JSIDBTransaction::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 155 | { |
| 156 | return JSIDBTransactionPrototype::create(vm, &globalObject, JSIDBTransactionPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
| 157 | } |
| 158 | |
| 159 | JSObject* JSIDBTransaction::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 160 | { |
| 161 | return getDOMPrototype<JSIDBTransaction>(vm, globalObject); |
| 162 | } |
| 163 | |
| 164 | JSValue JSIDBTransaction::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 165 | { |
| 166 | return getDOMConstructor<JSIDBTransactionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 167 | } |
| 168 | |
| 169 | template<> inline JSIDBTransaction* IDLAttribute<JSIDBTransaction>::cast(ExecState& state, EncodedJSValue thisValue) |
| 170 | { |
| 171 | return jsDynamicCast<JSIDBTransaction*>(state.vm(), JSValue::decode(thisValue)); |
| 172 | } |
| 173 | |
| 174 | template<> inline JSIDBTransaction* IDLOperation<JSIDBTransaction>::cast(ExecState& state) |
| 175 | { |
| 176 | return jsDynamicCast<JSIDBTransaction*>(state.vm(), state.thisValue()); |
| 177 | } |
| 178 | |
| 179 | EncodedJSValue jsIDBTransactionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 180 | { |
| 181 | VM& vm = state->vm(); |
| 182 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 183 | auto* prototype = jsDynamicCast<JSIDBTransactionPrototype*>(vm, JSValue::decode(thisValue)); |
| 184 | if (UNLIKELY(!prototype)) |
| 185 | return throwVMTypeError(state, throwScope); |
| 186 | return JSValue::encode(JSIDBTransaction::getConstructor(state->vm(), prototype->globalObject())); |
| 187 | } |
| 188 | |
| 189 | bool setJSIDBTransactionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 190 | { |
| 191 | VM& vm = state->vm(); |
| 192 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 193 | auto* prototype = jsDynamicCast<JSIDBTransactionPrototype*>(vm, JSValue::decode(thisValue)); |
| 194 | if (UNLIKELY(!prototype)) { |
| 195 | throwVMTypeError(state, throwScope); |
| 196 | return false; |
| 197 | } |
| 198 | // Shadowing a built-in constructor |
| 199 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 200 | } |
| 201 | |
| 202 | static inline JSValue jsIDBTransactionObjectStoreNamesGetter(ExecState& state, JSIDBTransaction& thisObject, ThrowScope& throwScope) |
| 203 | { |
| 204 | UNUSED_PARAM(throwScope); |
| 205 | UNUSED_PARAM(state); |
| 206 | auto& impl = thisObject.wrapped(); |
| 207 | JSValue result = toJS<IDLInterface<DOMStringList>>(state, *thisObject.globalObject(), throwScope, impl.objectStoreNames()); |
| 208 | return result; |
| 209 | } |
| 210 | |
| 211 | EncodedJSValue jsIDBTransactionObjectStoreNames(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 212 | { |
| 213 | return IDLAttribute<JSIDBTransaction>::get<jsIDBTransactionObjectStoreNamesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "objectStoreNames" ); |
| 214 | } |
| 215 | |
| 216 | static inline JSValue jsIDBTransactionModeGetter(ExecState& state, JSIDBTransaction& thisObject, ThrowScope& throwScope) |
| 217 | { |
| 218 | UNUSED_PARAM(throwScope); |
| 219 | UNUSED_PARAM(state); |
| 220 | auto& impl = thisObject.wrapped(); |
| 221 | JSValue result = toJS<IDLEnumeration<IDBTransactionMode>>(state, throwScope, impl.mode()); |
| 222 | return result; |
| 223 | } |
| 224 | |
| 225 | EncodedJSValue jsIDBTransactionMode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 226 | { |
| 227 | return IDLAttribute<JSIDBTransaction>::get<jsIDBTransactionModeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "mode" ); |
| 228 | } |
| 229 | |
| 230 | static inline JSValue jsIDBTransactionDbGetter(ExecState& state, JSIDBTransaction& thisObject, ThrowScope& throwScope) |
| 231 | { |
| 232 | UNUSED_PARAM(throwScope); |
| 233 | UNUSED_PARAM(state); |
| 234 | auto& impl = thisObject.wrapped(); |
| 235 | JSValue result = toJS<IDLInterface<IDBDatabase>>(state, *thisObject.globalObject(), throwScope, impl.db()); |
| 236 | return result; |
| 237 | } |
| 238 | |
| 239 | EncodedJSValue jsIDBTransactionDb(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 240 | { |
| 241 | return IDLAttribute<JSIDBTransaction>::get<jsIDBTransactionDbGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "db" ); |
| 242 | } |
| 243 | |
| 244 | static inline JSValue jsIDBTransactionErrorGetter(ExecState& state, JSIDBTransaction& thisObject, ThrowScope& throwScope) |
| 245 | { |
| 246 | UNUSED_PARAM(throwScope); |
| 247 | UNUSED_PARAM(state); |
| 248 | auto& impl = thisObject.wrapped(); |
| 249 | JSValue result = toJS<IDLInterface<DOMException>>(state, *thisObject.globalObject(), throwScope, impl.error()); |
| 250 | return result; |
| 251 | } |
| 252 | |
| 253 | EncodedJSValue jsIDBTransactionError(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 254 | { |
| 255 | return IDLAttribute<JSIDBTransaction>::get<jsIDBTransactionErrorGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "error" ); |
| 256 | } |
| 257 | |
| 258 | static inline JSValue jsIDBTransactionOnabortGetter(ExecState& state, JSIDBTransaction& thisObject, ThrowScope& throwScope) |
| 259 | { |
| 260 | UNUSED_PARAM(throwScope); |
| 261 | UNUSED_PARAM(state); |
| 262 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().abortEvent, worldForDOMObject(thisObject)); |
| 263 | } |
| 264 | |
| 265 | EncodedJSValue jsIDBTransactionOnabort(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 266 | { |
| 267 | return IDLAttribute<JSIDBTransaction>::get<jsIDBTransactionOnabortGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onabort" ); |
| 268 | } |
| 269 | |
| 270 | static inline bool setJSIDBTransactionOnabortSetter(ExecState& state, JSIDBTransaction& thisObject, JSValue value, ThrowScope& throwScope) |
| 271 | { |
| 272 | UNUSED_PARAM(throwScope); |
| 273 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().abortEvent, value); |
| 274 | return true; |
| 275 | } |
| 276 | |
| 277 | bool setJSIDBTransactionOnabort(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 278 | { |
| 279 | return IDLAttribute<JSIDBTransaction>::set<setJSIDBTransactionOnabortSetter>(*state, thisValue, encodedValue, "onabort" ); |
| 280 | } |
| 281 | |
| 282 | static inline JSValue jsIDBTransactionOncompleteGetter(ExecState& state, JSIDBTransaction& thisObject, ThrowScope& throwScope) |
| 283 | { |
| 284 | UNUSED_PARAM(throwScope); |
| 285 | UNUSED_PARAM(state); |
| 286 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().completeEvent, worldForDOMObject(thisObject)); |
| 287 | } |
| 288 | |
| 289 | EncodedJSValue jsIDBTransactionOncomplete(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 290 | { |
| 291 | return IDLAttribute<JSIDBTransaction>::get<jsIDBTransactionOncompleteGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "oncomplete" ); |
| 292 | } |
| 293 | |
| 294 | static inline bool setJSIDBTransactionOncompleteSetter(ExecState& state, JSIDBTransaction& thisObject, JSValue value, ThrowScope& throwScope) |
| 295 | { |
| 296 | UNUSED_PARAM(throwScope); |
| 297 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().completeEvent, value); |
| 298 | return true; |
| 299 | } |
| 300 | |
| 301 | bool setJSIDBTransactionOncomplete(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 302 | { |
| 303 | return IDLAttribute<JSIDBTransaction>::set<setJSIDBTransactionOncompleteSetter>(*state, thisValue, encodedValue, "oncomplete" ); |
| 304 | } |
| 305 | |
| 306 | static inline JSValue jsIDBTransactionOnerrorGetter(ExecState& state, JSIDBTransaction& thisObject, ThrowScope& throwScope) |
| 307 | { |
| 308 | UNUSED_PARAM(throwScope); |
| 309 | UNUSED_PARAM(state); |
| 310 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().errorEvent, worldForDOMObject(thisObject)); |
| 311 | } |
| 312 | |
| 313 | EncodedJSValue jsIDBTransactionOnerror(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 314 | { |
| 315 | return IDLAttribute<JSIDBTransaction>::get<jsIDBTransactionOnerrorGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onerror" ); |
| 316 | } |
| 317 | |
| 318 | static inline bool setJSIDBTransactionOnerrorSetter(ExecState& state, JSIDBTransaction& thisObject, JSValue value, ThrowScope& throwScope) |
| 319 | { |
| 320 | UNUSED_PARAM(throwScope); |
| 321 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().errorEvent, value); |
| 322 | return true; |
| 323 | } |
| 324 | |
| 325 | bool setJSIDBTransactionOnerror(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 326 | { |
| 327 | return IDLAttribute<JSIDBTransaction>::set<setJSIDBTransactionOnerrorSetter>(*state, thisValue, encodedValue, "onerror" ); |
| 328 | } |
| 329 | |
| 330 | static inline JSC::EncodedJSValue jsIDBTransactionPrototypeFunctionObjectStoreBody(JSC::ExecState* state, typename IDLOperation<JSIDBTransaction>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 331 | { |
| 332 | UNUSED_PARAM(state); |
| 333 | UNUSED_PARAM(throwScope); |
| 334 | auto& impl = castedThis->wrapped(); |
| 335 | if (UNLIKELY(state->argumentCount() < 1)) |
| 336 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 337 | auto name = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 338 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 339 | return JSValue::encode(toJS<IDLInterface<IDBObjectStore>>(*state, *castedThis->globalObject(), throwScope, impl.objectStore(WTFMove(name)))); |
| 340 | } |
| 341 | |
| 342 | EncodedJSValue JSC_HOST_CALL jsIDBTransactionPrototypeFunctionObjectStore(ExecState* state) |
| 343 | { |
| 344 | return IDLOperation<JSIDBTransaction>::call<jsIDBTransactionPrototypeFunctionObjectStoreBody>(*state, "objectStore" ); |
| 345 | } |
| 346 | |
| 347 | static inline JSC::EncodedJSValue jsIDBTransactionPrototypeFunctionAbortBody(JSC::ExecState* state, typename IDLOperation<JSIDBTransaction>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 348 | { |
| 349 | UNUSED_PARAM(state); |
| 350 | UNUSED_PARAM(throwScope); |
| 351 | auto& impl = castedThis->wrapped(); |
| 352 | propagateException(*state, throwScope, impl.abort()); |
| 353 | return JSValue::encode(jsUndefined()); |
| 354 | } |
| 355 | |
| 356 | EncodedJSValue JSC_HOST_CALL jsIDBTransactionPrototypeFunctionAbort(ExecState* state) |
| 357 | { |
| 358 | return IDLOperation<JSIDBTransaction>::call<jsIDBTransactionPrototypeFunctionAbortBody>(*state, "abort" ); |
| 359 | } |
| 360 | |
| 361 | void JSIDBTransaction::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 362 | { |
| 363 | auto* thisObject = jsCast<JSIDBTransaction*>(cell); |
| 364 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 365 | Base::visitChildren(thisObject, visitor); |
| 366 | thisObject->visitAdditionalChildren(visitor); |
| 367 | } |
| 368 | |
| 369 | void JSIDBTransaction::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
| 370 | { |
| 371 | auto* thisObject = jsCast<JSIDBTransaction*>(cell); |
| 372 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 373 | Base::visitOutputConstraints(thisObject, visitor); |
| 374 | thisObject->visitAdditionalChildren(visitor); |
| 375 | } |
| 376 | |
| 377 | void JSIDBTransaction::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 378 | { |
| 379 | auto* thisObject = jsCast<JSIDBTransaction*>(cell); |
| 380 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 381 | if (thisObject->scriptExecutionContext()) |
| 382 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 383 | Base::heapSnapshot(cell, builder); |
| 384 | } |
| 385 | |
| 386 | bool JSIDBTransactionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 387 | { |
| 388 | auto* jsIDBTransaction = jsCast<JSIDBTransaction*>(handle.slot()->asCell()); |
| 389 | if (jsIDBTransaction->wrapped().hasPendingActivity()) { |
| 390 | if (UNLIKELY(reason)) |
| 391 | *reason = "ActiveDOMObject with pending activity" ; |
| 392 | return true; |
| 393 | } |
| 394 | if (jsIDBTransaction->wrapped().isFiringEventListeners()) { |
| 395 | if (UNLIKELY(reason)) |
| 396 | *reason = "EventTarget firing event listeners" ; |
| 397 | return true; |
| 398 | } |
| 399 | UNUSED_PARAM(visitor); |
| 400 | UNUSED_PARAM(reason); |
| 401 | return false; |
| 402 | } |
| 403 | |
| 404 | void JSIDBTransactionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 405 | { |
| 406 | auto* jsIDBTransaction = static_cast<JSIDBTransaction*>(handle.slot()->asCell()); |
| 407 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 408 | uncacheWrapper(world, &jsIDBTransaction->wrapped(), jsIDBTransaction); |
| 409 | } |
| 410 | |
| 411 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<IDBTransaction>&& impl) |
| 412 | { |
| 413 | return createWrapper<IDBTransaction>(globalObject, WTFMove(impl)); |
| 414 | } |
| 415 | |
| 416 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, IDBTransaction& impl) |
| 417 | { |
| 418 | return wrap(state, globalObject, impl); |
| 419 | } |
| 420 | |
| 421 | IDBTransaction* JSIDBTransaction::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 422 | { |
| 423 | if (auto* wrapper = jsDynamicCast<JSIDBTransaction*>(vm, value)) |
| 424 | return &wrapper->wrapped(); |
| 425 | return nullptr; |
| 426 | } |
| 427 | |
| 428 | } |
| 429 | |
| 430 | #endif // ENABLE(INDEXED_DATABASE) |
| 431 | |