summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibWeb/DOM/Window.cpp19
-rw-r--r--Userland/Libraries/LibWeb/DOM/Window.h2
-rw-r--r--Userland/Libraries/LibWeb/Forward.h1
-rw-r--r--Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h36
-rw-r--r--Userland/Libraries/LibWeb/HTML/PageTransitionEvent.idl5
-rw-r--r--Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp10
7 files changed, 70 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt
index f60e97d754..1b0ca1a2f0 100644
--- a/Userland/Libraries/LibWeb/CMakeLists.txt
+++ b/Userland/Libraries/LibWeb/CMakeLists.txt
@@ -420,6 +420,7 @@ libweb_js_wrapper(HTML/ImageData)
libweb_js_wrapper(HTML/MessageChannel)
libweb_js_wrapper(HTML/MessageEvent)
libweb_js_wrapper(HTML/MessagePort)
+libweb_js_wrapper(HTML/PageTransitionEvent)
libweb_js_wrapper(HTML/SubmitEvent)
libweb_js_wrapper(HTML/WebSocket)
libweb_js_wrapper(HighResolutionTime/Performance)
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&);
diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h
index bae3610e66..fcc00aca80 100644
--- a/Userland/Libraries/LibWeb/Forward.h
+++ b/Userland/Libraries/LibWeb/Forward.h
@@ -346,6 +346,7 @@ class MessageEventWrapper;
class MessagePortWrapper;
class MouseEventWrapper;
class NodeWrapper;
+class PageTransitionEventWrapper;
class PerformanceTimingWrapper;
class PerformanceWrapper;
class ProcessingInstructionWrapper;
diff --git a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h
new file mode 100644
index 0000000000..7c3602ed1f
--- /dev/null
+++ b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibWeb/DOM/Event.h>
+
+namespace Web::HTML {
+
+class PageTransitionEvent final : public DOM::Event {
+public:
+ using WrapperType = Bindings::PageTransitionEventWrapper;
+
+ static NonnullRefPtr<PageTransitionEvent> create(FlyString event_name, bool persisted)
+ {
+ return adopt_ref(*new PageTransitionEvent(move(event_name), persisted));
+ }
+
+ virtual ~PageTransitionEvent() override = default;
+
+ bool persisted() const { return m_persisted; }
+
+protected:
+ PageTransitionEvent(FlyString event_name, bool persisted)
+ : DOM::Event(move(event_name))
+ , m_persisted(persisted)
+ {
+ }
+
+ bool m_persisted { false };
+};
+
+}
diff --git a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.idl b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.idl
new file mode 100644
index 0000000000..e569647c3a
--- /dev/null
+++ b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.idl
@@ -0,0 +1,5 @@
+interface PageTransitionEvent : Event {
+
+ readonly attribute boolean persisted;
+
+};
diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
index be45d48140..7a117bea5d 100644
--- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
@@ -246,14 +246,15 @@ void HTMLParser::the_end()
if (!document->browsing_context())
return;
- // FIXME: 3. Let window be the Document's relevant global object.
+ // 3. Let window be the Document's relevant global object.
+ NonnullRefPtr<DOM::Window> window = document->window();
// FIXME: 4. Set the Document's load timing info's load event start time to the current high resolution time given window.
// 5. Fire an event named load at window, with legacy target override flag set.
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
// We should reorganize this so that the flag appears explicitly here instead.
- document->window().dispatch_event(DOM::Event::create(HTML::EventNames::load));
+ window->dispatch_event(DOM::Event::create(HTML::EventNames::load));
// FIXME: 6. Invoke WebDriver BiDi load complete with the Document's browsing context, and a new WebDriver BiDi navigation status whose id is the Document object's navigation id, status is "complete", and url is the Document object's URL.
@@ -267,7 +268,8 @@ void HTMLParser::the_end()
// 10. Set the Document's page showing flag to true.
document->set_page_showing(true);
- // FIXME: 11. Fire a page transition event named pageshow at window with false.
+ // 11. Fire a page transition event named pageshow at window with false.
+ window->fire_a_page_transition_event(HTML::EventNames::pageshow, false);
// 12. Completely finish loading the Document.
document->completely_finish_loading();