PromiseRejectionEvent.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/Bindings/PromiseRejectionEventPrototype.h>
  8. #include <LibWeb/HTML/PromiseRejectionEvent.h>
  9. namespace Web::HTML {
  10. GC_DEFINE_ALLOCATOR(PromiseRejectionEvent);
  11. GC::Ref<PromiseRejectionEvent> PromiseRejectionEvent::create(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
  12. {
  13. return realm.create<PromiseRejectionEvent>(realm, event_name, event_init);
  14. }
  15. WebIDL::ExceptionOr<GC::Ref<PromiseRejectionEvent>> PromiseRejectionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
  16. {
  17. return create(realm, event_name, event_init);
  18. }
  19. PromiseRejectionEvent::PromiseRejectionEvent(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
  20. : DOM::Event(realm, event_name, event_init)
  21. , m_promise(*event_init.promise)
  22. , m_reason(event_init.reason)
  23. {
  24. }
  25. PromiseRejectionEvent::~PromiseRejectionEvent() = default;
  26. void PromiseRejectionEvent::visit_edges(Cell::Visitor& visitor)
  27. {
  28. Base::visit_edges(visitor);
  29. visitor.visit(m_promise);
  30. visitor.visit(m_reason);
  31. }
  32. void PromiseRejectionEvent::initialize(JS::Realm& realm)
  33. {
  34. Base::initialize(realm);
  35. WEB_SET_PROTOTYPE_FOR_INTERFACE(PromiseRejectionEvent);
  36. }
  37. }