IDBTransaction.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/HTML/EventNames.h>
  8. #include <LibWeb/IndexedDB/IDBTransaction.h>
  9. namespace Web::IndexedDB {
  10. GC_DEFINE_ALLOCATOR(IDBTransaction);
  11. IDBTransaction::~IDBTransaction() = default;
  12. IDBTransaction::IDBTransaction(JS::Realm& realm, GC::Ref<IDBDatabase> database)
  13. : EventTarget(realm)
  14. , m_connection(database)
  15. {
  16. }
  17. GC::Ref<IDBTransaction> IDBTransaction::create(JS::Realm& realm, GC::Ref<IDBDatabase> database)
  18. {
  19. return realm.create<IDBTransaction>(realm, database);
  20. }
  21. void IDBTransaction::initialize(JS::Realm& realm)
  22. {
  23. Base::initialize(realm);
  24. WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBTransaction);
  25. }
  26. void IDBTransaction::visit_edges(Visitor& visitor)
  27. {
  28. Base::visit_edges(visitor);
  29. visitor.visit(m_connection);
  30. visitor.visit(m_error);
  31. }
  32. void IDBTransaction::set_onabort(WebIDL::CallbackType* event_handler)
  33. {
  34. set_event_handler_attribute(HTML::EventNames::abort, event_handler);
  35. }
  36. WebIDL::CallbackType* IDBTransaction::onabort()
  37. {
  38. return event_handler_attribute(HTML::EventNames::abort);
  39. }
  40. void IDBTransaction::set_oncomplete(WebIDL::CallbackType* event_handler)
  41. {
  42. set_event_handler_attribute(HTML::EventNames::complete, event_handler);
  43. }
  44. WebIDL::CallbackType* IDBTransaction::oncomplete()
  45. {
  46. return event_handler_attribute(HTML::EventNames::complete);
  47. }
  48. void IDBTransaction::set_onerror(WebIDL::CallbackType* event_handler)
  49. {
  50. set_event_handler_attribute(HTML::EventNames::error, event_handler);
  51. }
  52. WebIDL::CallbackType* IDBTransaction::onerror()
  53. {
  54. return event_handler_attribute(HTML::EventNames::error);
  55. }
  56. }