From a5650211470a79560f19f3bf016eef7d024d4c5b Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 28 Aug 2023 17:41:09 +0200 Subject: [PATCH] LibWeb: De-duplicate definition of url_matches_about_blank We don't need two static methods for this. --- Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp | 2 +- Userland/Libraries/LibWeb/HTML/BrowsingContext.h | 4 ++++ Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp | 11 ----------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index b6584448ff..6615cf8d4c 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -37,7 +37,7 @@ namespace Web::HTML { // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#matches-about:blank -static bool url_matches_about_blank(AK::URL const& url) +bool url_matches_about_blank(AK::URL const& url) { // A URL matches about:blank if its scheme is "about", its path contains a single string "blank", its username and password are the empty string, and its host is null. return url.scheme() == "about"sv diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h index 12ba6c726c..8743a455c6 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -337,4 +338,7 @@ HTML::Origin determine_the_origin(BrowsingContext const& browsing_context, Optio HTML::Origin determine_the_origin(AK::URL const& url, SandboxingFlagSet sandbox_flags, Optional source_origin, Optional container_origin); +// FIXME: Find a better home for this +bool url_matches_about_blank(AK::URL const& url); + } diff --git a/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp index 6749182913..542b9550ad 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp +++ b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp @@ -211,17 +211,6 @@ HTML::WindowProxy* NavigableContainer::content_window() return m_nested_browsing_context->window_proxy(); } -// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#matches-about:blank -static bool url_matches_about_blank(AK::URL const& url) -{ - // A URL matches about:blank if its scheme is "about", its path contains a single string "blank", its username and password are the empty string, and its host is null. - return url.scheme() == "about"sv - && url.serialize_path() == "blank"sv - && url.raw_username().is_empty() - && url.raw_password().is_empty() - && url.host().has(); -} - // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#shared-attribute-processing-steps-for-iframe-and-frame-elements void NavigableContainer::shared_attribute_processing_steps_for_iframe_and_frame(bool initial_insertion) {