diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h index 1d0cce56ccb..694306f1a4d 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibWeb/HTML/HistoryHandlingBehavior.h b/Userland/Libraries/LibWeb/HTML/HistoryHandlingBehavior.h index 9d4fc3fdc0a..8b2de0a4f56 100644 --- a/Userland/Libraries/LibWeb/HTML/HistoryHandlingBehavior.h +++ b/Userland/Libraries/LibWeb/HTML/HistoryHandlingBehavior.h @@ -10,9 +10,6 @@ namespace Web::HTML { // https://html.spec.whatwg.org/multipage/browsing-the-web.html#history-handling-behavior enum class HistoryHandlingBehavior { - Default, // FIXME: This is no longer part of the spec. Remove. - EntryUpdate, // FIXME: This is no longer part of the spec. Remove. - Reload, // FIXME: This is no longer part of the spec. Remove. Push, Replace, }; diff --git a/Userland/Libraries/LibWeb/HTML/Location.cpp b/Userland/Libraries/LibWeb/HTML/Location.cpp index b0fb8ea22e0..0f258f46c1c 100644 --- a/Userland/Libraries/LibWeb/HTML/Location.cpp +++ b/Userland/Libraries/LibWeb/HTML/Location.cpp @@ -61,20 +61,8 @@ JS::GCPtr 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 Location::navigate(URL::URL url, HistoryHandlingBehavior history_handling) +WebIDL::ExceptionOr 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::relevant_global_object(*this)).navigable(); @@ -84,14 +72,14 @@ WebIDL::ExceptionOr 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(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 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 {}; } diff --git a/Userland/Libraries/LibWeb/HTML/Location.h b/Userland/Libraries/LibWeb/HTML/Location.h index 1b9ce40064a..a68f9b3c00d 100644 --- a/Userland/Libraries/LibWeb/HTML/Location.h +++ b/Userland/Libraries/LibWeb/HTML/Location.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include namespace Web::HTML { @@ -76,7 +76,7 @@ private: JS::GCPtr relevant_document() const; URL::URL url() const; - WebIDL::ExceptionOr navigate(URL::URL, HistoryHandlingBehavior = HistoryHandlingBehavior::Default); + WebIDL::ExceptionOr navigate(URL::URL, Bindings::NavigationHistoryBehavior = Bindings::NavigationHistoryBehavior::Auto); // [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap HTML::CrossOriginPropertyDescriptorMap m_cross_origin_property_descriptor_map; diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.h b/Userland/Libraries/LibWeb/HTML/Navigable.h index e3dbfcce156..f44762074a1 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.h +++ b/Userland/Libraries/LibWeb/HTML/Navigable.h @@ -231,7 +231,7 @@ HashTable& all_navigables(); bool navigation_must_be_a_replace(URL::URL const& url, DOM::Document const& document); void finalize_a_cross_document_navigation(JS::NonnullGCPtr, HistoryHandlingBehavior, JS::NonnullGCPtr); -void perform_url_and_history_update_steps(DOM::Document& document, URL::URL new_url, Optional = {}, HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Reload); +void perform_url_and_history_update_steps(DOM::Document& document, URL::URL new_url, Optional = {}, HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Replace); UserNavigationInvolvement user_navigation_involvement(DOM::Event const&); } diff --git a/Userland/Libraries/LibWeb/HTML/Navigation.cpp b/Userland/Libraries/LibWeb/HTML/Navigation.cpp index cc216cb507e..046a8205d12 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigation.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigation.cpp @@ -186,6 +186,7 @@ bool Navigation::can_go_forward() const return (m_current_entry_index != static_cast(m_entry_list.size())); } +// https://html.spec.whatwg.org/multipage/browsing-the-web.html#history-handling-behavior HistoryHandlingBehavior to_history_handling_behavior(Bindings::NavigationHistoryBehavior b) { // A history handling behavior is a NavigationHistoryBehavior that is either "push" or "replace", @@ -203,6 +204,21 @@ HistoryHandlingBehavior to_history_handling_behavior(Bindings::NavigationHistory VERIFY_NOT_REACHED(); } +// https://html.spec.whatwg.org/multipage/browsing-the-web.html#history-handling-behavior +Bindings::NavigationHistoryBehavior to_navigation_history_behavior(HistoryHandlingBehavior b) +{ + // A history handling behavior is a NavigationHistoryBehavior that is either "push" or "replace", + // i.e., that has been resolved away from any initial "auto" value. + + switch (b) { + case HistoryHandlingBehavior::Push: + return Bindings::NavigationHistoryBehavior::Push; + case HistoryHandlingBehavior::Replace: + return Bindings::NavigationHistoryBehavior::Replace; + } + VERIFY_NOT_REACHED(); +} + // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigation-navigate WebIDL::ExceptionOr Navigation::navigate(String url, NavigationNavigateOptions const& options) { diff --git a/Userland/Libraries/LibWeb/HTML/Navigation.h b/Userland/Libraries/LibWeb/HTML/Navigation.h index d352030402c..69ca7f169d6 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigation.h +++ b/Userland/Libraries/LibWeb/HTML/Navigation.h @@ -190,5 +190,6 @@ private: }; HistoryHandlingBehavior to_history_handling_behavior(Bindings::NavigationHistoryBehavior); +Bindings::NavigationHistoryBehavior to_navigation_history_behavior(HistoryHandlingBehavior); } diff --git a/Userland/Libraries/LibWeb/HTML/NavigationParams.h b/Userland/Libraries/LibWeb/HTML/NavigationParams.h index b9d8b949911..0e27c9fc64e 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigationParams.h +++ b/Userland/Libraries/LibWeb/HTML/NavigationParams.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include