From 1e54026269cc189b7e4ddea1b8138dfe3a700d11 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Thu, 24 Aug 2023 23:30:21 +0200 Subject: [PATCH] LibWeb: Update `History::go()` to use navigables --- Userland/Libraries/LibWeb/HTML/History.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/History.cpp b/Userland/Libraries/LibWeb/HTML/History.cpp index 8ebc1a97ce..5d8d420120 100644 --- a/Userland/Libraries/LibWeb/HTML/History.cpp +++ b/Userland/Libraries/LibWeb/HTML/History.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace Web::HTML { @@ -74,16 +75,14 @@ WebIDL::ExceptionOr History::go(long delta = 0) if (!m_associated_document->is_fully_active()) return WebIDL::SecurityError::create(realm(), "Cannot perform go on a document that isn't fully active."_fly_string); - // 3. If delta is 0, then act as if the location.reload() method was called, and return. - auto* browsing_context = m_associated_document->browsing_context(); - auto current_entry_index = browsing_context->session_history_index(); - auto next_entry_index = current_entry_index + delta; - auto const& sessions = browsing_context->session_history(); - if (next_entry_index < sessions.size()) { - auto const& next_entry = sessions.at(next_entry_index); - // FIXME: 4. Traverse the history by a delta with delta and document's browsing context. - browsing_context->loader().load(next_entry->url, FrameLoader::Type::Reload); - } + VERIFY(m_associated_document->navigable()); + + // 3. If delta is 0, then reload document's node navigable. + m_associated_document->navigable()->reload(); + + // 4. Traverse the history by a delta given document's node navigable's traversable navigable, delta, and with sourceDocument set to document. + auto traversable = m_associated_document->navigable()->traversable_navigable(); + traversable->traverse_the_history_by_delta(delta); return {}; }