Truly independent web browser
/*
* Copyright (c) 2020-2022, Andreas Kling <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/RefPtr.h>
#include <AK/Utf16String.h>
#include <LibWeb/Bindings/UIEvent.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/Export.h>
#include <LibWeb/HTML/Window.h>
namespace Web::UIEvents {
using UIEventInit = Bindings::UIEventInit;
class WEB_API UIEvent : public DOM::Event {
WEB_WRAPPABLE(UIEvent, DOM::Event);
GC_DECLARE_ALLOCATOR(UIEvent);
public:
[[nodiscard]] static GC::Ref<UIEvent> create(FlyString const& type, HighResolutionTime::DOMHighResTimeStamp);
[[nodiscard]] static GC::Ref<UIEvent> create(FlyString const& type, UIEventInit const&, HighResolutionTime::DOMHighResTimeStamp);
[[nodiscard]] static GC::Ref<UIEvent> create(Utf16String const& type, UIEventInit const&, HighResolutionTime::DOMHighResTimeStamp);
virtual ~UIEvent() override;
GC::Ptr<HTML::WindowProxy> const view() const { return m_view; }
int detail() const { return m_detail; }
virtual u32 which() const { return 0; }
void init_ui_event(Utf16FlyString const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, int detail)
{
// Initializes attributes of an UIEvent object. This method has the same behavior as initEvent().
// 1. If this’s dispatch flag is set, then return.
if (dispatched())
return;
// 2. Initialize this with type, bubbles, and cancelable.
initialize_event(type, bubbles, cancelable);
// Implementation Defined: Initialise other values.
m_view = view;
m_detail = detail;
}
protected:
UIEvent(FlyString const& event_name, HighResolutionTime::DOMHighResTimeStamp);
UIEvent(Utf16FlyString const& event_name, HighResolutionTime::DOMHighResTimeStamp);
UIEvent(FlyString const& event_name, UIEventInit const&, HighResolutionTime::DOMHighResTimeStamp);
UIEvent(Utf16FlyString const& event_name, UIEventInit const&, HighResolutionTime::DOMHighResTimeStamp);
virtual void visit_edges(GC::Cell::Visitor&) override;
GC::Ptr<HTML::WindowProxy> m_view;
int m_detail { 0 };
};
}