From cf1f14f58cfda59d9a4ac11c9f373f4ccf458356 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 28 Aug 2023 18:03:45 +0200 Subject: [PATCH] LibWeb: Make to_history_handling_behavior conversion helper public While we're here, assert that we're not doing this conversion when the NavigationHistoryBehavior is still "auto", as the HistoryHandlingBehavior enum is supposed to represent a "resolved" behavior. --- Userland/Libraries/LibWeb/HTML/Navigation.cpp | 10 +++++++--- Userland/Libraries/LibWeb/HTML/Navigation.h | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/Navigation.cpp b/Userland/Libraries/LibWeb/HTML/Navigation.cpp index 4c07411e99..260bc2ed0e 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigation.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigation.cpp @@ -181,15 +181,19 @@ bool Navigation::can_go_forward() const return (m_current_entry_index != static_cast(m_entry_list.size())); } -static HistoryHandlingBehavior to_history_handling_behavior(Bindings::NavigationHistoryBehavior b) +HistoryHandlingBehavior to_history_handling_behavior(Bindings::NavigationHistoryBehavior 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. + VERIFY(b != Bindings::NavigationHistoryBehavior::Auto); + switch (b) { - case Bindings::NavigationHistoryBehavior::Auto: - return HistoryHandlingBehavior::Default; case Bindings::NavigationHistoryBehavior::Push: return HistoryHandlingBehavior::Push; case Bindings::NavigationHistoryBehavior::Replace: return HistoryHandlingBehavior::Replace; + case Bindings::NavigationHistoryBehavior::Auto: + VERIFY_NOT_REACHED(); }; VERIFY_NOT_REACHED(); } diff --git a/Userland/Libraries/LibWeb/HTML/Navigation.h b/Userland/Libraries/LibWeb/HTML/Navigation.h index 57a90f49d0..eef25af99f 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigation.h +++ b/Userland/Libraries/LibWeb/HTML/Navigation.h @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace Web::HTML { @@ -152,4 +153,6 @@ private: HashMap> m_upcoming_traverse_api_method_trackers; }; +HistoryHandlingBehavior to_history_handling_behavior(Bindings::NavigationHistoryBehavior); + }