mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-05 18:52:56 +00:00
LibWeb: Bring HistoryHandlingBehavior up to date with the specification
Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
This commit is contained in:
parent
b6cf62d00a
commit
39f74d3437
Notes:
sideshowbarker
2024-07-17 08:59:18 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 39f74d3437
Pull-request: https://github.com/SerenityOS/serenity/pull/23751
8 changed files with 24 additions and 24 deletions
|
@ -61,20 +61,8 @@ JS::GCPtr<DOM::Document> Location::relevant_document() const
|
|||
return browsing_context ? browsing_context->active_document() : nullptr;
|
||||
}
|
||||
|
||||
static Bindings::NavigationHistoryBehavior to_navigation_history_behavior(HistoryHandlingBehavior b)
|
||||
{
|
||||
switch (b) {
|
||||
case HistoryHandlingBehavior::Push:
|
||||
return Bindings::NavigationHistoryBehavior::Push;
|
||||
case HistoryHandlingBehavior::Replace:
|
||||
return Bindings::NavigationHistoryBehavior::Replace;
|
||||
default:
|
||||
return Bindings::NavigationHistoryBehavior::Auto;
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#location-object-navigate
|
||||
WebIDL::ExceptionOr<void> Location::navigate(URL::URL url, HistoryHandlingBehavior history_handling)
|
||||
WebIDL::ExceptionOr<void> Location::navigate(URL::URL url, Bindings::NavigationHistoryBehavior history_handling)
|
||||
{
|
||||
// 1. Let navigable be location's relevant global object's navigable.
|
||||
auto navigable = verify_cast<HTML::Window>(HTML::relevant_global_object(*this)).navigable();
|
||||
|
@ -84,14 +72,14 @@ WebIDL::ExceptionOr<void> Location::navigate(URL::URL url, HistoryHandlingBehavi
|
|||
|
||||
// 3. If location's relevant Document is not yet completely loaded, and the incumbent global object does not have transient activation, then set historyHandling to "replace".
|
||||
if (!relevant_document()->is_completely_loaded() && !verify_cast<HTML::Window>(incumbent_global_object()).has_transient_activation()) {
|
||||
history_handling = HistoryHandlingBehavior::Replace;
|
||||
history_handling = Bindings::NavigationHistoryBehavior::Replace;
|
||||
}
|
||||
|
||||
// 4. Navigate navigable to url using sourceDocument, with exceptionsEnabled set to true and historyHandling set to historyHandling.
|
||||
TRY(navigable->navigate({ .url = url,
|
||||
.source_document = source_document,
|
||||
.exceptions_enabled = true,
|
||||
.history_handling = to_navigation_history_behavior(history_handling) }));
|
||||
.history_handling = history_handling }));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -389,7 +377,7 @@ WebIDL::ExceptionOr<void> Location::replace(String const& url)
|
|||
return WebIDL::SyntaxError::create(realm(), MUST(String::formatted("Invalid URL '{}'", url)));
|
||||
|
||||
// 3. Location-object navigate this to the resulting URL record given "replace".
|
||||
TRY(navigate(replace_url, HistoryHandlingBehavior::Replace));
|
||||
TRY(navigate(replace_url, Bindings::NavigationHistoryBehavior::Replace));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue