LibWeb: Add Navigable::set_ongoing_navigation()

This commit is contained in:
Aliaksandr Kalenik 2023-08-22 15:22:50 +02:00 committed by Andreas Kling
parent aa0d254fa3
commit 09013583f2
Notes: sideshowbarker 2024-07-16 20:08:14 +09:00
3 changed files with 17 additions and 3 deletions

View file

@ -260,6 +260,19 @@ JS::GCPtr<TraversableNavigable> Navigable::top_level_traversable()
return verify_cast<TraversableNavigable>(navigable);
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#set-the-ongoing-navigation
void Navigable::set_ongoing_navigation(Variant<Empty, Traversal, String> ongoing_navigation)
{
// 1. If navigable's ongoing navigation is equal to newValue, then return.
if (m_ongoing_navigation == ongoing_navigation)
return;
// FIXME: 2. Inform the navigation API about aborting navigation given navigable.
// 3. Set navigable's ongoing navigation to newValue.
m_ongoing_navigation = ongoing_navigation;
}
Navigable::ChosenNavigable Navigable::choose_a_navigable(StringView name, TokenizedFeature::NoOpener, ActivateTab)
{
// 1. Let chosen be null.
@ -919,7 +932,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(
}
// 17. Set navigable's ongoing navigation to navigationId.
m_ongoing_navigation = navigation_id;
set_ongoing_navigation(navigation_id);
// 18. If url's scheme is "javascript", then:
if (url.scheme() == "javascript"sv) {

View file

@ -105,6 +105,7 @@ public:
};
Variant<Empty, Traversal, String> ongoing_navigation() const { return m_ongoing_navigation; }
void set_ongoing_navigation(Variant<Empty, Traversal, String> ongoing_navigation);
WebIDL::ExceptionOr<void> populate_session_history_entry_document(JS::GCPtr<SessionHistoryEntry>, Optional<NavigationParams>, Optional<String> navigation_id, SourceSnapshotParams const&, bool allow_POST, Function<void()>);

View file

@ -256,7 +256,7 @@ void TraversableNavigable::apply_the_history_step(int step, Optional<SourceSnaps
navigable->set_current_session_history_entry(target_entry);
// 3. Set navigable's ongoing navigation to "traversal".
m_ongoing_navigation = Traversal::Tag;
set_ongoing_navigation(Traversal::Tag);
}
// 9. Let totalChangeJobs be the size of changingNavigables.
@ -390,7 +390,7 @@ void TraversableNavigable::apply_the_history_step(int step, Optional<SourceSnaps
auto navigable = changing_navigable_continuation.navigable;
// 7. Set navigable's ongoing navigation to null.
m_ongoing_navigation = {};
set_ongoing_navigation({});
// 8. Let (scriptHistoryLength, scriptHistoryIndex) be the result of getting the history object length and index given traversable and targetStep.
auto [script_history_length, script_history_index] = get_the_history_object_length_and_index(target_step);