From 6522fa8933e4697be40e75419ba9eaa707c6749d Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Thu, 14 Sep 2023 01:22:00 +0200 Subject: [PATCH] LibWeb: Use DocumentLoadEventDelayer to delay load event in Navigable Use a delayer object that actually delays load event for child navigables instead of boolean flag that does nothing. --- Userland/Libraries/LibWeb/HTML/Navigable.cpp | 11 +++++++++++ Userland/Libraries/LibWeb/HTML/Navigable.h | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp index ee18e1a9b6..69b1d54724 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp @@ -90,6 +90,17 @@ void Navigable::visit_edges(Cell::Visitor& visitor) visitor.visit(m_container); } +void Navigable::set_delaying_load_events(bool value) +{ + if (value) { + auto document = container_document(); + VERIFY(document); + m_delaying_the_load_event.emplace(*document); + } else { + m_delaying_the_load_event.clear(); + } +} + JS::GCPtr Navigable::navigable_with_active_document(JS::NonnullGCPtr document) { for (auto* navigable : all_navigables()) { diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.h b/Userland/Libraries/LibWeb/HTML/Navigable.h index 402646c10e..b5ccf02d59 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.h +++ b/Userland/Libraries/LibWeb/HTML/Navigable.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -56,8 +57,7 @@ public: bool is_closing() const { return m_closing; } void set_closing(bool value) { m_closing = value; } - bool is_delaying_load_events() const { return m_delaying_load_events; } - void set_delaying_load_events(bool value) { m_delaying_load_events = value; } + void set_delaying_load_events(bool value); JS::GCPtr active_session_history_entry() const { return m_active_session_history_entry; } void set_active_session_history_entry(JS::GCPtr entry) { m_active_session_history_entry = entry; } @@ -160,7 +160,7 @@ private: bool m_closing { false }; // https://html.spec.whatwg.org/multipage/document-sequences.html#delaying-load-events-mode - bool m_delaying_load_events { false }; + Optional m_delaying_the_load_event; // Implied link between navigable and its container. JS::GCPtr m_container;