diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp index e55e4a9a66..ffbd208693 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp @@ -2474,6 +2474,7 @@ using namespace Web::DOM; using namespace Web::Geometry; using namespace Web::HTML; using namespace Web::RequestIdleCallback; +using namespace Web::UIEvents; using namespace Web::XHR; namespace Web::Bindings { diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h index 0bf85a1932..9126eac520 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h @@ -12,22 +12,38 @@ namespace Web::UIEvents { +struct UIEventInit : public DOM::EventInit { + RefPtr view { nullptr }; + int detail { 0 }; +}; + class UIEvent : public DOM::Event { public: using WrapperType = Bindings::UIEventWrapper; + static NonnullRefPtr 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 { } - DOM::Window const* view() const { return m_window; } + DOM::Window const* view() const { return m_view; } int detail() const { return m_detail; } protected: - explicit UIEvent(const FlyString& event_name) + 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 m_window; + RefPtr m_view; int m_detail { 0 }; }; diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.idl b/Userland/Libraries/LibWeb/UIEvents/UIEvent.idl index 071dbffde9..d317d3011a 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.idl +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.idl @@ -1,4 +1,12 @@ +#import + interface UIEvent : Event { + constructor(DOMString type, optional UIEventInit eventInitDict = {}); readonly attribute Window? view; readonly attribute long detail; }; + +dictionary UIEventInit : EventInit { + Window? view = null; + long detail = 0; +};