1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:28:11 +00:00
serenity/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp
Andreas Kling ffad902c07 LibWeb: Use cached_web_prototype() as much as possible
Unlike ensure_web_prototype<T>(), the cached version doesn't require the
prototype type to be fully formed, so we can use it without including
the FooPrototype.h header. It's also a bit less verbose. :^)
2022-09-06 00:27:09 +02:00

44 lines
1.3 KiB
C++

/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/Window.h>
#include <LibWeb/UIEvents/UIEvent.h>
namespace Web::UIEvents {
UIEvent* UIEvent::create(HTML::Window& window_object, FlyString const& event_name)
{
return window_object.heap().allocate<UIEvent>(window_object.realm(), window_object, event_name);
}
UIEvent* UIEvent::create_with_global_object(HTML::Window& window_object, FlyString const& event_name, UIEventInit const& event_init)
{
return window_object.heap().allocate<UIEvent>(window_object.realm(), window_object, event_name, event_init);
}
UIEvent::UIEvent(HTML::Window& window_object, FlyString const& event_name)
: Event(window_object, event_name)
{
set_prototype(&window_object.cached_web_prototype("UIEvent"));
}
UIEvent::UIEvent(HTML::Window& window_object, FlyString const& event_name, UIEventInit const& event_init)
: Event(window_object, event_name, event_init)
, m_view(event_init.view)
, m_detail(event_init.detail)
{
set_prototype(&window_object.cached_web_prototype("UIEvent"));
}
UIEvent::~UIEvent() = default;
void UIEvent::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_view.ptr());
}
}