mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
LibWeb: Implement fire a push/replace/reload navigate event
This commit is contained in:
parent
5549371b52
commit
67bc3629a9
Notes:
sideshowbarker
2024-07-17 08:45:34 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/67bc3629a9 Pull-request: https://github.com/SerenityOS/serenity/pull/21199
@ -1252,4 +1252,46 @@ bool Navigation::fire_a_traverse_navigate_event(JS::NonnullGCPtr<SessionHistoryE
|
||||
return inner_navigate_event_firing_algorithm(Bindings::NavigationType::Traverse, destination, user_involvement, {}, {}, {});
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#fire-a-push/replace/reload-navigate-event
|
||||
bool Navigation::fire_a_push_replace_reload_navigate_event(
|
||||
Bindings::NavigationType navigation_type,
|
||||
AK::URL destination_url,
|
||||
bool is_same_document,
|
||||
UserNavigationInvolvement user_involvement,
|
||||
Optional<Vector<XHR::FormDataEntry>&> form_data_entry_list,
|
||||
Optional<SerializationRecord> navigation_api_state,
|
||||
Optional<SerializationRecord> classic_history_api_state)
|
||||
{
|
||||
auto& realm = relevant_realm(*this);
|
||||
auto& vm = this->vm();
|
||||
|
||||
// This fulfills the entry requirement: an optional serialized state navigationAPIState (default StructuredSerializeForStorage(null))
|
||||
if (!navigation_api_state.has_value())
|
||||
navigation_api_state = MUST(structured_serialize_for_storage(vm, JS::js_null()));
|
||||
|
||||
// 1. Let event be the result of creating an event given NavigateEvent, in navigation's relevant realm.
|
||||
// 2. Set event's classic history API state to classicHistoryAPIState.
|
||||
// AD-HOC: These are handled in the inner algorithm
|
||||
|
||||
// 3. Let destination be a new NavigationDestination created in navigation's relevant realm.
|
||||
auto destination = NavigationDestination::create(realm);
|
||||
|
||||
// 4. Set destination's URL to destinationURL.
|
||||
destination->set_url(destination_url);
|
||||
|
||||
// 5. Set destination's entry to null.
|
||||
destination->set_entry(nullptr);
|
||||
|
||||
// 6. Set destination's state to navigationAPIState.
|
||||
destination->set_state(*navigation_api_state);
|
||||
|
||||
// 7. Set destination's is same document to isSameDocument.
|
||||
destination->set_is_same_document(is_same_document);
|
||||
|
||||
// 8. Return the result of performing the inner navigate event firing algorithm given navigation,
|
||||
// navigationType, event, destination, userInvolvement, formDataEntryList, and null.
|
||||
// AD-HOC: We don't pass the event, but we do pass the classic_history_api state at the end to be set later
|
||||
return inner_navigate_event_firing_algorithm(navigation_type, destination, user_involvement, move(form_data_entry_list), {}, move(classic_history_api_state));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -110,6 +110,14 @@ public:
|
||||
i64 get_the_navigation_api_entry_index(SessionHistoryEntry const&) const;
|
||||
void abort_the_ongoing_navigation(Optional<JS::NonnullGCPtr<WebIDL::DOMException>> error = {});
|
||||
bool fire_a_traverse_navigate_event(JS::NonnullGCPtr<SessionHistoryEntry> destination_she, UserNavigationInvolvement = UserNavigationInvolvement::None);
|
||||
bool fire_a_push_replace_reload_navigate_event(
|
||||
Bindings::NavigationType,
|
||||
AK::URL destination_url,
|
||||
bool is_same_document,
|
||||
UserNavigationInvolvement = UserNavigationInvolvement::None,
|
||||
Optional<Vector<XHR::FormDataEntry>&> form_data_entry_list = {},
|
||||
Optional<SerializationRecord> navigation_api_state = {},
|
||||
Optional<SerializationRecord> classic_history_api_state = {});
|
||||
|
||||
virtual ~Navigation() override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user