1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:48:11 +00:00
serenity/Userland/Libraries/LibWeb/UIEvents/UIEvent.h
Lenny Maiorani c37820b898 Libraries: Use default constructors/destructors in LibWeb
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-17 17:23:49 +00:00

62 lines
1.5 KiB
C++

/*
* Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/RefPtr.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/HTML/Window.h>
namespace Web::UIEvents {
struct UIEventInit : public DOM::EventInit {
RefPtr<HTML::Window> view { nullptr };
int detail { 0 };
};
class UIEvent : public DOM::Event {
public:
using WrapperType = Bindings::UIEventWrapper;
static NonnullRefPtr<UIEvent> create(FlyString const& type)
{
return adopt_ref(*new UIEvent(type));
}
static NonnullRefPtr<UIEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, UIEventInit const& event_init)
{
return adopt_ref(*new UIEvent(event_name, event_init));
}
virtual ~UIEvent() override = default;
HTML::Window const* view() const { return m_view; }
int detail() const { return m_detail; }
void init_ui_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, int detail)
{
init_event(type, bubbles, cancelable);
m_view = view;
m_detail = detail;
}
protected:
explicit UIEvent(FlyString const& event_name)
: Event(event_name)
{
}
UIEvent(FlyString const& event_name, UIEventInit const& event_init)
: Event(event_name, event_init)
, m_view(event_init.view)
, m_detail(event_init.detail)
{
}
RefPtr<HTML::Window> m_view;
int m_detail { 0 };
};
}