summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-26 12:39:27 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-26 12:47:51 +0200
commit831fdcaabc95817d4bff9c8bd8a6741227a0b371 (patch)
tree3a7fcd8b6bcbfbdc28ad648a402c2a819d5842e7 /Userland/Libraries/LibWeb/DOM
parent508edcd217b23c0cc0107a094269e65373b813de (diff)
downloadserenity-831fdcaabc95817d4bff9c8bd8a6741227a0b371.zip
LibWeb: Add the PageTransitionEvent interface and fire "pageshow" events
We now fire "pageshow" events at the appropriate time during document loading (done by the parser.) Note that there are no corresponding "pagehide" events yet.
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Window.cpp19
-rw-r--r--Userland/Libraries/LibWeb/DOM/Window.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Window.cpp b/Userland/Libraries/LibWeb/DOM/Window.cpp
index 3e2532e9b5..5806c8418c 100644
--- a/Userland/Libraries/LibWeb/DOM/Window.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Window.cpp
@@ -12,6 +12,7 @@
#include <LibWeb/DOM/EventDispatcher.h>
#include <LibWeb/DOM/Timer.h>
#include <LibWeb/DOM/Window.h>
+#include <LibWeb/HTML/PageTransitionEvent.h>
#include <LibWeb/HighResolutionTime/Performance.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Page/BrowsingContext.h>
@@ -276,4 +277,22 @@ float Window::scroll_y() const
return 0;
}
+// https://html.spec.whatwg.org/#fire-a-page-transition-event
+void Window::fire_a_page_transition_event(FlyString 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);
+
+ // ...the cancelable attribute intialized to true,
+ event->set_cancelable(true);
+
+ // the bubbles attribute initialized to true,
+ event->set_bubbles(true);
+
+ // and legacy target override flag set.
+ dispatch_event(move(event));
+}
+
}
diff --git a/Userland/Libraries/LibWeb/DOM/Window.h b/Userland/Libraries/LibWeb/DOM/Window.h
index f17873cf49..7800d25cbb 100644
--- a/Userland/Libraries/LibWeb/DOM/Window.h
+++ b/Userland/Libraries/LibWeb/DOM/Window.h
@@ -83,6 +83,8 @@ public:
float scroll_x() const;
float scroll_y() const;
+ void fire_a_page_transition_event(FlyString event_name, bool persisted);
+
private:
explicit Window(Document&);