AK+LibURL: Move AK::URL into a new URL library

This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
This commit is contained in:
Shannon Booth 2024-03-18 16:22:27 +13:00 committed by Tim Flynn
commit e800605ad3
Notes: sideshowbarker 2024-07-17 04:41:05 +09:00
403 changed files with 1336 additions and 1305 deletions

View file

@ -7,11 +7,11 @@
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/URLParser.h>
#include <LibJS/Heap/MarkedVector.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/PropertyDescriptor.h>
#include <LibJS/Runtime/PropertyKey.h>
#include <LibURL/Parser.h>
#include <LibWeb/Bindings/LocationPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/CrossOrigin/AbstractOperations.h>
@ -74,7 +74,7 @@ static Bindings::NavigationHistoryBehavior to_navigation_history_behavior(Histor
}
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#location-object-navigate
WebIDL::ExceptionOr<void> Location::navigate(URL url, HistoryHandlingBehavior history_handling)
WebIDL::ExceptionOr<void> Location::navigate(URL::URL url, HistoryHandlingBehavior history_handling)
{
// 1. Let navigable be location's relevant global object's navigable.
auto navigable = verify_cast<HTML::Window>(HTML::relevant_global_object(*this)).navigable();
@ -97,7 +97,7 @@ WebIDL::ExceptionOr<void> Location::navigate(URL url, HistoryHandlingBehavior hi
}
// https://html.spec.whatwg.org/multipage/history.html#concept-location-url
URL Location::url() const
URL::URL Location::url() const
{
// A Location object has an associated url, which is this Location object's relevant Document's URL,
// if this Location object's relevant Document is non-null, and about:blank otherwise.
@ -348,7 +348,7 @@ WebIDL::ExceptionOr<void> Location::set_hash(String const& value)
copy_url.set_fragment(String {});
// 6. Basic URL parse input, with copyURL as url and fragment state as state override.
auto result_url = URLParser::basic_parse(input, {}, copy_url, URLParser::State::Fragment);
auto result_url = URL::Parser::basic_parse(input, {}, copy_url, URL::Parser::State::Fragment);
// 7. If copyURL's fragment is this's url's fragment, then return.
if (copy_url.fragment() == this->url().fragment())