소스 검색

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.
Andrew Kaster 1 년 전
부모
커밋
cf1f14f58c
2개의 변경된 파일10개의 추가작업 그리고 3개의 파일을 삭제
  1. 7 3
      Userland/Libraries/LibWeb/HTML/Navigation.cpp
  2. 3 0
      Userland/Libraries/LibWeb/HTML/Navigation.h

+ 7 - 3
Userland/Libraries/LibWeb/HTML/Navigation.cpp

@@ -181,15 +181,19 @@ bool Navigation::can_go_forward() const
     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) {
-    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();
 }

+ 3 - 0
Userland/Libraries/LibWeb/HTML/Navigation.h

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