summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-10-01 19:05:28 +0300
committerAndreas Kling <kling@serenityos.org>2021-10-01 20:14:45 +0200
commit1c4404c46a0a6a57246241dd428c5cefdb51c112 (patch)
tree52c2769373b3a84b2a419f0ed87f229a2b9598b3 /Userland
parent4d71f226730ad5d1a6ea9779b17a64e26c06488a (diff)
downloadserenity-1c4404c46a0a6a57246241dd428c5cefdb51c112.zip
LibWeb: Add the missing PageTransitionEvent IDL constructor
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Window.cpp6
-rw-r--r--Userland/Libraries/LibWeb/DOM/Window.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h18
-rw-r--r--Userland/Libraries/LibWeb/HTML/PageTransitionEvent.idl6
4 files changed, 24 insertions, 8 deletions
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<PageTransitionEvent> create(FlyString event_name, bool persisted)
+ static NonnullRefPtr<PageTransitionEvent> create(FlyString const& event_name, PageTransitionEventInit const& event_init)
+ {
+ return adopt_ref(*new PageTransitionEvent(event_name, event_init));
+ }
+ static NonnullRefPtr<PageTransitionEvent> 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 <DOM/Event.idl>
+
interface PageTransitionEvent : Event {
+ constructor(DOMString type, optional PageTransitionEventInit eventInitDict = {});
readonly attribute boolean persisted;
+};
+dictionary PageTransitionEventInit : EventInit {
+ boolean persisted = false;
};