Forráskód Böngészése

LibWeb: Add AO for navigation_must_be_a_replace to Navigable

This is used by both Navigable and Navigation, so let's put it in
Navigable. Also add a missing AK/String include to make clangd happier
with the Navigable file.
Andrew Kaster 1 éve
szülő
commit
34ea470d4f

+ 6 - 0
Userland/Libraries/LibWeb/HTML/Navigable.cpp

@@ -1113,4 +1113,10 @@ void Navigable::reload()
     });
 }
 
+// https://html.spec.whatwg.org/multipage/browsing-the-web.html#the-navigation-must-be-a-replace
+bool navigation_must_be_a_replace(AK::URL const& url, DOM::Document const& document)
+{
+    return url.scheme() == "javascript"sv || document.is_initial_about_blank();
+}
+
 }

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

@@ -7,6 +7,7 @@
 
 #pragma once
 
+#include <AK/String.h>
 #include <LibJS/Heap/Cell.h>
 #include <LibWeb/Forward.h>
 #include <LibWeb/HTML/ActivateTab.h>
@@ -135,4 +136,6 @@ private:
     JS::GCPtr<NavigableContainer> m_container;
 };
 
+bool navigation_must_be_a_replace(AK::URL const& url, DOM::Document const& document);
+
 }