1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 12:37:40 +00:00

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.
This commit is contained in:
Andrew Kaster 2023-08-28 18:03:45 +02:00 committed by Alexander Kalenik
parent 0ed67fc0ce
commit cf1f14f58c
2 changed files with 10 additions and 3 deletions

View file

@ -181,15 +181,19 @@ bool Navigation::can_go_forward() const
return (m_current_entry_index != static_cast<i64>(m_entry_list.size())); return (m_current_entry_index != static_cast<i64>(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) { switch (b) {
case Bindings::NavigationHistoryBehavior::Auto:
return HistoryHandlingBehavior::Default;
case Bindings::NavigationHistoryBehavior::Push: case Bindings::NavigationHistoryBehavior::Push:
return HistoryHandlingBehavior::Push; return HistoryHandlingBehavior::Push;
case Bindings::NavigationHistoryBehavior::Replace: case Bindings::NavigationHistoryBehavior::Replace:
return HistoryHandlingBehavior::Replace; return HistoryHandlingBehavior::Replace;
case Bindings::NavigationHistoryBehavior::Auto:
VERIFY_NOT_REACHED();
}; };
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
} }

View file

@ -9,6 +9,7 @@
#include <LibJS/Runtime/Promise.h> #include <LibJS/Runtime/Promise.h>
#include <LibWeb/Bindings/NavigationPrototype.h> #include <LibWeb/Bindings/NavigationPrototype.h>
#include <LibWeb/DOM/EventTarget.h> #include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/HTML/HistoryHandlingBehavior.h>
#include <LibWeb/HTML/StructuredSerialize.h> #include <LibWeb/HTML/StructuredSerialize.h>
namespace Web::HTML { namespace Web::HTML {
@ -152,4 +153,6 @@ private:
HashMap<String, JS::NonnullGCPtr<NavigationAPIMethodTracker>> m_upcoming_traverse_api_method_trackers; HashMap<String, JS::NonnullGCPtr<NavigationAPIMethodTracker>> m_upcoming_traverse_api_method_trackers;
}; };
HistoryHandlingBehavior to_history_handling_behavior(Bindings::NavigationHistoryBehavior);
} }