PromiseRejectionEvent.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/HTML/PromiseRejectionEvent.h>
  8. namespace Web::HTML {
  9. PromiseRejectionEvent* PromiseRejectionEvent::create(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
  10. {
  11. return realm.heap().allocate<PromiseRejectionEvent>(realm, realm, event_name, event_init);
  12. }
  13. PromiseRejectionEvent* PromiseRejectionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
  14. {
  15. return create(realm, event_name, event_init);
  16. }
  17. PromiseRejectionEvent::PromiseRejectionEvent(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
  18. : DOM::Event(realm, event_name, event_init)
  19. , m_promise(const_cast<JS::Promise*>(event_init.promise.cell()))
  20. , m_reason(event_init.reason)
  21. {
  22. set_prototype(&Bindings::cached_web_prototype(realm, "PromiseRejectionEvent"));
  23. }
  24. PromiseRejectionEvent::~PromiseRejectionEvent() = default;
  25. void PromiseRejectionEvent::visit_edges(Cell::Visitor& visitor)
  26. {
  27. Base::visit_edges(visitor);
  28. visitor.visit(m_promise);
  29. visitor.visit(m_reason);
  30. }
  31. }