mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
LibWeb: Update History::go()
to use navigables
This commit is contained in:
parent
7dd01b245b
commit
1e54026269
1 changed files with 9 additions and 10 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/HTML/History.h>
|
#include <LibWeb/HTML/History.h>
|
||||||
#include <LibWeb/HTML/StructuredSerialize.h>
|
#include <LibWeb/HTML/StructuredSerialize.h>
|
||||||
|
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
|
@ -74,16 +75,14 @@ WebIDL::ExceptionOr<void> History::go(long delta = 0)
|
||||||
if (!m_associated_document->is_fully_active())
|
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);
|
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.
|
VERIFY(m_associated_document->navigable());
|
||||||
auto* browsing_context = m_associated_document->browsing_context();
|
|
||||||
auto current_entry_index = browsing_context->session_history_index();
|
// 3. If delta is 0, then reload document's node navigable.
|
||||||
auto next_entry_index = current_entry_index + delta;
|
m_associated_document->navigable()->reload();
|
||||||
auto const& sessions = browsing_context->session_history();
|
|
||||||
if (next_entry_index < sessions.size()) {
|
// 4. Traverse the history by a delta given document's node navigable's traversable navigable, delta, and with sourceDocument set to document.
|
||||||
auto const& next_entry = sessions.at(next_entry_index);
|
auto traversable = m_associated_document->navigable()->traversable_navigable();
|
||||||
// FIXME: 4. Traverse the history by a delta with delta and document's browsing context.
|
traversable->traverse_the_history_by_delta(delta);
|
||||||
browsing_context->loader().load(next_entry->url, FrameLoader::Type::Reload);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue