From 1c4404c46a0a6a57246241dd428c5cefdb51c112 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Fri, 1 Oct 2021 19:05:28 +0300 Subject: LibWeb: Add the missing PageTransitionEvent IDL constructor --- Userland/Libraries/LibWeb/DOM/Window.cpp | 6 ++++-- Userland/Libraries/LibWeb/DOM/Window.h | 2 +- Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h | 18 +++++++++++++----- Userland/Libraries/LibWeb/HTML/PageTransitionEvent.idl | 6 ++++++ 4 files changed, 24 insertions(+), 8 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibWeb/DOM/Window.cpp b/Userland/Libraries/LibWeb/DOM/Window.cpp index b10be4f417..4983e85ced 100644 --- a/Userland/Libraries/LibWeb/DOM/Window.cpp +++ b/Userland/Libraries/LibWeb/DOM/Window.cpp @@ -282,12 +282,14 @@ float Window::scroll_y() const } // https://html.spec.whatwg.org/#fire-a-page-transition-event -void Window::fire_a_page_transition_event(FlyString event_name, bool persisted) +void Window::fire_a_page_transition_event(FlyString const& event_name, bool persisted) { // To fire a page transition event named eventName at a Window window with a boolean persisted, // fire an event named eventName at window, using PageTransitionEvent, // with the persisted attribute initialized to persisted, - auto event = HTML::PageTransitionEvent::create(move(event_name), persisted); + HTML::PageTransitionEventInit event_init {}; + event_init.persisted = persisted; + auto event = HTML::PageTransitionEvent::create(event_name, event_init); // ...the cancelable attribute initialized to true, event->set_cancelable(true); diff --git a/Userland/Libraries/LibWeb/DOM/Window.h b/Userland/Libraries/LibWeb/DOM/Window.h index 871da29dec..cd50872f46 100644 --- a/Userland/Libraries/LibWeb/DOM/Window.h +++ b/Userland/Libraries/LibWeb/DOM/Window.h @@ -87,7 +87,7 @@ public: float scroll_x() const; float scroll_y() const; - void fire_a_page_transition_event(FlyString event_name, bool persisted); + void fire_a_page_transition_event(FlyString const& event_name, bool persisted); float device_pixel_ratio() const; diff --git a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h index 7c3602ed1f..a2477524f0 100644 --- a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h +++ b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h @@ -10,13 +10,21 @@ namespace Web::HTML { +struct PageTransitionEventInit : public DOM::EventInit { + bool persisted { false }; +}; + class PageTransitionEvent final : public DOM::Event { public: using WrapperType = Bindings::PageTransitionEventWrapper; - static NonnullRefPtr create(FlyString event_name, bool persisted) + static NonnullRefPtr create(FlyString const& event_name, PageTransitionEventInit const& event_init) + { + return adopt_ref(*new PageTransitionEvent(event_name, event_init)); + } + static NonnullRefPtr create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, PageTransitionEventInit const& event_init) { - return adopt_ref(*new PageTransitionEvent(move(event_name), persisted)); + return PageTransitionEvent::create(event_name, event_init); } virtual ~PageTransitionEvent() override = default; @@ -24,9 +32,9 @@ public: bool persisted() const { return m_persisted; } protected: - PageTransitionEvent(FlyString event_name, bool persisted) - : DOM::Event(move(event_name)) - , m_persisted(persisted) + PageTransitionEvent(FlyString const& event_name, PageTransitionEventInit const& event_init) + : DOM::Event(event_name, event_init) + , m_persisted(event_init.persisted) { } diff --git a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.idl b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.idl index e569647c3a..3a43880430 100644 --- a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.idl +++ b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.idl @@ -1,5 +1,11 @@ +#import + interface PageTransitionEvent : Event { + constructor(DOMString type, optional PageTransitionEventInit eventInitDict = {}); readonly attribute boolean persisted; +}; +dictionary PageTransitionEventInit : EventInit { + boolean persisted = false; }; -- cgit v1.2.3