2022-08-08 23:29:40 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2022-09-26 03:06:11 +03:00
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2022-08-08 23:29:40 +03:00
|
|
|
#include <LibWeb/UIEvents/UIEvent.h>
|
|
|
|
|
|
|
|
namespace Web::UIEvents {
|
|
|
|
|
2023-04-06 17:12:33 +03:00
|
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> UIEvent::create(JS::Realm& realm, FlyString const& event_name)
|
2022-08-08 23:29:40 +03:00
|
|
|
{
|
2023-02-19 12:38:20 +03:00
|
|
|
return MUST_OR_THROW_OOM(realm.heap().allocate<UIEvent>(realm, realm, event_name));
|
2022-08-08 23:29:40 +03:00
|
|
|
}
|
|
|
|
|
2023-04-06 17:12:33 +03:00
|
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> UIEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, UIEventInit const& event_init)
|
2022-08-08 23:29:40 +03:00
|
|
|
{
|
2023-02-19 12:38:20 +03:00
|
|
|
return MUST_OR_THROW_OOM(realm.heap().allocate<UIEvent>(realm, realm, event_name, event_init));
|
2022-08-08 23:29:40 +03:00
|
|
|
}
|
|
|
|
|
2023-04-06 17:12:33 +03:00
|
|
|
UIEvent::UIEvent(JS::Realm& realm, FlyString const& event_name)
|
2022-09-26 03:06:11 +03:00
|
|
|
: Event(realm, event_name)
|
2022-08-08 23:29:40 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-04-06 17:12:33 +03:00
|
|
|
UIEvent::UIEvent(JS::Realm& realm, FlyString const& event_name, UIEventInit const& event_init)
|
2022-09-26 03:06:11 +03:00
|
|
|
: Event(realm, event_name, event_init)
|
2022-08-08 23:29:40 +03:00
|
|
|
, m_view(event_init.view)
|
|
|
|
, m_detail(event_init.detail)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEvent::~UIEvent() = default;
|
|
|
|
|
2023-01-28 20:33:35 +03:00
|
|
|
JS::ThrowCompletionOr<void> UIEvent::initialize(JS::Realm& realm)
|
2023-01-10 14:28:20 +03:00
|
|
|
{
|
2023-01-28 20:33:35 +03:00
|
|
|
MUST_OR_THROW_OOM(Base::initialize(realm));
|
2023-01-10 14:28:20 +03:00
|
|
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::UIEventPrototype>(realm, "UIEvent"));
|
2023-01-28 20:33:35 +03:00
|
|
|
|
|
|
|
return {};
|
2023-01-10 14:28:20 +03:00
|
|
|
}
|
|
|
|
|
2022-08-28 14:42:07 +03:00
|
|
|
void UIEvent::visit_edges(Cell::Visitor& visitor)
|
|
|
|
{
|
|
|
|
Base::visit_edges(visitor);
|
|
|
|
visitor.visit(m_view.ptr());
|
|
|
|
}
|
|
|
|
|
2022-08-08 23:29:40 +03:00
|
|
|
}
|