2022-08-08 22:29:40 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2022-09-25 16:38:21 -06:00
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2022-08-08 22:29:40 +02:00
|
|
|
#include <LibWeb/HTML/PromiseRejectionEvent.h>
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2023-02-15 19:30:27 +01:00
|
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> PromiseRejectionEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
2022-08-08 22:29:40 +02:00
|
|
|
{
|
2023-02-15 19:30:27 +01:00
|
|
|
return MUST_OR_THROW_OOM(realm.heap().allocate<PromiseRejectionEvent>(realm, realm, event_name, event_init));
|
2022-08-08 22:29:40 +02:00
|
|
|
}
|
|
|
|
|
2023-02-15 19:30:27 +01:00
|
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> PromiseRejectionEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
2022-08-08 22:29:40 +02:00
|
|
|
{
|
2022-09-25 16:38:21 -06:00
|
|
|
return create(realm, event_name, event_init);
|
2022-08-08 22:29:40 +02:00
|
|
|
}
|
|
|
|
|
2023-01-08 19:23:00 -05:00
|
|
|
PromiseRejectionEvent::PromiseRejectionEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
2022-09-25 16:38:21 -06:00
|
|
|
: DOM::Event(realm, event_name, event_init)
|
2022-08-08 22:29:40 +02:00
|
|
|
, m_promise(const_cast<JS::Promise*>(event_init.promise.cell()))
|
|
|
|
, m_reason(event_init.reason)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PromiseRejectionEvent::~PromiseRejectionEvent() = default;
|
|
|
|
|
|
|
|
void PromiseRejectionEvent::visit_edges(Cell::Visitor& visitor)
|
|
|
|
{
|
|
|
|
Base::visit_edges(visitor);
|
|
|
|
visitor.visit(m_promise);
|
|
|
|
visitor.visit(m_reason);
|
|
|
|
}
|
|
|
|
|
2023-01-28 12:33:35 -05:00
|
|
|
JS::ThrowCompletionOr<void> PromiseRejectionEvent::initialize(JS::Realm& realm)
|
2023-01-10 06:28:20 -05:00
|
|
|
{
|
2023-01-28 12:33:35 -05:00
|
|
|
MUST_OR_THROW_OOM(Base::initialize(realm));
|
2023-01-10 06:28:20 -05:00
|
|
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::PromiseRejectionEventPrototype>(realm, "PromiseRejectionEvent"));
|
2023-01-28 12:33:35 -05:00
|
|
|
|
|
|
|
return {};
|
2023-01-10 06:28:20 -05:00
|
|
|
}
|
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
}
|