diff --git a/AK/CMakeLists.txt b/AK/CMakeLists.txt index 235a5498332ac671ca9193c8ee5ea27c1b6ee00d..e7fb9e485e16ca768e331418acb5199f6f801fc1 100644 --- a/AK/CMakeLists.txt +++ b/AK/CMakeLists.txt @@ -35,8 +35,6 @@ set(AK_SOURCES StringUtils.cpp StringView.cpp Time.cpp - URL.cpp - URLParser.cpp UUID.cpp Utf16View.cpp Utf32View.cpp diff --git a/AK/Forward.h b/AK/Forward.h index 997ae19549d62538e719f4f9a062f091c598f37c..afc4e18dbdb5d9cec74f5866909a73941343d087 100644 --- a/AK/Forward.h +++ b/AK/Forward.h @@ -49,7 +49,6 @@ class String; class StringBuilder; class StringImpl; class StringView; -class URL; class UnixDateTime; class Utf16View; class Utf32CodePointIterator; @@ -204,7 +203,6 @@ using AK::StringView; using AK::TrailingCodePointTransformation; using AK::Traits; using AK::UnixDateTime; -using AK::URL; using AK::Utf16View; using AK::Utf32CodePointIterator; using AK::Utf32View; diff --git a/Ladybird/AppKit/Application/ApplicationDelegate.h b/Ladybird/AppKit/Application/ApplicationDelegate.h index b9fcc48dd6aee388d3e81dc8ee1c2d9c374b9e56..e76a3a05b4324a225137e8d7b1ccdf448c537ba3 100644 --- a/Ladybird/AppKit/Application/ApplicationDelegate.h +++ b/Ladybird/AppKit/Application/ApplicationDelegate.h @@ -8,9 +8,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -22,18 +22,18 @@ @interface ApplicationDelegate : NSObject -- (nullable instancetype)init:(Vector)initial_urls - newTabPageURL:(URL)new_tab_page_url +- (nullable instancetype)init:(Vector)initial_urls + newTabPageURL:(URL::URL)new_tab_page_url withCookieJar:(WebView::CookieJar)cookie_jar webContentOptions:(Ladybird::WebContentOptions const&)web_content_options webdriverContentIPCPath:(StringView)webdriver_content_ipc_path; -- (nonnull TabController*)createNewTab:(Optional const&)url +- (nonnull TabController*)createNewTab:(Optional const&)url fromTab:(nullable Tab*)tab activateTab:(Web::HTML::ActivateTab)activate_tab; - (nonnull TabController*)createNewTab:(StringView)html - url:(URL const&)url + url:(URL::URL const&)url fromTab:(nullable Tab*)tab activateTab:(Web::HTML::ActivateTab)activate_tab; diff --git a/Ladybird/AppKit/Application/ApplicationDelegate.mm b/Ladybird/AppKit/Application/ApplicationDelegate.mm index d109cfe3f6a993a7d27e2ab5c223e208cbf7bf5b..046b07c4c671e47570e3fd99a70cbed3966562c8 100644 --- a/Ladybird/AppKit/Application/ApplicationDelegate.mm +++ b/Ladybird/AppKit/Application/ApplicationDelegate.mm @@ -19,8 +19,8 @@ @interface ApplicationDelegate () { - Vector m_initial_urls; - URL m_new_tab_page_url; + Vector m_initial_urls; + URL::URL m_new_tab_page_url; // This will always be populated, but we cannot have a non-default constructible instance variable. Optional m_cookie_jar; @@ -50,8 +50,8 @@ @implementation ApplicationDelegate -- (instancetype)init:(Vector)initial_urls - newTabPageURL:(URL)new_tab_page_url +- (instancetype)init:(Vector)initial_urls + newTabPageURL:(URL::URL)new_tab_page_url withCookieJar:(WebView::CookieJar)cookie_jar webContentOptions:(Ladybird::WebContentOptions const&)web_content_options webdriverContentIPCPath:(StringView)webdriver_content_ipc_path @@ -95,7 +95,7 @@ #pragma mark - Public methods -- (TabController*)createNewTab:(Optional const&)url +- (TabController*)createNewTab:(Optional const&)url fromTab:(Tab*)tab activateTab:(Web::HTML::ActivateTab)activate_tab { @@ -106,7 +106,7 @@ } - (nonnull TabController*)createNewTab:(StringView)html - url:(URL const&)url + url:(URL::URL const&)url fromTab:(nullable Tab*)tab activateTab:(Web::HTML::ActivateTab)activate_tab { @@ -155,7 +155,7 @@ return; } - [self createNewTab:URL("about:version"sv) + [self createNewTab:URL::URL("about:version"sv) fromTab:(Tab*)current_tab activateTab:Web::HTML::ActivateTab::Yes]; } diff --git a/Ladybird/AppKit/UI/LadybirdWebView.h b/Ladybird/AppKit/UI/LadybirdWebView.h index 67150c7d8c0c68329667034da637af4938e3fcce..ccfeef84ca7f1b20bc5b7dd42b16842c75146274 100644 --- a/Ladybird/AppKit/UI/LadybirdWebView.h +++ b/Ladybird/AppKit/UI/LadybirdWebView.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -16,16 +17,16 @@ @protocol LadybirdWebViewObserver -- (String const&)onCreateNewTab:(URL const&)url +- (String const&)onCreateNewTab:(URL::URL const&)url activateTab:(Web::HTML::ActivateTab)activate_tab; - (String const&)onCreateNewTab:(StringView)html - url:(URL const&)url + url:(URL::URL const&)url activateTab:(Web::HTML::ActivateTab)activate_tab; -- (void)loadURL:(URL const&)url; -- (void)onLoadStart:(URL const&)url isRedirect:(BOOL)is_redirect; -- (void)onLoadFinish:(URL const&)url; +- (void)loadURL:(URL::URL const&)url; +- (void)onLoadStart:(URL::URL const&)url isRedirect:(BOOL)is_redirect; +- (void)onLoadFinish:(URL::URL const&)url; - (void)onTitleChange:(ByteString const&)title; - (void)onFaviconChange:(Gfx::Bitmap const&)bitmap; @@ -40,7 +41,7 @@ - (instancetype)init:(id)observer; -- (void)loadURL:(URL const&)url; +- (void)loadURL:(URL::URL const&)url; - (void)loadHTML:(StringView)html; - (WebView::ViewImplementation&)view; diff --git a/Ladybird/AppKit/UI/LadybirdWebView.mm b/Ladybird/AppKit/UI/LadybirdWebView.mm index e55f08b9c3e55a9bbe97e5662e3610c5880965bd..3eadce27fc833059531047cee8d5b3648b904fd9 100644 --- a/Ladybird/AppKit/UI/LadybirdWebView.mm +++ b/Ladybird/AppKit/UI/LadybirdWebView.mm @@ -6,9 +6,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -51,7 +51,7 @@ struct HideCursor { { OwnPtr m_web_view_bridge; - URL m_context_menu_url; + URL::URL m_context_menu_url; Gfx::ShareableBitmap m_context_menu_bitmap; Optional m_context_menu_search_text; @@ -118,7 +118,7 @@ struct HideCursor { #pragma mark - Public methods -- (void)loadURL:(URL const&)url +- (void)loadURL:(URL::URL const&)url { m_web_view_bridge->load(url); } diff --git a/Ladybird/AppKit/UI/Tab.mm b/Ladybird/AppKit/UI/Tab.mm index 0d8a2263a4547ae3dc522788396c7de336a2c673..108e1acc6ab44cc2c05c7ae77e641b1809e23c6e 100644 --- a/Ladybird/AppKit/UI/Tab.mm +++ b/Ladybird/AppKit/UI/Tab.mm @@ -6,11 +6,11 @@ #include #include -#include #include #include #include #include +#include #import #import @@ -34,7 +34,7 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800; @property (nonatomic, strong) InspectorController* inspector_controller; -@property (nonatomic, assign) URL last_url; +@property (nonatomic, assign) URL::URL last_url; @end @@ -188,7 +188,7 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800; #pragma mark - LadybirdWebViewObserver -- (String const&)onCreateNewTab:(URL const&)url +- (String const&)onCreateNewTab:(URL::URL const&)url activateTab:(Web::HTML::ActivateTab)activate_tab { auto* delegate = (ApplicationDelegate*)[NSApp delegate]; @@ -202,7 +202,7 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800; } - (String const&)onCreateNewTab:(StringView)html - url:(URL const&)url + url:(URL::URL const&)url activateTab:(Web::HTML::ActivateTab)activate_tab { auto* delegate = (ApplicationDelegate*)[NSApp delegate]; @@ -216,12 +216,12 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800; return [[tab web_view] handle]; } -- (void)loadURL:(URL const&)url +- (void)loadURL:(URL::URL const&)url { [[self tabController] loadURL:url]; } -- (void)onLoadStart:(URL const&)url isRedirect:(BOOL)is_redirect +- (void)onLoadStart:(URL::URL const&)url isRedirect:(BOOL)is_redirect { if (url != self.last_url) { self.last_url = url; @@ -239,7 +239,7 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800; } } -- (void)onLoadFinish:(URL const&)url +- (void)onLoadFinish:(URL::URL const&)url { if (self.inspector_controller != nil) { auto* inspector = (Inspector*)[self.inspector_controller window]; diff --git a/Ladybird/AppKit/UI/TabController.h b/Ladybird/AppKit/UI/TabController.h index f18fb187913e1151e97eac1d241585a63e17c2d3..8194da3be20ec9875b4a9ff427de4f0a3bdda205 100644 --- a/Ladybird/AppKit/UI/TabController.h +++ b/Ladybird/AppKit/UI/TabController.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #import @@ -23,10 +23,10 @@ struct TabSettings { - (instancetype)init; -- (void)loadURL:(URL const&)url; -- (void)loadHTML:(StringView)html url:(URL const&)url; +- (void)loadURL:(URL::URL const&)url; +- (void)loadHTML:(StringView)html url:(URL::URL const&)url; -- (void)onLoadStart:(URL const&)url isRedirect:(BOOL)isRedirect; +- (void)onLoadStart:(URL::URL const&)url isRedirect:(BOOL)isRedirect; - (void)onTitleChange:(ByteString const&)title; - (void)navigateBack:(id)sender; diff --git a/Ladybird/AppKit/UI/TabController.mm b/Ladybird/AppKit/UI/TabController.mm index ba8afb9e73868fde928f2a4fc21ea1932f898d8e..7886e316b237560ab638022f235040156d1d6381 100644 --- a/Ladybird/AppKit/UI/TabController.mm +++ b/Ladybird/AppKit/UI/TabController.mm @@ -106,17 +106,17 @@ enum class IsHistoryNavigation { #pragma mark - Public methods -- (void)loadURL:(URL const&)url +- (void)loadURL:(URL::URL const&)url { [[self tab].web_view loadURL:url]; } -- (void)loadHTML:(StringView)html url:(URL const&)url +- (void)loadHTML:(StringView)html url:(URL::URL const&)url { [[self tab].web_view loadHTML:html]; } -- (void)onLoadStart:(URL const&)url isRedirect:(BOOL)isRedirect +- (void)onLoadStart:(URL::URL const&)url isRedirect:(BOOL)isRedirect { if (isRedirect) { m_history.replace_current(url, m_title); diff --git a/Ladybird/AppKit/main.mm b/Ladybird/AppKit/main.mm index f8ee59699037f4d09c7bfd6d84881b5a95d38d82..0034f56aa5e44872594a43f1340a8c262caa4807 100644 --- a/Ladybird/AppKit/main.mm +++ b/Ladybird/AppKit/main.mm @@ -59,8 +59,8 @@ ErrorOr serenity_main(Main::Arguments arguments) auto database = TRY(WebView::Database::create(move(sql_server_paths))); auto cookie_jar = TRY(WebView::CookieJar::create(*database)); - URL new_tab_page_url = Browser::default_new_tab_url; - Vector initial_urls; + URL::URL new_tab_page_url = Browser::default_new_tab_url; + Vector initial_urls; for (auto const& raw_url : raw_urls) { if (auto url = WebView::sanitize_url(raw_url); url.has_value()) diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt index 172799216a42a76dc02eb62396741ea100652243..0f6f978a330a6fc723634bcc3eb59c258a56e1c7 100644 --- a/Ladybird/CMakeLists.txt +++ b/Ladybird/CMakeLists.txt @@ -175,7 +175,7 @@ target_sources(ladybird PUBLIC FILE_SET ladybird TYPE HEADERS BASE_DIRS ${SERENITY_SOURCE_DIR} FILES ${LADYBIRD_HEADERS} ) -target_link_libraries(ladybird PRIVATE AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebView LibProtocol) +target_link_libraries(ladybird PRIVATE AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebView LibProtocol LibURL) target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/) @@ -204,7 +204,7 @@ add_executable(headless-browser target_include_directories(headless-browser PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(headless-browser PRIVATE ${SERENITY_SOURCE_DIR}/Userland/) -target_link_libraries(headless-browser PRIVATE AK LibCore LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibGemini LibHTTP LibImageDecoderClient LibJS LibGfx LibMain LibTLS LibIPC LibDiff LibProtocol) +target_link_libraries(headless-browser PRIVATE AK LibCore LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibGemini LibHTTP LibImageDecoderClient LibJS LibGfx LibMain LibTLS LibIPC LibDiff LibProtocol LibURL) if (ANDROID) include(cmake/AndroidExtras.cmake) diff --git a/Ladybird/Qt/AutoComplete.cpp b/Ladybird/Qt/AutoComplete.cpp index ae35e4acf57cd8a024ace07eff70fe65cc45d64c..480d32a726e5060bff38e7350ee2e94b43f0e6c9 100644 --- a/Ladybird/Qt/AutoComplete.cpp +++ b/Ladybird/Qt/AutoComplete.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace Ladybird { diff --git a/Ladybird/Qt/BrowserWindow.cpp b/Ladybird/Qt/BrowserWindow.cpp index fcd5601fc6c1aeff723dbb602af685576714c522..7c8c04c3c6f9c1ca30c2bd28c18c99249a9d1ed5 100644 --- a/Ladybird/Qt/BrowserWindow.cpp +++ b/Ladybird/Qt/BrowserWindow.cpp @@ -42,7 +42,7 @@ static QIcon const& app_icon() return icon; } -BrowserWindow::BrowserWindow(Vector const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path) +BrowserWindow::BrowserWindow(Vector const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path) : m_cookie_jar(cookie_jar) , m_web_content_options(web_content_options) , m_webdriver_content_ipc_path(webdriver_content_ipc_path) @@ -471,7 +471,7 @@ void BrowserWindow::debug_request(ByteString const& request, ByteString const& a m_current_tab->debug_request(request, argument); } -Tab& BrowserWindow::new_tab_from_url(URL const& url, Web::HTML::ActivateTab activate_tab) +Tab& BrowserWindow::new_tab_from_url(URL::URL const& url, Web::HTML::ActivateTab activate_tab) { auto& tab = create_new_tab(activate_tab); tab.navigate(url); diff --git a/Ladybird/Qt/BrowserWindow.h b/Ladybird/Qt/BrowserWindow.h index d5508c9467936844b662cae36a68da016d448b69..bf2d83831e72880dd115ba8a0e10c1f642461f0e 100644 --- a/Ladybird/Qt/BrowserWindow.h +++ b/Ladybird/Qt/BrowserWindow.h @@ -28,7 +28,7 @@ class BrowserWindow : public QMainWindow { Q_OBJECT public: - BrowserWindow(Vector const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path); + BrowserWindow(Vector const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path); WebContentView& view() const { return m_current_tab->view(); } @@ -73,7 +73,7 @@ public slots: void device_pixel_ratio_changed(qreal dpi); void tab_title_changed(int index, QString const&); void tab_favicon_changed(int index, QIcon const& icon); - Tab& new_tab_from_url(URL const&, Web::HTML::ActivateTab); + Tab& new_tab_from_url(URL::URL const&, Web::HTML::ActivateTab); Tab& new_tab_from_content(StringView html, Web::HTML::ActivateTab); Tab& new_child_tab(Web::HTML::ActivateTab, Tab& parent, Web::HTML::WebViewHints, Optional page_index); void activate_tab(int index); diff --git a/Ladybird/Qt/LocationEdit.cpp b/Ladybird/Qt/LocationEdit.cpp index fac2ba5fadeaa33ef6543e71356e42a1563993fd..2fe4c09f112d421359e90fc5be119f9ccf7644a3 100644 --- a/Ladybird/Qt/LocationEdit.cpp +++ b/Ladybird/Qt/LocationEdit.cpp @@ -7,7 +7,7 @@ #include "LocationEdit.h" #include "Settings.h" #include "StringUtils.h" -#include +#include #include #include #include diff --git a/Ladybird/Qt/RequestManagerQt.cpp b/Ladybird/Qt/RequestManagerQt.cpp index 83810ee4b9b1b62660698db93e4f8b405293b499..e91552929734e67b340a3127174fd38694618396 100644 --- a/Ladybird/Qt/RequestManagerQt.cpp +++ b/Ladybird/Qt/RequestManagerQt.cpp @@ -26,7 +26,7 @@ void RequestManagerQt::reply_finished(QNetworkReply* reply) request->did_finish(); } -RefPtr RequestManagerQt::start_request(ByteString const& method, URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy) +RefPtr RequestManagerQt::start_request(ByteString const& method, URL::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy) { if (!url.scheme().bytes_as_string_view().is_one_of_ignoring_ascii_case("http"sv, "https"sv)) { return nullptr; @@ -40,7 +40,7 @@ RefPtr RequestManagerQt::start_request(Byte return request; } -ErrorOr> RequestManagerQt::Request::create(QNetworkAccessManager& qnam, ByteString const& method, URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) +ErrorOr> RequestManagerQt::Request::create(QNetworkAccessManager& qnam, ByteString const& method, URL::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) { QNetworkRequest request { QString(url.to_byte_string().characters()) }; request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::ManualRedirectPolicy); @@ -78,7 +78,7 @@ ErrorOr> RequestManagerQt::Request::cre return adopt_ref(*new Request(*reply)); } -RefPtr RequestManagerQt::websocket_connect(AK::URL const& url, AK::ByteString const& origin, Vector const& protocols) +RefPtr RequestManagerQt::websocket_connect(URL::URL const& url, AK::ByteString const& origin, Vector const& protocols) { WebSocket::ConnectionInfo connection_info(url); connection_info.set_origin(origin); diff --git a/Ladybird/Qt/RequestManagerQt.h b/Ladybird/Qt/RequestManagerQt.h index 61087de8918c130c68c1c3d222d8626e57aad022..1e090b263939be22bfcc4da9bd66af9b49016737 100644 --- a/Ladybird/Qt/RequestManagerQt.h +++ b/Ladybird/Qt/RequestManagerQt.h @@ -24,11 +24,11 @@ public: virtual ~RequestManagerQt() override { } - virtual void prefetch_dns(URL const&) override { } - virtual void preconnect(URL const&) override { } + virtual void prefetch_dns(URL::URL const&) override { } + virtual void preconnect(URL::URL const&) override { } - virtual RefPtr start_request(ByteString const& method, URL const&, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) override; - virtual RefPtr websocket_connect(const URL&, ByteString const& origin, Vector const& protocols) override; + virtual RefPtr start_request(ByteString const& method, URL::URL const&, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) override; + virtual RefPtr websocket_connect(const URL::URL&, ByteString const& origin, Vector const& protocols) override; private slots: void reply_finished(QNetworkReply*); @@ -39,7 +39,7 @@ private: class Request : public Web::ResourceLoaderConnectorRequest { public: - static ErrorOr> create(QNetworkAccessManager& qnam, ByteString const& method, URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); + static ErrorOr> create(QNetworkAccessManager& qnam, ByteString const& method, URL::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); virtual ~Request() override; diff --git a/Ladybird/Qt/SettingsDialog.cpp b/Ladybird/Qt/SettingsDialog.cpp index 11e6127360531a081248dcbc94b87d6f70cd0a89..342836df7bd1a4cd4aa3f84c0a90941ecb8926b8 100644 --- a/Ladybird/Qt/SettingsDialog.cpp +++ b/Ladybird/Qt/SettingsDialog.cpp @@ -8,7 +8,7 @@ #include "SettingsDialog.h" #include "Settings.h" #include "StringUtils.h" -#include +#include #include #include #include @@ -39,11 +39,11 @@ SettingsDialog::SettingsDialog(QMainWindow* window) m_new_tab_page->setText(Settings::the()->new_tab_page()); QObject::connect(m_new_tab_page, &QLineEdit::textChanged, this, [this] { auto url_string = ak_string_from_qstring(m_new_tab_page->text()); - m_new_tab_page->setStyleSheet(URL(url_string).is_valid() ? "" : "border: 1px solid red;"); + m_new_tab_page->setStyleSheet(URL::URL(url_string).is_valid() ? "" : "border: 1px solid red;"); }); QObject::connect(m_new_tab_page, &QLineEdit::editingFinished, this, [this] { auto url_string = ak_string_from_qstring(m_new_tab_page->text()); - if (URL(url_string).is_valid()) + if (URL::URL(url_string).is_valid()) Settings::the()->set_new_tab_page(m_new_tab_page->text()); }); QObject::connect(m_new_tab_page, &QLineEdit::returnPressed, this, [this] { diff --git a/Ladybird/Qt/StringUtils.cpp b/Ladybird/Qt/StringUtils.cpp index 09cd5cbdee72829c8564a2e239c4660301a243b8..1f7e7dbdfe5784bf3ed5d64c61c0a035397efee7 100644 --- a/Ladybird/Qt/StringUtils.cpp +++ b/Ladybird/Qt/StringUtils.cpp @@ -23,13 +23,13 @@ QString qstring_from_ak_string(StringView ak_string) return QString::fromUtf8(ak_string.characters_without_null_termination(), static_cast(ak_string.length())); } -URL ak_url_from_qstring(QString const& qstring) +URL::URL ak_url_from_qstring(QString const& qstring) { auto utf8_data = qstring.toUtf8(); - return URL(StringView(utf8_data.data(), utf8_data.size())); + return URL::URL(StringView(utf8_data.data(), utf8_data.size())); } -URL ak_url_from_qurl(QUrl const& qurl) +URL::URL ak_url_from_qurl(QUrl const& qurl) { return ak_url_from_qstring(qurl.toString()); } diff --git a/Ladybird/Qt/StringUtils.h b/Ladybird/Qt/StringUtils.h index 70a1040e923be4290cbf3ccbaa4e04b054907d16..93d492893c2749ed728ca9d073b1fe0f530abfcb 100644 --- a/Ladybird/Qt/StringUtils.h +++ b/Ladybird/Qt/StringUtils.h @@ -10,12 +10,12 @@ #include #include #include -#include +#include #include #include AK::ByteString ak_byte_string_from_qstring(QString const&); String ak_string_from_qstring(QString const&); QString qstring_from_ak_string(StringView); -URL ak_url_from_qstring(QString const&); -URL ak_url_from_qurl(QUrl const&); +URL::URL ak_url_from_qstring(QString const&); +URL::URL ak_url_from_qurl(QUrl const&); diff --git a/Ladybird/Qt/Tab.cpp b/Ladybird/Qt/Tab.cpp index 28dca89f8ebec3523af2b6dd37d59f5d11cde3df..b67a4fc74654e4d2b0722bf6557780319696e55a 100644 --- a/Ladybird/Qt/Tab.cpp +++ b/Ladybird/Qt/Tab.cpp @@ -121,7 +121,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St m_hover_label->hide(); }; - view().on_load_start = [this](const URL& url, bool is_redirect) { + view().on_load_start = [this](const URL::URL& url, bool is_redirect) { // If we are loading due to a redirect, we replace the current history entry // with the loaded URL if (is_redirect) { @@ -384,7 +384,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St search_selected_text_action->setIcon(load_icon_from_uri("resource://icons/16x16/find.png"sv)); QObject::connect(search_selected_text_action, &QAction::triggered, this, [this]() { auto url = MUST(String::formatted(Settings::the()->search_engine().query_url, URL::percent_encode(*m_page_context_menu_search_text))); - m_window->new_tab_from_url(URL(url), Web::HTML::ActivateTab::Yes); + m_window->new_tab_from_url(URL::URL(url), Web::HTML::ActivateTab::Yes); }); auto take_screenshot = [this](auto type) { @@ -733,7 +733,7 @@ void Tab::focus_location_editor() m_location_edit->selectAll(); } -void Tab::navigate(URL const& url) +void Tab::navigate(URL::URL const& url) { view().load(url); } @@ -772,17 +772,17 @@ void Tab::reload() view().load(m_history.current().url.to_byte_string()); } -void Tab::open_link(URL const& url) +void Tab::open_link(URL::URL const& url) { view().on_link_click(url, "", 0); } -void Tab::open_link_in_new_tab(URL const& url) +void Tab::open_link_in_new_tab(URL::URL const& url) { view().on_link_click(url, "_blank", 0); } -void Tab::copy_link_url(URL const& url) +void Tab::copy_link_url(URL::URL const& url) { auto* clipboard = QGuiApplication::clipboard(); clipboard->setText(qstring_from_ak_string(WebView::url_text_to_copy(url))); diff --git a/Ladybird/Qt/Tab.h b/Ladybird/Qt/Tab.h index 954d87024991e6ba3522574ecf4a54cea870396f..ce97eba64f457fa0e44bfec1d3ab2c4e8e27ce9a 100644 --- a/Ladybird/Qt/Tab.h +++ b/Ladybird/Qt/Tab.h @@ -33,7 +33,7 @@ public: WebContentView& view() { return *m_view; } - void navigate(URL const&); + void navigate(URL::URL const&); void load_html(StringView); void back(); @@ -69,9 +69,9 @@ private: void recreate_toolbar_icons(); void update_hover_label(); - void open_link(URL const&); - void open_link_in_new_tab(URL const&); - void copy_link_url(URL const&); + void open_link(URL::URL const&); + void open_link_in_new_tab(URL::URL const&); + void copy_link_url(URL::URL const&); void close_sub_widgets(); @@ -91,11 +91,11 @@ private: QMenu* m_link_context_menu { nullptr }; QAction* m_link_context_menu_copy_url_action { nullptr }; - URL m_link_context_menu_url; + URL::URL m_link_context_menu_url; QMenu* m_image_context_menu { nullptr }; Gfx::ShareableBitmap m_image_context_menu_bitmap; - URL m_image_context_menu_url; + URL::URL m_image_context_menu_url; QMenu* m_audio_context_menu { nullptr }; QMenu* m_video_context_menu { nullptr }; @@ -107,7 +107,7 @@ private: QAction* m_media_context_menu_mute_unmute_action { nullptr }; QAction* m_media_context_menu_controls_action { nullptr }; QAction* m_media_context_menu_loop_action { nullptr }; - URL m_media_context_menu_url; + URL::URL m_media_context_menu_url; QMenu* m_select_dropdown { nullptr }; diff --git a/Ladybird/Qt/WebContentView.h b/Ladybird/Qt/WebContentView.h index 95442e6994c6107647f6e132cb2282e973f2c155..3a943bd3fa92f389e6fc39d1fc427a514e3bfb81 100644 --- a/Ladybird/Qt/WebContentView.h +++ b/Ladybird/Qt/WebContentView.h @@ -11,11 +11,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -47,7 +47,7 @@ public: WebContentView(QWidget* window, WebContentOptions const&, StringView webdriver_content_ipc_path, RefPtr parent_client = nullptr, size_t page_index = 0); virtual ~WebContentView() override; - Function on_tab_open_request; + Function on_tab_open_request; virtual void paintEvent(QPaintEvent*) override; virtual void resizeEvent(QResizeEvent*) override; diff --git a/Ladybird/Qt/main.cpp b/Ladybird/Qt/main.cpp index 9bed495a00cd81af48a24f17d0f9a0425e0f46c6..b02eb7db42cdb8ab60c2b0287dbd79f37750e0c5 100644 --- a/Ladybird/Qt/main.cpp +++ b/Ladybird/Qt/main.cpp @@ -61,7 +61,7 @@ public: { } - Function on_open_file; + Function on_open_file; bool event(QEvent* event) override { @@ -133,7 +133,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto cookie_jar = database ? TRY(WebView::CookieJar::create(*database)) : WebView::CookieJar::create(); - Vector initial_urls; + Vector initial_urls; for (auto const& raw_url : raw_urls) { if (auto url = WebView::sanitize_url(raw_url); url.has_value()) diff --git a/Ladybird/RequestServer/CMakeLists.txt b/Ladybird/RequestServer/CMakeLists.txt index 128dc1dbd4fba8cf833cebff030cee0a3585da26..798d7715fae0b963acf79daa7c416bdaedf0c8ef 100644 --- a/Ladybird/RequestServer/CMakeLists.txt +++ b/Ladybird/RequestServer/CMakeLists.txt @@ -33,7 +33,7 @@ target_link_libraries(RequestServer PRIVATE requestserver) target_include_directories(requestserver PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/) target_include_directories(requestserver PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) -target_link_libraries(requestserver PUBLIC LibCore LibMain LibCrypto LibFileSystem LibGemini LibHTTP LibIPC LibMain LibTLS LibWebView LibWebSocket) +target_link_libraries(requestserver PUBLIC LibCore LibMain LibCrypto LibFileSystem LibGemini LibHTTP LibIPC LibMain LibTLS LibWebView LibWebSocket LibURL) if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") # Solaris has socket and networking related functions in two extra libraries target_link_libraries(requestserver PUBLIC nsl socket) diff --git a/Ladybird/WebContent/CMakeLists.txt b/Ladybird/WebContent/CMakeLists.txt index 6f7e9accbbb9a6fdd10b915da0ccbdfdd84f6fe6..d09de4361b7251e536e9dcba5427422e1d09780c 100644 --- a/Ladybird/WebContent/CMakeLists.txt +++ b/Ladybird/WebContent/CMakeLists.txt @@ -81,7 +81,7 @@ endif() target_include_directories(WebContent PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/) target_include_directories(WebContent PRIVATE ${SERENITY_SOURCE_DIR}/Userland/) target_include_directories(WebContent PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) -target_link_libraries(WebContent PRIVATE LibAudio LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebSocket LibProtocol LibWebView) +target_link_libraries(WebContent PRIVATE LibAudio LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebSocket LibProtocol LibWebView LibURL) if (HAVE_PULSEAUDIO) target_compile_definitions(WebContent PRIVATE HAVE_PULSEAUDIO=1) diff --git a/Ladybird/WebWorker/CMakeLists.txt b/Ladybird/WebWorker/CMakeLists.txt index dd435fbf9bd8491865958842640e82919999e86f..5be2980545ad89d4b7db6bf8a47ba04c2d292ece 100644 --- a/Ladybird/WebWorker/CMakeLists.txt +++ b/Ladybird/WebWorker/CMakeLists.txt @@ -19,7 +19,7 @@ add_library(webworker STATIC ${WEBWORKER_SOURCES}) target_include_directories(webworker PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/) target_include_directories(webworker PRIVATE ${SERENITY_SOURCE_DIR}/Userland/) target_include_directories(webworker PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) -target_link_libraries(webworker PUBLIC LibCore LibFileSystem LibGfx LibIPC LibJS LibProtocol LibWeb LibWebView LibLocale LibImageDecoderClient LibMain) +target_link_libraries(webworker PUBLIC LibCore LibFileSystem LibGfx LibIPC LibJS LibProtocol LibWeb LibWebView LibLocale LibImageDecoderClient LibMain LibURL) add_executable(WebWorker main.cpp) target_include_directories(WebWorker PRIVATE ${SERENITY_SOURCE_DIR}/Userland/) diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index 71b98ef0933453c50eebba979ae56c8d24182d6b..86387fccbdebf059f9380a429ff4c9a8614355ed 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -355,6 +355,8 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "BSD$" OR HAIKU) target_link_libraries(AK PRIVATE execinfo) endif() +add_serenity_subdirectory(Userland/Libraries/LibURL) + # LibCore add_serenity_subdirectory(Userland/Libraries/LibCore) target_link_libraries(LibCore PRIVATE Threads::Threads) @@ -370,6 +372,7 @@ if (HAIKU) # Haiku has networking related functions in the network library target_link_libraries(LibCore PRIVATE network) endif() +target_link_libraries(LibCore PRIVATE LibURL) # LibMain add_serenity_subdirectory(Userland/Libraries/LibMain) @@ -580,7 +583,7 @@ if (BUILD_LAGOM) add_serenity_subdirectory(Meta/Lagom/Contrib/VideoPlayerSDL) endif() - lagom_utility(icc SOURCES ../../Userland/Utilities/icc.cpp LIBS LibGfx LibMain) + lagom_utility(icc SOURCES ../../Userland/Utilities/icc.cpp LIBS LibGfx LibMain LibURL) lagom_utility(image SOURCES ../../Userland/Utilities/image.cpp LIBS LibGfx LibMain) lagom_utility(isobmff SOURCES ../../Userland/Utilities/isobmff.cpp LIBS LibGfx LibMain) lagom_utility(ttfdisasm SOURCES ../../Userland/Utilities/ttfdisasm.cpp LIBS LibGfx LibMain) @@ -596,7 +599,7 @@ if (BUILD_LAGOM) endif() lagom_utility(lzcat SOURCES ../../Userland/Utilities/lzcat.cpp LIBS LibCompress LibMain) - lagom_utility(markdown-check SOURCES ../../Userland/Utilities/markdown-check.cpp LIBS LibFileSystem LibMarkdown LibMain LibManual) + lagom_utility(markdown-check SOURCES ../../Userland/Utilities/markdown-check.cpp LIBS LibFileSystem LibMarkdown LibMain LibManual LibURL) lagom_utility(mkfs.fat SOURCES ../../Userland/Utilities/mkfs.fat.cpp LIBS LibFileSystem LibMain) if (NOT EMSCRIPTEN) @@ -626,7 +629,7 @@ if (BUILD_LAGOM) endif() lagom_utility(wasm SOURCES ../../Userland/Utilities/wasm.cpp LIBS LibFileSystem LibWasm LibLine LibMain LibJS) - lagom_utility(xml SOURCES ../../Userland/Utilities/xml.cpp LIBS LibFileSystem LibMain LibXML) + lagom_utility(xml SOURCES ../../Userland/Utilities/xml.cpp LIBS LibFileSystem LibMain LibXML LibURL) lagom_utility(xzcat SOURCES ../../Userland/Utilities/xzcat.cpp LIBS LibCompress LibMain) lagom_utility(fdtdump SOURCES ../../Userland/Utilities/fdtdump.cpp LIBS LibDeviceTree LibMain) diff --git a/Meta/Lagom/Fuzzers/FuzzGemini.cpp b/Meta/Lagom/Fuzzers/FuzzGemini.cpp index c624d7b6c960c8d02ee0ab56b3d1079be8611f15..b6a9ad5b76dfbdaeb0549fd76fa1e67e02928a29 100644 --- a/Meta/Lagom/Fuzzers/FuzzGemini.cpp +++ b/Meta/Lagom/Fuzzers/FuzzGemini.cpp @@ -5,7 +5,6 @@ */ #include -#include #include #include #include diff --git a/Meta/Lagom/Fuzzers/FuzzURL.cpp b/Meta/Lagom/Fuzzers/FuzzURL.cpp index 136a504ce156072d7aeb90b0a39fa6513f5dc808..68206f190f99047911e7b6778c39680f792f39bd 100644 --- a/Meta/Lagom/Fuzzers/FuzzURL.cpp +++ b/Meta/Lagom/Fuzzers/FuzzURL.cpp @@ -4,12 +4,12 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { AK::set_debug_enabled(false); auto string_view = StringView(data, size); - auto url = URL(string_view); + auto url = URL::URL(string_view); return 0; } diff --git a/Meta/Lagom/Fuzzers/fuzzers.cmake b/Meta/Lagom/Fuzzers/fuzzers.cmake index 66f025f3390b32e1f3991a4abdc01123d798552b..bb05b4086632d0caa04dda0b3eb2107b4fa68e54 100644 --- a/Meta/Lagom/Fuzzers/fuzzers.cmake +++ b/Meta/Lagom/Fuzzers/fuzzers.cmake @@ -130,6 +130,7 @@ set(FUZZER_DEPENDENCIES_TGALoader LibGfx) set(FUZZER_DEPENDENCIES_TIFFLoader LibGfx) set(FUZZER_DEPENDENCIES_TTF LibGfx) set(FUZZER_DEPENDENCIES_TinyVGLoader LibGfx) +set(FUZZER_DEPENDENCIES_URL LibURL) set(FUZZER_DEPENDENCIES_VP9Decoder LibVideo) set(FUZZER_DEPENDENCIES_WasmParser LibWasm) set(FUZZER_DEPENDENCIES_WAVLoader LibAudio) diff --git a/Tests/AK/CMakeLists.txt b/Tests/AK/CMakeLists.txt index 845415b70260b866a457893770cbe85a2092b5b8..5346d366e8900ba11d6b8318593fac303e011f2b 100644 --- a/Tests/AK/CMakeLists.txt +++ b/Tests/AK/CMakeLists.txt @@ -84,7 +84,6 @@ set(AK_TEST_SOURCES TestTypeTraits.cpp TestTypedTransfer.cpp TestUFixedBigInt.cpp - TestURL.cpp TestUtf16.cpp TestUtf8.cpp TestVariant.cpp diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index de523f1280f11c51c8c280086541d9ce9998ae35..74c86c32a115d8485bfda865b7eded8c8ff02b76 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -25,6 +25,7 @@ add_subdirectory(LibTextCodec) add_subdirectory(LibThreading) add_subdirectory(LibTimeZone) add_subdirectory(LibUnicode) +add_subdirectory(LibURL) add_subdirectory(LibVideo) add_subdirectory(LibWasm) add_subdirectory(LibWeb) diff --git a/Tests/LibURL/CMakeLists.txt b/Tests/LibURL/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..944d65cdc84cfe36a09021751739b59ada528b68 --- /dev/null +++ b/Tests/LibURL/CMakeLists.txt @@ -0,0 +1,7 @@ +set(URL_TEST_SOURCES + TestURL.cpp +) + +foreach(source IN LISTS URL_TEST_SOURCES) + serenity_test("${source}" LibURL LIBS LibURL) +endforeach() diff --git a/Tests/AK/TestURL.cpp b/Tests/LibURL/TestURL.cpp similarity index 73% rename from Tests/AK/TestURL.cpp rename to Tests/LibURL/TestURL.cpp index 61b5499b05af70ac5319420fbc6e379daf7197c5..77a0fd64b7580c0dd23c31b9480144456dd9939c 100644 --- a/Tests/AK/TestURL.cpp +++ b/Tests/LibURL/TestURL.cpp @@ -7,18 +7,18 @@ #include -#include -#include +#include +#include TEST_CASE(construct) { - EXPECT_EQ(URL().is_valid(), false); + EXPECT_EQ(URL::URL().is_valid(), false); } TEST_CASE(basic) { { - URL url("http://www.serenityos.org"sv); + URL::URL url("http://www.serenityos.org"sv); EXPECT_EQ(url.is_valid(), true); EXPECT_EQ(url.scheme(), "http"); EXPECT_EQ(MUST(url.serialized_host()), "www.serenityos.org"); @@ -28,7 +28,7 @@ TEST_CASE(basic) EXPECT(!url.fragment().has_value()); } { - URL url("https://www.serenityos.org/index.html"sv); + URL::URL url("https://www.serenityos.org/index.html"sv); EXPECT_EQ(url.is_valid(), true); EXPECT_EQ(url.scheme(), "https"); EXPECT_EQ(MUST(url.serialized_host()), "www.serenityos.org"); @@ -38,7 +38,7 @@ TEST_CASE(basic) EXPECT(!url.fragment().has_value()); } { - URL url("https://www.serenityos.org1/index.html"sv); + URL::URL url("https://www.serenityos.org1/index.html"sv); EXPECT_EQ(url.is_valid(), true); EXPECT_EQ(url.scheme(), "https"); EXPECT_EQ(MUST(url.serialized_host()), "www.serenityos.org1"); @@ -48,7 +48,7 @@ TEST_CASE(basic) EXPECT(!url.fragment().has_value()); } { - URL url("https://localhost:1234/~anon/test/page.html"sv); + URL::URL url("https://localhost:1234/~anon/test/page.html"sv); EXPECT_EQ(url.is_valid(), true); EXPECT_EQ(url.scheme(), "https"); EXPECT_EQ(MUST(url.serialized_host()), "localhost"); @@ -58,7 +58,7 @@ TEST_CASE(basic) EXPECT(!url.fragment().has_value()); } { - URL url("http://www.serenityos.org/index.html?#"sv); + URL::URL url("http://www.serenityos.org/index.html?#"sv); EXPECT_EQ(url.is_valid(), true); EXPECT_EQ(url.scheme(), "http"); EXPECT_EQ(MUST(url.serialized_host()), "www.serenityos.org"); @@ -68,7 +68,7 @@ TEST_CASE(basic) EXPECT_EQ(url.fragment(), ""); } { - URL url("http://www.serenityos.org/index.html?foo=1&bar=2"sv); + URL::URL url("http://www.serenityos.org/index.html?foo=1&bar=2"sv); EXPECT_EQ(url.is_valid(), true); EXPECT_EQ(url.scheme(), "http"); EXPECT_EQ(MUST(url.serialized_host()), "www.serenityos.org"); @@ -78,7 +78,7 @@ TEST_CASE(basic) EXPECT(!url.fragment().has_value()); } { - URL url("http://www.serenityos.org/index.html#fragment"sv); + URL::URL url("http://www.serenityos.org/index.html#fragment"sv); EXPECT_EQ(url.is_valid(), true); EXPECT_EQ(url.scheme(), "http"); EXPECT_EQ(MUST(url.serialized_host()), "www.serenityos.org"); @@ -88,7 +88,7 @@ TEST_CASE(basic) EXPECT_EQ(url.fragment(), "fragment"); } { - URL url("http://www.serenityos.org/index.html?foo=1&bar=2&baz=/?#frag/ment?test#"sv); + URL::URL url("http://www.serenityos.org/index.html?foo=1&bar=2&baz=/?#frag/ment?test#"sv); EXPECT_EQ(url.is_valid(), true); EXPECT_EQ(url.scheme(), "http"); EXPECT_EQ(MUST(url.serialized_host()), "www.serenityos.org"); @@ -101,29 +101,29 @@ TEST_CASE(basic) TEST_CASE(some_bad_urls) { - EXPECT_EQ(URL("http//serenityos.org"sv).is_valid(), false); - EXPECT_EQ(URL("serenityos.org"sv).is_valid(), false); - EXPECT_EQ(URL("://serenityos.org"sv).is_valid(), false); - EXPECT_EQ(URL("://:80"sv).is_valid(), false); - EXPECT_EQ(URL("http://serenityos.org:80:80/"sv).is_valid(), false); - EXPECT_EQ(URL("http://serenityos.org:80:80"sv).is_valid(), false); - EXPECT_EQ(URL("http://serenityos.org:abc"sv).is_valid(), false); - EXPECT_EQ(URL("http://serenityos.org:abc:80"sv).is_valid(), false); - EXPECT_EQ(URL("http://serenityos.org:abc:80/"sv).is_valid(), false); + EXPECT_EQ(URL::URL("http//serenityos.org"sv).is_valid(), false); + EXPECT_EQ(URL::URL("serenityos.org"sv).is_valid(), false); + EXPECT_EQ(URL::URL("://serenityos.org"sv).is_valid(), false); + EXPECT_EQ(URL::URL("://:80"sv).is_valid(), false); + EXPECT_EQ(URL::URL("http://serenityos.org:80:80/"sv).is_valid(), false); + EXPECT_EQ(URL::URL("http://serenityos.org:80:80"sv).is_valid(), false); + EXPECT_EQ(URL::URL("http://serenityos.org:abc"sv).is_valid(), false); + EXPECT_EQ(URL::URL("http://serenityos.org:abc:80"sv).is_valid(), false); + EXPECT_EQ(URL::URL("http://serenityos.org:abc:80/"sv).is_valid(), false); } TEST_CASE(serialization) { - EXPECT_EQ(URL("http://www.serenityos.org/"sv).serialize(), "http://www.serenityos.org/"); - EXPECT_EQ(URL("http://www.serenityos.org:0/"sv).serialize(), "http://www.serenityos.org:0/"); - EXPECT_EQ(URL("http://www.serenityos.org:80/"sv).serialize(), "http://www.serenityos.org/"); - EXPECT_EQ(URL("http://www.serenityos.org:81/"sv).serialize(), "http://www.serenityos.org:81/"); - EXPECT_EQ(URL("https://www.serenityos.org:443/foo/bar.html?query#fragment"sv).serialize(), "https://www.serenityos.org/foo/bar.html?query#fragment"); + EXPECT_EQ(URL::URL("http://www.serenityos.org/"sv).serialize(), "http://www.serenityos.org/"); + EXPECT_EQ(URL::URL("http://www.serenityos.org:0/"sv).serialize(), "http://www.serenityos.org:0/"); + EXPECT_EQ(URL::URL("http://www.serenityos.org:80/"sv).serialize(), "http://www.serenityos.org/"); + EXPECT_EQ(URL::URL("http://www.serenityos.org:81/"sv).serialize(), "http://www.serenityos.org:81/"); + EXPECT_EQ(URL::URL("https://www.serenityos.org:443/foo/bar.html?query#fragment"sv).serialize(), "https://www.serenityos.org/foo/bar.html?query#fragment"); } TEST_CASE(file_url_with_hostname) { - URL url("file://courage/my/file"sv); + URL::URL url("file://courage/my/file"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "file"); EXPECT_EQ(MUST(url.serialized_host()), "courage"); @@ -136,7 +136,7 @@ TEST_CASE(file_url_with_hostname) TEST_CASE(file_url_with_localhost) { - URL url("file://localhost/my/file"sv); + URL::URL url("file://localhost/my/file"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "file"); EXPECT_EQ(MUST(url.serialized_host()), ""); @@ -146,7 +146,7 @@ TEST_CASE(file_url_with_localhost) TEST_CASE(file_url_without_hostname) { - URL url("file:///my/file"sv); + URL::URL url("file:///my/file"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "file"); EXPECT_EQ(MUST(url.serialized_host()), ""); @@ -156,7 +156,7 @@ TEST_CASE(file_url_without_hostname) TEST_CASE(file_url_with_encoded_characters) { - URL url("file:///my/file/test%23file.txt"sv); + URL::URL url("file:///my/file/test%23file.txt"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "file"); EXPECT_EQ(url.serialize_path(), "/my/file/test#file.txt"); @@ -166,7 +166,7 @@ TEST_CASE(file_url_with_encoded_characters) TEST_CASE(file_url_with_fragment) { - URL url("file:///my/file#fragment"sv); + URL::URL url("file:///my/file#fragment"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "file"); EXPECT_EQ(url.serialize_path(), "/my/file"); @@ -176,7 +176,7 @@ TEST_CASE(file_url_with_fragment) TEST_CASE(file_url_with_root_path) { - URL url("file:///"sv); + URL::URL url("file:///"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "file"); EXPECT_EQ(url.serialize_path(), "/"); @@ -184,23 +184,23 @@ TEST_CASE(file_url_with_root_path) TEST_CASE(file_url_serialization) { - EXPECT_EQ(URL("file://courage/my/file"sv).serialize(), "file://courage/my/file"); - EXPECT_EQ(URL("file://localhost/my/file"sv).serialize(), "file:///my/file"); - EXPECT_EQ(URL("file:///my/file"sv).serialize(), "file:///my/file"); - EXPECT_EQ(URL("file:///my/directory/"sv).serialize(), "file:///my/directory/"); - EXPECT_EQ(URL("file:///my/file%23test"sv).serialize(), "file:///my/file%23test"); - EXPECT_EQ(URL("file:///my/file#fragment"sv).serialize(), "file:///my/file#fragment"); + EXPECT_EQ(URL::URL("file://courage/my/file"sv).serialize(), "file://courage/my/file"); + EXPECT_EQ(URL::URL("file://localhost/my/file"sv).serialize(), "file:///my/file"); + EXPECT_EQ(URL::URL("file:///my/file"sv).serialize(), "file:///my/file"); + EXPECT_EQ(URL::URL("file:///my/directory/"sv).serialize(), "file:///my/directory/"); + EXPECT_EQ(URL::URL("file:///my/file%23test"sv).serialize(), "file:///my/file%23test"); + EXPECT_EQ(URL::URL("file:///my/file#fragment"sv).serialize(), "file:///my/file#fragment"); } TEST_CASE(file_url_relative) { - EXPECT_EQ(URL("https://vkoskiv.com/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "https://vkoskiv.com/static/foo.js"); - EXPECT_EQ(URL("file:///home/vkoskiv/test/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "file:///home/vkoskiv/test/static/foo.js"); + EXPECT_EQ(URL::URL("https://vkoskiv.com/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "https://vkoskiv.com/static/foo.js"); + EXPECT_EQ(URL::URL("file:///home/vkoskiv/test/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "file:///home/vkoskiv/test/static/foo.js"); } TEST_CASE(about_url) { - URL url("about:blank"sv); + URL::URL url("about:blank"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "about"); EXPECT(url.host().has()); @@ -212,7 +212,7 @@ TEST_CASE(about_url) TEST_CASE(mailto_url) { - URL url("mailto:mail@example.com"sv); + URL::URL url("mailto:mail@example.com"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "mailto"); EXPECT(url.host().has()); @@ -226,7 +226,7 @@ TEST_CASE(mailto_url) TEST_CASE(mailto_url_with_subject) { - URL url("mailto:mail@example.com?subject=test"sv); + URL::URL url("mailto:mail@example.com?subject=test"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "mailto"); EXPECT(url.host().has()); @@ -240,7 +240,7 @@ TEST_CASE(mailto_url_with_subject) TEST_CASE(data_url) { - URL url("data:text/html,test"sv); + URL::URL url("data:text/html,test"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "data"); EXPECT(url.host().has()); @@ -253,7 +253,7 @@ TEST_CASE(data_url) TEST_CASE(data_url_default_mime_type) { - URL url("data:,test"sv); + URL::URL url("data:,test"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "data"); EXPECT(url.host().has()); @@ -266,7 +266,7 @@ TEST_CASE(data_url_default_mime_type) TEST_CASE(data_url_encoded) { - URL url("data:text/html,Hello%20friends%2C%0X%X0"sv); + URL::URL url("data:text/html,Hello%20friends%2C%0X%X0"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "data"); EXPECT(url.host().has()); @@ -279,7 +279,7 @@ TEST_CASE(data_url_encoded) TEST_CASE(data_url_base64_encoded) { - URL url("data:text/html;base64,dGVzdA=="sv); + URL::URL url("data:text/html;base64,dGVzdA=="sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "data"); EXPECT(url.host().has()); @@ -292,7 +292,7 @@ TEST_CASE(data_url_base64_encoded) TEST_CASE(data_url_base64_encoded_default_mime_type) { - URL url("data:;base64,dGVzdA=="sv); + URL::URL url("data:;base64,dGVzdA=="sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "data"); EXPECT(url.host().has()); @@ -305,7 +305,7 @@ TEST_CASE(data_url_base64_encoded_default_mime_type) TEST_CASE(data_url_base64_encoded_with_whitespace) { - URL url("data: text/html ; bAsE64 , dGVz dA== "sv); + URL::URL url("data: text/html ; bAsE64 , dGVz dA== "sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "data"); EXPECT(url.host().has()); @@ -318,7 +318,7 @@ TEST_CASE(data_url_base64_encoded_with_whitespace) TEST_CASE(data_url_base64_encoded_with_inline_whitespace) { - URL url("data:text/javascript;base64,%20ZD%20Qg%0D%0APS%20An%20Zm91cic%0D%0A%207%20"sv); + URL::URL url("data:text/javascript;base64,%20ZD%20Qg%0D%0APS%20An%20Zm91cic%0D%0A%207%20"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "data"); EXPECT(url.host().has()); @@ -330,7 +330,7 @@ TEST_CASE(data_url_base64_encoded_with_inline_whitespace) TEST_CASE(data_url_completed_with_fragment) { - auto url = URL("data:text/plain,test"sv).complete_url("#a"sv); + auto url = URL::URL("data:text/plain,test"sv).complete_url("#a"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "data"); EXPECT_EQ(url.fragment(), "a"); @@ -343,29 +343,29 @@ TEST_CASE(data_url_completed_with_fragment) TEST_CASE(trailing_slash_with_complete_url) { - EXPECT_EQ(URL("http://a/b/"sv).complete_url("c/"sv).serialize(), "http://a/b/c/"); - EXPECT_EQ(URL("http://a/b/"sv).complete_url("c"sv).serialize(), "http://a/b/c"); - EXPECT_EQ(URL("http://a/b"sv).complete_url("c/"sv).serialize(), "http://a/c/"); - EXPECT_EQ(URL("http://a/b"sv).complete_url("c"sv).serialize(), "http://a/c"); + EXPECT_EQ(URL::URL("http://a/b/"sv).complete_url("c/"sv).serialize(), "http://a/b/c/"); + EXPECT_EQ(URL::URL("http://a/b/"sv).complete_url("c"sv).serialize(), "http://a/b/c"); + EXPECT_EQ(URL::URL("http://a/b"sv).complete_url("c/"sv).serialize(), "http://a/c/"); + EXPECT_EQ(URL::URL("http://a/b"sv).complete_url("c"sv).serialize(), "http://a/c"); } TEST_CASE(trailing_port) { - URL url("http://example.com:8086"sv); + URL::URL url("http://example.com:8086"sv); EXPECT_EQ(url.port_or_default(), 8086); } TEST_CASE(port_overflow) { - EXPECT_EQ(URL("http://example.com:123456789/"sv).is_valid(), false); + EXPECT_EQ(URL::URL("http://example.com:123456789/"sv).is_valid(), false); } TEST_CASE(equality) { - EXPECT(URL("http://serenityos.org"sv).equals("http://serenityos.org#test"sv, URL::ExcludeFragment::Yes)); - EXPECT_EQ(URL("http://example.com/index.html"sv), URL("http://ex%61mple.com/index.html"sv)); - EXPECT_EQ(URL("file:///my/file"sv), URL("file://localhost/my/file"sv)); - EXPECT_NE(URL("http://serenityos.org/index.html"sv), URL("http://serenityos.org/test.html"sv)); + EXPECT(URL::URL("http://serenityos.org"sv).equals("http://serenityos.org#test"sv, URL::ExcludeFragment::Yes)); + EXPECT_EQ(URL::URL("http://example.com/index.html"sv), URL::URL("http://ex%61mple.com/index.html"sv)); + EXPECT_EQ(URL::URL("file:///my/file"sv), URL::URL("file://localhost/my/file"sv)); + EXPECT_NE(URL::URL("http://serenityos.org/index.html"sv), URL::URL("http://serenityos.org/test.html"sv)); } TEST_CASE(create_with_file_scheme) @@ -390,14 +390,14 @@ TEST_CASE(create_with_file_scheme) EXPECT_EQ(url.path_segment_at_index(2), ""); EXPECT_EQ(url.serialize_path(), "/home/anon/"); - url = URL("file:///home/anon/"sv); + url = URL::URL("file:///home/anon/"sv); EXPECT_EQ(url.serialize_path(), "/home/anon/"); } TEST_CASE(complete_url) { - URL base_url("http://serenityos.org/index.html#fragment"sv); - URL url = base_url.complete_url("test.html"sv); + URL::URL base_url("http://serenityos.org/index.html#fragment"sv); + URL::URL url = base_url.complete_url("test.html"sv); EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "http"); EXPECT_EQ(MUST(url.serialized_host()), "serenityos.org"); @@ -410,28 +410,28 @@ TEST_CASE(complete_url) TEST_CASE(leading_whitespace) { - URL url { " https://foo.com/"sv }; + URL::URL url { " https://foo.com/"sv }; EXPECT(url.is_valid()); EXPECT_EQ(url.to_byte_string(), "https://foo.com/"); } TEST_CASE(trailing_whitespace) { - URL url { "https://foo.com/ "sv }; + URL::URL url { "https://foo.com/ "sv }; EXPECT(url.is_valid()); EXPECT_EQ(url.to_byte_string(), "https://foo.com/"); } TEST_CASE(leading_and_trailing_whitespace) { - URL url { " https://foo.com/ "sv }; + URL::URL url { " https://foo.com/ "sv }; EXPECT(url.is_valid()); EXPECT_EQ(url.to_byte_string(), "https://foo.com/"); } TEST_CASE(unicode) { - URL url { "http://example.com/_ünicöde_téxt_©"sv }; + URL::URL url { "http://example.com/_ünicöde_téxt_©"sv }; EXPECT(url.is_valid()); EXPECT_EQ(url.serialize_path(), "/_ünicöde_téxt_©"); EXPECT(!url.query().has_value()); @@ -440,7 +440,7 @@ TEST_CASE(unicode) TEST_CASE(query_with_non_ascii) { - URL url { "http://example.com/?utf8=✓"sv }; + URL::URL url { "http://example.com/?utf8=✓"sv }; EXPECT(url.is_valid()); EXPECT_EQ(url.serialize_path(), "/"sv); EXPECT_EQ(url.query(), "utf8=%E2%9C%93"); @@ -449,7 +449,7 @@ TEST_CASE(query_with_non_ascii) TEST_CASE(complete_file_url_with_base) { - URL url { "file:///home/index.html" }; + URL::URL url { "file:///home/index.html" }; EXPECT(url.is_valid()); EXPECT_EQ(url.serialize_path(), "/home/index.html"); EXPECT_EQ(url.path_segment_count(), 2u); @@ -463,8 +463,8 @@ TEST_CASE(complete_file_url_with_base) TEST_CASE(empty_url_with_base_url) { - URL base_url { "https://foo.com/"sv }; - URL parsed_url = URLParser::basic_parse(""sv, base_url); + URL::URL base_url { "https://foo.com/"sv }; + URL::URL parsed_url = URL::Parser::basic_parse(""sv, base_url); EXPECT_EQ(parsed_url.is_valid(), true); EXPECT(base_url.equals(parsed_url)); } @@ -472,7 +472,7 @@ TEST_CASE(empty_url_with_base_url) TEST_CASE(google_street_view) { constexpr auto streetview_url = "https://www.google.co.uk/maps/@53.3354159,-1.9573545,3a,75y,121.1h,75.67t/data=!3m7!1e1!3m5!1sSY8xCv17jAX4S7SRdV38hg!2e0!6shttps:%2F%2Fstreetviewpixels-pa.googleapis.com%2Fv1%2Fthumbnail%3Fpanoid%3DSY8xCv17jAX4S7SRdV38hg%26cb_client%3Dmaps_sv.tactile.gps%26w%3D203%26h%3D100%26yaw%3D188.13148%26pitch%3D0%26thumbfov%3D100!7i13312!8i6656"; - URL url(streetview_url); + URL::URL url(streetview_url); EXPECT_EQ(url.serialize(), streetview_url); } @@ -480,7 +480,7 @@ TEST_CASE(ipv6_address) { { constexpr auto ipv6_url = "http://[::1]/index.html"sv; - URL url(ipv6_url); + URL::URL url(ipv6_url); EXPECT(url.is_valid()); EXPECT_EQ(MUST(url.serialized_host()), "[::1]"sv); EXPECT_EQ(url, ipv6_url); @@ -488,7 +488,7 @@ TEST_CASE(ipv6_address) { constexpr auto ipv6_url = "http://[0:f:0:0:f:f:0:0]/index.html"sv; - URL url(ipv6_url); + URL::URL url(ipv6_url); EXPECT(url.is_valid()); EXPECT_EQ(MUST(url.serialized_host()), "[0:f::f:f:0:0]"sv); EXPECT_EQ(url, ipv6_url); @@ -496,7 +496,7 @@ TEST_CASE(ipv6_address) { constexpr auto ipv6_url = "https://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/index.html"sv; - URL url(ipv6_url); + URL::URL url(ipv6_url); EXPECT(url.is_valid()); EXPECT_EQ(MUST(url.serialized_host()), "[2001:db8:85a3::8a2e:370:7334]"sv); EXPECT_EQ(url, ipv6_url); @@ -504,7 +504,7 @@ TEST_CASE(ipv6_address) { constexpr auto bad_ipv6_url = "https://[oops]/index.html"sv; - URL url(bad_ipv6_url); + URL::URL url(bad_ipv6_url); EXPECT_EQ(url.is_valid(), false); } } @@ -513,41 +513,41 @@ TEST_CASE(ipv4_address) { { constexpr auto ipv4_url = "http://127.0.0.1/index.html"sv; - URL url(ipv4_url); + URL::URL url(ipv4_url); EXPECT(url.is_valid()); EXPECT_EQ(MUST(url.serialized_host()), "127.0.0.1"sv); } { constexpr auto ipv4_url = "http://0x.0x.0"sv; - URL url(ipv4_url); + URL::URL url(ipv4_url); EXPECT(url.is_valid()); EXPECT_EQ(MUST(url.serialized_host()), "0.0.0.0"sv); } { constexpr auto bad_ipv4_url = "https://127..0.0.1"sv; - URL url(bad_ipv4_url); + URL::URL url(bad_ipv4_url); EXPECT(!url.is_valid()); } { constexpr auto ipv4_url = "http://256"sv; - URL url(ipv4_url); + URL::URL url(ipv4_url); EXPECT(url.is_valid()); EXPECT_EQ(MUST(url.serialized_host()), "0.0.1.0"sv); } { constexpr auto ipv4_url = "http://888888888"sv; - URL url(ipv4_url); + URL::URL url(ipv4_url); EXPECT(url.is_valid()); EXPECT_EQ(MUST(url.serialized_host()), "52.251.94.56"sv); } { constexpr auto ipv4_url = "http://9111111111"sv; - URL url(ipv4_url); + URL::URL url(ipv4_url); EXPECT(!url.is_valid()); } } @@ -556,7 +556,7 @@ TEST_CASE(username_and_password) { { constexpr auto url_with_username_and_password = "http://username:password@test.com/index.html"sv; - URL url(url_with_username_and_password); + URL::URL url(url_with_username_and_password); EXPECT(url.is_valid()); EXPECT_EQ(MUST(url.serialized_host()), "test.com"sv); EXPECT_EQ(MUST(url.username()), "username"sv); @@ -565,7 +565,7 @@ TEST_CASE(username_and_password) { constexpr auto url_with_percent_encoded_credentials = "http://username%21%24%25:password%21%24%25@test.com/index.html"sv; - URL url(url_with_percent_encoded_credentials); + URL::URL url(url_with_percent_encoded_credentials); EXPECT(url.is_valid()); EXPECT_EQ(MUST(url.serialized_host()), "test.com"sv); EXPECT_EQ(MUST(url.username()), "username!$%"sv); @@ -575,7 +575,7 @@ TEST_CASE(username_and_password) { auto const& username = MUST(String::repeated('a', 50000)); auto const& url_with_long_username = MUST(String::formatted("http://{}:@test.com/index.html", username)); - URL url(url_with_long_username); + URL::URL url(url_with_long_username); EXPECT(url.is_valid()); EXPECT_EQ(MUST(url.serialized_host()), "test.com"sv); EXPECT_EQ(MUST(url.username()), username); @@ -585,7 +585,7 @@ TEST_CASE(username_and_password) { auto const& password = MUST(String::repeated('a', 50000)); auto const& url_with_long_password = MUST(String::formatted("http://:{}@test.com/index.html", password)); - URL url(url_with_long_password); + URL::URL url(url_with_long_password); EXPECT(url.is_valid()); EXPECT_EQ(MUST(url.serialized_host()), "test.com"sv); EXPECT(MUST(url.username()).is_empty()); diff --git a/Tests/LibWebView/CMakeLists.txt b/Tests/LibWebView/CMakeLists.txt index 3022b1113a4c5af144eb4047ac962d8cd1a5ad27..86aea611a0707d88ae99cbfb0506c7106958abb7 100644 --- a/Tests/LibWebView/CMakeLists.txt +++ b/Tests/LibWebView/CMakeLists.txt @@ -3,5 +3,5 @@ set(TEST_SOURCES ) foreach(source IN LISTS TEST_SOURCES) - serenity_test("${source}" LibWebView LIBS LibWebView) + serenity_test("${source}" LibWebView LIBS LibWebView LibURL) endforeach() diff --git a/Userland/Applications/3DFileViewer/CMakeLists.txt b/Userland/Applications/3DFileViewer/CMakeLists.txt index 49d8c45bf00ae1ac41579991a572e316e89e5c34..0f856a7d0b4284e81261131fe3067d8831ab1740 100644 --- a/Userland/Applications/3DFileViewer/CMakeLists.txt +++ b/Userland/Applications/3DFileViewer/CMakeLists.txt @@ -12,4 +12,4 @@ set(SOURCES ) serenity_app(3DFileViewer ICON app-3d-file-viewer) -target_link_libraries(3DFileViewer PRIVATE LibCore LibDesktop LibGfx LibGUI LibGL LibFileSystemAccessClient LibMain) +target_link_libraries(3DFileViewer PRIVATE LibCore LibDesktop LibGfx LibGUI LibGL LibFileSystemAccessClient LibMain LibURL) diff --git a/Userland/Applications/Assistant/CMakeLists.txt b/Userland/Applications/Assistant/CMakeLists.txt index 06a3367897d3d0582b990f5e3408f5245afc599c..0f852677b54ebe309730794f5360595c5a0f9548 100644 --- a/Userland/Applications/Assistant/CMakeLists.txt +++ b/Userland/Applications/Assistant/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_app(Assistant ICON app-assistant) -target_link_libraries(Assistant PRIVATE LibCore LibDesktop LibGfx LibGUI LibJS LibMain LibThreading) +target_link_libraries(Assistant PRIVATE LibCore LibDesktop LibGfx LibGUI LibJS LibMain LibThreading LibURL) diff --git a/Userland/Applications/Assistant/Providers.cpp b/Userland/Applications/Assistant/Providers.cpp index 348ed0e13cd2fcaa0a89b47ddbaefb3e4a49effd..e51dfc92d47577446613c4b0b32b39650f6d7adc 100644 --- a/Userland/Applications/Assistant/Providers.cpp +++ b/Userland/Applications/Assistant/Providers.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -261,7 +261,7 @@ void URLProvider::query(ByteString const& query, Function #include -#include #include #include #include #include #include +#include #include namespace Assistant { @@ -118,7 +118,7 @@ private: class URLResult final : public Result { public: - explicit URLResult(const URL& url) + explicit URLResult(const URL::URL& url) : Result(url.to_byte_string(), "Open URL in Browser"_string, 50) , m_bitmap(GUI::Icon::default_icon("app-browser"sv).bitmap_for_size(16)) { diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index 47659ae462e81fc7622669fe73b11f93a15e18d0..4cf5292b1e10fc15e3812b5ce1146520838768c8 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -50,7 +50,7 @@ static ByteString bookmarks_file_path() return builder.to_byte_string(); } -BrowserWindow::BrowserWindow(WebView::CookieJar& cookie_jar, Vector const& initial_urls, StringView const man_file) +BrowserWindow::BrowserWindow(WebView::CookieJar& cookie_jar, Vector const& initial_urls, StringView const man_file) : m_cookie_jar(cookie_jar) , m_window_actions(*this) { @@ -278,7 +278,7 @@ void BrowserWindow::build_menus(StringView const man_file) "Set Homepage URL...", g_icon_bag.go_home, [this](auto&) { String homepage_url = String::from_byte_string(Config::read_string("Browser"sv, "Preferences"sv, "Home"sv, Browser::default_homepage_url)).release_value_but_fixme_should_propagate_errors(); if (GUI::InputBox::show(this, homepage_url, "Enter a URL:"sv, "Change Homepage"sv) == GUI::InputBox::ExecResult::OK) { - if (URL(homepage_url).is_valid()) { + if (URL::URL(homepage_url).is_valid()) { Config::write_string("Browser"sv, "Preferences"sv, "Home"sv, homepage_url); Browser::g_home_url = homepage_url.to_byte_string(); } else { @@ -531,7 +531,7 @@ void BrowserWindow::set_window_title_for_tab(Tab const& tab) set_title(ByteString::formatted("{} - Ladybird", title.is_empty() ? url.to_byte_string() : title)); } -Tab& BrowserWindow::create_new_tab(URL const& url, Web::HTML::ActivateTab activate) +Tab& BrowserWindow::create_new_tab(URL::URL const& url, Web::HTML::ActivateTab activate) { auto& new_tab = m_tab_widget->add_tab("New tab"_string, *this); @@ -618,7 +618,7 @@ Tab& BrowserWindow::create_new_tab(URL const& url, Web::HTML::ActivateTab activa return new_tab; } -void BrowserWindow::create_new_window(URL const& url) +void BrowserWindow::create_new_window(URL::URL const& url) { GUI::Process::spawn_or_show_error(this, "/bin/Browser"sv, Array { url.to_byte_string() }); } diff --git a/Userland/Applications/Browser/BrowserWindow.h b/Userland/Applications/Browser/BrowserWindow.h index 86c4df4f06037493e0c7b2ce4b8a849117f56d42..6269b842902f03829bf4bef044432df3a531d419 100644 --- a/Userland/Applications/Browser/BrowserWindow.h +++ b/Userland/Applications/Browser/BrowserWindow.h @@ -29,8 +29,8 @@ public: GUI::TabWidget& tab_widget(); Tab& active_tab(); - Tab& create_new_tab(URL const&, Web::HTML::ActivateTab activate); - void create_new_window(URL const&); + Tab& create_new_tab(URL::URL const&, Web::HTML::ActivateTab activate); + void create_new_window(URL::URL const&); GUI::Action& go_back_action() { return *m_go_back_action; } GUI::Action& go_forward_action() { return *m_go_forward_action; } @@ -51,7 +51,7 @@ public: void broadcast_window_size(Gfx::IntSize); private: - BrowserWindow(WebView::CookieJar&, Vector const&, StringView const); + BrowserWindow(WebView::CookieJar&, Vector const&, StringView const); void build_menus(StringView const); ErrorOr load_search_engines(GUI::Menu& settings_menu); diff --git a/Userland/Applications/Browser/CMakeLists.txt b/Userland/Applications/Browser/CMakeLists.txt index 95a40e7f75d3bcb42a0d8a24ff88f512d4a2a4c7..ceff5c1512adf6d2122cb6e140146de1c182e6a3 100644 --- a/Userland/Applications/Browser/CMakeLists.txt +++ b/Userland/Applications/Browser/CMakeLists.txt @@ -37,5 +37,5 @@ set(GENERATED_SOURCES ) serenity_app(Browser ICON app-browser) -target_link_libraries(Browser PRIVATE LibCore LibWebView LibWeb LibProtocol LibGUI LibDesktop LibConfig LibGfx LibIPC LibJS LibLocale LibMain LibSyntax) +target_link_libraries(Browser PRIVATE LibCore LibWebView LibWeb LibProtocol LibGUI LibDesktop LibConfig LibGfx LibIPC LibJS LibLocale LibMain LibSyntax LibURL) link_with_locale_data(Browser) diff --git a/Userland/Applications/Browser/DownloadWidget.cpp b/Userland/Applications/Browser/DownloadWidget.cpp index 82e68c5d834211c4d016a1b8052329e2b41a8073..9b35f991e85b952d9298b96c36554e7310c55317 100644 --- a/Userland/Applications/Browser/DownloadWidget.cpp +++ b/Userland/Applications/Browser/DownloadWidget.cpp @@ -27,7 +27,7 @@ namespace Browser { -DownloadWidget::DownloadWidget(const URL& url) +DownloadWidget::DownloadWidget(const URL::URL& url) : m_url(url) { { diff --git a/Userland/Applications/Browser/DownloadWidget.h b/Userland/Applications/Browser/DownloadWidget.h index 4d15dc3375c7a2e84cc5f827de87a0b6e8827f8e..761e239e409d64cc29b0fd1ddcaf9ba41f934537 100644 --- a/Userland/Applications/Browser/DownloadWidget.h +++ b/Userland/Applications/Browser/DownloadWidget.h @@ -7,11 +7,11 @@ #pragma once -#include #include #include #include #include +#include #include namespace Browser { @@ -23,12 +23,12 @@ public: virtual ~DownloadWidget() override = default; private: - explicit DownloadWidget(const URL&); + explicit DownloadWidget(const URL::URL&); void did_progress(Optional total_size, u64 downloaded_size); void did_finish(bool success); - URL m_url; + URL::URL m_url; ByteString m_destination_path; RefPtr m_download; RefPtr m_progressbar; diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 882233ac982ffe72f10f97046949922f58187dff..a428775068f0ca5a55b6e32660005877f579a7fb 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -18,7 +18,6 @@ #include "InspectorWidget.h" #include "StorageWidget.h" #include -#include #include #include #include @@ -42,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -59,7 +59,7 @@ Tab::~Tab() close_sub_widgets(); } -void Tab::start_download(const URL& url) +void Tab::start_download(const URL::URL& url) { auto window = GUI::Window::construct(&this->window()); window->resize(300, 170); @@ -69,7 +69,7 @@ void Tab::start_download(const URL& url) window->show(); } -void Tab::view_source(const URL& url, ByteString const& source) +void Tab::view_source(const URL::URL& url, ByteString const& source) { auto window = GUI::Window::construct(&this->window()); auto editor = window->set_main_widget(); @@ -654,7 +654,7 @@ Tab::Tab(BrowserWindow& window) view().on_new_web_view = [this](auto activate_tab, auto, auto) { // FIXME: Create a child tab that re-uses the ConnectionFromClient of the parent tab - auto& tab = this->window().create_new_tab(URL("about:blank"), activate_tab); + auto& tab = this->window().create_new_tab(URL::URL("about:blank"), activate_tab); return tab.view().handle(); }; @@ -799,14 +799,14 @@ void Tab::update_reset_zoom_button() } } -void Tab::load(URL const& url, LoadType load_type) +void Tab::load(URL::URL const& url, LoadType load_type) { m_is_history_navigation = (load_type == LoadType::HistoryNavigation); m_web_content_view->load(url); m_location_box->set_focus(false); } -URL Tab::url() const +URL::URL Tab::url() const { return m_web_content_view->url(); } diff --git a/Userland/Applications/Browser/Tab.h b/Userland/Applications/Browser/Tab.h index e6b7c08af3a28676c03522ef1780b5eb83824d17..ba24230d5d7f176de7e85be202f9be8356289171 100644 --- a/Userland/Applications/Browser/Tab.h +++ b/Userland/Applications/Browser/Tab.h @@ -8,11 +8,11 @@ #pragma once #include -#include #include #include #include #include +#include #include #include #include @@ -38,14 +38,14 @@ class Tab final : public GUI::Widget { public: virtual ~Tab() override; - URL url() const; + URL::URL url() const; enum class LoadType { Normal, HistoryNavigation, }; - void load(URL const&, LoadType = LoadType::Normal); + void load(URL::URL const&, LoadType = LoadType::Normal); void reload(); void go_back(int steps = 1); @@ -64,11 +64,11 @@ public: void window_size_changed(Gfx::IntSize); Function on_title_change; - Function on_tab_open_request; + Function on_tab_open_request; Function on_activate_tab_request; Function on_tab_close_request; Function on_tab_close_other_request; - Function on_window_open_request; + Function on_window_open_request; Function on_favicon_change; Function()> on_get_cookies_entries; Function()> on_get_local_storage_entries; @@ -104,8 +104,8 @@ private: void update_actions(); ErrorOr bookmark_current_url(); void update_bookmark_button(StringView url); - void start_download(const URL& url); - void view_source(const URL& url, ByteString const& source); + void start_download(const URL::URL& url); + void view_source(const URL::URL& url, ByteString const& source); void update_status(Optional text_override = {}, i32 count_waiting = 0); void close_sub_widgets(); @@ -129,11 +129,11 @@ private: RefPtr m_link_context_menu; RefPtr m_link_context_menu_default_action; RefPtr m_link_copy_action; - URL m_link_context_menu_url; + URL::URL m_link_context_menu_url; RefPtr m_image_context_menu; Gfx::ShareableBitmap m_image_context_menu_bitmap; - URL m_image_context_menu_url; + URL::URL m_image_context_menu_url; RefPtr m_audio_context_menu; RefPtr m_video_context_menu; @@ -141,7 +141,7 @@ private: RefPtr m_media_context_menu_mute_unmute_action; RefPtr m_media_context_menu_controls_action; RefPtr m_media_context_menu_loop_action; - URL m_media_context_menu_url; + URL::URL m_media_context_menu_url; RefPtr m_tab_context_menu; @@ -157,7 +157,7 @@ private: ByteString m_title; RefPtr m_icon; - Optional m_navigating_url; + Optional m_navigating_url; bool m_loaded { false }; bool m_is_history_navigation { false }; diff --git a/Userland/Applications/Browser/URLBox.cpp b/Userland/Applications/Browser/URLBox.cpp index a05eb096ca118df5e841a7214c89207bef9829be..29249fbfc5cc13fcd4eca6016d54868cc43f67c0 100644 --- a/Userland/Applications/Browser/URLBox.cpp +++ b/Userland/Applications/Browser/URLBox.cpp @@ -4,10 +4,10 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include #include #include #include +#include #include namespace Browser { diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index 77f1c68038d7462db0b970307a2a74a322569be6..0ea8e780b450947beeb722e88e9c87fe2f6c293f 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -164,7 +164,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } } - Vector initial_urls; + Vector initial_urls; for (auto specified_url : specified_urls) { if (auto url = WebView::sanitize_url(specified_url); url.has_value()) diff --git a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp index 42929210dd5c77740915b25f340fe58e99091f06..cef9c099163af312381abf13972c3abdf0582c04 100644 --- a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp @@ -197,7 +197,7 @@ void BrowserSettingsWidget::set_search_engine_url(StringView url) void BrowserSettingsWidget::apply_settings() { auto homepage_url = m_homepage_url_textbox->text(); - if (!URL(homepage_url).is_valid()) { + if (!URL::URL(homepage_url).is_valid()) { GUI::MessageBox::show_error(this->window(), "The homepage URL you have entered is not valid"sv); m_homepage_url_textbox->select_all(); m_homepage_url_textbox->set_focus(true); @@ -206,7 +206,7 @@ void BrowserSettingsWidget::apply_settings() Config::write_string("Browser"sv, "Preferences"sv, "Home"sv, homepage_url); auto new_tab_url = m_new_tab_url_textbox->text(); - if (!URL(new_tab_url).is_valid()) { + if (!URL::URL(new_tab_url).is_valid()) { GUI::MessageBox::show_error(this->window(), "The new tab URL you have entered is not valid"sv); m_new_tab_url_textbox->select_all(); m_new_tab_url_textbox->set_focus(true); diff --git a/Userland/Applications/BrowserSettings/CMakeLists.txt b/Userland/Applications/BrowserSettings/CMakeLists.txt index 94c348a1df4cecfe4b5d0e4f005bc6ba3d10954b..620a2b5e562ff502af1bc27c8ed7b9150714af23 100644 --- a/Userland/Applications/BrowserSettings/CMakeLists.txt +++ b/Userland/Applications/BrowserSettings/CMakeLists.txt @@ -19,4 +19,4 @@ set(SOURCES ) serenity_app(BrowserSettings ICON app-browser) -target_link_libraries(BrowserSettings PRIVATE LibCore LibGfx LibGUI LibConfig LibMain LibWebView) +target_link_libraries(BrowserSettings PRIVATE LibCore LibGfx LibGUI LibConfig LibMain LibWebView LibURL) diff --git a/Userland/Applications/Calculator/CMakeLists.txt b/Userland/Applications/Calculator/CMakeLists.txt index 676e8389317a722fab133e4d7e42ecbc25fbfde8..4429ffe4aa70af38971968a612817f92bce448fa 100644 --- a/Userland/Applications/Calculator/CMakeLists.txt +++ b/Userland/Applications/Calculator/CMakeLists.txt @@ -15,4 +15,4 @@ set(SOURCES ) serenity_app(Calculator ICON app-calculator) -target_link_libraries(Calculator PRIVATE LibCore LibCrypto LibDesktop LibGfx LibGUI LibMain) +target_link_libraries(Calculator PRIVATE LibCore LibCrypto LibDesktop LibGfx LibGUI LibMain LibURL) diff --git a/Userland/Applications/Calculator/main.cpp b/Userland/Applications/Calculator/main.cpp index 3f3660107213f8e8e10d2e5310e294849f0e7105..0a67ba196fcae0c587bb90eb19d04f29fb3daf5b 100644 --- a/Userland/Applications/Calculator/main.cpp +++ b/Userland/Applications/Calculator/main.cpp @@ -5,7 +5,6 @@ */ #include "CalculatorWidget.h" -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { diff --git a/Userland/Applications/Calendar/CMakeLists.txt b/Userland/Applications/Calendar/CMakeLists.txt index fc0b5ee2242b07be9331990fde345033ec0880bb..a435011dc28835b94162f5e8c7db45436ea0593c 100644 --- a/Userland/Applications/Calendar/CMakeLists.txt +++ b/Userland/Applications/Calendar/CMakeLists.txt @@ -22,4 +22,4 @@ set(SOURCES ) serenity_app(Calendar ICON app-calendar) -target_link_libraries(Calendar PRIVATE LibConfig LibCore LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibMain LibDesktop) +target_link_libraries(Calendar PRIVATE LibConfig LibCore LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibMain LibDesktop LibURL) diff --git a/Userland/Applications/CharacterMap/CMakeLists.txt b/Userland/Applications/CharacterMap/CMakeLists.txt index 053bce24d2c171bfd93c47ed7ae87fe56e06fe1d..42d1f29121b0f21dac96bf5a992f3a2572778204 100644 --- a/Userland/Applications/CharacterMap/CMakeLists.txt +++ b/Userland/Applications/CharacterMap/CMakeLists.txt @@ -20,4 +20,4 @@ set(GENERATED_SOURCES ) serenity_app(CharacterMap ICON app-character-map) -target_link_libraries(CharacterMap PRIVATE LibConfig LibCore LibDesktop LibGfx LibGUI LibMain LibUnicode) +target_link_libraries(CharacterMap PRIVATE LibConfig LibCore LibDesktop LibGfx LibGUI LibMain LibUnicode LibURL) diff --git a/Userland/Applications/CharacterMap/main.cpp b/Userland/Applications/CharacterMap/main.cpp index afb939850b117bc010adb6595808c024dd9c3087..faf9716c9445e0083bca3fd2e7365a4f7beeae1e 100644 --- a/Userland/Applications/CharacterMap/main.cpp +++ b/Userland/Applications/CharacterMap/main.cpp @@ -6,7 +6,6 @@ #include "CharacterMapWidget.h" #include "SearchCharacters.h" -#include #include #include #include @@ -16,6 +15,7 @@ #include #include #include +#include static void search_and_print_results(ByteString const& query) { diff --git a/Userland/Applications/CrashReporter/CMakeLists.txt b/Userland/Applications/CrashReporter/CMakeLists.txt index 5430fc3a216c521d7f2cb7fd13d25b286f08a14d..4c6a8f6c305e41886a11d82bd772b829c684adc4 100644 --- a/Userland/Applications/CrashReporter/CMakeLists.txt +++ b/Userland/Applications/CrashReporter/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_app(CrashReporter ICON app-crash-reporter) -target_link_libraries(CrashReporter PRIVATE LibCore LibCoredump LibDebug LibDesktop LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibMain LibThreading) +target_link_libraries(CrashReporter PRIVATE LibCore LibCoredump LibDebug LibDesktop LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibMain LibThreading LibURL) diff --git a/Userland/Applications/CrashReporter/main.cpp b/Userland/Applications/CrashReporter/main.cpp index d513d80afe53c49556bf9fb7b89abe0bc29984ae..c2ec437d240b3fafa54f7dcb6d674aa467d1d9a6 100644 --- a/Userland/Applications/CrashReporter/main.cpp +++ b/Userland/Applications/CrashReporter/main.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -37,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Applications/DisplaySettings/CMakeLists.txt b/Userland/Applications/DisplaySettings/CMakeLists.txt index 469f10dc7ad9bce8f5c63f1a797318e1454d8dc6..c150c66b4481c2f4ac80c9af68a986baa7693175 100644 --- a/Userland/Applications/DisplaySettings/CMakeLists.txt +++ b/Userland/Applications/DisplaySettings/CMakeLists.txt @@ -33,4 +33,4 @@ set(GENERATED_SOURCES ) serenity_app(DisplaySettings ICON app-display-settings) -target_link_libraries(DisplaySettings PRIVATE LibCore LibDesktop LibGfx LibGUI LibConfig LibIPC LibMain LibEDID LibThreading LibFileSystemAccessClient) +target_link_libraries(DisplaySettings PRIVATE LibCore LibDesktop LibGfx LibGUI LibConfig LibIPC LibMain LibEDID LibThreading LibFileSystemAccessClient LibURL) diff --git a/Userland/Applications/FileManager/CMakeLists.txt b/Userland/Applications/FileManager/CMakeLists.txt index d9aa0e3e7b4f10161e54b45e6ca64878b9199431..1bd19be091e3b8989a55696a09319cc4ff00097d 100644 --- a/Userland/Applications/FileManager/CMakeLists.txt +++ b/Userland/Applications/FileManager/CMakeLists.txt @@ -35,4 +35,4 @@ set(GENERATED_SOURCES ) serenity_app(FileManager ICON app-file-manager) -target_link_libraries(FileManager PRIVATE LibArchive LibAudio LibConfig LibCore LibDesktop LibFileSystem LibGfx LibGUI LibMain LibPDF LibThreading) +target_link_libraries(FileManager PRIVATE LibArchive LibAudio LibConfig LibCore LibDesktop LibFileSystem LibGfx LibGUI LibMain LibPDF LibThreading LibURL) diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index 541667669ef765b93956946c5fb82ee4c3d9ea7e..535e2cf2273ad834056f0d21ba8e92342f215054 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -67,7 +67,7 @@ RefPtr DirectoryView::get_default_launch_handler(Vector> DirectoryView::get_launch_handlers(URL const& url) +Vector> DirectoryView::get_launch_handlers(URL::URL const& url) { Vector> handlers; for (auto& h : Desktop::Launcher::get_handlers_with_details_for_url(url)) { @@ -491,7 +491,7 @@ void DirectoryView::set_should_show_dotfiles(bool show_dotfiles) m_model->set_should_show_dotfiles(show_dotfiles); } -void DirectoryView::launch(URL const&, LauncherHandler const& launcher_handler) const +void DirectoryView::launch(URL::URL const&, LauncherHandler const& launcher_handler) const { pid_t child; diff --git a/Userland/Applications/FileManager/DirectoryView.h b/Userland/Applications/FileManager/DirectoryView.h index 3ef39a480009e5fd08a6f9e9c23e43b0d46646bb..bcfffb384ac2b70cf77946617aac87afce02a5dd 100644 --- a/Userland/Applications/FileManager/DirectoryView.h +++ b/Userland/Applications/FileManager/DirectoryView.h @@ -6,7 +6,6 @@ #pragma once -#include #include #include #include @@ -16,6 +15,7 @@ #include #include #include +#include #include #include @@ -59,12 +59,12 @@ public: int path_history_size() const { return m_path_history.size(); } int path_history_position() const { return m_path_history_position; } static RefPtr get_default_launch_handler(Vector> const& handlers); - static Vector> get_launch_handlers(URL const& url); + static Vector> get_launch_handlers(URL::URL const& url); static Vector> get_launch_handlers(ByteString const& path); void refresh(); - void launch(URL const&, LauncherHandler const&) const; + void launch(URL::URL const&, LauncherHandler const&) const; Function on_path_change; Function on_selection_change; diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 7cadff815de2bbba6575bea76519228bdef053e0..4c85c59a410c7ff066d0232179bc053dbce54a39 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -49,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -197,7 +197,7 @@ void do_paste(ByteString const& target_directory, GUI::Window* window) for (auto& uri_as_string : copied_lines) { if (uri_as_string.is_empty()) continue; - URL url = uri_as_string; + URL::URL url = uri_as_string; if (!url.is_valid() || url.scheme() != "file") { dbgln("Cannot paste URI {}", uri_as_string); continue; diff --git a/Userland/Applications/FontEditor/CMakeLists.txt b/Userland/Applications/FontEditor/CMakeLists.txt index 9d03e0796c7664c9b89a2bd1a5ae354d3ccc5a83..0f5d0a00cbaed1b9892e9bf377707ee51348cd6e 100644 --- a/Userland/Applications/FontEditor/CMakeLists.txt +++ b/Userland/Applications/FontEditor/CMakeLists.txt @@ -25,4 +25,4 @@ set(GENERATED_SOURCES ) serenity_app(FontEditor ICON app-font-editor) -target_link_libraries(FontEditor PRIVATE LibConfig LibCore LibFileSystemAccessClient LibGUI LibDesktop LibGfx LibMain LibUnicode) +target_link_libraries(FontEditor PRIVATE LibConfig LibCore LibFileSystemAccessClient LibGUI LibDesktop LibGfx LibMain LibUnicode LibURL) diff --git a/Userland/Applications/FontEditor/main.cpp b/Userland/Applications/FontEditor/main.cpp index 6d85f83415aaf882eb0bca1c70df9d3c22054882..bdeb396c4ac3f87e801a3c909e01149596328330 100644 --- a/Userland/Applications/FontEditor/main.cpp +++ b/Userland/Applications/FontEditor/main.cpp @@ -5,7 +5,6 @@ */ #include "MainWidget.h" -#include #include #include #include @@ -15,6 +14,7 @@ #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { diff --git a/Userland/Applications/Help/CMakeLists.txt b/Userland/Applications/Help/CMakeLists.txt index 7b958012c4fa5d4a231ecb783be187cdcc12c7a2..e5f516321c0e5c9158992155d65bea790dfee7bc 100644 --- a/Userland/Applications/Help/CMakeLists.txt +++ b/Userland/Applications/Help/CMakeLists.txt @@ -16,5 +16,5 @@ set(SOURCES ) serenity_app(Help ICON app-help) -target_link_libraries(Help PRIVATE LibCore LibWebView LibWeb LibMarkdown LibGfx LibGUI LibDesktop LibMain LibManual LibLocale) +target_link_libraries(Help PRIVATE LibCore LibWebView LibWeb LibMarkdown LibGfx LibGUI LibDesktop LibMain LibManual LibLocale LibURL) link_with_locale_data(Help) diff --git a/Userland/Applications/Help/MainWidget.cpp b/Userland/Applications/Help/MainWidget.cpp index de19b10497224cf216b44f8f6623a647739b05ba..cecd7d8734547fb85bfaa4824f0cd66763587aed 100644 --- a/Userland/Applications/Help/MainWidget.cpp +++ b/Userland/Applications/Help/MainWidget.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -35,6 +34,7 @@ #include #include #include +#include namespace Help { @@ -154,7 +154,7 @@ ErrorOr MainWidget::initialize(GUI::Window& window) m_copy_action->set_enabled(!m_web_view->selected_text().is_empty()); m_context_menu->popup(screen_position); }; - m_web_view->on_link_hover = [this](URL const& url) { + m_web_view->on_link_hover = [this](URL::URL const& url) { if (url.is_valid()) m_statusbar->set_text(String::from_byte_string(url.to_byte_string()).release_value_but_fixme_should_propagate_errors()); else @@ -245,7 +245,7 @@ ErrorOr MainWidget::initialize(GUI::Window& window) return {}; } -void MainWidget::open_url(URL const& url) +void MainWidget::open_url(URL::URL const& url) { m_go_back_action->set_enabled(m_history.can_go_back()); m_go_forward_action->set_enabled(m_history.can_go_forward()); @@ -273,7 +273,7 @@ void MainWidget::open_url(URL const& url) } } -void MainWidget::open_external(URL const& url) +void MainWidget::open_external(URL::URL const& url) { if (!Desktop::Launcher::open(url)) GUI::MessageBox::show(window(), ByteString::formatted("The link to '{}' could not be opened.", url), "Failed to open link"sv, GUI::MessageBox::Type::Error); diff --git a/Userland/Applications/Help/MainWidget.h b/Userland/Applications/Help/MainWidget.h index f56c0c2c0e4fd2f92eba38b88039e6955e4d45f3..d6adbf6f935844599553bbb256ac3281c7895cd6 100644 --- a/Userland/Applications/Help/MainWidget.h +++ b/Userland/Applications/Help/MainWidget.h @@ -27,9 +27,9 @@ public: private: MainWidget(); - void open_url(URL const&); + void open_url(URL::URL const&); void open_page(Optional const& path); - void open_external(URL const&); + void open_external(URL::URL const&); History m_history; RefPtr m_context_menu; diff --git a/Userland/Applications/Help/main.cpp b/Userland/Applications/Help/main.cpp index 0afc99cd0faa6c5b36b1b9af6e44fe5b05ead4a4..f0513d01988309826a09596761ae706e775c69a0 100644 --- a/Userland/Applications/Help/main.cpp +++ b/Userland/Applications/Help/main.cpp @@ -8,13 +8,13 @@ */ #include "MainWidget.h" -#include #include #include #include #include #include #include +#include using namespace Help; diff --git a/Userland/Applications/HexEditor/CMakeLists.txt b/Userland/Applications/HexEditor/CMakeLists.txt index d63e3a1cb86529b0ac82f69f44c3ae6c0f32fe2b..212bc5d587511d1ec8ddc98a83e466172f24ac6c 100644 --- a/Userland/Applications/HexEditor/CMakeLists.txt +++ b/Userland/Applications/HexEditor/CMakeLists.txt @@ -25,4 +25,4 @@ set(SOURCES ) serenity_app(HexEditor ICON app-hex-editor) -target_link_libraries(HexEditor PRIVATE LibCore LibGfx LibGUI LibConfig LibDesktop LibFileSystemAccessClient LibMain LibTextCodec) +target_link_libraries(HexEditor PRIVATE LibCore LibGfx LibGUI LibConfig LibDesktop LibFileSystemAccessClient LibMain LibTextCodec LibURL) diff --git a/Userland/Applications/ImageViewer/CMakeLists.txt b/Userland/Applications/ImageViewer/CMakeLists.txt index 66718d6ff12c958b1f65d0d0af8c3fb691bf759a..1d09b71fa9e9a8c3b6fe9104d0d583817a3e0b8f 100644 --- a/Userland/Applications/ImageViewer/CMakeLists.txt +++ b/Userland/Applications/ImageViewer/CMakeLists.txt @@ -11,5 +11,5 @@ set(SOURCES ViewWidget.cpp ) -serenity_app(ImageViewer ICON app-image-viewer) -target_link_libraries(ImageViewer PRIVATE LibCore LibDesktop LibFileSystemAccessClient LibGUI LibGfx LibConfig LibImageDecoderClient LibMain) +serenity_app(ImageViewer ICON filetype-image) +target_link_libraries(ImageViewer PRIVATE LibCore LibDesktop LibFileSystemAccessClient LibGUI LibGfx LibConfig LibImageDecoderClient LibMain LibURL) diff --git a/Userland/Applications/ImageViewer/main.cpp b/Userland/Applications/ImageViewer/main.cpp index f9789a2e9650c1cf8d057afe92985b2bdd9d0ed8..2e65d8e578b0910b70afb66b76119edc8cdab9eb 100644 --- a/Userland/Applications/ImageViewer/main.cpp +++ b/Userland/Applications/ImageViewer/main.cpp @@ -8,7 +8,6 @@ #include "MainWidget.h" #include "ViewWidget.h" -#include #include #include #include @@ -32,6 +31,7 @@ #include #include #include +#include #include #include diff --git a/Userland/Applications/Magnifier/CMakeLists.txt b/Userland/Applications/Magnifier/CMakeLists.txt index 2b2b039b01fc45029e6ae02d8529674e595d4615..21ae179cd3e234271aaa55af787aa79557bcc00a 100644 --- a/Userland/Applications/Magnifier/CMakeLists.txt +++ b/Userland/Applications/Magnifier/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_app(Magnifier ICON app-magnifier) -target_link_libraries(Magnifier PRIVATE LibConfig LibCore LibDesktop LibGfx LibGUI LibIPC LibMain LibFileSystemAccessClient) +target_link_libraries(Magnifier PRIVATE LibConfig LibCore LibDesktop LibGfx LibGUI LibIPC LibMain LibFileSystemAccessClient LibURL) diff --git a/Userland/Applications/Mail/CMakeLists.txt b/Userland/Applications/Mail/CMakeLists.txt index cd8ba0c12a2a177cb180ae24e5a3617738a32771..dfab2b0a95a64ede5575c16d1a105219eba9e34d 100644 --- a/Userland/Applications/Mail/CMakeLists.txt +++ b/Userland/Applications/Mail/CMakeLists.txt @@ -20,4 +20,4 @@ set(GENERATED_SOURCES ) serenity_app(Mail ICON app-mail) -target_link_libraries(Mail PRIVATE LibConfig LibCore LibDesktop LibGfx LibGUI LibIMAP LibWebView LibWeb LibMain) +target_link_libraries(Mail PRIVATE LibConfig LibCore LibDesktop LibGfx LibGUI LibIMAP LibWebView LibWeb LibMain LibURL) diff --git a/Userland/Applications/Mail/MailWidget.h b/Userland/Applications/Mail/MailWidget.h index bfd4cc4f257288bc2acb735551fcd6a1ab026acd..3b25b93e92eaf36b5502e1f907369c0f654163fa 100644 --- a/Userland/Applications/Mail/MailWidget.h +++ b/Userland/Applications/Mail/MailWidget.h @@ -49,11 +49,11 @@ private: RefPtr m_link_context_menu; RefPtr m_link_context_menu_default_action; - URL m_link_context_menu_url; + URL::URL m_link_context_menu_url; RefPtr m_image_context_menu; Gfx::ShareableBitmap m_image_context_menu_bitmap; - URL m_image_context_menu_url; + URL::URL m_image_context_menu_url; OwnPtr m_account_holder; }; diff --git a/Userland/Applications/Maps/CMakeLists.txt b/Userland/Applications/Maps/CMakeLists.txt index 6494d152acd43c8f61fdc91529cafa3c5e9f629b..132fb5be559571409e0ae6136e59aa9f8b0430d6 100644 --- a/Userland/Applications/Maps/CMakeLists.txt +++ b/Userland/Applications/Maps/CMakeLists.txt @@ -21,4 +21,4 @@ set(SOURCES ) serenity_app(Maps ICON app-maps) -target_link_libraries(Maps PRIVATE LibConfig LibCore LibDesktop LibGfx LibGUI LibMain LibProtocol) +target_link_libraries(Maps PRIVATE LibConfig LibCore LibDesktop LibGfx LibGUI LibMain LibProtocol LibURL) diff --git a/Userland/Applications/Maps/MapWidget.cpp b/Userland/Applications/Maps/MapWidget.cpp index 6a6ce5bfea4c8c8a02082c02ae9a0ef539ff901b..9df7b7b0e4b277ef70b98356dc103e4b052c47bd 100644 --- a/Userland/Applications/Maps/MapWidget.cpp +++ b/Userland/Applications/Maps/MapWidget.cpp @@ -6,7 +6,6 @@ */ #include "MapWidget.h" -#include #include #include #include @@ -15,6 +14,7 @@ #include #include #include +#include namespace Maps { @@ -74,7 +74,7 @@ MapWidget::MapWidget(Options const& options) m_request_client = Protocol::RequestClient::try_create().release_value_but_fixme_should_propagate_errors(); if (options.attribution_enabled) { auto attribution_text = options.attribution_text.value_or(MUST(String::from_byte_string(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderAttributionText"sv, Maps::default_tile_provider_attribution_text)))); - URL attribution_url = options.attribution_url.value_or(URL(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderAttributionUrl"sv, Maps::default_tile_provider_attribution_url))); + URL::URL attribution_url = options.attribution_url.value_or(URL::URL(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderAttributionUrl"sv, Maps::default_tile_provider_attribution_url))); add_panel({ attribution_text, Panel::Position::BottomRight, attribution_url, "attribution"_string }); } m_marker_image = Gfx::Bitmap::load_from_file("/res/graphics/maps/marker-blue.png"sv).release_value_but_fixme_should_propagate_errors(); @@ -117,7 +117,7 @@ void MapWidget::config_string_did_change(StringView domain, StringView group, St // Update attribution panel url when it exists for (auto& panel : m_panels) { if (panel.name == "attribution") { - panel.url = URL(value); + panel.url = URL::URL(value); return; } } @@ -248,19 +248,19 @@ void MapWidget::context_menu_event(GUI::ContextMenuEvent& event) auto link_icon = MUST(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-symlink.png"sv)); m_context_menu->add_action(GUI::Action::create( "Open in &OpenStreetMap", link_icon, [this](auto&) { - Desktop::Launcher::open(URL(MUST(String::formatted("https://www.openstreetmap.org/#map={}/{}/{}", m_zoom, m_context_menu_latlng.latitude, m_context_menu_latlng.longitude)))); + Desktop::Launcher::open(URL::URL(MUST(String::formatted("https://www.openstreetmap.org/#map={}/{}/{}", m_zoom, m_context_menu_latlng.latitude, m_context_menu_latlng.longitude)))); })); m_context_menu->add_action(GUI::Action::create( "Open in &Google Maps", link_icon, [this](auto&) { - Desktop::Launcher::open(URL(MUST(String::formatted("https://www.google.com/maps/@{},{},{}z", m_context_menu_latlng.latitude, m_context_menu_latlng.longitude, m_zoom)))); + Desktop::Launcher::open(URL::URL(MUST(String::formatted("https://www.google.com/maps/@{},{},{}z", m_context_menu_latlng.latitude, m_context_menu_latlng.longitude, m_zoom)))); })); m_context_menu->add_action(GUI::Action::create( "Open in &Bing Maps", link_icon, [this](auto&) { - Desktop::Launcher::open(URL(MUST(String::formatted("https://www.bing.com/maps/?cp={}~{}&lvl={}", m_context_menu_latlng.latitude, m_context_menu_latlng.longitude, m_zoom)))); + Desktop::Launcher::open(URL::URL(MUST(String::formatted("https://www.bing.com/maps/?cp={}~{}&lvl={}", m_context_menu_latlng.latitude, m_context_menu_latlng.longitude, m_zoom)))); })); m_context_menu->add_action(GUI::Action::create( "Open in &DuckDuckGo Maps", link_icon, [this](auto&) { - Desktop::Launcher::open(URL(MUST(String::formatted("https://duckduckgo.com/?q={},+{}&ia=web&iaxm=maps", m_context_menu_latlng.latitude, m_context_menu_latlng.longitude)))); + Desktop::Launcher::open(URL::URL(MUST(String::formatted("https://duckduckgo.com/?q={},+{}&ia=web&iaxm=maps", m_context_menu_latlng.latitude, m_context_menu_latlng.longitude)))); })); m_context_menu->add_separator(); m_context_menu->add_action(GUI::Action::create( @@ -318,7 +318,7 @@ void MapWidget::process_tile_queue() HashMap headers; headers.set("User-Agent", "SerenityOS Maps"); headers.set("Accept", "image/png"); - URL url(MUST(String::formatted(m_tile_provider.value_or(m_default_tile_provider), tile_key.zoom, tile_key.x, tile_key.y))); + URL::URL url(MUST(String::formatted(m_tile_provider.value_or(m_default_tile_provider), tile_key.zoom, tile_key.x, tile_key.y))); auto request = m_request_client->start_request("GET", url, headers, {}); VERIFY(!request.is_null()); diff --git a/Userland/Applications/Maps/MapWidget.h b/Userland/Applications/Maps/MapWidget.h index ae721bd4c6eb4a8e419475e9a9a4a63ed2aad53f..ca08cfc8a73f518d7ee7ac90f07f342df0f9dd24 100644 --- a/Userland/Applications/Maps/MapWidget.h +++ b/Userland/Applications/Maps/MapWidget.h @@ -48,7 +48,7 @@ public: int scale_max_width { 100 }; bool attribution_enabled { true }; Optional attribution_text {}; - Optional attribution_url {}; + Optional attribution_url {}; }; LatLng center() const { return m_center; } @@ -90,7 +90,7 @@ public: }; String text; Position position; - Optional url {}; + Optional url {}; Optional name {}; Gfx::IntRect rect { 0, 0, 0, 0 }; }; @@ -188,7 +188,7 @@ private: bool m_scale_enabled {}; int m_scale_max_width {}; bool m_attribution_enabled {}; - URL m_attribution_url; + URL::URL m_attribution_url; bool m_dragging { false }; int m_last_mouse_x { 0 }; int m_last_mouse_y { 0 }; diff --git a/Userland/Applications/Maps/SearchPanel.cpp b/Userland/Applications/Maps/SearchPanel.cpp index 82cf13330cbea16d4bee8f1e3831092353636c68..6376f54e7e4cfed271dbbec10b49d27267150660 100644 --- a/Userland/Applications/Maps/SearchPanel.cpp +++ b/Userland/Applications/Maps/SearchPanel.cpp @@ -55,7 +55,7 @@ void SearchPanel::search(StringView query) HashMap headers; headers.set("User-Agent", "SerenityOS Maps"); headers.set("Accept", "application/json"); - URL url(MUST(String::formatted("https://nominatim.openstreetmap.org/search?q={}&format=json", URL::percent_encode(query, URL::PercentEncodeSet::Query)))); + URL::URL url(MUST(String::formatted("https://nominatim.openstreetmap.org/search?q={}&format=json", URL::percent_encode(query, URL::PercentEncodeSet::Query)))); auto request = m_request_client->start_request("GET", url, headers, {}); VERIFY(!request.is_null()); m_request = request; diff --git a/Userland/Applications/Maps/UsersMapWidget.cpp b/Userland/Applications/Maps/UsersMapWidget.cpp index aa66a446dec6bc26737d7ede086ab6c02893d5a2..ab962ba03448460154c72fae977898eaf639802f 100644 --- a/Userland/Applications/Maps/UsersMapWidget.cpp +++ b/Userland/Applications/Maps/UsersMapWidget.cpp @@ -22,7 +22,7 @@ void UsersMapWidget::get_users() HashMap headers; headers.set("User-Agent", "SerenityOS Maps"); headers.set("Accept", "application/json"); - URL url("https://usermap.serenityos.org/people.json"); + URL::URL url("https://usermap.serenityos.org/people.json"); auto request = request_client()->start_request("GET", url, headers, {}); VERIFY(!request.is_null()); m_request = request; diff --git a/Userland/Applications/MapsSettings/CMakeLists.txt b/Userland/Applications/MapsSettings/CMakeLists.txt index 488f36e596286b89493fdb35bdbecf2816ba950b..b88391153dcbdfeddbab318b26645ab4f86ecc50 100644 --- a/Userland/Applications/MapsSettings/CMakeLists.txt +++ b/Userland/Applications/MapsSettings/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_app(MapsSettings ICON app-maps) -target_link_libraries(MapsSettings PRIVATE LibConfig LibCore LibGfx LibGUI LibMain) +target_link_libraries(MapsSettings PRIVATE LibConfig LibCore LibGfx LibGUI LibMain LibURL) diff --git a/Userland/Applications/PDFViewer/CMakeLists.txt b/Userland/Applications/PDFViewer/CMakeLists.txt index e9c235e7b4abb6efd0b74db7fbc385164271871a..5b58772f3fcbf6ed029a10b85683f6b49ca6a958 100644 --- a/Userland/Applications/PDFViewer/CMakeLists.txt +++ b/Userland/Applications/PDFViewer/CMakeLists.txt @@ -12,4 +12,4 @@ set(SOURCES ) serenity_app(PDFViewer ICON app-pdf-viewer) -target_link_libraries(PDFViewer PRIVATE LibCore LibGfx LibGUI LibPDF LibFileSystemAccessClient LibConfig LibMain) +target_link_libraries(PDFViewer PRIVATE LibCore LibGfx LibGUI LibPDF LibFileSystemAccessClient LibConfig LibMain LibURL) diff --git a/Userland/Applications/PixelPaint/CMakeLists.txt b/Userland/Applications/PixelPaint/CMakeLists.txt index c741105ac81c4f9209e98cdb97492a5ab9c5a369..d19a485d44d8dfa6f3f1b39d710cfd39b3eeacf2 100644 --- a/Userland/Applications/PixelPaint/CMakeLists.txt +++ b/Userland/Applications/PixelPaint/CMakeLists.txt @@ -91,4 +91,4 @@ set(GENERATED_SOURCES ) serenity_app(PixelPaint ICON app-pixel-paint) -target_link_libraries(PixelPaint PRIVATE LibCore LibImageDecoderClient LibGUI LibGfx LibFileSystemAccessClient LibConfig LibDesktop LibMain LibThreading) +target_link_libraries(PixelPaint PRIVATE LibCore LibImageDecoderClient LibGUI LibGfx LibFileSystemAccessClient LibConfig LibDesktop LibMain LibThreading LibURL) diff --git a/Userland/Applications/Presenter/CMakeLists.txt b/Userland/Applications/Presenter/CMakeLists.txt index 40938869ed5c484a814a4f6e1fe1cfbd5bff3149..13d6192b6ba30d2ceab4bd9b5eec3cd543e356c2 100644 --- a/Userland/Applications/Presenter/CMakeLists.txt +++ b/Userland/Applications/Presenter/CMakeLists.txt @@ -14,4 +14,4 @@ set(SOURCES SlideObject.cpp ) serenity_app(Presenter ICON app-presenter) -target_link_libraries(Presenter PRIVATE LibWebView LibGUI LibGfx LibFileSystemAccessClient LibCore LibDesktop LibMain) +target_link_libraries(Presenter PRIVATE LibWebView LibGUI LibGfx LibFileSystemAccessClient LibCore LibDesktop LibMain LibURL) diff --git a/Userland/Applications/Presenter/SlideObject.cpp b/Userland/Applications/Presenter/SlideObject.cpp index 44d31d4fb71c27d7209b5deed9b72b9d5c6c859e..a3cb7afd909164ecfbaaceb639726d6afd6f78f3 100644 --- a/Userland/Applications/Presenter/SlideObject.cpp +++ b/Userland/Applications/Presenter/SlideObject.cpp @@ -7,10 +7,10 @@ #include "SlideObject.h" #include "Presentation.h" #include -#include #include #include #include +#include static ByteString to_css_length(float design_value, Presentation const& presentation) { diff --git a/Userland/Applications/Run/CMakeLists.txt b/Userland/Applications/Run/CMakeLists.txt index dbaee6f6b008f45535b7ecfb5f9b7c1fb74b26b6..46af0a3f2a67cfb39d528e2c2a23a8e0cf8c2926 100644 --- a/Userland/Applications/Run/CMakeLists.txt +++ b/Userland/Applications/Run/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_app(Run ICON app-run) -target_link_libraries(Run PRIVATE LibCore LibFileSystem LibDesktop LibGfx LibGUI LibMain) +target_link_libraries(Run PRIVATE LibCore LibFileSystem LibDesktop LibGfx LibGUI LibMain LibURL) diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp index 459cd21889e2f571f89ed8940f6c7414b83bc0b1..00db397147fe2c68b15293425e321430b121a042 100644 --- a/Userland/Applications/Run/RunWindow.cpp +++ b/Userland/Applications/Run/RunWindow.cpp @@ -8,7 +8,6 @@ #include "RunWindow.h" #include "MainWidget.h" #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Applications/SoundPlayer/CMakeLists.txt b/Userland/Applications/SoundPlayer/CMakeLists.txt index 568698bbe43289193b98b9827ec2b23513bde96a..b2cf2edbd27a9ea6db986538329370db8bb0ac4d 100644 --- a/Userland/Applications/SoundPlayer/CMakeLists.txt +++ b/Userland/Applications/SoundPlayer/CMakeLists.txt @@ -19,4 +19,4 @@ set(SOURCES ) serenity_app(SoundPlayer ICON app-sound-player) -target_link_libraries(SoundPlayer PRIVATE LibAudio LibConfig LibCore LibFileSystem LibDSP LibGfx LibGUI LibIPC LibMain LibThreading LibImageDecoderClient) +target_link_libraries(SoundPlayer PRIVATE LibAudio LibConfig LibCore LibFileSystem LibDSP LibGfx LibGUI LibIPC LibMain LibThreading LibImageDecoderClient LibURL) diff --git a/Userland/Applications/SpaceAnalyzer/CMakeLists.txt b/Userland/Applications/SpaceAnalyzer/CMakeLists.txt index 5ae1961511a20dbd1dcdac830f72d63e057befca..4be9dd2eb9e3f45d90477341b4a5f5ac077d9217 100644 --- a/Userland/Applications/SpaceAnalyzer/CMakeLists.txt +++ b/Userland/Applications/SpaceAnalyzer/CMakeLists.txt @@ -14,4 +14,4 @@ set(SOURCES ) serenity_app(SpaceAnalyzer ICON app-space-analyzer) -target_link_libraries(SpaceAnalyzer PRIVATE LibCore LibDesktop LibFileSystem LibGfx LibGUI LibIPC LibMain) +target_link_libraries(SpaceAnalyzer PRIVATE LibCore LibDesktop LibFileSystem LibGfx LibGUI LibIPC LibMain LibURL) diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 456b974ecf7674123ba0867d3efbe44a5c4249b0..738a175f586b98f70e89a8459461245c004a9ad3 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -10,7 +10,6 @@ #include "TreeMapWidget.h" #include #include -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include static auto const APP_NAME = "Space Analyzer"_string; diff --git a/Userland/Applications/Spreadsheet/CMakeLists.txt b/Userland/Applications/Spreadsheet/CMakeLists.txt index 1c03f149bfc9a8f9903ab5827dcaa1b6c0af55e2..3613ce0d86e458a15d78b8a6c8f339abd646b32f 100644 --- a/Userland/Applications/Spreadsheet/CMakeLists.txt +++ b/Userland/Applications/Spreadsheet/CMakeLists.txt @@ -42,7 +42,7 @@ set(GENERATED_SOURCES ) serenity_app(Spreadsheet ICON app-spreadsheet) -target_link_libraries(Spreadsheet PRIVATE LibConfig LibCore LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibJS LibMain LibMarkdown LibSyntax LibWebView LibWeb) +target_link_libraries(Spreadsheet PRIVATE LibConfig LibCore LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibJS LibMain LibMarkdown LibSyntax LibWebView LibWeb LibURL) serenity_test(Writers/Test/TestXSVWriter.cpp Spreadsheet) diff --git a/Userland/Applications/Spreadsheet/Position.h b/Userland/Applications/Spreadsheet/Position.h index 2c7d4feae0f7b988fc15297e8065deeb4364acfc..04558f4b8380f08b721788c1d08ba1cf61f9d2cb 100644 --- a/Userland/Applications/Spreadsheet/Position.h +++ b/Userland/Applications/Spreadsheet/Position.h @@ -8,7 +8,7 @@ #include #include -#include +#include namespace Spreadsheet { @@ -38,7 +38,7 @@ struct Position { } ByteString to_cell_identifier(Sheet const& sheet) const; - URL to_url(Sheet const& sheet) const; + URL::URL to_url(Sheet const& sheet) const; size_t column { 0 }; size_t row { 0 }; diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 2285c75940524cbf6e4923e1e7d8af09dda15a03..70e6ef97d6ae9a614fe7fd7a0dfcfbc7cf56b150 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -15,13 +15,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include @@ -243,7 +243,7 @@ Optional Sheet::column_arithmetic(StringView column_name, int offset return m_columns.last(); } -Cell* Sheet::from_url(const URL& url) +Cell* Sheet::from_url(const URL::URL& url) { auto maybe_position = position_from_url(url); if (!maybe_position.has_value()) @@ -252,7 +252,7 @@ Cell* Sheet::from_url(const URL& url) return at(maybe_position.value()); } -Optional Sheet::position_from_url(const URL& url) const +Optional Sheet::position_from_url(const URL::URL& url) const { if (!url.is_valid()) { dbgln("Invalid url: {}", url.to_byte_string()); @@ -747,9 +747,9 @@ ByteString Position::to_cell_identifier(Sheet const& sheet) const return ByteString::formatted("{}{}", sheet.column(column), row); } -URL Position::to_url(Sheet const& sheet) const +URL::URL Position::to_url(Sheet const& sheet) const { - URL url; + URL::URL url; url.set_scheme("spreadsheet"_string); url.set_host("cell"_string); url.set_paths({ ByteString::number(getpid()) }); diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.h b/Userland/Applications/Spreadsheet/Spreadsheet.h index 72d6a4fec31ddf1b15fa8d37f13f173d3fba040d..20e441a939ecc701576d2ebe39fff5bd6ec06c69 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.h +++ b/Userland/Applications/Spreadsheet/Spreadsheet.h @@ -53,9 +53,9 @@ public: Optional column_index(StringView column_name) const; Optional column_arithmetic(StringView column_name, int offset); - Cell* from_url(const URL&); - Cell const* from_url(const URL& url) const { return const_cast(this)->from_url(url); } - Optional position_from_url(const URL& url) const; + Cell* from_url(const URL::URL&); + Cell const* from_url(const URL::URL& url) const { return const_cast(this)->from_url(url); } + Optional position_from_url(const URL::URL& url) const; /// Resolve 'offset' to an absolute position assuming 'base' is at 'offset_base'. /// Effectively, "Walk the distance between 'offset' and 'offset_base' away from 'base'". diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp index f1c17af961de86f8e4babf3b515383b3ea0123bb..964755e2195565942da303677d47d096448b79f8 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp @@ -6,10 +6,10 @@ #include "SpreadsheetModel.h" #include "ConditionalFormatting.h" -#include #include #include #include +#include namespace Spreadsheet { diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp index e447b40db59ab51ff16236d016710163dbed08fc..0a052ca9d3aecae0495914ecdefab9bad257d809 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp @@ -7,7 +7,6 @@ #include "SpreadsheetView.h" #include "CellTypeDialog.h" #include -#include #include #include #include @@ -17,6 +16,7 @@ #include #include #include +#include namespace Spreadsheet { diff --git a/Userland/Applications/Terminal/CMakeLists.txt b/Userland/Applications/Terminal/CMakeLists.txt index f4622cf2ff29b0c8930be838f59ee3318b644f8a..f6884b73ca1473cb37217925db81266c33e95270 100644 --- a/Userland/Applications/Terminal/CMakeLists.txt +++ b/Userland/Applications/Terminal/CMakeLists.txt @@ -9,4 +9,4 @@ set(SOURCES ) serenity_app(Terminal ICON app-terminal) -target_link_libraries(Terminal PRIVATE LibConfig LibCore LibFileSystem LibDesktop LibGfx LibGUI LibVT LibMain) +target_link_libraries(Terminal PRIVATE LibConfig LibCore LibFileSystem LibDesktop LibGfx LibGUI LibVT LibMain LibURL) diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index a2a9f4063b4c5ff6c3cc836548878e0e1dd2651f..a7ef2f9bf69c01713ec32d07ebaff9b8b6e0b18b 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -36,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/Userland/Applications/TextEditor/CMakeLists.txt b/Userland/Applications/TextEditor/CMakeLists.txt index 331f89673f821ba5b3b3b380d135de625c796e99..fab90b141c7f73ce675b6c6588683f66e9d42533 100644 --- a/Userland/Applications/TextEditor/CMakeLists.txt +++ b/Userland/Applications/TextEditor/CMakeLists.txt @@ -18,4 +18,4 @@ set(GENERATED_SOURCES ) serenity_app(TextEditor ICON app-text-editor) -target_link_libraries(TextEditor PRIVATE LibCore LibWebView LibWeb LibMarkdown LibGfx LibGUI LibShell LibRegex LibDesktop LibCpp LibCMake LibJS LibSQL LibSyntax LibFileSystemAccessClient LibConfig LibMain) +target_link_libraries(TextEditor PRIVATE LibCore LibWebView LibWeb LibMarkdown LibGfx LibGUI LibShell LibRegex LibDesktop LibCpp LibCMake LibJS LibSQL LibSyntax LibFileSystemAccessClient LibConfig LibMain LibURL) diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp index 08ddcd5a1cbdea3bb750bed66be181303e40d6f1..fae57c30aca736898641ac25a64ba29b388ae231 100644 --- a/Userland/Applications/TextEditor/MainWidget.cpp +++ b/Userland/Applications/TextEditor/MainWidget.cpp @@ -8,7 +8,6 @@ #include "MainWidget.h" #include #include -#include #include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Applications/ThemeEditor/CMakeLists.txt b/Userland/Applications/ThemeEditor/CMakeLists.txt index aa9c49ac6290d13efe280a0bb15609a3da7073a5..acbcb9927fa2e2849f4a28a12e2b32f21b2c5436 100644 --- a/Userland/Applications/ThemeEditor/CMakeLists.txt +++ b/Userland/Applications/ThemeEditor/CMakeLists.txt @@ -28,4 +28,4 @@ set(GENERATED_SOURCES ) serenity_app(ThemeEditor ICON app-theme-editor) -target_link_libraries(ThemeEditor PRIVATE LibConfig LibCore LibGfx LibGUI LibFileSystem LibFileSystemAccessClient LibIPC LibMain) +target_link_libraries(ThemeEditor PRIVATE LibConfig LibCore LibGfx LibGUI LibFileSystem LibFileSystemAccessClient LibIPC LibMain LibURL) diff --git a/Userland/Applications/VideoPlayer/CMakeLists.txt b/Userland/Applications/VideoPlayer/CMakeLists.txt index 16ed221736295a2e661b8ac266df71704485fe86..eb24ff91e1d0d9471d2235c6a9ae201cf5a3e373 100644 --- a/Userland/Applications/VideoPlayer/CMakeLists.txt +++ b/Userland/Applications/VideoPlayer/CMakeLists.txt @@ -14,4 +14,4 @@ set(SOURCES ) serenity_app(VideoPlayer ICON app-video-player) -target_link_libraries(VideoPlayer PRIVATE LibVideo LibAudio LibConfig LibCore LibGfx LibGUI LibMain LibFileSystemAccessClient) +target_link_libraries(VideoPlayer PRIVATE LibVideo LibAudio LibConfig LibCore LibGfx LibGUI LibMain LibFileSystemAccessClient LibURL) diff --git a/Userland/Applications/Welcome/CMakeLists.txt b/Userland/Applications/Welcome/CMakeLists.txt index 92936a78b1fbc050406efc11e12f8b9ad4a20185..39f2f791a3bb4233de028ff6333cca7ecf3ae5b0 100644 --- a/Userland/Applications/Welcome/CMakeLists.txt +++ b/Userland/Applications/Welcome/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_app(Welcome ICON app-welcome) -target_link_libraries(Welcome PRIVATE LibConfig LibCore LibGfx LibGUI LibWebView LibWeb LibMain) +target_link_libraries(Welcome PRIVATE LibConfig LibCore LibGfx LibGUI LibWebView LibWeb LibMain LibURL) diff --git a/Userland/BuggieBox/CMakeLists.txt b/Userland/BuggieBox/CMakeLists.txt index 66714a6ae3ab622c97314774697a54e618cbbef2..9f36bedb5b85c567c72f6c287953efef4371fa23 100644 --- a/Userland/BuggieBox/CMakeLists.txt +++ b/Userland/BuggieBox/CMakeLists.txt @@ -41,7 +41,7 @@ set(utility_srcs serenity_bin(BuggieBox) target_sources(BuggieBox PRIVATE main.cpp) -target_link_libraries(BuggieBox PRIVATE LibMain LibShell LibArchive LibCompress LibCore LibCrypto LibFileSystem LibGfx LibLine LibRegex LibAudio) +target_link_libraries(BuggieBox PRIVATE LibMain LibShell LibArchive LibCompress LibCore LibCrypto LibFileSystem LibGfx LibLine LibRegex LibAudio LibURL) foreach(file IN LISTS utility_srcs) buggiebox_utility(${file}) diff --git a/Userland/Demos/Eyes/CMakeLists.txt b/Userland/Demos/Eyes/CMakeLists.txt index cd8a53a74e01ebfff655d4e26d9c412c07d653c5..d16e83e7a0c81a96447d7cfa46fdfd90917c1602 100644 --- a/Userland/Demos/Eyes/CMakeLists.txt +++ b/Userland/Demos/Eyes/CMakeLists.txt @@ -9,4 +9,4 @@ set(SOURCES ) serenity_app(Eyes ICON app-eyes) -target_link_libraries(Eyes PRIVATE LibCore LibDesktop LibGUI LibGfx LibMain) +target_link_libraries(Eyes PRIVATE LibCore LibDesktop LibGUI LibGfx LibMain LibURL) diff --git a/Userland/Demos/Eyes/main.cpp b/Userland/Demos/Eyes/main.cpp index bf4892ff81d1ccbf338508a61449526d007ac4e8..4094623229297d075a41d14ed95f745b5702def7 100644 --- a/Userland/Demos/Eyes/main.cpp +++ b/Userland/Demos/Eyes/main.cpp @@ -5,7 +5,6 @@ */ #include "EyesWidget.h" -#include #include #include #include @@ -15,6 +14,7 @@ #include #include #include +#include #include ErrorOr serenity_main(Main::Arguments arguments) diff --git a/Userland/DevTools/GMLPlayground/CMakeLists.txt b/Userland/DevTools/GMLPlayground/CMakeLists.txt index e31e5562e9b5b5344a9fa19a114c186b352814ea..775ebe5232864553cad8ec62ccdca57cdcc99909 100644 --- a/Userland/DevTools/GMLPlayground/CMakeLists.txt +++ b/Userland/DevTools/GMLPlayground/CMakeLists.txt @@ -16,4 +16,4 @@ set(GENERATED_SOURCES ) serenity_app(GMLPlayground ICON app-gml-playground) -target_link_libraries(GMLPlayground PRIVATE LibConfig LibCore LibDesktop LibFileSystemAccessClient LibGfx LibGUI LibMain LibSyntax) +target_link_libraries(GMLPlayground PRIVATE LibConfig LibCore LibDesktop LibFileSystemAccessClient LibGfx LibGUI LibMain LibSyntax LibURL) diff --git a/Userland/DevTools/GMLPlayground/main.cpp b/Userland/DevTools/GMLPlayground/main.cpp index 47d3c9081be193aa97ca88a1b905ee3af50542e8..0422e6d1924520f7cddc848b5d5fdbcfe2482092 100644 --- a/Userland/DevTools/GMLPlayground/main.cpp +++ b/Userland/DevTools/GMLPlayground/main.cpp @@ -8,7 +8,6 @@ */ #include "MainWidget.h" -#include #include #include #include @@ -17,6 +16,7 @@ #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { diff --git a/Userland/DevTools/HackStudio/CMakeLists.txt b/Userland/DevTools/HackStudio/CMakeLists.txt index 949402cb1258ce44205d6b38e92a8a59b2010e93..65f95da95d0c534ad3945a2a262bfa93cfef076a 100644 --- a/Userland/DevTools/HackStudio/CMakeLists.txt +++ b/Userland/DevTools/HackStudio/CMakeLists.txt @@ -55,5 +55,5 @@ set(GENERATED_SOURCES ) serenity_app(HackStudio ICON app-hack-studio) -target_link_libraries(HackStudio PRIVATE LibWebView LibWeb LibMarkdown LibGUI LibCpp LibCMake LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibFileSystem LibIPC LibJS LibMain LibThreading) +target_link_libraries(HackStudio PRIVATE LibWebView LibWeb LibMarkdown LibGUI LibCpp LibCMake LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibFileSystem LibIPC LibJS LibMain LibThreading LibURL) add_dependencies(HackStudio CppLanguageServer) diff --git a/Userland/DevTools/Profiler/CMakeLists.txt b/Userland/DevTools/Profiler/CMakeLists.txt index bf3aa6b4cf8efdb7e58536629fc122c82c207a64..bce613fd9e94e43dd407fc55ab3325f58ced5af2 100644 --- a/Userland/DevTools/Profiler/CMakeLists.txt +++ b/Userland/DevTools/Profiler/CMakeLists.txt @@ -24,4 +24,4 @@ set(SOURCES ) serenity_app(Profiler ICON app-profiler) -target_link_libraries(Profiler PRIVATE LibCore LibDebug LibFileSystem LibGfx LibGUI LibDesktop LibX86 LibSymbolication LibMain) +target_link_libraries(Profiler PRIVATE LibCore LibDebug LibFileSystem LibGfx LibGUI LibDesktop LibX86 LibSymbolication LibMain LibURL) diff --git a/Userland/DevTools/SQLStudio/CMakeLists.txt b/Userland/DevTools/SQLStudio/CMakeLists.txt index 8aeff8436bc1e96412e58c36592348443bf69d77..94580ecf49f34f0607e323095433b3aa11b36cf0 100644 --- a/Userland/DevTools/SQLStudio/CMakeLists.txt +++ b/Userland/DevTools/SQLStudio/CMakeLists.txt @@ -17,4 +17,4 @@ set(GENERATED_SOURCES ) serenity_app(SQLStudio ICON app-sql-studio) -target_link_libraries(SQLStudio PRIVATE LibCore LibDesktop LibFileSystem LibGfx LibGUI LibIPC LibMain LibSQL LibSyntax) +target_link_libraries(SQLStudio PRIVATE LibCore LibDesktop LibFileSystem LibGfx LibGUI LibIPC LibMain LibSQL LibSyntax LibURL) diff --git a/Userland/Games/2048/CMakeLists.txt b/Userland/Games/2048/CMakeLists.txt index f8efada2645dc2557971b3378267932fbcff5d1e..983d8036fcba860f4cdf99c5f0962e8ee8a1e2da 100644 --- a/Userland/Games/2048/CMakeLists.txt +++ b/Userland/Games/2048/CMakeLists.txt @@ -20,4 +20,4 @@ set(GENERATED_SOURCES ) serenity_app(2048 ICON app-2048) -target_link_libraries(2048 PRIVATE LibConfig LibCore LibGfx LibGUI LibMain LibDesktop) +target_link_libraries(2048 PRIVATE LibConfig LibCore LibGfx LibGUI LibMain LibDesktop LibURL) diff --git a/Userland/Games/2048/main.cpp b/Userland/Games/2048/main.cpp index 47b7920eb3c1f63ab1699a1bac0712e8a10b1954..0454430dabc4fdfea3de5d89d54cfb351be2c264 100644 --- a/Userland/Games/2048/main.cpp +++ b/Userland/Games/2048/main.cpp @@ -7,7 +7,6 @@ #include "BoardView.h" #include "Game.h" #include "GameSizeDialog.h" -#include #include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/Userland/Games/BrickGame/CMakeLists.txt b/Userland/Games/BrickGame/CMakeLists.txt index a016f0a30dcf4630e8f660ee4b3fc3ddaee6e917..0602a6335ed9374222163ca22e1460a71aa1254c 100644 --- a/Userland/Games/BrickGame/CMakeLists.txt +++ b/Userland/Games/BrickGame/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_app(BrickGame ICON app-brickgame) -target_link_libraries(BrickGame PRIVATE LibGUI LibCore LibGfx LibConfig LibMain LibDesktop) +target_link_libraries(BrickGame PRIVATE LibGUI LibCore LibGfx LibConfig LibMain LibDesktop LibURL) diff --git a/Userland/Games/BrickGame/main.cpp b/Userland/Games/BrickGame/main.cpp index cfd00d6179fd96e96877351c86c6a500e44dcea1..cfd42623939397fd7f2a335404211a13ccbf844d 100644 --- a/Userland/Games/BrickGame/main.cpp +++ b/Userland/Games/BrickGame/main.cpp @@ -5,7 +5,6 @@ */ #include "BrickGame.h" -#include #include #include #include @@ -18,6 +17,7 @@ #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { diff --git a/Userland/Games/Chess/CMakeLists.txt b/Userland/Games/Chess/CMakeLists.txt index e1bc90fd2b60a1e7975e6c516834d98ed702fd87..21ed49fd56e0e90d86427ba04c090ec5ecee52dd 100644 --- a/Userland/Games/Chess/CMakeLists.txt +++ b/Userland/Games/Chess/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_app(Chess ICON app-chess) -target_link_libraries(Chess PRIVATE LibChess LibConfig LibFileSystemAccessClient LibGfx LibGUI LibCore LibMain LibDesktop) +target_link_libraries(Chess PRIVATE LibChess LibConfig LibFileSystemAccessClient LibGfx LibGUI LibCore LibMain LibDesktop LibURL) diff --git a/Userland/Games/ColorLines/CMakeLists.txt b/Userland/Games/ColorLines/CMakeLists.txt index 12ee78ddb5aef97dcc2443ce039e3d24af548d2f..b51e0067718f790b326916ab7a83526b6930a579 100644 --- a/Userland/Games/ColorLines/CMakeLists.txt +++ b/Userland/Games/ColorLines/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_app(ColorLines ICON app-colorlines) -target_link_libraries(ColorLines PRIVATE LibGUI LibCore LibGfx LibConfig LibMain LibDesktop) +target_link_libraries(ColorLines PRIVATE LibGUI LibCore LibGfx LibConfig LibMain LibDesktop LibURL) diff --git a/Userland/Games/ColorLines/main.cpp b/Userland/Games/ColorLines/main.cpp index 846a02c62e9416c34dbb5b07a0660c5846175168..61d5112ca820640e626d0b2adcce6f5b021787bb 100644 --- a/Userland/Games/ColorLines/main.cpp +++ b/Userland/Games/ColorLines/main.cpp @@ -6,7 +6,6 @@ */ #include "ColorLines.h" -#include #include #include #include @@ -17,6 +16,7 @@ #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { diff --git a/Userland/Games/FlappyBug/CMakeLists.txt b/Userland/Games/FlappyBug/CMakeLists.txt index 0ae866786eaed970cd7044ed997fd99fc694a8dc..2dc62c1e34d73694baa5f10b53877f2cf29f9cb1 100644 --- a/Userland/Games/FlappyBug/CMakeLists.txt +++ b/Userland/Games/FlappyBug/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_app(FlappyBug ICON app-flappybug) -target_link_libraries(FlappyBug PRIVATE LibCore LibGfx LibGUI LibConfig LibMain LibDesktop) +target_link_libraries(FlappyBug PRIVATE LibCore LibGfx LibGUI LibConfig LibMain LibDesktop LibURL) diff --git a/Userland/Games/FlappyBug/main.cpp b/Userland/Games/FlappyBug/main.cpp index 874e8531db7062d63dc52ad50b992d4777296a25..b3345d4077cb11c35336057630f097ee8e86e56b 100644 --- a/Userland/Games/FlappyBug/main.cpp +++ b/Userland/Games/FlappyBug/main.cpp @@ -5,7 +5,6 @@ */ #include "Game.h" -#include #include #include #include @@ -16,6 +15,7 @@ #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { diff --git a/Userland/Games/Flood/CMakeLists.txt b/Userland/Games/Flood/CMakeLists.txt index 6737cb6c2725560230a6b00b0ee5e981dccbc584..9c466e6b1dbc4f48e4ad836ce341800ce323af64 100644 --- a/Userland/Games/Flood/CMakeLists.txt +++ b/Userland/Games/Flood/CMakeLists.txt @@ -17,4 +17,4 @@ set(SOURCES ) serenity_app(Flood ICON app-flood) -target_link_libraries(Flood PRIVATE LibConfig LibCore LibDesktop LibGfx LibGUI LibMain) +target_link_libraries(Flood PRIVATE LibConfig LibCore LibDesktop LibGfx LibGUI LibMain LibURL) diff --git a/Userland/Games/Flood/main.cpp b/Userland/Games/Flood/main.cpp index 2ad60f0ea70a555eca74808623043b014d166d49..62807f62cc579073e867da52bc1d83a36ee00154 100644 --- a/Userland/Games/Flood/main.cpp +++ b/Userland/Games/Flood/main.cpp @@ -8,7 +8,6 @@ #include "MainWidget.h" #include "SettingsDialog.h" #include -#include #include #include #include @@ -21,6 +20,7 @@ #include #include #include +#include // FIXME: Improve this AI. // Currently, this AI always chooses a move that gets the most cells flooded immediately. diff --git a/Userland/Games/GameOfLife/CMakeLists.txt b/Userland/Games/GameOfLife/CMakeLists.txt index 51f6ece7dbac2834b24971e130cbab021491cac3..50a060af8ef9407d315bd7ab70b8d8fbfce2e51c 100644 --- a/Userland/Games/GameOfLife/CMakeLists.txt +++ b/Userland/Games/GameOfLife/CMakeLists.txt @@ -15,4 +15,4 @@ set(SOURCES ) serenity_app(GameOfLife ICON app-gameoflife) -target_link_libraries(GameOfLife PRIVATE LibCore LibGfx LibGUI LibMain LibDesktop) +target_link_libraries(GameOfLife PRIVATE LibCore LibGfx LibGUI LibMain LibDesktop LibURL) diff --git a/Userland/Games/GameOfLife/main.cpp b/Userland/Games/GameOfLife/main.cpp index 95ca1ff172cb10b30e3a8957f60cf2a6f2943308..f5958d1d88783555bb879bead9237fed56a91062 100644 --- a/Userland/Games/GameOfLife/main.cpp +++ b/Userland/Games/GameOfLife/main.cpp @@ -8,7 +8,6 @@ #include "BoardWidget.h" #include "MainWidget.h" #include -#include #include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { diff --git a/Userland/Games/Hearts/CMakeLists.txt b/Userland/Games/Hearts/CMakeLists.txt index ef6832b69e4ca7a7455bc565a58c428c58d65e50..384324bc3955f5377dcfcfe0657e3a2c00c2b583 100644 --- a/Userland/Games/Hearts/CMakeLists.txt +++ b/Userland/Games/Hearts/CMakeLists.txt @@ -17,4 +17,4 @@ set(SOURCES ) serenity_app(Hearts ICON app-hearts) -target_link_libraries(Hearts PRIVATE LibCards LibGUI LibGfx LibCore LibConfig LibMain LibDesktop) +target_link_libraries(Hearts PRIVATE LibCards LibGUI LibGfx LibCore LibConfig LibMain LibDesktop LibURL) diff --git a/Userland/Games/Hearts/main.cpp b/Userland/Games/Hearts/main.cpp index 33f781273173c12ae5c7e4be18c6803b835f2878..ccb14f990ed0a4a7d0f8983d89dcbb82c6cb6f41 100644 --- a/Userland/Games/Hearts/main.cpp +++ b/Userland/Games/Hearts/main.cpp @@ -10,7 +10,6 @@ #include "Game.h" #include "MainWidget.h" #include "SettingsDialog.h" -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { diff --git a/Userland/Games/MasterWord/CMakeLists.txt b/Userland/Games/MasterWord/CMakeLists.txt index 3d8b757ad887e128c9806ffad0a8393796921366..c4948473c9faab9ad503857530bc3344962fd637 100644 --- a/Userland/Games/MasterWord/CMakeLists.txt +++ b/Userland/Games/MasterWord/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_app(MasterWord ICON app-masterword) -target_link_libraries(MasterWord PRIVATE LibCore LibGfx LibGUI LibConfig LibMain LibDesktop) +target_link_libraries(MasterWord PRIVATE LibCore LibGfx LibGUI LibConfig LibMain LibDesktop LibURL) diff --git a/Userland/Games/MasterWord/main.cpp b/Userland/Games/MasterWord/main.cpp index 823c003fbc68feac946078412834de8cd6e8d10c..a00c43a3375679aa5cb9d66a3fe67b6eed0b33d9 100644 --- a/Userland/Games/MasterWord/main.cpp +++ b/Userland/Games/MasterWord/main.cpp @@ -6,7 +6,6 @@ #include "MainWidget.h" #include "WordGame.h" -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { diff --git a/Userland/Games/Minesweeper/CMakeLists.txt b/Userland/Games/Minesweeper/CMakeLists.txt index 665903d122a0a0633fb74ae59ba4f9822af72528..10d5d00251bcccd8443e119fed070956e96167be 100644 --- a/Userland/Games/Minesweeper/CMakeLists.txt +++ b/Userland/Games/Minesweeper/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES ) serenity_app(Minesweeper ICON app-minesweeper) -target_link_libraries(Minesweeper PRIVATE LibCore LibGfx LibGUI LibConfig LibMain LibDesktop) +target_link_libraries(Minesweeper PRIVATE LibCore LibGfx LibGUI LibConfig LibMain LibDesktop LibURL) diff --git a/Userland/Games/Minesweeper/main.cpp b/Userland/Games/Minesweeper/main.cpp index 04b6357899183821f10b37263daddb51b04dde3a..a3620c2105b73b93ca0f97511cd33e5a86f80ce0 100644 --- a/Userland/Games/Minesweeper/main.cpp +++ b/Userland/Games/Minesweeper/main.cpp @@ -7,7 +7,6 @@ #include "CustomGameDialog.h" #include "Field.h" #include "MainWidget.h" -#include #include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include #include ErrorOr serenity_main(Main::Arguments arguments) diff --git a/Userland/Games/Snake/CMakeLists.txt b/Userland/Games/Snake/CMakeLists.txt index a888a00509f8f5b59fc7a09977260826bfa05752..8fab6c6efb5a23c46187e95deb97276592574076 100644 --- a/Userland/Games/Snake/CMakeLists.txt +++ b/Userland/Games/Snake/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES ) serenity_app(Snake ICON app-snake) -target_link_libraries(Snake PRIVATE LibCore LibFileSystem LibGfx LibGUI LibConfig LibMain LibDesktop) +target_link_libraries(Snake PRIVATE LibCore LibFileSystem LibGfx LibGUI LibConfig LibMain LibDesktop LibURL) diff --git a/Userland/Games/Snake/main.cpp b/Userland/Games/Snake/main.cpp index c53b3df9d2b7de587d56662713aafdf1f9ff68d0..c9aa392de4507bf21671ac727a09b242607cae7c 100644 --- a/Userland/Games/Snake/main.cpp +++ b/Userland/Games/Snake/main.cpp @@ -8,7 +8,6 @@ #include "Game.h" #include "MainWidget.h" #include "Skins/SnakeSkin.h" -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { diff --git a/Userland/Games/Solitaire/CMakeLists.txt b/Userland/Games/Solitaire/CMakeLists.txt index cff7e5076075ea1d6c293912916af1eca5b46f8b..c486c05cdc389f12601da4a019077b56a7073d73 100644 --- a/Userland/Games/Solitaire/CMakeLists.txt +++ b/Userland/Games/Solitaire/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_app(Solitaire ICON app-solitaire) -target_link_libraries(Solitaire PRIVATE LibCards LibConfig LibGUI LibDesktop LibGfx LibCore LibMain) +target_link_libraries(Solitaire PRIVATE LibCards LibConfig LibGUI LibDesktop LibGfx LibCore LibMain LibURL) diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp index d2b7bb84f09d80096631becdab1aa660f0c963d3..32ffb49eeac978a224ea65e620147178f1050484 100644 --- a/Userland/Games/Solitaire/main.cpp +++ b/Userland/Games/Solitaire/main.cpp @@ -10,7 +10,6 @@ #include "Game.h" #include "MainWidget.h" #include -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include #include ErrorOr serenity_main(Main::Arguments arguments) diff --git a/Userland/Games/Spider/CMakeLists.txt b/Userland/Games/Spider/CMakeLists.txt index b4314ee202a32ea87f3e26fad23cae371782074a..5fc369f400d1bc2cff814595cdc5cc20d7bb0037 100644 --- a/Userland/Games/Spider/CMakeLists.txt +++ b/Userland/Games/Spider/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_app(Spider ICON app-spider) -target_link_libraries(Spider PRIVATE LibCards LibGUI LibGfx LibCore LibDesktop LibConfig LibMain) +target_link_libraries(Spider PRIVATE LibCards LibGUI LibGfx LibCore LibDesktop LibConfig LibMain LibURL) diff --git a/Userland/Games/Spider/main.cpp b/Userland/Games/Spider/main.cpp index 52876b27be18e93329e201197e24b4cab88ef568..28087385aeed6438a9c79e383bc578fcdaf252c3 100644 --- a/Userland/Games/Spider/main.cpp +++ b/Userland/Games/Spider/main.cpp @@ -9,7 +9,6 @@ #include "Game.h" #include "MainWidget.h" #include -#include #include #include #include @@ -24,6 +23,7 @@ #include #include #include +#include #include enum class StatisticDisplay : u8 { diff --git a/Userland/Libraries/CMakeLists.txt b/Userland/Libraries/CMakeLists.txt index a78830232da0d135bd094565afecf23cf3a3aadf..65462af2b7e8e8b6cbf33c1924d4cb7d56914fde 100644 --- a/Userland/Libraries/CMakeLists.txt +++ b/Userland/Libraries/CMakeLists.txt @@ -61,6 +61,7 @@ add_subdirectory(LibThreading) add_subdirectory(LibTimeZone) add_subdirectory(LibTLS) add_subdirectory(LibUnicode) +add_subdirectory(LibURL) add_subdirectory(LibUSBDB) add_subdirectory(LibVideo) add_subdirectory(LibVirtGPU) diff --git a/Userland/Libraries/LibCore/CMakeLists.txt b/Userland/Libraries/LibCore/CMakeLists.txt index e4c248d6a6db279619df332d675d37ffcfa2d579..f8194a56c6258b597d0e7eab950e9e69f2df6429 100644 --- a/Userland/Libraries/LibCore/CMakeLists.txt +++ b/Userland/Libraries/LibCore/CMakeLists.txt @@ -62,7 +62,7 @@ else() endif() serenity_lib(LibCore core) -target_link_libraries(LibCore PRIVATE LibCrypt LibSystem) +target_link_libraries(LibCore PRIVATE LibCrypt LibSystem LibURL) if (APPLE) target_link_libraries(LibCore PUBLIC "-framework CoreFoundation") diff --git a/Userland/Libraries/LibCore/MimeData.cpp b/Userland/Libraries/LibCore/MimeData.cpp index cc919511f5947e15a4759bdcde165a5e89a14410..8398c72a9b5710e2b5fd5ee73203910127e8100e 100644 --- a/Userland/Libraries/LibCore/MimeData.cpp +++ b/Userland/Libraries/LibCore/MimeData.cpp @@ -11,19 +11,19 @@ namespace Core { -Vector MimeData::urls() const +Vector MimeData::urls() const { auto it = m_data.find("text/uri-list"sv); if (it == m_data.end()) return {}; - Vector urls; + Vector urls; for (auto& line : StringView(it->value).split_view('\n')) { - urls.append(URL(line)); + urls.append(URL::URL(line)); } return urls; } -ErrorOr MimeData::set_urls(Vector const& urls) +ErrorOr MimeData::set_urls(Vector const& urls) { StringBuilder builder; for (auto& url : urls) { diff --git a/Userland/Libraries/LibCore/MimeData.h b/Userland/Libraries/LibCore/MimeData.h index 5811e940813430f62cc1b3daed5ec146c101ccd8..03a530e27ced47d3f979c251b1a0f6a5bfb0bcdf 100644 --- a/Userland/Libraries/LibCore/MimeData.h +++ b/Userland/Libraries/LibCore/MimeData.h @@ -9,8 +9,8 @@ #include #include -#include #include +#include namespace Core { @@ -33,8 +33,8 @@ public: // Convenience helpers for "text/uri-list" bool has_urls() const { return has_format("text/uri-list"sv); } - Vector urls() const; - ErrorOr set_urls(Vector const&); + Vector urls() const; + ErrorOr set_urls(Vector const&); HashMap const& all_data() const { return m_data; } diff --git a/Userland/Libraries/LibCore/Proxy.h b/Userland/Libraries/LibCore/Proxy.h index cf8c9a7a67bc8215e9effc87537854006728bc4a..6a0688dc4cbdbd01795049a4d948c022ab557ead 100644 --- a/Userland/Libraries/LibCore/Proxy.h +++ b/Userland/Libraries/LibCore/Proxy.h @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include namespace Core { // FIXME: Username/password support. @@ -25,7 +25,7 @@ struct ProxyData { bool operator==(ProxyData const& other) const = default; - static ErrorOr parse_url(URL const& url) + static ErrorOr parse_url(URL::URL const& url) { if (!url.is_valid()) return Error::from_string_literal("Invalid proxy URL"); diff --git a/Userland/Libraries/LibDesktop/CMakeLists.txt b/Userland/Libraries/LibDesktop/CMakeLists.txt index 072c64cc4e4d86626352bc7fd47309659fb34d0b..5320eb54a392a78ce6e786c19964d0aabeca1981 100644 --- a/Userland/Libraries/LibDesktop/CMakeLists.txt +++ b/Userland/Libraries/LibDesktop/CMakeLists.txt @@ -10,4 +10,4 @@ set(GENERATED_SOURCES ) serenity_lib(LibDesktop desktop) -target_link_libraries(LibDesktop PRIVATE LibCore LibIPC LibGfx LibGUI LibFileSystem) +target_link_libraries(LibDesktop PRIVATE LibCore LibIPC LibGfx LibGUI LibFileSystem LibURL) diff --git a/Userland/Libraries/LibDesktop/Launcher.cpp b/Userland/Libraries/LibDesktop/Launcher.cpp index c30d2c520f2aa83cd0095ac34f8464a29dcb9fff..84b75376a8cf20e8573144939ad1d0873e1bacde 100644 --- a/Userland/Libraries/LibDesktop/Launcher.cpp +++ b/Userland/Libraries/LibDesktop/Launcher.cpp @@ -5,11 +5,11 @@ */ #include -#include #include #include #include #include +#include namespace Desktop { @@ -54,7 +54,7 @@ void Launcher::ensure_connection() [[maybe_unused]] auto& conn = connection(); } -ErrorOr Launcher::add_allowed_url(URL const& url) +ErrorOr Launcher::add_allowed_url(URL::URL const& url) { auto response_or_error = connection().try_add_allowed_url(url); if (response_or_error.is_error()) @@ -70,7 +70,7 @@ ErrorOr Launcher::add_allowed_handler_with_any_url(ByteString const& handl return {}; } -ErrorOr Launcher::add_allowed_handler_with_only_specific_urls(ByteString const& handler, Vector const& urls) +ErrorOr Launcher::add_allowed_handler_with_only_specific_urls(ByteString const& handler, Vector const& urls) { auto response_or_error = connection().try_add_allowed_handler_with_only_specific_urls(handler, urls); if (response_or_error.is_error()) @@ -86,23 +86,23 @@ ErrorOr Launcher::seal_allowlist() return {}; } -bool Launcher::open(const URL& url, ByteString const& handler_name) +bool Launcher::open(const URL::URL& url, ByteString const& handler_name) { return connection().open_url(url, handler_name); } -bool Launcher::open(const URL& url, Details const& details) +bool Launcher::open(const URL::URL& url, Details const& details) { VERIFY(details.launcher_type != LauncherType::Application); // Launcher should not be used to execute arbitrary applications return open(url, details.executable); } -Vector Launcher::get_handlers_for_url(const URL& url) +Vector Launcher::get_handlers_for_url(const URL::URL& url) { return connection().get_handlers_for_url(url.to_byte_string()); } -auto Launcher::get_handlers_with_details_for_url(const URL& url) -> Vector> +auto Launcher::get_handlers_with_details_for_url(const URL::URL& url) -> Vector> { auto details = connection().get_handlers_with_details_for_url(url.to_byte_string()); Vector> handlers_with_details; diff --git a/Userland/Libraries/LibDesktop/Launcher.h b/Userland/Libraries/LibDesktop/Launcher.h index 2ddddd306d488d20afa11031687ec4b94ef15430..5de48012926d7d111fda898d75e13de066d1308b 100644 --- a/Userland/Libraries/LibDesktop/Launcher.h +++ b/Userland/Libraries/LibDesktop/Launcher.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace Desktop { @@ -31,14 +32,14 @@ public: }; static void ensure_connection(); - static ErrorOr add_allowed_url(URL const&); + static ErrorOr add_allowed_url(URL::URL const&); static ErrorOr add_allowed_handler_with_any_url(ByteString const& handler); - static ErrorOr add_allowed_handler_with_only_specific_urls(ByteString const& handler, Vector const&); + static ErrorOr add_allowed_handler_with_only_specific_urls(ByteString const& handler, Vector const&); static ErrorOr seal_allowlist(); - static bool open(const URL&, ByteString const& handler_name = {}); - static bool open(const URL&, Details const& details); - static Vector get_handlers_for_url(const URL&); - static Vector> get_handlers_with_details_for_url(const URL&); + static bool open(const URL::URL&, ByteString const& handler_name = {}); + static bool open(const URL::URL&, Details const& details); + static Vector get_handlers_for_url(const URL::URL&); + static Vector> get_handlers_with_details_for_url(const URL::URL&); }; } diff --git a/Userland/Libraries/LibGUI/CMakeLists.txt b/Userland/Libraries/LibGUI/CMakeLists.txt index b10a2d79644f1d19b54f854ba30d68854c0999ec..7c1842173b2212b8f5c208e8f5a5648a62d1bbc6 100644 --- a/Userland/Libraries/LibGUI/CMakeLists.txt +++ b/Userland/Libraries/LibGUI/CMakeLists.txt @@ -156,5 +156,5 @@ set(GENERATED_SOURCES ) serenity_lib(LibGUI gui) -target_link_libraries(LibGUI PRIVATE LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibThreading LibRegex LibConfig LibUnicode) +target_link_libraries(LibGUI PRIVATE LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibThreading LibRegex LibConfig LibUnicode LibURL) target_link_libraries(LibGUI PUBLIC LibSyntax) diff --git a/Userland/Libraries/LibGemini/CMakeLists.txt b/Userland/Libraries/LibGemini/CMakeLists.txt index 6c5bbeb22d5131a41b4a69a05beb086e507d72f0..2955e8dd2e0b40f3ada3e8cc93a342441a3b2a39 100644 --- a/Userland/Libraries/LibGemini/CMakeLists.txt +++ b/Userland/Libraries/LibGemini/CMakeLists.txt @@ -7,4 +7,4 @@ set(SOURCES ) serenity_lib(LibGemini gemini) -target_link_libraries(LibGemini PRIVATE LibCore LibTLS) +target_link_libraries(LibGemini PRIVATE LibCore LibTLS LibURL) diff --git a/Userland/Libraries/LibGemini/Document.cpp b/Userland/Libraries/LibGemini/Document.cpp index df43088374e4ab57147c0a668eb88af3cf2c3b72..88b98ac1f1b0764f42a88ac989ca84b6fc8ff7b0 100644 --- a/Userland/Libraries/LibGemini/Document.cpp +++ b/Userland/Libraries/LibGemini/Document.cpp @@ -29,7 +29,7 @@ ByteString Document::render_to_html() const return html_builder.to_byte_string(); } -NonnullRefPtr Document::parse(StringView lines, const URL& url) +NonnullRefPtr Document::parse(StringView lines, const URL::URL& url) { auto document = adopt_ref(*new Document(url)); document->read_lines(lines); diff --git a/Userland/Libraries/LibGemini/Document.h b/Userland/Libraries/LibGemini/Document.h index d7957a98f9f4225449a84ff0cb0d39d782813873..09edf65c3ed7ed1fe2932ac7e9cbf94b2320bb65 100644 --- a/Userland/Libraries/LibGemini/Document.h +++ b/Userland/Libraries/LibGemini/Document.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace Gemini { @@ -32,12 +32,12 @@ class Document : public RefCounted { public: ByteString render_to_html() const; - static NonnullRefPtr parse(StringView source, const URL&); + static NonnullRefPtr parse(StringView source, const URL::URL&); - const URL& url() const { return m_url; } + const URL::URL& url() const { return m_url; } private: - explicit Document(const URL& url) + explicit Document(const URL::URL& url) : m_url(url) { } @@ -45,7 +45,7 @@ private: void read_lines(StringView); Vector> m_lines; - URL m_url; + URL::URL m_url; bool m_inside_preformatted_block { false }; bool m_inside_unordered_list { false }; }; @@ -67,7 +67,7 @@ public: virtual ByteString render_to_html() const override; private: - URL m_url; + URL::URL m_url; ByteString m_name; }; diff --git a/Userland/Libraries/LibGemini/GeminiRequest.cpp b/Userland/Libraries/LibGemini/GeminiRequest.cpp index ea59f8a06ddbfb54b3d148a77a055b1541c7340b..bc81111190163d6ef6c0744d24093e49e153a408 100644 --- a/Userland/Libraries/LibGemini/GeminiRequest.cpp +++ b/Userland/Libraries/LibGemini/GeminiRequest.cpp @@ -5,8 +5,8 @@ */ #include -#include #include +#include namespace Gemini { @@ -20,7 +20,7 @@ ErrorOr GeminiRequest::to_raw_request() const Optional GeminiRequest::from_raw_request(ByteBuffer const& raw_request) { - URL url = StringView(raw_request); + URL::URL url = StringView(raw_request); if (!url.is_valid()) return {}; GeminiRequest request; diff --git a/Userland/Libraries/LibGemini/GeminiRequest.h b/Userland/Libraries/LibGemini/GeminiRequest.h index d4e0179bf980bf233e7c29e1eee1ad55cc152e97..e76d59c147e08a3957e50c9495bb14d202734f78 100644 --- a/Userland/Libraries/LibGemini/GeminiRequest.h +++ b/Userland/Libraries/LibGemini/GeminiRequest.h @@ -7,8 +7,8 @@ #pragma once #include -#include #include +#include namespace Gemini { @@ -17,15 +17,15 @@ public: GeminiRequest() = default; ~GeminiRequest() = default; - const URL& url() const { return m_url; } - void set_url(const URL& url) { m_url = url; } + const URL::URL& url() const { return m_url; } + void set_url(const URL::URL& url) { m_url = url; } ErrorOr to_raw_request() const; static Optional from_raw_request(ByteBuffer const&); private: - URL m_url; + URL::URL m_url; }; } diff --git a/Userland/Libraries/LibGemini/Job.h b/Userland/Libraries/LibGemini/Job.h index c5eb28cd2e0a3455a01a648b663562db99e1e42d..89c23142cad6a2121274a8e863d056b87d5c081b 100644 --- a/Userland/Libraries/LibGemini/Job.h +++ b/Userland/Libraries/LibGemini/Job.h @@ -27,7 +27,7 @@ public: GeminiResponse* response() { return static_cast(Core::NetworkJob::response()); } GeminiResponse const* response() const { return static_cast(Core::NetworkJob::response()); } - const URL& url() const { return m_request.url(); } + const URL::URL& url() const { return m_request.url(); } Core::Socket const* socket() const { return m_socket; } ErrorOr response_length() const; diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index 619936626f86734a80f3d2fbca8f2d942ba17aef..1fb695f601a81c46c000ee9962540858e836106e 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -85,7 +85,7 @@ set(SOURCES ) serenity_lib(LibGfx gfx) -target_link_libraries(LibGfx PRIVATE LibCompress LibCore LibCrypto LibFileSystem LibRIFF LibTextCodec LibIPC LibUnicode) +target_link_libraries(LibGfx PRIVATE LibCompress LibCore LibCrypto LibFileSystem LibRIFF LibTextCodec LibIPC LibUnicode LibURL) set(generated_sources TIFFMetadata.h TIFFTagHandler.cpp) list(TRANSFORM generated_sources PREPEND "ImageFormats/") diff --git a/Userland/Libraries/LibGfx/ICC/Profile.cpp b/Userland/Libraries/LibGfx/ICC/Profile.cpp index ca29a63de1cf38f3fed105341cf363957f09a816..20c30780dd5324c480415e0c14a4720ef30094c8 100644 --- a/Userland/Libraries/LibGfx/ICC/Profile.cpp +++ b/Userland/Libraries/LibGfx/ICC/Profile.cpp @@ -305,15 +305,15 @@ ErrorOr parse_reserved(ICCHeader const& header) } } -URL device_manufacturer_url(DeviceManufacturer device_manufacturer) +URL::URL device_manufacturer_url(DeviceManufacturer device_manufacturer) { - return URL(ByteString::formatted("https://www.color.org/signatureRegistry/?entityEntry={:c}{:c}{:c}{:c}-{:08X}", + return URL::URL(ByteString::formatted("https://www.color.org/signatureRegistry/?entityEntry={:c}{:c}{:c}{:c}-{:08X}", device_manufacturer.c0(), device_manufacturer.c1(), device_manufacturer.c2(), device_manufacturer.c3(), device_manufacturer.value)); } -URL device_model_url(DeviceModel device_model) +URL::URL device_model_url(DeviceModel device_model) { - return URL(ByteString::formatted("https://www.color.org/signatureRegistry/deviceRegistry/?entityEntry={:c}{:c}{:c}{:c}-{:08X}", + return URL::URL(ByteString::formatted("https://www.color.org/signatureRegistry/deviceRegistry/?entityEntry={:c}{:c}{:c}{:c}-{:08X}", device_model.c0(), device_model.c1(), device_model.c2(), device_model.c3(), device_model.value)); } diff --git a/Userland/Libraries/LibGfx/ICC/Profile.h b/Userland/Libraries/LibGfx/ICC/Profile.h index 2c35680176b6c0fe5e092c9772cabf74fdbd549a..a96981741ab755ed67b00514cd83e8e71496fe2a 100644 --- a/Userland/Libraries/LibGfx/ICC/Profile.h +++ b/Userland/Libraries/LibGfx/ICC/Profile.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -20,11 +19,12 @@ #include #include #include +#include namespace Gfx::ICC { -URL device_manufacturer_url(DeviceManufacturer); -URL device_model_url(DeviceModel); +URL::URL device_manufacturer_url(DeviceManufacturer); +URL::URL device_model_url(DeviceModel); // ICC v4, 7.2.4 Profile version field class Version { diff --git a/Userland/Libraries/LibHTTP/CMakeLists.txt b/Userland/Libraries/LibHTTP/CMakeLists.txt index 6ab67b4b7d6cc447dd5b0610cec28a48dd6d5643..483d7729e71558eaefe105b93edbb8c2d2600779 100644 --- a/Userland/Libraries/LibHTTP/CMakeLists.txt +++ b/Userland/Libraries/LibHTTP/CMakeLists.txt @@ -6,4 +6,4 @@ set(SOURCES ) serenity_lib(LibHTTP http) -target_link_libraries(LibHTTP PRIVATE LibCompress LibCore LibTLS) +target_link_libraries(LibHTTP PRIVATE LibCompress LibCore LibTLS LibURL) diff --git a/Userland/Libraries/LibHTTP/HttpRequest.cpp b/Userland/Libraries/LibHTTP/HttpRequest.cpp index b600e163afa3ce06cc6fc4e79ad53315d8783922..d0f5ef61a5895d11b4dfecc847db09434b43586c 100644 --- a/Userland/Libraries/LibHTTP/HttpRequest.cpp +++ b/Userland/Libraries/LibHTTP/HttpRequest.cpp @@ -7,9 +7,9 @@ #include #include -#include #include #include +#include namespace HTTP { @@ -269,7 +269,7 @@ void HttpRequest::set_headers(HashMap const& headers) m_headers.append({ it.key, it.value }); } -Optional HttpRequest::get_http_basic_authentication_header(URL const& url) +Optional HttpRequest::get_http_basic_authentication_header(URL::URL const& url) { if (!url.includes_credentials()) return {}; diff --git a/Userland/Libraries/LibHTTP/HttpRequest.h b/Userland/Libraries/LibHTTP/HttpRequest.h index f41cbc2803c20121cafda760726cf67307865430..ba2d3a23c6871d22f2bd1abfe304f339897ef270 100644 --- a/Userland/Libraries/LibHTTP/HttpRequest.h +++ b/Userland/Libraries/LibHTTP/HttpRequest.h @@ -10,9 +10,9 @@ #include #include #include -#include #include #include +#include namespace HTTP { @@ -71,8 +71,8 @@ public: ByteString const& resource() const { return m_resource; } Vector
const& headers() const { return m_headers; } - URL const& url() const { return m_url; } - void set_url(URL const& url) { m_url = url; } + URL::URL const& url() const { return m_url; } + void set_url(URL::URL const& url) { m_url = url; } Method method() const { return m_method; } void set_method(Method method) { m_method = method; } @@ -86,11 +86,11 @@ public: void set_headers(HashMap const&); static ErrorOr from_raw_request(ReadonlyBytes); - static Optional
get_http_basic_authentication_header(URL const&); + static Optional
get_http_basic_authentication_header(URL::URL const&); static Optional parse_http_basic_authentication_header(ByteString const&); private: - URL m_url; + URL::URL m_url; ByteString m_resource; Method m_method { GET }; Vector
m_headers; diff --git a/Userland/Libraries/LibHTTP/Job.h b/Userland/Libraries/LibHTTP/Job.h index 9734776d348033135b962ca899b8ae7d74b74382..4da1c9be45ea27aaddf370a24aaefc9cbe1662d1 100644 --- a/Userland/Libraries/LibHTTP/Job.h +++ b/Userland/Libraries/LibHTTP/Job.h @@ -26,7 +26,7 @@ public: virtual void shutdown(ShutdownMode) override; Core::Socket const* socket() const { return m_socket; } - URL url() const { return m_request.url(); } + URL::URL url() const { return m_request.url(); } HttpResponse* response() { return static_cast(Core::NetworkJob::response()); } HttpResponse const* response() const { return static_cast(Core::NetworkJob::response()); } diff --git a/Userland/Libraries/LibIPC/CMakeLists.txt b/Userland/Libraries/LibIPC/CMakeLists.txt index 9e2b2138977748c91fae66747c966667acf75aba..a6c508d8a34c90a822eabf428919dea2e1ae94f8 100644 --- a/Userland/Libraries/LibIPC/CMakeLists.txt +++ b/Userland/Libraries/LibIPC/CMakeLists.txt @@ -6,4 +6,4 @@ set(SOURCES ) serenity_lib(LibIPC ipc) -target_link_libraries(LibIPC PRIVATE LibCore) +target_link_libraries(LibIPC PRIVATE LibCore LibURL) diff --git a/Userland/Libraries/LibIPC/Decoder.cpp b/Userland/Libraries/LibIPC/Decoder.cpp index f659897dd5e578631bc88867b93f89ba8efd9f6d..3e2ac066776b68050ef43539ffe6bec882d5fe40 100644 --- a/Userland/Libraries/LibIPC/Decoder.cpp +++ b/Userland/Libraries/LibIPC/Decoder.cpp @@ -7,13 +7,13 @@ #include #include -#include #include #include #include #include #include #include +#include #include namespace IPC { @@ -81,10 +81,10 @@ ErrorOr decode(Decoder& decoder) } template<> -ErrorOr decode(Decoder& decoder) +ErrorOr decode(Decoder& decoder) { auto url = TRY(decoder.decode()); - return URL { url }; + return URL::URL { url }; } template<> diff --git a/Userland/Libraries/LibIPC/Decoder.h b/Userland/Libraries/LibIPC/Decoder.h index 108b43e2a05176dcdee64d123431398b93e5c387..dd6c6b9b379f88eb1bcddf0f382cde36b5408152 100644 --- a/Userland/Libraries/LibIPC/Decoder.h +++ b/Userland/Libraries/LibIPC/Decoder.h @@ -22,6 +22,7 @@ #include #include #include +#include namespace IPC { @@ -100,7 +101,7 @@ template<> ErrorOr decode(Decoder&); template<> -ErrorOr decode(Decoder&); +ErrorOr decode(Decoder&); template<> ErrorOr decode(Decoder&); diff --git a/Userland/Libraries/LibIPC/Encoder.cpp b/Userland/Libraries/LibIPC/Encoder.cpp index 13de3bea0cb74ea61744726fd38db8ae451f9254..0469eba2e14076e3d8e646f7acf5b44d2a631d0a 100644 --- a/Userland/Libraries/LibIPC/Encoder.cpp +++ b/Userland/Libraries/LibIPC/Encoder.cpp @@ -14,13 +14,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include namespace IPC { @@ -97,7 +97,7 @@ ErrorOr encode(Encoder& encoder, UnixDateTime const& value) } template<> -ErrorOr encode(Encoder& encoder, URL const& value) +ErrorOr encode(Encoder& encoder, URL::URL const& value) { return encoder.encode(value.to_byte_string()); } diff --git a/Userland/Libraries/LibIPC/Encoder.h b/Userland/Libraries/LibIPC/Encoder.h index 075de49a82f20ca3ccd161ac5c171b3f1a124d93..d3364f9cfbc93d784cd77a44122ef5dfa79f81fd 100644 --- a/Userland/Libraries/LibIPC/Encoder.h +++ b/Userland/Libraries/LibIPC/Encoder.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace IPC { @@ -100,7 +101,7 @@ template<> ErrorOr encode(Encoder&, UnixDateTime const&); template<> -ErrorOr encode(Encoder&, URL const&); +ErrorOr encode(Encoder&, URL::URL const&); template<> ErrorOr encode(Encoder&, File const&); diff --git a/Userland/Libraries/LibManual/CMakeLists.txt b/Userland/Libraries/LibManual/CMakeLists.txt index 20359709a51bcc02db674914b9c3e8f59d8c2a2e..af1d08d87dced5e7b5f10fca0f1d08777d092528 100644 --- a/Userland/Libraries/LibManual/CMakeLists.txt +++ b/Userland/Libraries/LibManual/CMakeLists.txt @@ -7,4 +7,4 @@ set(SOURCES ) serenity_lib(LibManual manual) -target_link_libraries(LibManual PRIVATE LibCore LibFileSystem) +target_link_libraries(LibManual PRIVATE LibCore LibFileSystem LibURL) diff --git a/Userland/Libraries/LibManual/Node.cpp b/Userland/Libraries/LibManual/Node.cpp index 237b96f054e20009ec36bfbc617c6cefc0fa9902..20d8115599676201572066e2bd07db01903f207c 100644 --- a/Userland/Libraries/LibManual/Node.cpp +++ b/Userland/Libraries/LibManual/Node.cpp @@ -11,9 +11,9 @@ #include #include #include -#include #include #include +#include namespace Manual { @@ -80,7 +80,7 @@ ErrorOr> Node::try_create_from_query(Vector> Node::try_find_from_help_url(URL const& url) +ErrorOr> Node::try_find_from_help_url(URL::URL const& url) { if (url.host() != "man"_string) return Error::from_string_view("Bad help operation"sv); diff --git a/Userland/Libraries/LibManual/Node.h b/Userland/Libraries/LibManual/Node.h index 947d8e8ff5a78c13bb3635503b835027b9cfcf73..58b0e4a47f35f9254ec6d93cd8b66f572c6e3e49 100644 --- a/Userland/Libraries/LibManual/Node.h +++ b/Userland/Libraries/LibManual/Node.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace Manual { @@ -37,7 +38,7 @@ public: // Finds a page via the help://man///page URLs. // This will automatically start discovering pages by inspecting the filesystem. - static ErrorOr> try_find_from_help_url(URL const&); + static ErrorOr> try_find_from_help_url(URL::URL const&); bool operator==(Node const& other) const { diff --git a/Userland/Libraries/LibProtocol/RequestClient.cpp b/Userland/Libraries/LibProtocol/RequestClient.cpp index d9cb3f7a34c94eaf5ce03605bf6d2ba01a2c1d77..4489dd4277d2feb1a983af12e9bafd9042e416bc 100644 --- a/Userland/Libraries/LibProtocol/RequestClient.cpp +++ b/Userland/Libraries/LibProtocol/RequestClient.cpp @@ -14,13 +14,13 @@ RequestClient::RequestClient(NonnullOwnPtr socket) { } -void RequestClient::ensure_connection(URL const& url, ::RequestServer::CacheLevel cache_level) +void RequestClient::ensure_connection(URL::URL const& url, ::RequestServer::CacheLevel cache_level) { async_ensure_connection(url, cache_level); } template -RefPtr RequestClient::start_request(ByteString const& method, URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy_data) +RefPtr RequestClient::start_request(ByteString const& method, URL::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy_data) { auto headers_or_error = request_headers.template clone>(); if (headers_or_error.is_error()) @@ -103,7 +103,7 @@ void RequestClient::certificate_requested(i32 request_id) } } -RefPtr RequestClient::websocket_connect(const URL& url, ByteString const& origin, Vector const& protocols, Vector const& extensions, HashMap const& request_headers) +RefPtr RequestClient::websocket_connect(const URL::URL& url, ByteString const& origin, Vector const& protocols, Vector const& extensions, HashMap const& request_headers) { auto headers_or_error = request_headers.clone(); if (headers_or_error.is_error()) @@ -153,5 +153,5 @@ void RequestClient::websocket_certificate_requested(i32 connection_id) } -template RefPtr Protocol::RequestClient::start_request(ByteString const& method, URL const&, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); -template RefPtr Protocol::RequestClient::start_request(ByteString const& method, URL const&, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); +template RefPtr Protocol::RequestClient::start_request(ByteString const& method, URL::URL const&, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); +template RefPtr Protocol::RequestClient::start_request(ByteString const& method, URL::URL const&, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); diff --git a/Userland/Libraries/LibProtocol/RequestClient.h b/Userland/Libraries/LibProtocol/RequestClient.h index 05fb4f1119c22dea826032ff77cc9df5c32fe9a1..e390123ec1835420734dbe4b915200757f158b20 100644 --- a/Userland/Libraries/LibProtocol/RequestClient.h +++ b/Userland/Libraries/LibProtocol/RequestClient.h @@ -26,11 +26,11 @@ public: explicit RequestClient(NonnullOwnPtr); template> - RefPtr start_request(ByteString const& method, URL const&, HashMap const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}); + RefPtr start_request(ByteString const& method, URL::URL const&, HashMap const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}); - RefPtr websocket_connect(const URL&, ByteString const& origin = {}, Vector const& protocols = {}, Vector const& extensions = {}, HashMap const& request_headers = {}); + RefPtr websocket_connect(const URL::URL&, ByteString const& origin = {}, Vector const& protocols = {}, Vector const& extensions = {}, HashMap const& request_headers = {}); - void ensure_connection(URL const&, ::RequestServer::CacheLevel); + void ensure_connection(URL::URL const&, ::RequestServer::CacheLevel); bool stop_request(Badge, Request&); bool set_certificate(Badge, Request&, ByteString, ByteString); diff --git a/Userland/Libraries/LibURL/CMakeLists.txt b/Userland/Libraries/LibURL/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..547dc63fa6a0a5b4c0bdcfa29ff2ad776aa98069 --- /dev/null +++ b/Userland/Libraries/LibURL/CMakeLists.txt @@ -0,0 +1,6 @@ +set(SOURCES + URL.cpp + Parser.cpp +) + +serenity_lib(LibURL url) diff --git a/Userland/Libraries/LibURL/Forward.h b/Userland/Libraries/LibURL/Forward.h new file mode 100644 index 0000000000000000000000000000000000000000..5cfe7221487817cde23aa6a19c3b131280b39f2f --- /dev/null +++ b/Userland/Libraries/LibURL/Forward.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2024, Shannon Booth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +namespace URL { +class URL; +class Parser; +} diff --git a/AK/URLParser.cpp b/Userland/Libraries/LibURL/Parser.cpp similarity index 95% rename from AK/URLParser.cpp rename to Userland/Libraries/LibURL/Parser.cpp index 1062937e2420ab967cdb5c2b277433176874798d..7ab1826b7a47f02d54ae005c39fea4c06fe6fadd 100644 --- a/AK/URLParser.cpp +++ b/Userland/Libraries/LibURL/Parser.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2021, Max Wipfli - * Copyright (c) 2023, Shannon Booth + * Copyright (c) 2023-2024, Shannon Booth * * SPDX-License-Identifier: BSD-2-Clause */ @@ -13,10 +13,10 @@ #include #include #include -#include #include +#include -namespace AK { +namespace URL { // NOTE: This is similar to the LibC macro EOF = -1. constexpr u32 end_of_file = 0xFFFFFFFF; @@ -36,11 +36,11 @@ static bool is_url_code_point(u32 code_point) static void report_validation_error(SourceLocation const& location = SourceLocation::current()) { - dbgln_if(URL_PARSER_DEBUG, "URLParser::basic_parse: Validation error! {}", location); + dbgln_if(URL_PARSER_DEBUG, "URL::Parser::basic_parse: Validation error! {}", location); } // https://url.spec.whatwg.org/#concept-opaque-host-parser -static Optional parse_opaque_host(StringView input) +static Optional parse_opaque_host(StringView input) { // 1. If input contains a forbidden host code point, host-invalid-code-point validation error, return failure. auto forbidden_host_characters_excluding_percent = "\0\t\n\r #/:<>?@[\\]^|"sv; @@ -57,7 +57,7 @@ static Optional parse_opaque_host(StringView input) // currently report validation errors, they are only useful for debugging efforts in the URL parsing code. // 4. Return the result of running UTF-8 percent-encode on input using the C0 control percent-encode set. - return String::from_byte_string(URL::percent_encode(input, URL::PercentEncodeSet::C0Control)).release_value_but_fixme_should_propagate_errors(); + return String::from_byte_string(percent_encode(input, PercentEncodeSet::C0Control)).release_value_but_fixme_should_propagate_errors(); } struct ParsedIPv4Number { @@ -122,11 +122,11 @@ static Optional parse_ipv4_number(StringView input) // 8. Let output be the mathematical integer value that is represented by input in radix-R notation, using ASCII hex digits for digits with values 0 through 15. Optional maybe_output; if (radix == 8) - maybe_output = StringUtils::convert_to_uint_from_octal(input); + maybe_output = AK::StringUtils::convert_to_uint_from_octal(input); else if (radix == 10) maybe_output = input.to_number(); else if (radix == 16) - maybe_output = StringUtils::convert_to_uint_from_hex(input); + maybe_output = AK::StringUtils::convert_to_uint_from_hex(input); else VERIFY_NOT_REACHED(); @@ -139,7 +139,7 @@ static Optional parse_ipv4_number(StringView input) } // https://url.spec.whatwg.org/#concept-ipv4-parser -static Optional parse_ipv4_address(StringView input) +static Optional parse_ipv4_address(StringView input) { // 1. Let parts be the result of strictly splitting input on U+002E (.). auto parts = input.split_view("."sv, SplitBehavior::KeepEmpty); @@ -193,7 +193,7 @@ static Optional parse_ipv4_address(StringView input) } // 8. If the last item in numbers is greater than or equal to 256^(5 − numbers’s size), then return failure. - if (numbers.last() >= pow(256, 5 - numbers.size())) + if (numbers.last() >= AK::pow(256, 5 - numbers.size())) return {}; // 9. Let ipv4 be the last item in numbers. @@ -208,7 +208,7 @@ static Optional parse_ipv4_address(StringView input) // 12. For each n of numbers: for (u32 n : numbers) { // 1. Increment ipv4 by n × 256^(3 − counter). - ipv4 += n * pow(256, 3 - counter); + ipv4 += n * AK::pow(256, 3 - counter); // 2. Increment counter by 1. ++counter; @@ -219,7 +219,7 @@ static Optional parse_ipv4_address(StringView input) } // https://url.spec.whatwg.org/#concept-ipv4-serializer -static ErrorOr serialize_ipv4_address(URL::IPv4Address address) +static ErrorOr serialize_ipv4_address(IPv4Address address) { // 1. Let output be the empty string. // NOTE: Array to avoid prepend. @@ -245,7 +245,7 @@ static ErrorOr serialize_ipv4_address(URL::IPv4Address address) } // https://url.spec.whatwg.org/#concept-ipv6-serializer -static void serialize_ipv6_address(URL::IPv6Address const& address, StringBuilder& output) +static void serialize_ipv6_address(IPv6Address const& address, StringBuilder& output) { // 1. Let output be the empty string. @@ -315,7 +315,7 @@ static void serialize_ipv6_address(URL::IPv6Address const& address, StringBuilde } // https://url.spec.whatwg.org/#concept-ipv6-parser -static Optional parse_ipv6_address(StringView input) +static Optional parse_ipv6_address(StringView input) { // 1. Let address be a new IPv6 address whose IPv6 pieces are all 0. Array address {}; @@ -576,7 +576,7 @@ static bool ends_in_a_number_checker(StringView input) // https://url.spec.whatwg.org/#concept-host-parser // NOTE: This is a very bare-bones implementation. -static Optional parse_host(StringView input, bool is_opaque = false) +static Optional parse_host(StringView input, bool is_opaque = false) { // 1. If input starts with U+005B ([), then: if (input.starts_with('[')) { @@ -601,7 +601,7 @@ static Optional parse_host(StringView input, bool is_opaque = false) VERIFY(!input.is_empty()); // FIXME: 4. Let domain be the result of running UTF-8 decode without BOM on the percent-decoding of input. - auto domain = URL::percent_decode(input); + auto domain = percent_decode(input); // NOTE: This is handled in Unicode::create_unicode_url, to work around the fact that we can't call into LibUnicode here // FIXME: 5. Let asciiDomain be the result of running domain to ASCII with domain and false. @@ -635,17 +635,17 @@ static Optional parse_host(StringView input, bool is_opaque = false) } // https://url.spec.whatwg.org/#concept-host-serializer -ErrorOr URLParser::serialize_host(URL::Host const& host) +ErrorOr Parser::serialize_host(Host const& host) { // 1. If host is an IPv4 address, return the result of running the IPv4 serializer on host. - if (host.has()) - return serialize_ipv4_address(host.get()); + if (host.has()) + return serialize_ipv4_address(host.get()); // 2. Otherwise, if host is an IPv6 address, return U+005B ([), followed by the result of running the IPv6 serializer on host, followed by U+005D (]). - if (host.has()) { + if (host.has()) { StringBuilder output; TRY(output.try_append('[')); - serialize_ipv6_address(host.get(), output); + serialize_ipv6_address(host.get(), output); TRY(output.try_append(']')); return output.to_string(); } @@ -689,7 +689,7 @@ constexpr bool is_double_dot_path_segment(StringView input) } // https://url.spec.whatwg.org/#shorten-a-urls-path -void URLParser::shorten_urls_path(URL& url) +void Parser::shorten_urls_path(URL& url) { // 1. Assert: url does not have an opaque path. VERIFY(!url.cannot_be_a_base_url()); @@ -707,7 +707,7 @@ void URLParser::shorten_urls_path(URL& url) } // https://url.spec.whatwg.org/#string-percent-encode-after-encoding -ErrorOr URLParser::percent_encode_after_encoding(StringView input, URL::PercentEncodeSet percent_encode_set, bool space_as_plus) +ErrorOr Parser::percent_encode_after_encoding(StringView input, PercentEncodeSet percent_encode_set, bool space_as_plus) { // NOTE: This is written somewhat ad-hoc since we don't yet implement the Encoding spec. @@ -727,7 +727,7 @@ ErrorOr URLParser::percent_encode_after_encoding(StringView input, URL:: // 3. Assert: percentEncodeSet includes all non-ASCII code points. // 4. If isomorphic is not in percentEncodeSet, then append isomorph to output. - if (!URL::code_point_is_in_percent_encode_set(isomorph, percent_encode_set)) { + if (!code_point_is_in_percent_encode_set(isomorph, percent_encode_set)) { output.append_code_point(isomorph); } @@ -748,9 +748,9 @@ ErrorOr URLParser::percent_encode_after_encoding(StringView input, URL:: // future for validation of URLs, which would then lead to infinite recursion. // The same goes for base_url, because e.g. the port() getter does not always return m_port, and we are interested in the underlying member // variables' values here, not what the URL class presents to its users. -URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, Optional url, Optional state_override) +URL Parser::basic_parse(StringView raw_input, Optional const& base_url, Optional url, Optional state_override) { - dbgln_if(URL_PARSER_DEBUG, "URLParser::parse: Parsing '{}'", raw_input); + dbgln_if(URL_PARSER_DEBUG, "URL::Parser::parse: Parsing '{}'", raw_input); if (raw_input.is_empty()) return base_url.has_value() ? *base_url : URL {}; @@ -841,11 +841,11 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, if constexpr (URL_PARSER_DEBUG) { if (code_point == end_of_file) - dbgln("URLParser::basic_parse: {} state with EOF.", state_name(state)); + dbgln("URL::Parser::basic_parse: {} state with EOF.", state_name(state)); else if (is_ascii_printable(code_point)) - dbgln("URLParser::basic_parse: {} state with code point U+{:04X} ({:c}).", state_name(state), code_point, code_point); + dbgln("URL::Parser::basic_parse: {} state with code point U+{:04X} ({:c}).", state_name(state), code_point, code_point); else - dbgln("URLParser::basic_parse: {} state with code point U+{:04X}.", state_name(state), code_point); + dbgln("URL::Parser::basic_parse: {} state with code point U+{:04X}.", state_name(state), code_point); } switch (state) { @@ -877,11 +877,11 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, // 1. If state override is given, then: if (state_override.has_value()) { // 1. If url’s scheme is a special scheme and buffer is not a special scheme, then return. - if (URL::is_special_scheme(url->scheme()) && !URL::is_special_scheme(buffer.string_view())) + if (is_special_scheme(url->scheme()) && !is_special_scheme(buffer.string_view())) return *url; // 2. If url’s scheme is not a special scheme and buffer is a special scheme, then return. - if (!URL::is_special_scheme(url->scheme()) && URL::is_special_scheme(buffer.string_view())) + if (!is_special_scheme(url->scheme()) && is_special_scheme(buffer.string_view())) return *url; // 3. If url includes credentials or has a non-null port, and buffer is "file", then return. @@ -899,7 +899,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, // 3. If state override is given, then: if (state_override.has_value()) { // 1. If url’s port is url’s scheme’s default port, then set url’s port to null. - if (url->port() == URL::default_port_for_scheme(url->scheme())) + if (url->port() == default_port_for_scheme(url->scheme())) url->m_port = {}; // 2. Return. @@ -1147,14 +1147,14 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, if (password_builder.is_empty()) password_builder.append(url->m_password); - URL::append_percent_encoded_if_necessary(password_builder, c, URL::PercentEncodeSet::Userinfo); + append_percent_encoded_if_necessary(password_builder, c, PercentEncodeSet::Userinfo); } // 4. Otherwise, append encodedCodePoints to url’s username. else { if (username_builder.is_empty()) username_builder.append(url->m_username); - URL::append_percent_encoded_if_necessary(username_builder, c, URL::PercentEncodeSet::Userinfo); + append_percent_encoded_if_necessary(username_builder, c, PercentEncodeSet::Userinfo); } } @@ -1305,7 +1305,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, } // 3. Set url’s port to null, if port is url’s scheme’s default port; otherwise to port. - if (port.value() == URL::default_port_for_scheme(url->scheme())) + if (port.value() == default_port_for_scheme(url->scheme())) url->m_port = {}; else url->m_port = port.value(); @@ -1585,7 +1585,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, report_validation_error(); // 3. UTF-8 percent-encode c using the path percent-encode set and append the result to buffer. - URL::append_percent_encoded_if_necessary(buffer, code_point, URL::PercentEncodeSet::Path); + append_percent_encoded_if_necessary(buffer, code_point, PercentEncodeSet::Path); } break; // -> opaque path state, https://url.spec.whatwg.org/#cannot-be-a-base-url-path-state @@ -1620,7 +1620,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, // 3. If c is not the EOF code point, UTF-8 percent-encode c using the C0 control percent-encode set and append the result to url’s path. if (code_point != end_of_file) { - URL::append_percent_encoded_if_necessary(buffer, code_point, URL::PercentEncodeSet::C0Control); + append_percent_encoded_if_necessary(buffer, code_point, PercentEncodeSet::C0Control); } else { url->m_paths[0] = buffer.to_string_without_validation(); buffer.clear(); @@ -1642,7 +1642,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, // then: // 1. Let queryPercentEncodeSet be the special-query percent-encode set if url is special; otherwise the query percent-encode set. - auto query_percent_encode_set = url->is_special() ? URL::PercentEncodeSet::SpecialQuery : URL::PercentEncodeSet::Query; + auto query_percent_encode_set = url->is_special() ? PercentEncodeSet::SpecialQuery : PercentEncodeSet::Query; // 2. Percent-encode after encoding, with encoding, buffer, and queryPercentEncodeSet, and append the result to url’s query. url->m_query = percent_encode_after_encoding(buffer.string_view(), query_percent_encode_set).release_value_but_fixme_should_propagate_errors(); @@ -1687,7 +1687,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, // NOTE: The percent-encode is done on EOF on the entire buffer. buffer.append_code_point(code_point); } else { - url->m_fragment = percent_encode_after_encoding(buffer.string_view(), URL::PercentEncodeSet::Fragment).release_value_but_fixme_should_propagate_errors(); + url->m_fragment = percent_encode_after_encoding(buffer.string_view(), PercentEncodeSet::Fragment).release_value_but_fixme_should_propagate_errors(); buffer.clear(); } break; @@ -1701,7 +1701,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, } url->m_valid = true; - dbgln_if(URL_PARSER_DEBUG, "URLParser::parse: Parsed URL to be '{}'.", url->serialize()); + dbgln_if(URL_PARSER_DEBUG, "URL::Parser::parse: Parsed URL to be '{}'.", url->serialize()); // 10. Return url. return url.release_value(); diff --git a/AK/URLParser.h b/Userland/Libraries/LibURL/Parser.h similarity index 86% rename from AK/URLParser.h rename to Userland/Libraries/LibURL/Parser.h index e43ed9a52ee52effd6c7044ea71f1bdadbe59f58..185e2a2126f314c0285512ed4275f838c4587fab 100644 --- a/AK/URLParser.h +++ b/Userland/Libraries/LibURL/Parser.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2021, Max Wipfli - * Copyright (c) 2023, Shannon Booth + * Copyright (c) 2023-2024, Shannon Booth * * SPDX-License-Identifier: BSD-2-Clause */ @@ -9,9 +9,9 @@ #include #include -#include +#include -namespace AK { +namespace URL { #define ENUMERATE_STATES \ STATE(SchemeStart) \ @@ -36,7 +36,7 @@ namespace AK { STATE(Query) \ STATE(Fragment) -class URLParser { +class Parser { public: enum class State { #define STATE(state) state, @@ -60,10 +60,10 @@ public: static URL basic_parse(StringView input, Optional const& base_url = {}, Optional url = {}, Optional state_override = {}); // https://url.spec.whatwg.org/#string-percent-encode-after-encoding - static ErrorOr percent_encode_after_encoding(StringView input, URL::PercentEncodeSet percent_encode_set, bool space_as_plus = false); + static ErrorOr percent_encode_after_encoding(StringView input, PercentEncodeSet percent_encode_set, bool space_as_plus = false); // https://url.spec.whatwg.org/#concept-host-serializer - static ErrorOr serialize_host(URL::Host const&); + static ErrorOr serialize_host(Host const&); // https://url.spec.whatwg.org/#shorten-a-urls-path static void shorten_urls_path(URL&); @@ -72,7 +72,3 @@ public: #undef ENUMERATE_STATES } - -#if USING_AK_GLOBALLY -using AK::URLParser; -#endif diff --git a/AK/URL.cpp b/Userland/Libraries/LibURL/URL.cpp similarity index 86% rename from AK/URL.cpp rename to Userland/Libraries/LibURL/URL.cpp index fa843e4cbe967149ef441d1be840d92f12aae5bf..37dc8075d7e12a40d4c845646eadaea17c7c33e1 100644 --- a/AK/URL.cpp +++ b/Userland/Libraries/LibURL/URL.cpp @@ -10,15 +10,15 @@ #include #include #include -#include -#include #include +#include +#include -namespace AK { +namespace URL { -// FIXME: It could make sense to force users of URL to use URLParser::basic_parse() explicitly instead of using a constructor. +// FIXME: It could make sense to force users of URL to use URL::Parser::basic_parse() explicitly instead of using a constructor. URL::URL(StringView string) - : URL(URLParser::basic_parse(string)) + : URL(Parser::basic_parse(string)) { if constexpr (URL_PARSER_DEBUG) { if (m_valid) @@ -33,7 +33,7 @@ URL URL::complete_url(StringView relative_url) const if (!is_valid()) return {}; - return URLParser::basic_parse(relative_url, *this); + return Parser::basic_parse(relative_url, *this); } ErrorOr URL::username() const @@ -95,7 +95,7 @@ void URL::set_host(Host host) // https://url.spec.whatwg.org/#concept-host-serializer ErrorOr URL::serialized_host() const { - return URLParser::serialize_host(m_host); + return Parser::serialize_host(m_host); } void URL::set_port(Optional port) @@ -157,7 +157,7 @@ bool URL::compute_validity() const } // https://url.spec.whatwg.org/#default-port -Optional URL::default_port_for_scheme(StringView scheme) +Optional default_port_for_scheme(StringView scheme) { // Spec defined mappings with port: if (scheme == "ftp") @@ -182,7 +182,7 @@ Optional URL::default_port_for_scheme(StringView scheme) return {}; } -URL URL::create_with_file_scheme(ByteString const& path, ByteString const& fragment, ByteString const& hostname) +URL create_with_file_scheme(ByteString const& path, ByteString const& fragment, ByteString const& hostname) { LexicalPath lexical_path(path); if (!lexical_path.is_absolute()) @@ -199,7 +199,7 @@ URL URL::create_with_file_scheme(ByteString const& path, ByteString const& fragm return url; } -URL URL::create_with_help_scheme(ByteString const& path, ByteString const& fragment, ByteString const& hostname) +URL create_with_help_scheme(ByteString const& path, ByteString const& fragment, ByteString const& hostname) { LexicalPath lexical_path(path); @@ -215,17 +215,17 @@ URL URL::create_with_help_scheme(ByteString const& path, ByteString const& fragm return url; } -URL URL::create_with_url_or_path(ByteString const& url_or_path) +URL create_with_url_or_path(ByteString const& url_or_path) { URL url = url_or_path; if (url.is_valid()) return url; ByteString path = LexicalPath::canonicalized_path(url_or_path); - return URL::create_with_file_scheme(path); + return create_with_file_scheme(path); } -URL URL::create_with_data(StringView mime_type, StringView payload, bool is_base64) +URL create_with_data(StringView mime_type, StringView payload, bool is_base64) { URL url; url.set_cannot_be_a_base_url(true); @@ -242,7 +242,7 @@ URL URL::create_with_data(StringView mime_type, StringView payload, bool is_base } // https://url.spec.whatwg.org/#special-scheme -bool URL::is_special_scheme(StringView scheme) +bool is_special_scheme(StringView scheme) { return scheme.is_one_of("ftp", "file", "http", "https", "ws", "wss"); } @@ -420,13 +420,13 @@ bool URL::equals(URL const& other, ExcludeFragment exclude_fragments) const } // https://fetch.spec.whatwg.org/#data-url-processor -ErrorOr URL::process_data_url() const +ErrorOr URL::process_data_url() const { // 1. Assert: dataURL’s scheme is "data". VERIFY(scheme() == "data"); // 2. Let input be the result of running the URL serializer on dataURL with exclude fragment set to true. - auto input = serialize(URL::ExcludeFragment::Yes); + auto input = serialize(ExcludeFragment::Yes); // 3. Remove the leading "data:" from input. input = input.substring("data:"sv.length()); @@ -451,7 +451,7 @@ ErrorOr URL::process_data_url() const auto encoded_body = input.substring_view(position.value()); // 10. Let body be the percent-decoding of encodedBody. - auto body = URL::percent_decode(encoded_body).to_byte_buffer(); + auto body = percent_decode(encoded_body).to_byte_buffer(); // 11. If mimeType ends with U+003B (;), followed by zero or more U+0020 SPACE, followed by an ASCII case-insensitive match for "base64", then: if (mime_type.ends_with("base64"sv, CaseSensitivity::CaseInsensitive)) { @@ -490,10 +490,10 @@ ErrorOr URL::process_data_url() const mime_type_record = "text/plain;charset=US-ASCII"sv; // 15. Return a new data: URL struct whose MIME type is mimeTypeRecord and body is body. - return URL::DataURL { TRY(String::from_utf8(mime_type_record)), body }; + return DataURL { TRY(String::from_utf8(mime_type_record)), body }; } -void URL::append_percent_encoded(StringBuilder& builder, u32 code_point) +void append_percent_encoded(StringBuilder& builder, u32 code_point) { if (code_point <= 0x7f) builder.appendff("%{:02X}", code_point); @@ -508,28 +508,28 @@ void URL::append_percent_encoded(StringBuilder& builder, u32 code_point) } // https://url.spec.whatwg.org/#c0-control-percent-encode-set -bool URL::code_point_is_in_percent_encode_set(u32 code_point, URL::PercentEncodeSet set) +bool code_point_is_in_percent_encode_set(u32 code_point, PercentEncodeSet set) { // NOTE: Once we've checked for presence in the C0Control set, we know that the code point is // a valid ASCII character in the range 0x20..0x7E, so we can safely cast it to char. switch (set) { - case URL::PercentEncodeSet::C0Control: + case PercentEncodeSet::C0Control: return code_point < 0x20 || code_point > 0x7E; - case URL::PercentEncodeSet::Fragment: - return code_point_is_in_percent_encode_set(code_point, URL::PercentEncodeSet::C0Control) || " \"<>`"sv.contains(static_cast(code_point)); - case URL::PercentEncodeSet::Query: - return code_point_is_in_percent_encode_set(code_point, URL::PercentEncodeSet::C0Control) || " \"#<>"sv.contains(static_cast(code_point)); - case URL::PercentEncodeSet::SpecialQuery: - return code_point_is_in_percent_encode_set(code_point, URL::PercentEncodeSet::Query) || code_point == '\''; - case URL::PercentEncodeSet::Path: - return code_point_is_in_percent_encode_set(code_point, URL::PercentEncodeSet::Query) || "?`{}"sv.contains(static_cast(code_point)); - case URL::PercentEncodeSet::Userinfo: - return code_point_is_in_percent_encode_set(code_point, URL::PercentEncodeSet::Path) || "/:;=@[\\]^|"sv.contains(static_cast(code_point)); - case URL::PercentEncodeSet::Component: - return code_point_is_in_percent_encode_set(code_point, URL::PercentEncodeSet::Userinfo) || "$%&+,"sv.contains(static_cast(code_point)); - case URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded: - return code_point_is_in_percent_encode_set(code_point, URL::PercentEncodeSet::Component) || "!'()~"sv.contains(static_cast(code_point)); - case URL::PercentEncodeSet::EncodeURI: + case PercentEncodeSet::Fragment: + return code_point_is_in_percent_encode_set(code_point, PercentEncodeSet::C0Control) || " \"<>`"sv.contains(static_cast(code_point)); + case PercentEncodeSet::Query: + return code_point_is_in_percent_encode_set(code_point, PercentEncodeSet::C0Control) || " \"#<>"sv.contains(static_cast(code_point)); + case PercentEncodeSet::SpecialQuery: + return code_point_is_in_percent_encode_set(code_point, PercentEncodeSet::Query) || code_point == '\''; + case PercentEncodeSet::Path: + return code_point_is_in_percent_encode_set(code_point, PercentEncodeSet::Query) || "?`{}"sv.contains(static_cast(code_point)); + case PercentEncodeSet::Userinfo: + return code_point_is_in_percent_encode_set(code_point, PercentEncodeSet::Path) || "/:;=@[\\]^|"sv.contains(static_cast(code_point)); + case PercentEncodeSet::Component: + return code_point_is_in_percent_encode_set(code_point, PercentEncodeSet::Userinfo) || "$%&+,"sv.contains(static_cast(code_point)); + case PercentEncodeSet::ApplicationXWWWFormUrlencoded: + return code_point_is_in_percent_encode_set(code_point, PercentEncodeSet::Component) || "!'()~"sv.contains(static_cast(code_point)); + case PercentEncodeSet::EncodeURI: // NOTE: This is the same percent encode set that JS encodeURI() uses. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI return code_point > 0x7E || (!is_ascii_alphanumeric(code_point) && !";,/?:@&=+$-_.!~*'()#"sv.contains(static_cast(code_point))); @@ -538,7 +538,7 @@ bool URL::code_point_is_in_percent_encode_set(u32 code_point, URL::PercentEncode } } -void URL::append_percent_encoded_if_necessary(StringBuilder& builder, u32 code_point, URL::PercentEncodeSet set) +void append_percent_encoded_if_necessary(StringBuilder& builder, u32 code_point, PercentEncodeSet set) { if (code_point_is_in_percent_encode_set(code_point, set)) append_percent_encoded(builder, code_point); @@ -546,7 +546,7 @@ void URL::append_percent_encoded_if_necessary(StringBuilder& builder, u32 code_p builder.append_code_point(code_point); } -ByteString URL::percent_encode(StringView input, URL::PercentEncodeSet set, SpaceAsPlus space_as_plus) +ByteString percent_encode(StringView input, PercentEncodeSet set, SpaceAsPlus space_as_plus) { StringBuilder builder; for (auto code_point : Utf8View(input)) { @@ -558,7 +558,7 @@ ByteString URL::percent_encode(StringView input, URL::PercentEncodeSet set, Spac return builder.to_byte_string(); } -ByteString URL::percent_decode(StringView input) +ByteString percent_decode(StringView input) { if (!input.contains('%')) return input; diff --git a/AK/URL.h b/Userland/Libraries/LibURL/URL.h similarity index 63% rename from AK/URL.h rename to Userland/Libraries/LibURL/URL.h index 2aeee6365ff95e5148195917a51262e69da8e9fd..98492f95f923ae6ddd5aa8481d1ee847dc280e74 100644 --- a/AK/URL.h +++ b/Userland/Libraries/LibURL/URL.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2021, Max Wipfli - * Copyright (c) 2023, Shannon Booth + * Copyright (c) 2023-2024, Shannon Booth * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,31 +18,70 @@ # undef basename #endif -namespace AK { +namespace URL { + +enum class PercentEncodeSet { + C0Control, + Fragment, + Query, + SpecialQuery, + Path, + Userinfo, + Component, + ApplicationXWWWFormUrlencoded, + EncodeURI +}; + +enum class ExcludeFragment { + No, + Yes +}; + +// https://url.spec.whatwg.org/#concept-ipv4 +// An IPv4 address is a 32-bit unsigned integer that identifies a network address. [RFC791] +// FIXME: It would be nice if this were an AK::IPv4Address +using IPv4Address = u32; + +// https://url.spec.whatwg.org/#concept-ipv6 +// An IPv6 address is a 128-bit unsigned integer that identifies a network address. For the purposes of this standard +// it is represented as a list of eight 16-bit unsigned integers, also known as IPv6 pieces. [RFC4291] +// FIXME: It would be nice if this were an AK::IPv6Address +using IPv6Address = Array; + +// https://url.spec.whatwg.org/#concept-host +// A host is a domain, an IP address, an opaque host, or an empty host. Typically a host serves as a network address, +// but it is sometimes used as opaque identifier in URLs where a network address is not necessary. +using Host = Variant; + +enum class ApplyPercentDecoding { + Yes, + No +}; + +struct DataURL { + String mime_type; + ByteBuffer body; +}; + +void append_percent_encoded_if_necessary(StringBuilder&, u32 code_point, PercentEncodeSet set = PercentEncodeSet::Userinfo); +void append_percent_encoded(StringBuilder&, u32 code_point); +bool code_point_is_in_percent_encode_set(u32 code_point, PercentEncodeSet); +Optional default_port_for_scheme(StringView); +bool is_special_scheme(StringView); + +enum class SpaceAsPlus { + No, + Yes, +}; +ByteString percent_encode(StringView input, PercentEncodeSet set = PercentEncodeSet::Userinfo, SpaceAsPlus = SpaceAsPlus::No); +ByteString percent_decode(StringView input); // https://url.spec.whatwg.org/#url-representation // A URL is a struct that represents a universal identifier. To disambiguate from a valid URL string it can also be referred to as a URL record. class URL { - friend class URLParser; + friend class Parser; public: - enum class PercentEncodeSet { - C0Control, - Fragment, - Query, - SpecialQuery, - Path, - Userinfo, - Component, - ApplicationXWWWFormUrlencoded, - EncodeURI - }; - - enum class ExcludeFragment { - No, - Yes - }; - URL() = default; URL(StringView); URL(ByteString const& string) @@ -54,22 +93,6 @@ public: { } - // https://url.spec.whatwg.org/#concept-ipv4 - // An IPv4 address is a 32-bit unsigned integer that identifies a network address. [RFC791] - // FIXME: It would be nice if this were an AK::IPv4Address - using IPv4Address = u32; - - // https://url.spec.whatwg.org/#concept-ipv6 - // An IPv6 address is a 128-bit unsigned integer that identifies a network address. For the purposes of this standard - // it is represented as a list of eight 16-bit unsigned integers, also known as IPv6 pieces. [RFC4291] - // FIXME: It would be nice if this were an AK::IPv6Address - using IPv6Address = Array; - - // https://url.spec.whatwg.org/#concept-host - // A host is a domain, an IP address, an opaque host, or an empty host. Typically a host serves as a network address, - // but it is sometimes used as opaque identifier in URLs where a network address is not necessary. - using Host = Variant; - bool is_valid() const { return m_valid; } String const& scheme() const { return m_scheme; } @@ -107,10 +130,6 @@ public: m_paths.append(String {}); } - enum class ApplyPercentDecoding { - Yes, - No - }; ByteString serialize_path(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const; ByteString serialize(ExcludeFragment = ExcludeFragment::No) const; ByteString serialize_for_display() const; @@ -124,40 +143,16 @@ public: URL complete_url(StringView) const; - struct DataURL { - String mime_type; - ByteBuffer body; - }; ErrorOr process_data_url() const; - static URL create_with_url_or_path(ByteString const&); - static URL create_with_file_scheme(ByteString const& path, ByteString const& fragment = {}, ByteString const& hostname = {}); - static URL create_with_help_scheme(ByteString const& path, ByteString const& fragment = {}, ByteString const& hostname = {}); - static URL create_with_data(StringView mime_type, StringView payload, bool is_base64 = false); - - static Optional default_port_for_scheme(StringView); - static bool is_special_scheme(StringView); - - enum class SpaceAsPlus { - No, - Yes, - }; - static ByteString percent_encode(StringView input, PercentEncodeSet set = PercentEncodeSet::Userinfo, SpaceAsPlus = SpaceAsPlus::No); - static ByteString percent_decode(StringView input); - bool operator==(URL const& other) const { return equals(other, ExcludeFragment::No); } - static bool code_point_is_in_percent_encode_set(u32 code_point, URL::PercentEncodeSet); - String const& raw_username() const { return m_username; } String const& raw_password() const { return m_password; } private: bool compute_validity() const; - static void append_percent_encoded_if_necessary(StringBuilder&, u32 code_point, PercentEncodeSet set = PercentEncodeSet::Userinfo); - static void append_percent_encoded(StringBuilder&, u32 code_point); - bool m_valid { false }; // A URL’s scheme is an ASCII string that identifies the type of URL and can be used to dispatch a URL for further processing after parsing. It is initially the empty string. @@ -188,17 +183,22 @@ private: bool m_cannot_be_a_base_url { false }; }; +URL create_with_url_or_path(ByteString const&); +URL create_with_file_scheme(ByteString const& path, ByteString const& fragment = {}, ByteString const& hostname = {}); +URL create_with_help_scheme(ByteString const& path, ByteString const& fragment = {}, ByteString const& hostname = {}); +URL create_with_data(StringView mime_type, StringView payload, bool is_base64 = false); + +} + template<> -struct Formatter : Formatter { - ErrorOr format(FormatBuilder& builder, URL const& value) +struct AK::Formatter : AK::Formatter { + ErrorOr format(FormatBuilder& builder, URL::URL const& value) { return Formatter::format(builder, value.serialize()); } }; template<> -struct Traits : public DefaultTraits { - static unsigned hash(URL const& url) { return url.to_byte_string().hash(); } +struct AK::Traits : public AK::DefaultTraits { + static unsigned hash(URL::URL const& url) { return url.to_byte_string().hash(); } }; - -} diff --git a/Userland/Libraries/LibUnicode/CMakeLists.txt b/Userland/Libraries/LibUnicode/CMakeLists.txt index 45ac83182c40809802266a160ec0c30a7414d452..38b0cc989c29c379949b0aea4d0fcb97e147b014 100644 --- a/Userland/Libraries/LibUnicode/CMakeLists.txt +++ b/Userland/Libraries/LibUnicode/CMakeLists.txt @@ -16,4 +16,6 @@ set(SOURCES set(GENERATED_SOURCES ${CURRENT_LIB_GENERATED}) serenity_lib(LibUnicode unicode) +target_link_libraries(LibUnicode PRIVATE LibURL) + target_compile_definitions(LibUnicode PRIVATE ENABLE_UNICODE_DATA=$) diff --git a/Userland/Libraries/LibUnicode/URL.cpp b/Userland/Libraries/LibUnicode/URL.cpp index 5c69f447d5cfa3db89fe9d04b8e32953ffc4be6d..d9c382453bd885d40037cb6915a8588ee1d38378 100644 --- a/Userland/Libraries/LibUnicode/URL.cpp +++ b/Userland/Libraries/LibUnicode/URL.cpp @@ -33,11 +33,11 @@ static ErrorOr domain_to_ascii(StringView domain, bool be_strict) } // https://url.spec.whatwg.org/#concept-host-parser -ErrorOr create_unicode_url(String const& url_string) +ErrorOr create_unicode_url(String const& url_string) { - // NOTE: 1.-4. are implemented in URLParser::parse_host + // NOTE: 1.-4. are implemented in URL::Parser::parse_host - URL url = url_string; + URL::URL url = url_string; if (!url.is_valid() || !url.host().has()) return url; @@ -49,7 +49,7 @@ ErrorOr create_unicode_url(String const& url_string) // 6. If asciiDomain is failure, then return failure. auto ascii_domain = TRY(domain_to_ascii(domain.bytes_as_string_view(), false)); - // FIXME: Reimplement 7. or call into URLParser::parse_host using ascii_domain (8. & 9. do not apply) + // FIXME: Reimplement 7. or call into URL::Parser::parse_host using ascii_domain (8. & 9. do not apply) url.set_host(ascii_domain); return url; } diff --git a/Userland/Libraries/LibUnicode/URL.h b/Userland/Libraries/LibUnicode/URL.h index ab19cdd7d9a7a3f3f8a062bbb6601ff6edfcc9a3..1e410da10e6ce6c68c43e2ff878f819e1560873f 100644 --- a/Userland/Libraries/LibUnicode/URL.h +++ b/Userland/Libraries/LibUnicode/URL.h @@ -7,10 +7,10 @@ #pragma once #include -#include +#include namespace Unicode { -ErrorOr create_unicode_url(String const&); +ErrorOr create_unicode_url(String const&); } diff --git a/Userland/Libraries/LibVT/CMakeLists.txt b/Userland/Libraries/LibVT/CMakeLists.txt index 01d7ec90d9e5909cd04857b5f5671772922a8374..6d07972f4c461a4ea6ea134f79fc9caafe4026fe 100644 --- a/Userland/Libraries/LibVT/CMakeLists.txt +++ b/Userland/Libraries/LibVT/CMakeLists.txt @@ -11,4 +11,4 @@ set(GENERATED_SOURCES generate_state_machine(StateMachine.txt EscapeSequenceStateMachine.h) serenity_lib(LibVT vt) -target_link_libraries(LibVT PRIVATE LibCore LibGUI LibGfx LibDesktop LibConfig) +target_link_libraries(LibVT PRIVATE LibCore LibGUI LibGfx LibDesktop LibConfig LibURL) diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp index 5de996a4cdc7797f757abdddcbcf91635b32fa92..861c86700c839c0f91780cc7a34e369d21c33a38 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.cpp +++ b/Userland/Libraries/LibVT/TerminalWidget.cpp @@ -883,7 +883,7 @@ void TerminalWidget::mousemove_event(GUI::MouseEvent& event) auto handlers = Desktop::Launcher::get_handlers_for_url(attribute.href); if (!handlers.is_empty()) { - auto url = URL(attribute.href); + auto url = URL::URL(attribute.href); auto path = url.serialize_path(); auto app_file = Desktop::AppFile::get_for_app(LexicalPath::basename(handlers[0])); @@ -1179,7 +1179,7 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event) })); m_context_menu_for_hyperlink->add_action(GUI::Action::create("Copy &Name", [&](auto&) { // file://courage/home/anon/something -> /home/anon/something - auto path = URL(m_context_menu_href).serialize_path(); + auto path = URL::URL(m_context_menu_href).serialize_path(); // /home/anon/something -> something auto name = LexicalPath::basename(path); GUI::Clipboard::the().set_plain_text(name); diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 8fec889536ce4c11449dc6fd0069b75ce72278b8..01f143fa340c7b41307fdf082a05d844853ad4ac 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -705,7 +705,7 @@ set(GENERATED_SOURCES serenity_lib(LibWeb web) # NOTE: We link with LibSoftGPU here instead of lazy loading it via dlopen() so that we do not have to unveil the library and pledge prot_exec. -target_link_libraries(LibWeb PRIVATE LibCore LibCrypto LibJS LibMarkdown LibHTTP LibGemini LibGUI LibGfx LibIPC LibLocale LibRegex LibSoftGPU LibSyntax LibTextCodec LibUnicode LibAudio LibVideo LibWasm LibXML LibIDL) +target_link_libraries(LibWeb PRIVATE LibCore LibCrypto LibJS LibMarkdown LibHTTP LibGemini LibGUI LibGfx LibIPC LibLocale LibRegex LibSoftGPU LibSyntax LibTextCodec LibUnicode LibAudio LibVideo LibWasm LibXML LibIDL LibURL) link_with_locale_data(LibWeb) if (HAS_ACCELERATED_GRAPHICS) diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp index a17284f772687247e7cf1439b7bdfb70f61025fc..7711f44b1c96f764d6500742076aafb7a3a98c96 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp @@ -64,8 +64,8 @@ String CSSFontFaceRule::serialized() const // 2. The result of invoking serialize a comma-separated list on performing serialize a URL or serialize a LOCAL for each source on the source list. serialize_a_comma_separated_list(builder, m_font_face.sources(), [&](StringBuilder& builder, FontFace::Source source) -> void { - if (source.local_or_url.has()) { - serialize_a_url(builder, MUST(source.local_or_url.get().to_string())); + if (source.local_or_url.has()) { + serialize_a_url(builder, MUST(source.local_or_url.get().to_string())); } else { builder.appendff("local({})", source.local_or_url.get()); } diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp index 6449393d5161e897a046626e2e221fa0b01dd45e..8e60d6498080286cce8ce572341b00b7b6304c27 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include #include @@ -21,13 +21,13 @@ namespace Web::CSS { JS_DEFINE_ALLOCATOR(CSSImportRule); -JS::NonnullGCPtr CSSImportRule::create(URL url, DOM::Document& document) +JS::NonnullGCPtr CSSImportRule::create(URL::URL url, DOM::Document& document) { auto& realm = document.realm(); return realm.heap().allocate(realm, move(url), document); } -CSSImportRule::CSSImportRule(URL url, DOM::Document& document) +CSSImportRule::CSSImportRule(URL::URL url, DOM::Document& document) : CSSRule(document.realm()) , m_url(move(url)) , m_document(document) diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h index d3fd12f4199deb8aacffcd639ffcbff030421a0f..a59fecb254e4c13e15c18b513f9e27657f443186 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h @@ -8,7 +8,7 @@ #pragma once -#include +#include #include #include #include @@ -23,11 +23,11 @@ class CSSImportRule final JS_DECLARE_ALLOCATOR(CSSImportRule); public: - [[nodiscard]] static JS::NonnullGCPtr create(URL, DOM::Document&); + [[nodiscard]] static JS::NonnullGCPtr create(URL::URL, DOM::Document&); virtual ~CSSImportRule() = default; - URL const& url() const { return m_url; } + URL::URL const& url() const { return m_url; } // FIXME: This should return only the specified part of the url. eg, "stuff/foo.css", not "https://example.com/stuff/foo.css". String href() const { return MUST(m_url.to_string()); } @@ -39,7 +39,7 @@ public: virtual Type type() const override { return Type::Import; } private: - CSSImportRule(URL, DOM::Document&); + CSSImportRule(URL::URL, DOM::Document&); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; @@ -50,7 +50,7 @@ private: virtual void resource_did_fail() override; virtual void resource_did_load() override; - URL m_url; + URL::URL m_url; JS::GCPtr m_document; JS::GCPtr m_style_sheet; Optional m_document_load_event_delayer; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index 34a9c7850e67ba15b4933aee8cf93812a49b61f5..06a45f9ddfb30d9b53c1221d8ffb14def31a8643 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -20,7 +20,7 @@ namespace Web::CSS { JS_DEFINE_ALLOCATOR(CSSStyleSheet); -JS::NonnullGCPtr CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional location) +JS::NonnullGCPtr CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional location) { return realm.heap().allocate(realm, realm, rules, media, move(location)); } @@ -37,12 +37,12 @@ WebIDL::ExceptionOr> CSSStyleSheet::construct_im // 3. Set sheet’s stylesheet base URL to the baseURL attribute value from options. if (options.has_value() && options->base_url.has_value()) { - Optional sheet_location_url; + Optional sheet_location_url; if (sheet->location().has_value()) sheet_location_url = sheet->location().release_value(); // AD-HOC: This isn't explicitly mentioned in the specification, but multiple modern browsers do this. - URL url = sheet->location().has_value() ? sheet_location_url->complete_url(options->base_url.value()) : options->base_url.value(); + URL::URL url = sheet->location().has_value() ? sheet_location_url->complete_url(options->base_url.value()) : options->base_url.value(); if (!url.is_valid()) return WebIDL::NotAllowedError::create(realm, "Constructed style sheets must have a valid base URL"_fly_string); @@ -91,7 +91,7 @@ WebIDL::ExceptionOr> CSSStyleSheet::construct_im return sheet; } -CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional location) +CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional location) : StyleSheet(realm, media) , m_rules(&rules) { diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h index fc102319eaaae1f12443a0c88b68040b5b98c99a..7d67d7dd5528d15b0142b244bf36b81518ab6056 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h @@ -32,7 +32,7 @@ class CSSStyleSheet final JS_DECLARE_ALLOCATOR(CSSStyleSheet); public: - [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, CSSRuleList&, MediaList&, Optional location); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, CSSRuleList&, MediaList&, Optional location); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, Optional const& options = {}); virtual ~CSSStyleSheet() override = default; @@ -69,8 +69,8 @@ public: Optional namespace_uri(StringView namespace_prefix) const; - Optional base_url() const { return m_base_url; } - void set_base_url(Optional base_url) { m_base_url = move(base_url); } + Optional base_url() const { return m_base_url; } + void set_base_url(Optional base_url) { m_base_url = move(base_url); } bool constructed() const { return m_constructed; } @@ -80,7 +80,7 @@ public: bool disallow_modification() const { return m_disallow_modification; } private: - CSSStyleSheet(JS::Realm&, CSSRuleList&, MediaList&, Optional location); + CSSStyleSheet(JS::Realm&, CSSRuleList&, MediaList&, Optional location); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; @@ -97,7 +97,7 @@ private: JS::GCPtr m_style_sheet_list; JS::GCPtr m_owner_css_rule; - Optional m_base_url; + Optional m_base_url; JS::GCPtr m_constructor_document; bool m_constructed { false }; bool m_disallow_modification { false }; diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index e0257373ecd5ecb128389a6875e00f658135f3ec..da2b39385b0419bc059164dd9b3963a2f0ab5295 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -201,33 +201,33 @@ public: : m_value(color) { } - SVGPaint(URL const& url) + SVGPaint(URL::URL const& url) : m_value(url) { } bool is_color() const { return m_value.has(); } - bool is_url() const { return m_value.has(); } + bool is_url() const { return m_value.has(); } Color as_color() const { return m_value.get(); } - URL const& as_url() const { return m_value.get(); } + URL::URL const& as_url() const { return m_value.get(); } private: - Variant m_value; + Variant m_value; }; // https://drafts.fxtf.org/css-masking-1/#typedef-mask-reference class MaskReference { public: // TODO: Support other mask types. - MaskReference(URL const& url) + MaskReference(URL::URL const& url) : m_url(url) { } - URL const& url() const { return m_url; } + URL::URL const& url() const { return m_url; } private: - URL m_url; + URL::URL m_url; }; struct BackgroundLayerData { diff --git a/Userland/Libraries/LibWeb/CSS/FontFace.h b/Userland/Libraries/LibWeb/CSS/FontFace.h index 561374d07565e58272567556cc0ae170ebb57a60..c415b40ab9de5c604f8ed4d76007929ef03ebc8c 100644 --- a/Userland/Libraries/LibWeb/CSS/FontFace.h +++ b/Userland/Libraries/LibWeb/CSS/FontFace.h @@ -8,15 +8,15 @@ #pragma once #include -#include #include +#include namespace Web::CSS { class FontFace { public: struct Source { - Variant local_or_url; + Variant local_or_url; // FIXME: Do we need to keep this around, or is it only needed to discard unwanted formats during parsing? Optional format; }; diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp index 0ee97f00a7d8bda18453a2e5fb58132237d164fd..5ea096f70c6e8a3ffe241dfd574d7ad61f5e1954 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp @@ -15,7 +15,7 @@ namespace Web { -CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const& context, StringView css, Optional location) +CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const& context, StringView css, Optional location) { if (css.is_empty()) { auto rule_list = CSS::CSSRuleList::create_empty(context.realm()); diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 0b06e86952fca526df9c574c294bee9764319787..501ecaa663a732505c2d17e6f4a9d68fa1455919 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -124,7 +124,7 @@ Parser::Parser(Parser&& other) // 5.3.3. Parse a stylesheet // https://www.w3.org/TR/css-syntax-3/#parse-stylesheet template -Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream& tokens, Optional location) +Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream& tokens, Optional location) { // To parse a stylesheet from an input given an optional url location: @@ -144,7 +144,7 @@ Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream& tokens, Opti } // https://www.w3.org/TR/css-syntax-3/#parse-a-css-stylesheet -CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional location) +CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional location) { // To parse a CSS stylesheet, first parse a stylesheet. auto style_sheet = parse_a_stylesheet(m_token_stream, {}); @@ -1160,11 +1160,11 @@ ElementInlineCSSStyleDeclaration* Parser::parse_as_style_attribute(DOM::Element& return ElementInlineCSSStyleDeclaration::create(element, move(properties), move(custom_properties)); } -Optional Parser::parse_url_function(ComponentValue const& component_value) +Optional Parser::parse_url_function(ComponentValue const& component_value) { // FIXME: Handle list of media queries. https://www.w3.org/TR/css-cascade-3/#conditional-import - auto convert_string_to_url = [&](StringView url_string) -> Optional { + auto convert_string_to_url = [&](StringView url_string) -> Optional { auto url = m_context.complete_url(url_string); if (url.is_valid()) return url; @@ -1215,7 +1215,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr rule) return parse_font_face_rule(tokens); } if (rule->at_rule_name().equals_ignoring_ascii_case("import"sv) && !rule->prelude().is_empty()) { - Optional url; + Optional url; for (auto const& token : rule->prelude()) { if (token.is(Token::Type::Whitespace)) continue; diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index 2f5c6276421edaacf19e9a90a77e488a1c0a6259..64ba9bfab2fa5e0d8aee6adb66f201988db4bde4 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -44,7 +44,7 @@ public: Parser(Parser&&); - CSSStyleSheet* parse_as_css_stylesheet(Optional location); + CSSStyleSheet* parse_as_css_stylesheet(Optional location); ElementInlineCSSStyleDeclaration* parse_as_style_attribute(DOM::Element&); CSSRule* parse_as_css_rule(); Optional parse_as_supports_condition(); @@ -86,11 +86,11 @@ private: // "Parse a stylesheet" is intended to be the normal parser entry point, for parsing stylesheets. struct ParsedStyleSheet { - Optional location; + Optional location; Vector> rules; }; template - ParsedStyleSheet parse_a_stylesheet(TokenStream&, Optional location); + ParsedStyleSheet parse_a_stylesheet(TokenStream&, Optional location); // "Parse a list of rules" is intended for the content of at-rules such as @media. It differs from "Parse a stylesheet" in the handling of and . template @@ -195,7 +195,7 @@ private: Optional parse_repeat(Vector const&); Optional parse_track_sizing_function(ComponentValue const&); - Optional parse_url_function(ComponentValue const&); + Optional parse_url_function(ComponentValue const&); RefPtr parse_url_value(ComponentValue const&); Optional> parse_linear_color_stop_list(TokenStream&); @@ -330,7 +330,7 @@ private: namespace Web { -CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const&, StringView, Optional location = {}); +CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const&, StringView, Optional location = {}); CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::ParsingContext const&, StringView, DOM::Element&); RefPtr parse_css_value(CSS::Parser::ParsingContext const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid); Optional parse_selector(CSS::Parser::ParsingContext const&, StringView); diff --git a/Userland/Libraries/LibWeb/CSS/Parser/ParsingContext.cpp b/Userland/Libraries/LibWeb/CSS/Parser/ParsingContext.cpp index bd4585250c612bcc59ae57a098a8df352e81730e..e3e6f897df4c80fc69e0a1ca9315f4392f566bf6 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/ParsingContext.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/ParsingContext.cpp @@ -19,7 +19,7 @@ ParsingContext::ParsingContext(JS::Realm& realm, Mode mode) { } -ParsingContext::ParsingContext(DOM::Document const& document, URL url, Mode mode) +ParsingContext::ParsingContext(DOM::Document const& document, URL::URL url, Mode mode) : m_realm(const_cast(document.realm())) , m_document(&document) , m_url(move(url)) @@ -49,7 +49,7 @@ bool ParsingContext::in_quirks_mode() const } // https://www.w3.org/TR/css-values-4/#relative-urls -URL ParsingContext::complete_url(StringView relative_url) const +URL::URL ParsingContext::complete_url(StringView relative_url) const { return m_url.complete_url(relative_url); } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/ParsingContext.h b/Userland/Libraries/LibWeb/CSS/Parser/ParsingContext.h index fef3d7e6d9ca655e096412281255b22a3fea2730..becc800257fdaf23e99f8a209ae567df77509228 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/ParsingContext.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/ParsingContext.h @@ -21,7 +21,7 @@ public: explicit ParsingContext(JS::Realm&, Mode = Mode::Normal); explicit ParsingContext(DOM::Document const&, Mode = Mode::Normal); - explicit ParsingContext(DOM::Document const&, URL, Mode = Mode::Normal); + explicit ParsingContext(DOM::Document const&, URL::URL, Mode = Mode::Normal); explicit ParsingContext(DOM::ParentNode&, Mode = Mode::Normal); Mode mode() const { return m_mode; } @@ -30,7 +30,7 @@ public: bool in_quirks_mode() const; DOM::Document const* document() const { return m_document; } HTML::Window const* window() const; - URL complete_url(StringView) const; + URL::URL complete_url(StringView) const; PropertyID current_property_id() const { return m_current_property_id; } void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; } @@ -41,7 +41,7 @@ private: JS::NonnullGCPtr m_realm; JS::GCPtr m_document; PropertyID m_current_property_id { PropertyID::Invalid }; - URL m_url; + URL::URL m_url; Mode m_mode { Mode::Normal }; }; diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp index a796400619d74edfe84332f5099c8162910baea1..7d06318f6d84adfce54501f3e6a9f6858ec6969f 100644 --- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -285,7 +285,7 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla if (!matches_link_pseudo_class(element)) return false; auto document_url = element.document().url(); - URL target_url = element.document().parse_url(element.attribute(HTML::AttributeNames::href).value_or({})); + URL::URL target_url = element.document().parse_url(element.attribute(HTML::AttributeNames::href).value_or({})); if (target_url.fragment().has_value()) return document_url.equals(target_url, URL::ExcludeFragment::No); return document_url.equals(target_url, URL::ExcludeFragment::Yes); diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 36539ccded09a5ba28672f9eb5cdf6271b5a8c06..396dd3d39e82a91a4962444ccd9fe5f1f5892661 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -102,7 +102,7 @@ StyleComputer::~StyleComputer() = default; class StyleComputer::FontLoader : public ResourceClient { public: - explicit FontLoader(StyleComputer& style_computer, FlyString family_name, Vector unicode_ranges, Vector urls) + explicit FontLoader(StyleComputer& style_computer, FlyString family_name, Vector unicode_ranges, Vector urls) : m_style_computer(style_computer) , m_family_name(move(family_name)) , m_unicode_ranges(move(unicode_ranges)) @@ -187,7 +187,7 @@ private: FlyString m_family_name; Vector m_unicode_ranges; RefPtr m_vector_font; - Vector m_urls; + Vector m_urls; }; struct StyleComputer::MatchingFontCandidate { @@ -2494,11 +2494,11 @@ void StyleComputer::load_fonts_from_sheet(CSSStyleSheet const& sheet) .slope = font_face.slope().value_or(0), }; - Vector urls; + Vector urls; for (auto& source : font_face.sources()) { // FIXME: These should be loaded relative to the stylesheet URL instead of the document URL. - if (source.local_or_url.has()) - urls.append(m_document->parse_url(MUST(source.local_or_url.get().to_string()))); + if (source.local_or_url.has()) + urls.append(m_document->parse_url(MUST(source.local_or_url.get().to_string()))); // FIXME: Handle local() } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 9896131a63127b45c8650cfbf6069b55cb69e1a3..addd269ff10e8e11dc82cf88aa73d0eca1186a4d 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -16,11 +16,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp index b88253d37b013701779faf9ec8fb70660bbb0a01..991f04096c7460f2d6cc33aa1d5ab5846a8fc2f1 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp @@ -20,7 +20,7 @@ namespace Web::CSS { -ImageStyleValue::ImageStyleValue(URL const& url) +ImageStyleValue::ImageStyleValue(URL::URL const& url) : AbstractImageStyleValue(Type::Image) , m_url(url) { diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.h index b237a26e37f696fcd2c7d7c919aca9bea899f233..a67467cdf43523f1b60d4dbf506ed09d4278e00c 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.h @@ -9,9 +9,9 @@ #pragma once -#include #include #include +#include #include #include #include @@ -22,7 +22,7 @@ class ImageStyleValue final : public AbstractImageStyleValue , public Weakable { public: - static ValueComparingNonnullRefPtr create(URL const& url) + static ValueComparingNonnullRefPtr create(URL::URL const& url) { return adopt_ref(*new (nothrow) ImageStyleValue(url)); } @@ -54,14 +54,14 @@ public: JS::GCPtr image_data() const; private: - ImageStyleValue(URL const&); + ImageStyleValue(URL::URL const&); JS::GCPtr m_image_request; void animate(); Gfx::ImmutableBitmap const* bitmap(size_t frame_index, Gfx::IntSize = {}) const; - URL m_url; + URL::URL m_url; WeakPtr m_document; size_t m_current_frame_index { 0 }; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/URLStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/URLStyleValue.h index 573ae5215daaa065ffcc0dbab9954602125517c6..2287b22b10fea4384d785e81171993b91498691d 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/URLStyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/URLStyleValue.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -14,14 +14,14 @@ namespace Web::CSS { class URLStyleValue final : public StyleValueWithDefaultOperators { public: - static ValueComparingNonnullRefPtr create(URL const& url) + static ValueComparingNonnullRefPtr create(URL::URL const& url) { return adopt_ref(*new (nothrow) URLStyleValue(url)); } virtual ~URLStyleValue() override = default; - URL const& url() const { return m_url; } + URL::URL const& url() const { return m_url; } bool properties_equal(URLStyleValue const& other) const { return m_url == other.m_url; } @@ -31,13 +31,13 @@ public: } private: - URLStyleValue(URL const& url) + URLStyleValue(URL::URL const& url) : StyleValueWithDefaultOperators(Type::URL) , m_url(url) { } - URL m_url; + URL::URL m_url; }; } diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index aa8c4b9e158d80a2b691a7ec2c88e6e0f65c017e..12588a4048da5a1617b2d67898c0d95d7cb3d348 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -314,8 +314,8 @@ WebIDL::ExceptionOr> Document::create_and_initialize( auto const& referrer = navigation_params.request->referrer(); // 3. If referrer is a URL record, then set document's referrer to the serialization of referrer. - if (referrer.has()) { - document->m_referrer = MUST(String::from_byte_string(referrer.get().serialize())); + if (referrer.has()) { + document->m_referrer = MUST(String::from_byte_string(referrer.get().serialize())); } } @@ -339,12 +339,12 @@ WebIDL::ExceptionOr> Document::construct_impl(JS::Rea return Document::create(realm); } -JS::NonnullGCPtr Document::create(JS::Realm& realm, URL const& url) +JS::NonnullGCPtr Document::create(JS::Realm& realm, URL::URL const& url) { return realm.heap().allocate(realm, realm, url); } -Document::Document(JS::Realm& realm, const URL& url) +Document::Document(JS::Realm& realm, const URL::URL& url) : ParentNode(realm, *this, NodeType::DOCUMENT_NODE) , m_page(Bindings::host_defined_page(realm)) , m_style_computer(make(*this)) @@ -945,7 +945,7 @@ JS::GCPtr Document::first_base_element_with_href_in } // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fallback-base-url -URL Document::fallback_base_url() const +URL::URL Document::fallback_base_url() const { // 1. If document is an iframe srcdoc document, then: if (HTML::url_matches_about_srcdoc(m_url)) { @@ -965,7 +965,7 @@ URL Document::fallback_base_url() const } // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#document-base-url -URL Document::base_url() const +URL::URL Document::base_url() const { // 1. If there is no base element that has an href attribute in the Document, then return the Document's fallback base URL. auto base_element = first_base_element_with_href_in_tree_order(); @@ -977,7 +977,7 @@ URL Document::base_url() const } // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url -URL Document::parse_url(StringView url) const +URL::URL Document::parse_url(StringView url) const { // FIXME: Pass in document's character encoding. return base_url().complete_url(url); @@ -2747,7 +2747,7 @@ String Document::domain() const return String {}; // 3. Return effectiveDomain, serialized. - return MUST(URLParser::serialize_host(effective_domain.release_value())); + return MUST(URL::Parser::serialize_host(effective_domain.release_value())); } void Document::set_domain(String const& domain) @@ -3803,7 +3803,7 @@ void Document::update_for_history_step_application(JS::NonnullGCPtrurl : URL {}; + auto old_url = m_latest_entry ? m_latest_entry->url : URL::URL {}; // 2. Set document's latest entry to entry. m_latest_entry = entry; @@ -3866,7 +3866,7 @@ void Document::update_for_history_step_application(JS::NonnullGCPtr>& Document::shared_image_requests() +HashMap>& Document::shared_image_requests() { return m_shared_image_requests; } diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 378321185f783a93b97e08b9287360b414e3c8a0..fc4e0bf352e32bb05a17229900229b10660dd503 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -12,11 +12,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -93,7 +93,7 @@ public: static WebIDL::ExceptionOr> create_and_initialize(Type, String content_type, HTML::NavigationParams&); - [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, URL const& url = "about:blank"sv); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, URL::URL const& url = "about:blank"sv); static WebIDL::ExceptionOr> construct_impl(JS::Realm&); virtual ~Document() override; @@ -107,10 +107,10 @@ public: String referrer() const; void set_referrer(String); - void set_url(const URL& url) { m_url = url; } - URL url() const { return m_url; } - URL fallback_base_url() const; - URL base_url() const; + void set_url(const URL::URL& url) { m_url = url; } + URL::URL url() const { return m_url; } + URL::URL fallback_base_url() const; + URL::URL base_url() const; void update_base_element(Badge); JS::GCPtr first_base_element_with_href_in_tree_order() const; @@ -124,7 +124,7 @@ public: HTML::CrossOriginOpenerPolicy const& cross_origin_opener_policy() const { return m_cross_origin_opener_policy; } void set_cross_origin_opener_policy(HTML::CrossOriginOpenerPolicy policy) { m_cross_origin_opener_policy = move(policy); } - URL parse_url(StringView) const; + URL::URL parse_url(StringView) const; CSS::StyleComputer& style_computer() { return *m_style_computer; } const CSS::StyleComputer& style_computer() const { return *m_style_computer; } @@ -454,8 +454,8 @@ public: void set_is_initial_about_blank(bool b) { m_is_initial_about_blank = b; } // https://html.spec.whatwg.org/multipage/dom.html#concept-document-about-base-url - Optional about_base_url() const { return m_about_base_url; } - void set_about_base_url(Optional url) { m_about_base_url = url; } + Optional about_base_url() const { return m_about_base_url; } + void set_about_base_url(Optional url) { m_about_base_url = url; } String domain() const; void set_domain(String const&); @@ -547,7 +547,7 @@ public: void update_for_history_step_application(JS::NonnullGCPtr, bool do_not_reactivate, size_t script_history_length, size_t script_history_index, Optional>> entries_for_navigation_api = {}, bool update_navigation_api = true); - HashMap>& shared_image_requests(); + HashMap>& shared_image_requests(); void restore_the_history_object_state(JS::NonnullGCPtr entry); @@ -612,7 +612,7 @@ protected: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; - Document(JS::Realm&, URL const&); + Document(JS::Realm&, URL::URL const&); private: // ^HTML::GlobalEventHandlers @@ -641,7 +641,7 @@ private: Optional m_inspected_pseudo_element; JS::GCPtr m_active_favicon; WeakPtr m_browsing_context; - URL m_url; + URL::URL m_url; JS::GCPtr m_window; @@ -742,7 +742,7 @@ private: bool m_is_initial_about_blank { false }; // https://html.spec.whatwg.org/multipage/dom.html#concept-document-about-base-url - Optional m_about_base_url; + Optional m_about_base_url; // https://html.spec.whatwg.org/multipage/dom.html#concept-document-coop HTML::CrossOriginOpenerPolicy m_cross_origin_opener_policy; @@ -818,7 +818,7 @@ private: // https://html.spec.whatwg.org/multipage/browsing-the-web.html#latest-entry JS::GCPtr m_latest_entry; - HashMap> m_shared_image_requests; + HashMap> m_shared_image_requests; // https://www.w3.org/TR/web-animations-1/#timeline-associated-with-a-document HashTable> m_associated_animation_timelines; diff --git a/Userland/Libraries/LibWeb/DOM/DocumentLoading.h b/Userland/Libraries/LibWeb/DOM/DocumentLoading.h index e249be31f65598352108ea7c1ab110674f6f0ad8..093ce1351b20e62224ed5fe80070293d6ac9010b 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentLoading.h +++ b/Userland/Libraries/LibWeb/DOM/DocumentLoading.h @@ -31,7 +31,7 @@ JS::NonnullGCPtr create_document_for_inline_content(JS::GCPtr create_document_for_inline_content(JS::GCPtrurl_list().append(URL("about:error")); // AD-HOC: https://github.com/whatwg/html/issues/9122 + response->url_list().append(URL::URL("about:error")); // AD-HOC: https://github.com/whatwg/html/issues/9122 HTML::NavigationParams navigation_params { .id = navigation_id, .navigable = navigable, diff --git a/Userland/Libraries/LibWeb/DOM/XMLDocument.cpp b/Userland/Libraries/LibWeb/DOM/XMLDocument.cpp index 4c58d3d8d4c70bb0d794e317d7e625aca440923e..2d1fcce76833e3ed0652e0c215368dcf4344d039 100644 --- a/Userland/Libraries/LibWeb/DOM/XMLDocument.cpp +++ b/Userland/Libraries/LibWeb/DOM/XMLDocument.cpp @@ -11,12 +11,12 @@ namespace Web::DOM { JS_DEFINE_ALLOCATOR(XMLDocument); -JS::NonnullGCPtr XMLDocument::create(JS::Realm& realm, URL const& url) +JS::NonnullGCPtr XMLDocument::create(JS::Realm& realm, URL::URL const& url) { return realm.heap().allocate(realm, realm, url); } -XMLDocument::XMLDocument(JS::Realm& realm, URL const& url) +XMLDocument::XMLDocument(JS::Realm& realm, URL::URL const& url) : Document(realm, url) { } diff --git a/Userland/Libraries/LibWeb/DOM/XMLDocument.h b/Userland/Libraries/LibWeb/DOM/XMLDocument.h index 1f715df28264d16713061717148fcde180a35bd0..e1b2000cdb9902f7eed82c37fa2987a552ffbd89 100644 --- a/Userland/Libraries/LibWeb/DOM/XMLDocument.h +++ b/Userland/Libraries/LibWeb/DOM/XMLDocument.h @@ -15,11 +15,11 @@ class XMLDocument final : public Document { JS_DECLARE_ALLOCATOR(XMLDocument); public: - static JS::NonnullGCPtr create(JS::Realm&, URL const& url = "about:blank"sv); + static JS::NonnullGCPtr create(JS::Realm&, URL::URL const& url = "about:blank"sv); virtual ~XMLDocument() override = default; private: - XMLDocument(JS::Realm& realm, URL const& url); + XMLDocument(JS::Realm& realm, URL::URL const& url); virtual void initialize(JS::Realm&) override; }; diff --git a/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp b/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp index 099c104431c60e4f126ca6997fbb12284d97ad85..c1c0620703f7b12bbaf4d7eb40c8d750ac0e20dd 100644 --- a/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp +++ b/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include @@ -18,24 +18,24 @@ namespace Web::DOMURL { JS_DEFINE_ALLOCATOR(DOMURL); -JS::NonnullGCPtr DOMURL::create(JS::Realm& realm, URL url, JS::NonnullGCPtr query) +JS::NonnullGCPtr DOMURL::create(JS::Realm& realm, URL::URL url, JS::NonnullGCPtr query) { return realm.heap().allocate(realm, realm, move(url), move(query)); } // https://url.spec.whatwg.org/#api-url-parser -static Optional parse_api_url(String const& url, Optional const& base) +static Optional parse_api_url(String const& url, Optional const& base) { // FIXME: We somewhat awkwardly have two failure states encapsulated in the return type (and convert between them in the steps), // ideally we'd get rid of URL's valid flag // 1. Let parsedBase be null. - Optional parsed_base; + Optional parsed_base; // 2. If base is non-null: if (base.has_value()) { // 1. Set parsedBase to the result of running the basic URL parser on base. - auto parsed_base_url = URLParser::basic_parse(*base); + auto parsed_base_url = URL::Parser::basic_parse(*base); // 2. If parsedBase is failure, then return failure. if (!parsed_base_url.is_valid()) @@ -45,8 +45,8 @@ static Optional parse_api_url(String const& url, Optional const& ba } // 3. Return the result of running the basic URL parser on url with parsedBase. - auto parsed = URLParser::basic_parse(url, parsed_base); - return parsed.is_valid() ? parsed : Optional {}; + auto parsed = URL::Parser::basic_parse(url, parsed_base); + return parsed.is_valid() ? parsed : Optional {}; } // https://url.spec.whatwg.org/#dom-url-url @@ -75,7 +75,7 @@ WebIDL::ExceptionOr> DOMURL::construct_impl(JS::Realm& return result_url; } -DOMURL::DOMURL(JS::Realm& realm, URL url, JS::NonnullGCPtr query) +DOMURL::DOMURL(JS::Realm& realm, URL::URL url, JS::NonnullGCPtr query) : PlatformObject(realm) , m_url(move(url)) , m_query(move(query)) @@ -166,7 +166,7 @@ WebIDL::ExceptionOr DOMURL::set_href(String const& href) auto& vm = realm().vm(); // 1. Let parsedURL be the result of running the basic URL parser on the given value. - URL parsed_url = href; + URL::URL parsed_url = href; // 2. If parsedURL is failure, then throw a TypeError. if (!parsed_url.is_valid()) @@ -212,7 +212,7 @@ WebIDL::ExceptionOr DOMURL::set_protocol(String const& protocol) // The protocol setter steps are to basic URL parse the given value, followed by U+003A (:), with this’s URL as // url and scheme start state as state override. - auto result_url = URLParser::basic_parse(TRY_OR_THROW_OOM(vm, String::formatted("{}:", protocol)), {}, m_url, URLParser::State::SchemeStart); + auto result_url = URL::Parser::basic_parse(TRY_OR_THROW_OOM(vm, String::formatted("{}:", protocol)), {}, m_url, URL::Parser::State::SchemeStart); if (result_url.is_valid()) m_url = move(result_url); return {}; @@ -286,7 +286,7 @@ void DOMURL::set_host(String const& host) return; // 2. Basic URL parse the given value with this’s URL as url and host state as state override. - auto result_url = URLParser::basic_parse(host, {}, m_url, URLParser::State::Host); + auto result_url = URL::Parser::basic_parse(host, {}, m_url, URL::Parser::State::Host); if (result_url.is_valid()) m_url = move(result_url); } @@ -312,7 +312,7 @@ void DOMURL::set_hostname(String const& hostname) return; // 2. Basic URL parse the given value with this’s URL as url and hostname state as state override. - auto result_url = URLParser::basic_parse(hostname, {}, m_url, URLParser::State::Hostname); + auto result_url = URL::Parser::basic_parse(hostname, {}, m_url, URL::Parser::State::Hostname); if (result_url.is_valid()) m_url = move(result_url); } @@ -343,7 +343,7 @@ void DOMURL::set_port(String const& port) } // 3. Otherwise, basic URL parse the given value with this’s URL as url and port state as state override. else { - auto result_url = URLParser::basic_parse(port, {}, m_url, URLParser::State::Port); + auto result_url = URL::Parser::basic_parse(port, {}, m_url, URL::Parser::State::Port); if (result_url.is_valid()) m_url = move(result_url); } @@ -371,7 +371,7 @@ void DOMURL::set_pathname(String const& pathname) url.set_paths({}); // 3. Basic URL parse the given value with this’s URL as url and path start state as state override. - auto result_url = URLParser::basic_parse(pathname, {}, move(url), URLParser::State::PathStart); + auto result_url = URL::Parser::basic_parse(pathname, {}, move(url), URL::Parser::State::PathStart); if (result_url.is_valid()) m_url = move(result_url); } @@ -421,7 +421,7 @@ WebIDL::ExceptionOr DOMURL::set_search(String const& search) url_copy.set_query(String {}); // 5. Basic URL parse input with url as url and query state as state override. - auto result_url = URLParser::basic_parse(input, {}, move(url_copy), URLParser::State::Query); + auto result_url = URL::Parser::basic_parse(input, {}, move(url_copy), URL::Parser::State::Query); if (result_url.is_valid()) { m_url = move(result_url); @@ -476,15 +476,15 @@ void DOMURL::set_hash(String const& hash) url.set_fragment(String {}); // 4. Basic URL parse input with this’s URL as url and fragment state as state override. - auto result_url = URLParser::basic_parse(input, {}, move(url), URLParser::State::Fragment); + auto result_url = URL::Parser::basic_parse(input, {}, move(url), URL::Parser::State::Fragment); if (result_url.is_valid()) m_url = move(result_url); } // https://url.spec.whatwg.org/#concept-url-origin -HTML::Origin url_origin(URL const& url) +HTML::Origin url_origin(URL::URL const& url) { - // FIXME: We should probably have an extended version of AK::URL for LibWeb instead of standalone functions like this. + // FIXME: We should probably have an extended version of URL::URL for LibWeb instead of standalone functions like this. // The origin of a URL url is the origin returned by running these steps, switching on url’s scheme: // -> "blob" @@ -563,12 +563,12 @@ void strip_trailing_spaces_from_an_opaque_path(DOMURL& url) } // https://url.spec.whatwg.org/#concept-url-parser -URL parse(StringView input, Optional const& base_url) +URL::URL parse(StringView input, Optional const& base_url) { - // FIXME: We should probably have an extended version of AK::URL for LibWeb instead of standalone functions like this. + // FIXME: We should probably have an extended version of URL::URL for LibWeb instead of standalone functions like this. // 1. Let url be the result of running the basic URL parser on input with base and encoding. - auto url = URLParser::basic_parse(input, base_url); + auto url = URL::Parser::basic_parse(input, base_url); // 2. If url is failure, return failure. if (!url.is_valid()) diff --git a/Userland/Libraries/LibWeb/DOMURL/DOMURL.h b/Userland/Libraries/LibWeb/DOMURL/DOMURL.h index 62df78f46b5e2c127bd3be9fcd4f3fb659749e08..b69ce0441605202f0ab832ed94cce0fa7671bfc2 100644 --- a/Userland/Libraries/LibWeb/DOMURL/DOMURL.h +++ b/Userland/Libraries/LibWeb/DOMURL/DOMURL.h @@ -8,7 +8,7 @@ #pragma once -#include +#include #include #include #include @@ -20,7 +20,7 @@ class DOMURL : public Bindings::PlatformObject { JS_DECLARE_ALLOCATOR(DOMURL); public: - [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, URL, JS::NonnullGCPtr query); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, URL::URL, JS::NonnullGCPtr query); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, String const& url, Optional const& base = {}); virtual ~DOMURL() override; @@ -79,22 +79,22 @@ public: void set_query(Badge, Optional query) { m_url.set_query(move(query)); } private: - DOMURL(JS::Realm&, URL, JS::NonnullGCPtr query); + DOMURL(JS::Realm&, URL::URL, JS::NonnullGCPtr query); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; - URL m_url; + URL::URL m_url; JS::NonnullGCPtr m_query; }; -HTML::Origin url_origin(URL const&); +HTML::Origin url_origin(URL::URL const&); bool host_is_domain(URL::Host const&); // https://url.spec.whatwg.org/#potentially-strip-trailing-spaces-from-an-opaque-path void strip_trailing_spaces_from_an_opaque_path(DOMURL& url); // https://url.spec.whatwg.org/#concept-url-parser -URL parse(StringView input, Optional const& base_url = {}); +URL::URL parse(StringView input, Optional const& base_url = {}); } diff --git a/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.cpp index 4ce11ff24248248e2ed1795157d79d3e60731861..59922dbc4e16fda019fb2cc8ce9ee6223b70d913 100644 --- a/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.cpp +++ b/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.cpp @@ -7,9 +7,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -54,12 +54,12 @@ ErrorOr url_encode(Vector const& tuples, StringView encoding // 1. Assert: tuple’s name and tuple’s value are scalar value strings. // 2. Let name be the result of running percent-encode after encoding with encoding, tuple’s name, the application/x-www-form-urlencoded percent-encode set, and true. - // FIXME: URLParser does not currently implement encoding. - auto name = TRY(URLParser::percent_encode_after_encoding(tuple.name, URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true)); + // FIXME: URL::Parser does not currently implement encoding. + auto name = TRY(URL::Parser::percent_encode_after_encoding(tuple.name, URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true)); // 3. Let value be the result of running percent-encode after encoding with encoding, tuple’s value, the application/x-www-form-urlencoded percent-encode set, and true. - // FIXME: URLParser does not currently implement encoding. - auto value = TRY(URLParser::percent_encode_after_encoding(tuple.value, URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true)); + // FIXME: URL::Parser does not currently implement encoding. + auto value = TRY(URL::Parser::percent_encode_after_encoding(tuple.value, URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true)); // 4. If output is not the empty string, then append U+0026 (&) to output. if (!output.is_empty()) diff --git a/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.h b/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.h index 26f73a7db9ac97449c27c615df39eed04c0d13f0..a4c86e9fbf0fdca08cbda3cc4a10d9312d854c9b 100644 --- a/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.h +++ b/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.h @@ -6,8 +6,8 @@ #pragma once -#include #include +#include #include namespace Web::DOMURL { diff --git a/Userland/Libraries/LibWeb/Dump.cpp b/Userland/Libraries/LibWeb/Dump.cpp index 48e67100b3bd41079d3d54a64078175d47980fed..bfa0ec5834d089376798e7887dd9be598d9e354a 100644 --- a/Userland/Libraries/LibWeb/Dump.cpp +++ b/Userland/Libraries/LibWeb/Dump.cpp @@ -647,8 +647,8 @@ void dump_font_face_rule(StringBuilder& builder, CSS::CSSFontFaceRule const& rul builder.append("sources:\n"sv); for (auto const& source : font_face.sources()) { indent(builder, indent_levels + 2); - if (source.local_or_url.has()) - builder.appendff("url={}, format={}\n", source.local_or_url.get(), source.format.value_or("???"_string)); + if (source.local_or_url.has()) + builder.appendff("url={}, format={}\n", source.local_or_url.get(), source.format.value_or("???"_string)); else builder.appendff("local={}\n", source.local_or_url.get()); } diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index 7804304d26e5a787024ba09bcc7a8b219ce13f1f..83b039050840448e49275603ed1932aa61543ea0 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -1335,9 +1335,9 @@ WebIDL::ExceptionOr> http_network_or_cache_fet } // 11. If httpRequest’s referrer is a URL, then: - if (http_request->referrer().has()) { + if (http_request->referrer().has()) { // 1. Let referrerValue be httpRequest’s referrer, serialized and isomorphic encoded. - auto referrer_value = TRY_OR_THROW_OOM(vm, ByteBuffer::copy(http_request->referrer().get().serialize().bytes())); + auto referrer_value = TRY_OR_THROW_OOM(vm, ByteBuffer::copy(http_request->referrer().get().serialize().bytes())); // 2. Append (`Referer`, referrerValue) to httpRequest’s header list. auto header = Infrastructure::Header { diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp index 10bd89b0bd1a988014d2614aeac36445d83d33d1..e391e4103790f8e31bc1c51a481c3f2880f5a4ee 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp @@ -44,7 +44,7 @@ JS::NonnullGCPtr Request::create(JS::VM& vm) } // https://fetch.spec.whatwg.org/#concept-request-url -URL& Request::url() +URL::URL& Request::url() { // A request has an associated URL (a URL). // NOTE: Implementations are encouraged to make this a pointer to the first URL in request’s URL list. It is provided as a distinct field solely for the convenience of other standards hooking into Fetch. @@ -53,13 +53,13 @@ URL& Request::url() } // https://fetch.spec.whatwg.org/#concept-request-url -URL const& Request::url() const +URL::URL const& Request::url() const { return const_cast(*this).url(); } // https://fetch.spec.whatwg.org/#concept-request-current-url -URL& Request::current_url() +URL::URL& Request::current_url() { // A request has an associated current URL. It is a pointer to the last URL in request’s URL list. VERIFY(!m_url_list.is_empty()); @@ -67,12 +67,12 @@ URL& Request::current_url() } // https://fetch.spec.whatwg.org/#concept-request-current-url -URL const& Request::current_url() const +URL::URL const& Request::current_url() const { return const_cast(*this).current_url(); } -void Request::set_url(URL url) +void Request::set_url(URL::URL url) { // Sometimes setting the URL and URL list are done as two distinct steps in the spec, // but since we know the URL is always the URL list's first item and doesn't change later @@ -163,7 +163,7 @@ bool Request::has_redirect_tainted_origin() const // A request request has a redirect-tainted origin if these steps return true: // 1. Let lastURL be null. - Optional last_url; + Optional last_url; // 2. For each url of request’s URL list: for (auto const& url : m_url_list) { diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h index 6f790e8fd75acc7aec583ace606794940581eab0..de57845e7296b8d766110be6221bc8145eb43853 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h @@ -12,12 +12,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -164,7 +164,7 @@ public: using BodyType = Variant>; using OriginType = Variant; using PolicyContainerType = Variant; - using ReferrerType = Variant; + using ReferrerType = Variant; using ReservedClientType = Variant>; using WindowType = Variant>; @@ -263,9 +263,9 @@ public: [[nodiscard]] bool render_blocking() const { return m_render_blocking; } void set_render_blocking(bool render_blocking) { m_render_blocking = render_blocking; } - [[nodiscard]] Vector const& url_list() const { return m_url_list; } - [[nodiscard]] Vector& url_list() { return m_url_list; } - void set_url_list(Vector url_list) { m_url_list = move(url_list); } + [[nodiscard]] Vector const& url_list() const { return m_url_list; } + [[nodiscard]] Vector& url_list() { return m_url_list; } + void set_url_list(Vector url_list) { m_url_list = move(url_list); } [[nodiscard]] u8 redirect_count() const { return m_redirect_count; } void set_redirect_count(u8 redirect_count) { m_redirect_count = redirect_count; } @@ -288,11 +288,11 @@ public: [[nodiscard]] bool timing_allow_failed() const { return m_timing_allow_failed; } void set_timing_allow_failed(bool timing_allow_failed) { m_timing_allow_failed = timing_allow_failed; } - [[nodiscard]] URL& url(); - [[nodiscard]] URL const& url() const; - [[nodiscard]] URL& current_url(); - [[nodiscard]] URL const& current_url() const; - void set_url(URL url); + [[nodiscard]] URL::URL& url(); + [[nodiscard]] URL::URL const& url() const; + [[nodiscard]] URL::URL& current_url(); + [[nodiscard]] URL::URL const& current_url() const; + void set_url(URL::URL url); [[nodiscard]] bool destination_is_script_like() const; @@ -487,7 +487,7 @@ private: // https://fetch.spec.whatwg.org/#concept-request-url-list // A request has an associated URL list (a list of one or more URLs). Unless stated otherwise, it is a list // containing a copy of request’s URL. - Vector m_url_list; + Vector m_url_list; // https://fetch.spec.whatwg.org/#concept-request-redirect-count // A request has an associated redirect count. Unless stated otherwise, it is zero. diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp index bb508de114afa8fe7e0af3b24e345a20bd9fbece..4249bab2ae1fb1a73789446e16298a0e635fcf2d 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp @@ -104,7 +104,7 @@ bool Response::is_network_error() const } // https://fetch.spec.whatwg.org/#concept-response-url -Optional Response::url() const +Optional Response::url() const { // A response has an associated URL. It is a pointer to the last URL in response’s URL list and null if response’s URL list is empty. // NOTE: We have to use the virtual getter here to not bypass filtered responses. @@ -114,23 +114,23 @@ Optional Response::url() const } // https://fetch.spec.whatwg.org/#concept-response-location-url -ErrorOr> Response::location_url(Optional const& request_fragment) const +ErrorOr> Response::location_url(Optional const& request_fragment) const { // The location URL of a response response, given null or an ASCII string requestFragment, is the value returned by the following steps. They return null, failure, or a URL. // 1. If response’s status is not a redirect status, then return null. // NOTE: We have to use the virtual getter here to not bypass filtered responses. if (!is_redirect_status(status())) - return Optional {}; + return Optional {}; // 2. Let location be the result of extracting header list values given `Location` and response’s header list. auto location_values_or_failure = TRY(extract_header_list_values("Location"sv.bytes(), m_header_list)); if (location_values_or_failure.has() || location_values_or_failure.has()) - return Optional {}; + return Optional {}; auto const& location_values = location_values_or_failure.get>(); if (location_values.size() != 1) - return Optional {}; + return Optional {}; // 3. If location is a header value, then set location to the result of parsing location with response’s URL. auto location = DOMURL::parse(location_values.first(), url()); diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h index 21896567f5d8eb6648e4cbbf2af40f126f863acd..ec35fc1e63343b3e5ed52b6cf71e9053a589214f 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h @@ -10,11 +10,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -65,9 +65,9 @@ public: [[nodiscard]] virtual bool aborted() const { return m_aborted; } void set_aborted(bool aborted) { m_aborted = aborted; } - [[nodiscard]] virtual Vector const& url_list() const { return m_url_list; } - [[nodiscard]] virtual Vector& url_list() { return m_url_list; } - void set_url_list(Vector url_list) { m_url_list = move(url_list); } + [[nodiscard]] virtual Vector const& url_list() const { return m_url_list; } + [[nodiscard]] virtual Vector& url_list() { return m_url_list; } + void set_url_list(Vector url_list) { m_url_list = move(url_list); } [[nodiscard]] virtual Status status() const { return m_status; } void set_status(Status status) { m_status = status; } @@ -106,8 +106,8 @@ public: [[nodiscard]] bool is_aborted_network_error() const; [[nodiscard]] bool is_network_error() const; - [[nodiscard]] Optional url() const; - [[nodiscard]] ErrorOr> location_url(Optional const& request_fragment) const; + [[nodiscard]] Optional url() const; + [[nodiscard]] ErrorOr> location_url(Optional const& request_fragment) const; [[nodiscard]] WebIDL::ExceptionOr> clone(JS::Realm&) const; @@ -134,7 +134,7 @@ private: // https://fetch.spec.whatwg.org/#concept-response-url-list // A response has an associated URL list (a list of zero or more URLs). Unless stated otherwise, it is the empty list. - Vector m_url_list; + Vector m_url_list; // https://fetch.spec.whatwg.org/#concept-response-status // A response has an associated status, which is a status. Unless stated otherwise it is 200. @@ -197,8 +197,8 @@ public: [[nodiscard]] virtual Type type() const override { return m_internal_response->type(); } [[nodiscard]] virtual bool aborted() const override { return m_internal_response->aborted(); } - [[nodiscard]] virtual Vector const& url_list() const override { return m_internal_response->url_list(); } - [[nodiscard]] virtual Vector& url_list() override { return m_internal_response->url_list(); } + [[nodiscard]] virtual Vector const& url_list() const override { return m_internal_response->url_list(); } + [[nodiscard]] virtual Vector& url_list() override { return m_internal_response->url_list(); } [[nodiscard]] virtual Status status() const override { return m_internal_response->status(); } [[nodiscard]] virtual ReadonlyBytes status_message() const override { return m_internal_response->status_message(); } [[nodiscard]] virtual JS::NonnullGCPtr header_list() const override { return m_internal_response->header_list(); } @@ -268,8 +268,8 @@ public: [[nodiscard]] static JS::NonnullGCPtr create(JS::VM&, JS::NonnullGCPtr); [[nodiscard]] virtual Type type() const override { return Type::Opaque; } - [[nodiscard]] virtual Vector const& url_list() const override { return m_url_list; } - [[nodiscard]] virtual Vector& url_list() override { return m_url_list; } + [[nodiscard]] virtual Vector const& url_list() const override { return m_url_list; } + [[nodiscard]] virtual Vector& url_list() override { return m_url_list; } [[nodiscard]] virtual Status status() const override { return 0; } [[nodiscard]] virtual ReadonlyBytes status_message() const override { return {}; } [[nodiscard]] virtual JS::NonnullGCPtr header_list() const override { return m_header_list; } @@ -281,7 +281,7 @@ private: virtual void visit_edges(JS::Cell::Visitor&) override; - Vector m_url_list; + Vector m_url_list; JS::NonnullGCPtr m_header_list; JS::GCPtr m_body; }; diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.cpp index d9caad07d8219561a89073fc35b7bf996539ef96..d789fb6fe3eca860f925d7a6725d358aae506ffd 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.cpp @@ -10,7 +10,7 @@ namespace Web::Fetch::Infrastructure { // https://fetch.spec.whatwg.org/#is-local -bool is_local_url(URL const& url) +bool is_local_url(URL::URL const& url) { // A URL is local if its scheme is a local scheme. return any_of(LOCAL_SCHEMES, [&](auto scheme) { return url.scheme() == scheme; }); diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.h index 4a4cbb61807c58697c2dad8eb6dbbdcdde6f08ab..a8fc1fd83e7c4b5d77f4cb0df3a22c988bd43f8b 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.h +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include namespace Web::Fetch::Infrastructure { @@ -33,7 +33,7 @@ inline constexpr Array FETCH_SCHEMES = { "resource"sv }; -[[nodiscard]] bool is_local_url(URL const&); +[[nodiscard]] bool is_local_url(URL::URL const&); [[nodiscard]] bool is_fetch_scheme(StringView); [[nodiscard]] bool is_http_or_https_scheme(StringView); diff --git a/Userland/Libraries/LibWeb/Fetch/Request.cpp b/Userland/Libraries/LibWeb/Fetch/Request.cpp index ef9dd3e9a61d441b16d62ee682c715f39e7d0342..7bb218740941b363fefa7273ec38b2633af625c1 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Request.cpp @@ -548,7 +548,7 @@ WebIDL::ExceptionOr Request::referrer() const VERIFY_NOT_REACHED(); } }, - [&](URL const& url) -> WebIDL::ExceptionOr { + [&](URL::URL const& url) -> WebIDL::ExceptionOr { // 3. Return this’s request’s referrer, serialized. return TRY_OR_THROW_OOM(vm, String::from_byte_string(url.serialize())); }); diff --git a/Userland/Libraries/LibWeb/FileAPI/BlobURLStore.cpp b/Userland/Libraries/LibWeb/FileAPI/BlobURLStore.cpp index fafadab99a0bf4471b5d749117ade7bfbc159204..08e2adb9e7b91026648bc663f39a6efeb6c5c1bb 100644 --- a/Userland/Libraries/LibWeb/FileAPI/BlobURLStore.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/BlobURLStore.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include @@ -82,7 +82,7 @@ ErrorOr remove_entry_from_blob_url_store(StringView url) auto& store = blob_url_store(); // 2. Let url string be the result of serializing url. - auto url_string = TRY(URL { url }.to_string()); + auto url_string = TRY(URL::URL { url }.to_string()); // 3. Remove store[url string]. store.remove(url_string); diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index 84a3965e7243d9d768d1645362d8d7e657bcfeb8..703a0ae9f0538b065d0352a5b80c466d64b3a060 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -36,7 +36,7 @@ namespace Web::HTML { JS_DEFINE_ALLOCATOR(BrowsingContext); // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#matches-about:blank -bool url_matches_about_blank(URL const& url) +bool url_matches_about_blank(URL::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 @@ -47,7 +47,7 @@ bool url_matches_about_blank(URL const& url) } // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#matches-about:srcdoc -bool url_matches_about_srcdoc(URL const& url) +bool url_matches_about_srcdoc(URL::URL const& url) { // A URL matches about:srcdoc if its scheme is "about", its path contains a single string "srcdoc", its query is null, its username and password are the empty string, and its host is null. return url.scheme() == "about"sv @@ -59,7 +59,7 @@ bool url_matches_about_srcdoc(URL const& url) } // https://html.spec.whatwg.org/multipage/document-sequences.html#determining-the-origin -HTML::Origin determine_the_origin(URL const& url, SandboxingFlagSet sandbox_flags, Optional source_origin) +HTML::Origin determine_the_origin(URL::URL const& url, SandboxingFlagSet sandbox_flags, Optional source_origin) { // 1. If sandboxFlags has its sandboxed origin browsing context flag set, then return a new opaque origin. if (has_flag(sandbox_flags, SandboxingFlagSet::SandboxedOrigin)) { @@ -132,7 +132,7 @@ WebIDL::ExceptionOr BrowsingContext Optional creator_origin = {}; // FIXME: This algorithm needs re-aligned with the spec - Optional creator_base_url = {}; + Optional creator_base_url = {}; // 4. If creator is non-null, then: if (creator) { @@ -151,7 +151,7 @@ WebIDL::ExceptionOr BrowsingContext SandboxingFlagSet sandbox_flags = {}; // 6. Let origin be the result of determining the origin given about:blank, sandboxFlags, and creatorOrigin. - auto origin = determine_the_origin(URL("about:blank"sv), sandbox_flags, creator_origin); + auto origin = determine_the_origin(URL::URL("about:blank"sv), sandbox_flags, creator_origin); // FIXME: 7. Let permissionsPolicy be the result of creating a permissions policy given browsingContext and origin. [PERMISSIONSPOLICY] @@ -176,7 +176,7 @@ WebIDL::ExceptionOr BrowsingContext }); // 10. Let topLevelCreationURL be about:blank if embedder is null; otherwise embedder's relevant settings object's top-level creation URL. - auto top_level_creation_url = !embedder ? URL("about:blank") : relevant_settings_object(*embedder).top_level_creation_url; + auto top_level_creation_url = !embedder ? URL::URL("about:blank") : relevant_settings_object(*embedder).top_level_creation_url; // 11. Let topLevelOrigin be origin if embedder is null; otherwise embedder's relevant settings object's top-level origin. auto top_level_origin = !embedder ? origin : relevant_settings_object(*embedder).origin(); @@ -184,7 +184,7 @@ WebIDL::ExceptionOr BrowsingContext // 12. Set up a window environment settings object with about:blank, realm execution context, null, topLevelCreationURL, and topLevelOrigin. WindowEnvironmentSettingsObject::setup( page, - URL("about:blank"), + URL::URL("about:blank"), move(realm_execution_context), {}, top_level_creation_url, diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h index a46a3b39977797161e71a2564e39ce14146c944b..9a765b7a3970b6b1dd6935ca128cd1ed07a9588a 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h @@ -179,7 +179,7 @@ private: bool m_is_auxiliary { false }; // https://html.spec.whatwg.org/multipage/document-sequences.html#browsing-context-initial-url - Optional m_initial_url; + Optional m_initial_url; // https://html.spec.whatwg.org/multipage/document-sequences.html#virtual-browsing-context-group-id u64 m_virtual_browsing_context_group_id = { 0 }; @@ -199,12 +199,12 @@ private: JS::GCPtr m_previous_sibling; }; -HTML::Origin determine_the_origin(URL const& url, SandboxingFlagSet sandbox_flags, Optional source_origin); +HTML::Origin determine_the_origin(URL::URL const& url, SandboxingFlagSet sandbox_flags, Optional source_origin); SandboxingFlagSet determine_the_creation_sandboxing_flags(BrowsingContext const&, JS::GCPtr embedder); // FIXME: Find a better home for these -bool url_matches_about_blank(URL const& url); -bool url_matches_about_srcdoc(URL const& url); +bool url_matches_about_blank(URL::URL const& url); +bool url_matches_about_srcdoc(URL::URL const& url); } diff --git a/Userland/Libraries/LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicyEnforcementResult.h b/Userland/Libraries/LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicyEnforcementResult.h index 45f17d755f8fff7feb39cef0085b6d6651c7de6e..14178111e777abddd0f6be94eece4122acf51e19 100644 --- a/Userland/Libraries/LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicyEnforcementResult.h +++ b/Userland/Libraries/LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicyEnforcementResult.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -21,7 +21,7 @@ struct CrossOriginOpenerPolicyEnforcementResult { bool would_need_a_browsing_context_group_switch_due_to_report_only { false }; // A URL url. - URL url; + URL::URL url; // An origin origin. Origin origin; diff --git a/Userland/Libraries/LibWeb/HTML/DocumentState.h b/Userland/Libraries/LibWeb/HTML/DocumentState.h index e30efb40c7209fa63e42b93188116c64655b9e10..82e0186bdfe6976945ceaab809bbfdcac96a3f71 100644 --- a/Userland/Libraries/LibWeb/HTML/DocumentState.h +++ b/Userland/Libraries/LibWeb/HTML/DocumentState.h @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include #include #include @@ -53,8 +53,8 @@ public: [[nodiscard]] Optional origin() const { return m_origin; } void set_origin(Optional origin) { m_origin = move(origin); } - [[nodiscard]] Optional const& about_base_url() const { return m_about_base_url; } - void set_about_base_url(Optional url) { m_about_base_url = move(url); } + [[nodiscard]] Optional const& about_base_url() const { return m_about_base_url; } + void set_about_base_url(Optional url) { m_about_base_url = move(url); } [[nodiscard]] Vector const& nested_histories() const { return m_nested_histories; } [[nodiscard]] Vector& nested_histories() { return m_nested_histories; } @@ -95,7 +95,7 @@ private: Optional m_origin; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-about-base-url - Optional m_about_base_url = {}; + Optional m_about_base_url = {}; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-nested-histories Vector m_nested_histories; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h index 8311204f49a642f3bb74e654618e1412efd6186a..e2a5c44315e4269dbd4f547f3a279d5889b7fca5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h @@ -20,7 +20,7 @@ public: String href() const; WebIDL::ExceptionOr set_href(String const& href); - URL const& frozen_base_url() const { return m_frozen_base_url; } + URL::URL const& frozen_base_url() const { return m_frozen_base_url; } virtual void inserted() override; virtual void removed_from(Node*) override; @@ -34,7 +34,7 @@ private: // https://html.spec.whatwg.org/multipage/semantics.html#frozen-base-url // A base element that is the first base element with an href content attribute in a document tree has a frozen base URL. - URL m_frozen_base_url; + URL::URL m_frozen_base_url; void set_the_frozen_base_url(); }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDocument.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDocument.cpp index 601a70ee97825402034cf0e15c7faae612e71224..be4d961aa4a11b45d752f5d4e7dfe82d47db3d3c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDocument.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDocument.cpp @@ -10,7 +10,7 @@ namespace Web::HTML { JS_DEFINE_ALLOCATOR(HTMLDocument); -HTMLDocument::HTMLDocument(JS::Realm& realm, URL const& url) +HTMLDocument::HTMLDocument(JS::Realm& realm, URL::URL const& url) : Document(realm, url) { } @@ -22,7 +22,7 @@ WebIDL::ExceptionOr> HTMLDocument::construct_impl return HTMLDocument::create(realm); } -JS::NonnullGCPtr HTMLDocument::create(JS::Realm& realm, URL const& url) +JS::NonnullGCPtr HTMLDocument::create(JS::Realm& realm, URL::URL const& url) { return realm.heap().allocate(realm, realm, url); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDocument.h b/Userland/Libraries/LibWeb/HTML/HTMLDocument.h index 9d481e80c79f24f81ac621600edf7bcfb97ff456..8c025a97e964dd7fb93a3c61e6c57ef0ad94c580 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDocument.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDocument.h @@ -21,13 +21,13 @@ class HTMLDocument final : public DOM::Document { public: virtual ~HTMLDocument() override; - [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, URL const& url = "about:blank"sv); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, URL::URL const& url = "about:blank"sv); WebIDL::ExceptionOr> construct_impl(JS::Realm&); private: virtual void initialize(JS::Realm&) override; - HTMLDocument(JS::Realm&, URL const&); + HTMLDocument(JS::Realm&, URL::URL const&); }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index a43dbe46a93595fda97992e52bdceeadc61ce0f6..30312dc6188fd94e01b5882e5e4e9eec5da9e09e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -708,7 +708,7 @@ static ErrorOr plain_text_encode(Vector const& pairs } // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submit-mutate-action -ErrorOr HTMLFormElement::mutate_action_url(URL parsed_action, Vector entry_list, String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) +ErrorOr HTMLFormElement::mutate_action_url(URL::URL parsed_action, Vector entry_list, String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) { // 1. Let pairs be the result of converting to a list of name-value pairs with entry list. auto pairs = TRY(convert_to_list_of_name_value_pairs(entry_list)); @@ -725,7 +725,7 @@ ErrorOr HTMLFormElement::mutate_action_url(URL parsed_action, Vector HTMLFormElement::submit_as_entity_body(URL parsed_action, Vector entry_list, EncodingTypeAttributeState encoding_type, [[maybe_unused]] String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) +ErrorOr HTMLFormElement::submit_as_entity_body(URL::URL parsed_action, Vector entry_list, EncodingTypeAttributeState encoding_type, [[maybe_unused]] String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) { // 1. Assert: method is POST. @@ -784,7 +784,7 @@ ErrorOr HTMLFormElement::submit_as_entity_body(URL parsed_action, Vector target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) +void HTMLFormElement::get_action_url(URL::URL parsed_action, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) { // 1. Plan to navigate to parsed action. // Spec Note: entry list is discarded. @@ -792,7 +792,7 @@ void HTMLFormElement::get_action_url(URL parsed_action, JS::NonnullGCPtr HTMLFormElement::mail_with_headers(URL parsed_action, Vector entry_list, [[maybe_unused]] String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) +ErrorOr HTMLFormElement::mail_with_headers(URL::URL parsed_action, Vector entry_list, [[maybe_unused]] String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) { // 1. Let pairs be the result of converting to a list of name-value pairs with entry list. auto pairs = TRY(convert_to_list_of_name_value_pairs(entry_list)); @@ -811,7 +811,7 @@ ErrorOr HTMLFormElement::mail_with_headers(URL parsed_action, Vector HTMLFormElement::mail_as_body(URL parsed_action, Vector entry_list, EncodingTypeAttributeState encoding_type, [[maybe_unused]] String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) +ErrorOr HTMLFormElement::mail_as_body(URL::URL parsed_action, Vector entry_list, EncodingTypeAttributeState encoding_type, [[maybe_unused]] String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) { // 1. Let pairs be the result of converting to a list of name-value pairs with entry list. auto pairs = TRY(convert_to_list_of_name_value_pairs(entry_list)); @@ -865,7 +865,7 @@ ErrorOr HTMLFormElement::mail_as_body(URL parsed_action, Vector post_resource, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) +void HTMLFormElement::plan_to_navigate_to(URL::URL url, Variant post_resource, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement) { // 1. Let referrerPolicy be the empty string. ReferrerPolicy::ReferrerPolicy referrer_policy = ReferrerPolicy::ReferrerPolicy::EmptyString; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h index aa05ba821237cc682bbc08a11c658667eed2c9c6..a770a9a73cdf33ca0f4e70b39216e209e8e0b12c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h @@ -111,12 +111,12 @@ private: ErrorOr pick_an_encoding() const; - ErrorOr mutate_action_url(URL parsed_action, Vector entry_list, String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); - ErrorOr submit_as_entity_body(URL parsed_action, Vector entry_list, EncodingTypeAttributeState encoding_type, String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); - void get_action_url(URL parsed_action, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); - ErrorOr mail_with_headers(URL parsed_action, Vector entry_list, String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); - ErrorOr mail_as_body(URL parsed_action, Vector entry_list, EncodingTypeAttributeState encoding_type, String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); - void plan_to_navigate_to(URL url, Variant post_resource, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); + ErrorOr mutate_action_url(URL::URL parsed_action, Vector entry_list, String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); + ErrorOr submit_as_entity_body(URL::URL parsed_action, Vector entry_list, EncodingTypeAttributeState encoding_type, String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); + void get_action_url(URL::URL parsed_action, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); + ErrorOr mail_with_headers(URL::URL parsed_action, Vector entry_list, String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); + ErrorOr mail_as_body(URL::URL parsed_action, Vector entry_list, EncodingTypeAttributeState encoding_type, String encoding, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); + void plan_to_navigate_to(URL::URL url, Variant post_resource, JS::NonnullGCPtr target_navigable, Bindings::NavigationHistoryBehavior history_handling, UserNavigationInvolvement user_involvement); FormAssociatedElement* default_button(); size_t number_of_fields_blocking_implicit_submission() const; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp index 9895983da2c01b6353bee0dbfc63d79950f3255b..fad05dfa2428c64bac6633baccca79d87cfeee63 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -78,7 +78,7 @@ void HTMLHyperlinkElementUtils::set_protocol(StringView protocol) return; // 3. Basic URL parse the given value, followed by ":", with this element's url as url and scheme start state as state override. - auto result_url = URLParser::basic_parse(MUST(String::formatted("{}:", protocol)), {}, m_url, URLParser::State::SchemeStart); + auto result_url = URL::Parser::basic_parse(MUST(String::formatted("{}:", protocol)), {}, m_url, URL::Parser::State::SchemeStart); if (result_url.is_valid()) m_url = move(result_url); @@ -192,7 +192,7 @@ void HTMLHyperlinkElementUtils::set_host(StringView host) return; // 4. Basic URL parse the given value, with url as url and host state as state override. - auto result_url = URLParser::basic_parse(host, {}, url, URLParser::State::Host); + auto result_url = URL::Parser::basic_parse(host, {}, url, URL::Parser::State::Host); if (result_url.is_valid()) m_url = move(result_url); @@ -205,7 +205,7 @@ String HTMLHyperlinkElementUtils::hostname() const // 1. Reinitialize url. // // 2. Let url be this element's url. - URL url(href()); + URL::URL url(href()); // 3. If url or url's host is null, return the empty string. if (url.host().has()) @@ -228,7 +228,7 @@ void HTMLHyperlinkElementUtils::set_hostname(StringView hostname) return; // 4. Basic URL parse the given value, with url as url and hostname state as state override. - auto result_url = URLParser::basic_parse(hostname, {}, m_url, URLParser::State::Hostname); + auto result_url = URL::Parser::basic_parse(hostname, {}, m_url, URL::Parser::State::Hostname); if (result_url.is_valid()) m_url = move(result_url); @@ -270,7 +270,7 @@ void HTMLHyperlinkElementUtils::set_port(StringView port) m_url->set_port({}); } else { // 5. Otherwise, basic URL parse the given value, with url as url and port state as state override. - auto result_url = URLParser::basic_parse(port, {}, m_url, URLParser::State::Port); + auto result_url = URL::Parser::basic_parse(port, {}, m_url, URL::Parser::State::Port); if (result_url.is_valid()) m_url = move(result_url); } @@ -314,7 +314,7 @@ void HTMLHyperlinkElementUtils::set_pathname(StringView pathname) url->set_paths({}); // 5. Basic URL parse the given value, with url as url and path start state as state override. - auto result_url = URLParser::basic_parse(pathname, {}, move(url), URLParser::State::PathStart); + auto result_url = URL::Parser::basic_parse(pathname, {}, move(url), URL::Parser::State::PathStart); if (result_url.is_valid()) m_url = move(result_url); @@ -361,7 +361,7 @@ void HTMLHyperlinkElementUtils::set_search(StringView search) url_copy->set_query(String {}); // 3. Basic URL parse input, with null, this element's node document's document's character encoding, url as url, and query state as state override. - auto result_url = URLParser::basic_parse(input, {}, move(url_copy), URLParser::State::Query); + auto result_url = URL::Parser::basic_parse(input, {}, move(url_copy), URL::Parser::State::Query); if (result_url.is_valid()) m_url = move(result_url); } @@ -409,7 +409,7 @@ void HTMLHyperlinkElementUtils::set_hash(StringView hash) url_copy->set_fragment(String {}); // 3. Basic URL parse input, with url as url and fragment state as state override. - auto result_url = URLParser::basic_parse(input, {}, move(url_copy), URLParser::State::Fragment); + auto result_url = URL::Parser::basic_parse(input, {}, move(url_copy), URL::Parser::State::Fragment); if (result_url.is_valid()) m_url = move(result_url); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.h b/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.h index c0467a9dd3b478d9fed562ad2c78f35531bb478d..62f73329ed31a4e9141c0fb42dc53d6b7cd93e1e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -69,7 +69,7 @@ private: void update_href(); bool cannot_navigate() const; - Optional m_url; + Optional m_url; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 842b2b8cf0e3456f59e42710a0a886ef6c6b2e15..24ca3786947954c166efb2eb0c874e44922da4d0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -85,7 +85,7 @@ void HTMLIFrameElement::process_the_iframe_attributes(bool initial_insertion) // 1. Set element's lazy load resumption steps to the rest of this algorithm starting with the step labeled navigate to the srcdoc resource. set_lazy_load_resumption_steps([this]() { // 3. Navigate to the srcdoc resource: navigate an iframe or frame given element, about:srcdoc, the empty string, and the value of element's srcdoc attribute. - navigate_an_iframe_or_frame(URL("about:srcdoc"sv), ReferrerPolicy::ReferrerPolicy::EmptyString, get_attribute(HTML::AttributeNames::srcdoc)); + navigate_an_iframe_or_frame(URL::URL("about:srcdoc"sv), ReferrerPolicy::ReferrerPolicy::EmptyString, get_attribute(HTML::AttributeNames::srcdoc)); // FIXME: The resulting Document must be considered an iframe srcdoc document. }); @@ -101,7 +101,7 @@ void HTMLIFrameElement::process_the_iframe_attributes(bool initial_insertion) } // 3. Navigate to the srcdoc resource: navigate an iframe or frame given element, about:srcdoc, the empty string, and the value of element's srcdoc attribute. - navigate_an_iframe_or_frame(URL("about:srcdoc"sv), ReferrerPolicy::ReferrerPolicy::EmptyString, get_attribute(HTML::AttributeNames::srcdoc)); + navigate_an_iframe_or_frame(URL::URL("about:srcdoc"sv), ReferrerPolicy::ReferrerPolicy::EmptyString, get_attribute(HTML::AttributeNames::srcdoc)); // FIXME: The resulting Document must be considered an iframe srcdoc document. diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index 2b2723de317ae4fbc5775ded4220ec6e870c4a64..14a687a017bd49a0415694073a66a61e81236e84 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -582,7 +582,7 @@ after_step_7: return {}; } -void HTMLImageElement::add_callbacks_to_image_request(JS::NonnullGCPtr image_request, bool maybe_omit_events, URL const& url_string, URL const& previous_url) +void HTMLImageElement::add_callbacks_to_image_request(JS::NonnullGCPtr image_request, bool maybe_omit_events, URL::URL const& url_string, URL::URL const& previous_url) { image_request->add_callbacks( [this, image_request, maybe_omit_events, url_string, previous_url]() { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h index cfb0c85f430a33522b9cf06fb76ec2c24ba00b25..cc86b848387604cdf6a9402ff9d0f5d0a1f86bae 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h @@ -111,9 +111,9 @@ private: virtual void did_set_viewport_rect(CSSPixelRect const&) override; - void handle_successful_fetch(URL const&, StringView mime_type, ImageRequest&, ByteBuffer, bool maybe_omit_events, URL const& previous_url); + void handle_successful_fetch(URL::URL const&, StringView mime_type, ImageRequest&, ByteBuffer, bool maybe_omit_events, URL::URL const& previous_url); void handle_failed_fetch(); - void add_callbacks_to_image_request(JS::NonnullGCPtr, bool maybe_omit_events, URL const& url_string, URL const& previous_url); + void add_callbacks_to_image_request(JS::NonnullGCPtr, bool maybe_omit_events, URL::URL const& url_string, URL::URL const& previous_url); void animate(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index 9a5e25a5633fb973eabd05c37496b57bdafa126c..d406d674e4fedf6848c9c9f66c558995bf01c377 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -9,8 +9,8 @@ #include #include -#include #include +#include #include #include #include @@ -362,7 +362,7 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru auto const& encoded_string = body_bytes.get(); auto maybe_decoded_string = TextCodec::convert_input_to_utf8_using_given_decoder_unless_there_is_a_byte_order_mark(*decoder, encoded_string); if (maybe_decoded_string.is_error()) { - dbgln("Style sheet {} claimed to be '{}' but decoding failed", response.url().value_or(URL()), encoding); + dbgln("Style sheet {} claimed to be '{}' but decoding failed", response.url().value_or(URL::URL()), encoding); dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error)); } else { auto const decoded_string = maybe_decoded_string.release_value(); @@ -443,7 +443,7 @@ void HTMLLinkElement::resource_did_load_favicon() document().check_favicon_after_loading_link_resource(); } -static bool decode_favicon(ReadonlyBytes favicon_data, URL const& favicon_url, JS::GCPtr navigable) +static bool decode_favicon(ReadonlyBytes favicon_data, URL::URL const& favicon_url, JS::GCPtr navigable) { auto decoded_image = Platform::ImageCodecPlugin::the().decode_image(favicon_data); if (!decoded_image.has_value() || decoded_image->frames.is_empty()) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h index 3b453745394cad59138d07ed9bbb830ba33e8619..55c58235702913a56fc4f0980244cc3d2c6252ce 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -75,7 +75,7 @@ private: // Null or a source set // base URL // A URL - URL base_url; + URL::URL base_url; // origin // An origin HTML::Origin origin; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index 0b4265808bce93f6a268e8339f627c9617365676..bf6ab8a3f7b200eaae3725da04393133cd625674 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -892,7 +892,7 @@ enum class FetchMode { }; // https://html.spec.whatwg.org/multipage/media.html#concept-media-load-resource -WebIDL::ExceptionOr HTMLMediaElement::fetch_resource(URL const& url_record, Function failure_callback) +WebIDL::ExceptionOr HTMLMediaElement::fetch_resource(URL::URL const& url_record, Function failure_callback) { auto& realm = this->realm(); auto& vm = realm.vm(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h index 7ad753eded4f5b988872f7e9c6f15bd95dbca014..7f908424da3cb97ff12a04401b5845493227ed94 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h @@ -158,7 +158,7 @@ private: Task::Source media_element_event_task_source() const { return m_media_element_event_task_source.source; } WebIDL::ExceptionOr load_element(); - WebIDL::ExceptionOr fetch_resource(URL const&, Function failure_callback); + WebIDL::ExceptionOr fetch_resource(URL::URL const&, Function failure_callback); static bool verify_response(JS::NonnullGCPtr, ByteRange const&); WebIDL::ExceptionOr process_media_data(Function failure_callback); WebIDL::ExceptionOr handle_media_source_failure(Span> promises, String error_message); diff --git a/Userland/Libraries/LibWeb/HTML/History.cpp b/Userland/Libraries/LibWeb/HTML/History.cpp index 5e6b8a7eaf32a5d4c8d9cde987c5af2f19cdcc1c..4fd3ecdc0860aa71d06286897f3f99ae9ac73d6c 100644 --- a/Userland/Libraries/LibWeb/HTML/History.cpp +++ b/Userland/Libraries/LibWeb/HTML/History.cpp @@ -121,7 +121,7 @@ WebIDL::ExceptionOr History::forward() } // https://html.spec.whatwg.org/multipage/nav-history-apis.html#can-have-its-url-rewritten -bool can_have_its_url_rewritten(DOM::Document const& document, ::URL const& target_url) +bool can_have_its_url_rewritten(DOM::Document const& document, URL::URL const& target_url) { // 1. Let documentURL be document's URL. auto document_url = document.url(); diff --git a/Userland/Libraries/LibWeb/HTML/History.h b/Userland/Libraries/LibWeb/HTML/History.h index 6135583cb84a9d2e0c88e0724b53d5ad7263a74f..b70f6bcd7240c7555df803a7aca9ea936ae07159 100644 --- a/Userland/Libraries/LibWeb/HTML/History.h +++ b/Userland/Libraries/LibWeb/HTML/History.h @@ -48,6 +48,6 @@ private: JS::Value m_state { JS::js_null() }; }; -bool can_have_its_url_rewritten(DOM::Document const& document, URL const& target_url); +bool can_have_its_url_rewritten(DOM::Document const& document, URL::URL const& target_url); } diff --git a/Userland/Libraries/LibWeb/HTML/ImageRequest.cpp b/Userland/Libraries/LibWeb/HTML/ImageRequest.cpp index eaa37cbc9948957c5e52b8077cb9e4f9d192de9b..a3128d160d5e9feb2d29e2758df0d24b0b47faad 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageRequest.cpp +++ b/Userland/Libraries/LibWeb/HTML/ImageRequest.cpp @@ -66,12 +66,12 @@ void ImageRequest::set_state(State state) m_state = state; } -URL const& ImageRequest::current_url() const +URL::URL const& ImageRequest::current_url() const { return m_current_url; } -void ImageRequest::set_current_url(JS::Realm& realm, URL url) +void ImageRequest::set_current_url(JS::Realm& realm, URL::URL url) { m_current_url = move(url); if (m_current_url.is_valid()) diff --git a/Userland/Libraries/LibWeb/HTML/ImageRequest.h b/Userland/Libraries/LibWeb/HTML/ImageRequest.h index 20ddb1a9ac49aa6d683c64820b792d956a80b301..9741fc81e882b4484c5a61062da58cff3408009e 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageRequest.h +++ b/Userland/Libraries/LibWeb/HTML/ImageRequest.h @@ -8,9 +8,9 @@ #include #include -#include #include #include +#include #include #include @@ -40,8 +40,8 @@ public: State state() const; void set_state(State); - URL const& current_url() const; - void set_current_url(JS::Realm&, URL); + URL::URL const& current_url() const; + void set_current_url(JS::Realm&, URL::URL); [[nodiscard]] JS::GCPtr image_data() const; void set_image_data(JS::GCPtr); @@ -73,7 +73,7 @@ private: // https://html.spec.whatwg.org/multipage/images.html#img-req-url // An image request's current URL is initially the empty string. - URL m_current_url; + URL::URL m_current_url; // https://html.spec.whatwg.org/multipage/images.html#img-req-data JS::GCPtr m_image_data; diff --git a/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.cpp b/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.cpp index 34b945904ebd9e53d52747a6af4a320c45fc172e..e98ac2b5cfa0e53151a4b8bc7a485167083c7bc5 100644 --- a/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.cpp +++ b/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.cpp @@ -22,7 +22,7 @@ bool ListOfAvailableImages::Key::operator==(Key const& other) const u32 ListOfAvailableImages::Key::hash() const { if (!cached_hash.has_value()) { - u32 url_hash = Traits::hash(url); + u32 url_hash = Traits::hash(url); u32 mode_hash = static_cast(mode); u32 origin_hash = 0; if (origin.has_value()) diff --git a/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.h b/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.h index af2f9d6c44a4cbd3de329c46699f1c8770bfe28e..f2bace9ae6a7b9dae8ebf955c23c0188de39970a 100644 --- a/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.h +++ b/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.h @@ -7,8 +7,8 @@ #pragma once #include -#include #include +#include #include #include #include @@ -22,7 +22,7 @@ class ListOfAvailableImages : public JS::Cell { public: struct Key { - URL url; + URL::URL url; HTML::CORSSettingAttribute mode; Optional origin; diff --git a/Userland/Libraries/LibWeb/HTML/Location.cpp b/Userland/Libraries/LibWeb/HTML/Location.cpp index c03e199bde46dc8c4c93bc07f7c296196d7e636f..b0fb8ea22e0745c04e46dda650e992f5f04a4a1a 100644 --- a/Userland/Libraries/LibWeb/HTML/Location.cpp +++ b/Userland/Libraries/LibWeb/HTML/Location.cpp @@ -7,11 +7,11 @@ #include #include -#include #include #include #include #include +#include #include #include #include @@ -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 Location::navigate(URL url, HistoryHandlingBehavior history_handling) +WebIDL::ExceptionOr Location::navigate(URL::URL url, HistoryHandlingBehavior history_handling) { // 1. Let navigable be location's relevant global object's navigable. auto navigable = verify_cast(HTML::relevant_global_object(*this)).navigable(); @@ -97,7 +97,7 @@ WebIDL::ExceptionOr 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 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()) diff --git a/Userland/Libraries/LibWeb/HTML/Location.h b/Userland/Libraries/LibWeb/HTML/Location.h index b1b3272aa04db4f5c4aff473c4f5e8c7d06d67a1..1b9ce40064a90e52bb01b108a06c0a6a0f5d5f6c 100644 --- a/Userland/Libraries/LibWeb/HTML/Location.h +++ b/Userland/Libraries/LibWeb/HTML/Location.h @@ -7,9 +7,9 @@ #pragma once -#include #include #include +#include #include #include #include @@ -75,8 +75,8 @@ private: virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr relevant_document() const; - URL url() const; - WebIDL::ExceptionOr navigate(URL, HistoryHandlingBehavior = HistoryHandlingBehavior::Default); + URL::URL url() const; + WebIDL::ExceptionOr navigate(URL::URL, HistoryHandlingBehavior = HistoryHandlingBehavior::Default); // [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap HTML::CrossOriginPropertyDescriptorMap m_cross_origin_property_descriptor_map; diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp index e5050104e07365c8987f75d5cf8fb02da56ddc17..7e442aef091e316bb55d21d476c1baad2624cb15 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp @@ -501,7 +501,7 @@ Vector>& Navigable::get_session_history_en } // https://html.spec.whatwg.org/multipage/browsers.html#determining-navigation-params-policy-container -static PolicyContainer determine_navigation_params_policy_container(URL const& response_url, +static PolicyContainer determine_navigation_params_policy_container(URL::URL const& response_url, Optional history_policy_container, Optional initiator_policy_container, Optional parent_policy_container, @@ -594,7 +594,7 @@ static WebIDL::ExceptionOr create_navigation_params_from_a_src // header list: (`Content-Type`, `text/html`) // body: the UTF-8 encoding of documentResource, as a body auto response = Fetch::Infrastructure::Response::create(vm); - response->url_list().append(URL("about:srcdoc")); + response->url_list().append(URL::URL("about:srcdoc")); auto header = TRY_OR_THROW_OOM(vm, Fetch::Infrastructure::Header::from_string_pair("Content-Type"sv, "text/html"sv)); TRY_OR_THROW_OOM(vm, response->header_list()->append(move(header))); response->set_body(TRY(Fetch::Infrastructure::byte_sequence_as_body(realm, document_resource.get().bytes()))); @@ -791,10 +791,10 @@ static WebIDL::ExceptionOr> location_url { OptionalNone {} }; + ErrorOr> location_url { OptionalNone {} }; // 17. Let currentURL be request's current URL. - URL current_url = request->current_url(); + URL::URL current_url = request->current_url(); // 18. Let commitEarlyHints be null. Function commit_early_hints = nullptr; @@ -1126,7 +1126,7 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document( auto error_html = load_error_page(entry->url).release_value_but_fixme_should_propagate_errors(); entry->document_state->set_document(create_document_for_inline_content(this, navigation_id, [error_html](auto& document) { auto parser = HTML::HTMLParser::create(document, error_html, "utf-8"); - document.set_url(URL("about:error")); + document.set_url(URL::URL("about:error")); parser->run(); })); @@ -1437,7 +1437,7 @@ WebIDL::ExceptionOr Navigable::navigate(NavigateParams params) } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-fragid -WebIDL::ExceptionOr Navigable::navigate_to_a_fragment(URL const& url, HistoryHandlingBehavior history_handling, UserNavigationInvolvement user_involvement, Optional navigation_api_state, String navigation_id) +WebIDL::ExceptionOr Navigable::navigate_to_a_fragment(URL::URL const& url, HistoryHandlingBehavior history_handling, UserNavigationInvolvement user_involvement, Optional navigation_api_state, String navigation_id) { (void)navigation_id; @@ -1524,7 +1524,7 @@ WebIDL::ExceptionOr Navigable::navigate_to_a_fragment(URL const& url, Hist } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#evaluate-a-javascript:-url -WebIDL::ExceptionOr> Navigable::evaluate_javascript_url(URL const& url, Origin const& new_document_origin, String navigation_id) +WebIDL::ExceptionOr> Navigable::evaluate_javascript_url(URL::URL const& url, Origin const& new_document_origin, String navigation_id) { auto& vm = this->vm(); auto& realm = active_window()->realm(); @@ -1626,7 +1626,7 @@ WebIDL::ExceptionOr> Navigable::evaluate_javascript_url } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-to-a-javascript:-url -WebIDL::ExceptionOr Navigable::navigate_to_a_javascript_url(URL const& url, HistoryHandlingBehavior history_handling, Origin const& initiator_origin, CSPNavigationType csp_navigation_type, String navigation_id) +WebIDL::ExceptionOr Navigable::navigate_to_a_javascript_url(URL::URL const& url, HistoryHandlingBehavior history_handling, Origin const& initiator_origin, CSPNavigationType csp_navigation_type, String navigation_id) { // 1. Assert: historyHandling is "replace". VERIFY(history_handling == HistoryHandlingBehavior::Replace); @@ -1715,7 +1715,7 @@ 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(URL const& url, DOM::Document const& document) +bool navigation_must_be_a_replace(URL::URL const& url, DOM::Document const& document) { return url.scheme() == "javascript"sv || document.is_initial_about_blank(); } @@ -1863,7 +1863,7 @@ void finalize_a_cross_document_navigation(JS::NonnullGCPtr navigable, } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#url-and-history-update-steps -void perform_url_and_history_update_steps(DOM::Document& document, URL new_url, Optional serialized_data, HistoryHandlingBehavior history_handling) +void perform_url_and_history_update_steps(DOM::Document& document, URL::URL new_url, Optional serialized_data, HistoryHandlingBehavior history_handling) { // 1. Let navigable be document's node navigable. auto navigable = document.navigable(); diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.h b/Userland/Libraries/LibWeb/HTML/Navigable.h index 2d143474858c29ca3e3724cc464d7788260447b5..e3dbfcce156c511442dac41b8ad5fb6c83005f76 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.h +++ b/Userland/Libraries/LibWeb/HTML/Navigable.h @@ -125,7 +125,7 @@ public: Function completion_steps = [] {}); struct NavigateParams { - URL const& url; + URL::URL const& url; JS::NonnullGCPtr source_document; Variant document_resource = Empty {}; JS::GCPtr response = nullptr; @@ -139,10 +139,10 @@ public: WebIDL::ExceptionOr navigate(NavigateParams); - WebIDL::ExceptionOr navigate_to_a_fragment(URL const&, HistoryHandlingBehavior, UserNavigationInvolvement, Optional navigation_api_state, String navigation_id); + WebIDL::ExceptionOr navigate_to_a_fragment(URL::URL const&, HistoryHandlingBehavior, UserNavigationInvolvement, Optional navigation_api_state, String navigation_id); - WebIDL::ExceptionOr> evaluate_javascript_url(URL const&, Origin const& new_document_origin, String navigation_id); - WebIDL::ExceptionOr navigate_to_a_javascript_url(URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, CSPNavigationType csp_navigation_type, String navigation_id); + WebIDL::ExceptionOr> evaluate_javascript_url(URL::URL const&, Origin const& new_document_origin, String navigation_id); + WebIDL::ExceptionOr navigate_to_a_javascript_url(URL::URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, CSPNavigationType csp_navigation_type, String navigation_id); bool allowed_by_sandboxing_to_navigate(Navigable const& target, SourceSnapshotParams const&); @@ -229,9 +229,9 @@ private: HashTable& all_navigables(); -bool navigation_must_be_a_replace(URL const& url, DOM::Document const& document); +bool navigation_must_be_a_replace(URL::URL const& url, DOM::Document const& document); void finalize_a_cross_document_navigation(JS::NonnullGCPtr, HistoryHandlingBehavior, JS::NonnullGCPtr); -void perform_url_and_history_update_steps(DOM::Document& document, URL new_url, Optional = {}, HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Reload); +void perform_url_and_history_update_steps(DOM::Document& document, URL::URL new_url, Optional = {}, HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Reload); UserNavigationInvolvement user_navigation_involvement(DOM::Event const&); } diff --git a/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp index 4e72b1a0d04fa31621f5fdec3341cdfe86243e0f..32f040ee2d991e890e4034de8b275627b1c42bc3 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp +++ b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp @@ -188,10 +188,10 @@ HTML::WindowProxy* NavigableContainer::content_window() } // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#shared-attribute-processing-steps-for-iframe-and-frame-elements -Optional NavigableContainer::shared_attribute_processing_steps_for_iframe_and_frame(bool initial_insertion) +Optional NavigableContainer::shared_attribute_processing_steps_for_iframe_and_frame(bool initial_insertion) { // 1. Let url be the URL record about:blank. - auto url = URL("about:blank"); + auto url = URL::URL("about:blank"); // 2. If element has a src attribute specified, and its value is not the empty string, // then parse the value of that attribute relative to element's node document. @@ -223,7 +223,7 @@ Optional NavigableContainer::shared_attribute_processing_steps_for_iframe_a } // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#navigate-an-iframe-or-frame -void NavigableContainer::navigate_an_iframe_or_frame(URL url, ReferrerPolicy::ReferrerPolicy referrer_policy, Optional srcdoc_string) +void NavigableContainer::navigate_an_iframe_or_frame(URL::URL url, ReferrerPolicy::ReferrerPolicy referrer_policy, Optional srcdoc_string) { // 1. Let historyHandling be "auto". auto history_handling = Bindings::NavigationHistoryBehavior::Auto; diff --git a/Userland/Libraries/LibWeb/HTML/NavigableContainer.h b/Userland/Libraries/LibWeb/HTML/NavigableContainer.h index 3277a9430c729d38762105723105c5d8c28a1bf9..1c9f7e729ad5b8c1f2aaa193349458685b926858 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigableContainer.h +++ b/Userland/Libraries/LibWeb/HTML/NavigableContainer.h @@ -57,10 +57,10 @@ protected: virtual void visit_edges(Cell::Visitor&) override; // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#shared-attribute-processing-steps-for-iframe-and-frame-elements - Optional shared_attribute_processing_steps_for_iframe_and_frame(bool initial_insertion); + Optional shared_attribute_processing_steps_for_iframe_and_frame(bool initial_insertion); // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#navigate-an-iframe-or-frame - void navigate_an_iframe_or_frame(URL url, ReferrerPolicy::ReferrerPolicy referrer_policy, Optional srcdoc_string = {}); + void navigate_an_iframe_or_frame(URL::URL url, ReferrerPolicy::ReferrerPolicy referrer_policy, Optional srcdoc_string = {}); WebIDL::ExceptionOr create_new_child_navigable(); diff --git a/Userland/Libraries/LibWeb/HTML/Navigation.cpp b/Userland/Libraries/LibWeb/HTML/Navigation.cpp index b0ab3321d057ce45e389f8da2b336e0f4c41936a..b9e9f43534cb38be10847269dd667a2c27cb9627 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigation.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigation.cpp @@ -1282,7 +1282,7 @@ bool Navigation::fire_a_traverse_navigate_event(JS::NonnullGCPtr&> form_data_entry_list, @@ -1322,7 +1322,7 @@ bool Navigation::fire_a_push_replace_reload_navigate_event( } // https://html.spec.whatwg.org/multipage/nav-history-apis.html#fire-a-download-request-navigate-event -bool Navigation::fire_a_download_request_navigate_event(URL destination_url, UserNavigationInvolvement user_involvement, String filename) +bool Navigation::fire_a_download_request_navigate_event(URL::URL destination_url, UserNavigationInvolvement user_involvement, String filename) { auto& realm = relevant_realm(*this); auto& vm = this->vm(); diff --git a/Userland/Libraries/LibWeb/HTML/Navigation.h b/Userland/Libraries/LibWeb/HTML/Navigation.h index 231e500288328610f753cdbd16a022835acc2498..d352030402ce8cab04431426693fd11a7f485b89 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigation.h +++ b/Userland/Libraries/LibWeb/HTML/Navigation.h @@ -113,13 +113,13 @@ public: bool fire_a_traverse_navigate_event(JS::NonnullGCPtr destination_she, UserNavigationInvolvement = UserNavigationInvolvement::None); bool fire_a_push_replace_reload_navigate_event( Bindings::NavigationType, - URL destination_url, + URL::URL destination_url, bool is_same_document, UserNavigationInvolvement = UserNavigationInvolvement::None, Optional&> form_data_entry_list = {}, Optional navigation_api_state = {}, Optional classic_history_api_state = {}); - bool fire_a_download_request_navigate_event(URL destination_url, UserNavigationInvolvement user_involvement, String filename); + bool fire_a_download_request_navigate_event(URL::URL destination_url, UserNavigationInvolvement user_involvement, String filename); void initialize_the_navigation_api_entries_for_a_new_document(Vector> const& new_shes, JS::NonnullGCPtr initial_she); void update_the_navigation_api_entries_for_a_same_document_navigation(JS::NonnullGCPtr destination_she, Bindings::NavigationType); diff --git a/Userland/Libraries/LibWeb/HTML/NavigationDestination.h b/Userland/Libraries/LibWeb/HTML/NavigationDestination.h index 18a6506e32f23399c4ae5cfde6a183738cdc4b16..9a9597c7347db5025d91af27fb44c49d4032f498 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigationDestination.h +++ b/Userland/Libraries/LibWeb/HTML/NavigationDestination.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -31,14 +31,14 @@ public: JS::GCPtr navigation_history_entry() const { return m_entry; } // Setters are not available to JS, but expected in many spec algorithms - void set_url(URL const& url) { m_url = url; } + void set_url(URL::URL const& url) { m_url = url; } void set_entry(JS::GCPtr entry) { m_entry = entry; } void set_state(SerializationRecord state) { m_state = move(state); } void set_is_same_document(bool b) { m_is_same_document = b; } virtual ~NavigationDestination() override; - URL const& raw_url() const { return m_url; } + URL::URL const& raw_url() const { return m_url; } private: NavigationDestination(JS::Realm&); @@ -47,7 +47,7 @@ private: virtual void visit_edges(JS::Cell::Visitor&) override; // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationdestination-url - URL m_url; + URL::URL m_url; // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationdestination-url JS::GCPtr m_entry; diff --git a/Userland/Libraries/LibWeb/HTML/NavigationParams.h b/Userland/Libraries/LibWeb/HTML/NavigationParams.h index f1f2b556903a4d29b0a345482021c7db25834a29..b9d8b949911dcd8fd80ad228c8c3e5ecc2551c11 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigationParams.h +++ b/Userland/Libraries/LibWeb/HTML/NavigationParams.h @@ -59,7 +59,7 @@ struct NavigationParams { // FIXME: a NavigationTimingType used for creating the navigation timing entry for the new Document // a URL or null used to populate the new Document's about base URL - Optional about_base_url; + Optional about_base_url; }; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#non-fetch-scheme-navigation-params @@ -71,7 +71,7 @@ struct NonFetchSchemeNavigationParams { JS::Handle navigable; // a URL - URL url; + URL::URL url; // the target snapshot params's sandboxing flags present during navigation SandboxingFlagSet target_snapshot_sandboxing_flags = {}; diff --git a/Userland/Libraries/LibWeb/HTML/NavigatorBeacon.cpp b/Userland/Libraries/LibWeb/HTML/NavigatorBeacon.cpp index 543a09d4633545c5fb3ff380aa6b409709e8dee5..9cc67a81f06953d87a6b0a5494899f230f38fe89 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigatorBeacon.cpp +++ b/Userland/Libraries/LibWeb/HTML/NavigatorBeacon.cpp @@ -29,7 +29,7 @@ WebIDL::ExceptionOr NavigatorBeaconMixin::send_beacon(String const& url, O auto origin = relevant_settings_object.origin(); // 3. Set parsedUrl to the result of the URL parser steps with url and base. If the algorithm returns an error, or if parsedUrl's scheme is not "http" or "https", throw a "TypeError" exception and terminate these steps. - auto parsed_url = URLParser::basic_parse(url, base_url); + auto parsed_url = URL::Parser::basic_parse(url, base_url); if (!parsed_url.is_valid()) return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Beacon URL {} is invalid.", url)) }; if (parsed_url.scheme() != "http" && parsed_url.scheme() != "https") diff --git a/Userland/Libraries/LibWeb/HTML/Origin.h b/Userland/Libraries/LibWeb/HTML/Origin.h index ad6c4089e8a3c4acd73f35a0d708f855f39d4334..18adeb561cacc324210eb7b880dffc4002cd3ee0 100644 --- a/Userland/Libraries/LibWeb/HTML/Origin.h +++ b/Userland/Libraries/LibWeb/HTML/Origin.h @@ -8,9 +8,10 @@ #pragma once #include -#include -#include -#include +#include +#include +#include +#include namespace Web::HTML { @@ -87,7 +88,7 @@ public: result.append("://"sv); // 4. Append origin's host, serialized, to result. - result.append(URLParser::serialize_host(host()).release_value_but_fixme_should_propagate_errors().to_byte_string()); + result.append(URL::Parser::serialize_host(host()).release_value_but_fixme_should_propagate_errors().to_byte_string()); // 5. If origin's port is non-null, append a U+003A COLON character (:), and origin's port, serialized, to result. if (port() != 0) { @@ -129,7 +130,7 @@ struct Traits : public DefaultTraits { auto hash_without_host = pair_int_hash(origin.scheme().hash(), origin.port()); if (origin.host().has()) return hash_without_host; - return pair_int_hash(hash_without_host, URLParser::serialize_host(origin.host()).release_value_but_fixme_should_propagate_errors().hash()); + return pair_int_hash(hash_without_host, URL::Parser::serialize_host(origin.host()).release_value_but_fixme_should_propagate_errors().hash()); } }; } // namespace AK diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index 527562be1e65e9176594bf4667ab7a1e266b7119..62901d05bbc1a568de85a3b60fb69cbc91921b3a 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -216,7 +216,7 @@ void HTMLParser::run(HTMLTokenizer::StopAtInsertionPoint stop_at_insertion_point flush_character_insertions(); } -void HTMLParser::run(const URL& url, HTMLTokenizer::StopAtInsertionPoint stop_at_insertion_point) +void HTMLParser::run(const URL::URL& url, HTMLTokenizer::StopAtInsertionPoint stop_at_insertion_point) { m_document->set_url(url); m_document->set_source(MUST(String::from_byte_string(m_tokenizer.source()))); diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h index 3a56b7614bb2ce6597c36192f22a052b7495cffc..9fcb3a0a74d34699a2ff1c2d1860816995b81f30 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h @@ -54,7 +54,7 @@ public: static JS::NonnullGCPtr create(DOM::Document&, StringView input, ByteString const& encoding); void run(HTMLTokenizer::StopAtInsertionPoint = HTMLTokenizer::StopAtInsertionPoint::No); - void run(const URL&, HTMLTokenizer::StopAtInsertionPoint = HTMLTokenizer::StopAtInsertionPoint::No); + void run(const URL::URL&, HTMLTokenizer::StopAtInsertionPoint = HTMLTokenizer::StopAtInsertionPoint::No); static void the_end(JS::NonnullGCPtr, JS::GCPtr = nullptr); diff --git a/Userland/Libraries/LibWeb/HTML/PotentialCORSRequest.cpp b/Userland/Libraries/LibWeb/HTML/PotentialCORSRequest.cpp index 60f79b6171e2060a690002f3346e65f86f118ccb..7810b85a5cf62bfa78950c941f820ded7183e978 100644 --- a/Userland/Libraries/LibWeb/HTML/PotentialCORSRequest.cpp +++ b/Userland/Libraries/LibWeb/HTML/PotentialCORSRequest.cpp @@ -11,7 +11,7 @@ namespace Web::HTML { // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#create-a-potential-cors-request JS::NonnullGCPtr -create_potential_CORS_request(JS::VM& vm, URL const& url, Optional destination, CORSSettingAttribute cors_attribute_state, SameOriginFallbackFlag same_origin_fallback_flag) +create_potential_CORS_request(JS::VM& vm, URL::URL const& url, Optional destination, CORSSettingAttribute cors_attribute_state, SameOriginFallbackFlag same_origin_fallback_flag) { // 1. Let mode be "no-cors" if corsAttributeState is No CORS, and "cors" otherwise. auto mode = cors_attribute_state == CORSSettingAttribute::NoCORS diff --git a/Userland/Libraries/LibWeb/HTML/PotentialCORSRequest.h b/Userland/Libraries/LibWeb/HTML/PotentialCORSRequest.h index c2e348dc4b1c2e9b786b161bd2ec83aa6c301e50..20ec9197b88818aabe899454a97b021261a5c157 100644 --- a/Userland/Libraries/LibWeb/HTML/PotentialCORSRequest.h +++ b/Userland/Libraries/LibWeb/HTML/PotentialCORSRequest.h @@ -6,8 +6,8 @@ #pragma once -#include #include +#include #include #include @@ -18,6 +18,6 @@ enum class SameOriginFallbackFlag { Yes, }; -[[nodiscard]] JS::NonnullGCPtr create_potential_CORS_request(JS::VM&, const URL&, Optional, CORSSettingAttribute, SameOriginFallbackFlag = SameOriginFallbackFlag::No); +[[nodiscard]] JS::NonnullGCPtr create_potential_CORS_request(JS::VM&, const URL::URL&, Optional, CORSSettingAttribute, SameOriginFallbackFlag = SameOriginFallbackFlag::No); } diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp index 1a41984f99cdefc8350b5cb6117074da37f83664..6b89a9c0bdc2a957684ba760a1ff0068bafe9566 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp @@ -18,7 +18,7 @@ namespace Web::HTML { JS_DEFINE_ALLOCATOR(ClassicScript); // https://html.spec.whatwg.org/multipage/webappapis.html#creating-a-classic-script -JS::NonnullGCPtr ClassicScript::create(ByteString filename, StringView source, EnvironmentSettingsObject& environment_settings_object, URL base_url, size_t source_line_number, MutedErrors muted_errors) +JS::NonnullGCPtr ClassicScript::create(ByteString filename, StringView source, EnvironmentSettingsObject& environment_settings_object, URL::URL base_url, size_t source_line_number, MutedErrors muted_errors) { auto& vm = environment_settings_object.realm().vm(); @@ -147,7 +147,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors, JS::GCPtr create(ByteString filename, StringView source, EnvironmentSettingsObject&, URL base_url, size_t source_line_number = 1, MutedErrors = MutedErrors::No); + static JS::NonnullGCPtr create(ByteString filename, StringView source, EnvironmentSettingsObject&, URL::URL base_url, size_t source_line_number = 1, MutedErrors = MutedErrors::No); JS::Script* script_record() { return m_script_record; } JS::Script const* script_record() const { return m_script_record; } @@ -38,7 +38,7 @@ public: MutedErrors muted_errors() const { return m_muted_errors; } private: - ClassicScript(URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object); + ClassicScript(URL::URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object); virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/EnvironmentSettingsSnapshot.h b/Userland/Libraries/LibWeb/HTML/Scripting/EnvironmentSettingsSnapshot.h index 10a13d15dc4c7b74ec0cb46329f3bf4e96740b80..36651101ffba7c5e592b2d3b699dc1b775e3d945 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/EnvironmentSettingsSnapshot.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/EnvironmentSettingsSnapshot.h @@ -24,14 +24,14 @@ public: JS::GCPtr responsible_document() override { return nullptr; } String api_url_character_encoding() override { return m_api_url_character_encoding; } - URL api_base_url() override { return m_url; } + URL::URL api_base_url() override { return m_url; } Origin origin() override { return m_origin; } PolicyContainer policy_container() override { return m_policy_container; } CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() override { return CanUseCrossOriginIsolatedAPIs::No; } private: String m_api_url_character_encoding; - URL m_url; + URL::URL m_url; HTML::Origin m_origin; HTML::PolicyContainer m_policy_container; }; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp index 8581535a92a877805de986304b5ed32f60cf69d2..a9894898205dfb04e49987f13cedf41b231da232 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp @@ -161,7 +161,7 @@ void EnvironmentSettingsObject::prepare_to_run_callback() } // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url -URL EnvironmentSettingsObject::parse_url(StringView url) +URL::URL EnvironmentSettingsObject::parse_url(StringView url) { // 1. Let encoding be document's character encoding, if document was given, and environment settings object's API URL character encoding otherwise. // FIXME: Pass in environment settings object's API URL character encoding. diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h index f9f4cfa299a1012b1916e3f2a63d8567c581a13c..8dfeffc4d8ec5c44da8796fe37dd87dd6ee99467 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include #include #include @@ -24,10 +24,10 @@ struct Environment { String id; // https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-creation-url - URL creation_url; + URL::URL creation_url; // https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-top-level-creation-url - URL top_level_creation_url; + URL::URL top_level_creation_url; // https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-top-level-origin Origin top_level_origin; @@ -68,7 +68,7 @@ struct EnvironmentSettingsObject virtual String api_url_character_encoding() = 0; // https://html.spec.whatwg.org/multipage/webappapis.html#api-base-url - virtual URL api_base_url() = 0; + virtual URL::URL api_base_url() = 0; // https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-origin virtual Origin origin() = 0; @@ -79,7 +79,7 @@ struct EnvironmentSettingsObject // https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-cross-origin-isolated-capability virtual CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() = 0; - URL parse_url(StringView); + URL::URL parse_url(StringView); JS::Realm& realm(); JS::Object& global_object(); diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp index 13a1dc60a084275188b8c950cc092710527df163..94d680a217b263bad872e3c0aee43a3b85d88100 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp @@ -77,11 +77,11 @@ ByteString module_type_from_module_request(JS::ModuleRequest const& module_reque } // https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier -WebIDL::ExceptionOr resolve_module_specifier(Optional referring_script, ByteString const& specifier) +WebIDL::ExceptionOr resolve_module_specifier(Optional referring_script, ByteString const& specifier) { // 1. Let settingsObject and baseURL be null. Optional settings_object; - Optional base_url; + Optional base_url; // 2. If referringScript is not null, then: if (referring_script.has_value()) { @@ -153,7 +153,7 @@ WebIDL::ExceptionOr resolve_module_specifier(Optional referring_sc } // https://html.spec.whatwg.org/multipage/webappapis.html#resolving-an-imports-match -WebIDL::ExceptionOr> resolve_imports_match(ByteString const& normalized_specifier, Optional as_url, ModuleSpecifierMap const& specifier_map) +WebIDL::ExceptionOr> resolve_imports_match(ByteString const& normalized_specifier, Optional as_url, ModuleSpecifierMap const& specifier_map) { // 1. For each specifierKey → resolutionResult of specifierMap: for (auto const& [specifier_key, resolution_result] : specifier_map) { @@ -216,11 +216,11 @@ WebIDL::ExceptionOr> resolve_imports_match(ByteString const& norma } // 2. Return null. - return Optional {}; + return Optional {}; } // https://html.spec.whatwg.org/multipage/webappapis.html#resolving-a-url-like-module-specifier -Optional resolve_url_like_module_specifier(ByteString const& specifier, URL const& base_url) +Optional resolve_url_like_module_specifier(ByteString const& specifier, URL::URL const& base_url) { // 1. If specifier starts with "/", "./", or "../", then: if (specifier.starts_with("/"sv) || specifier.starts_with("./"sv) || specifier.starts_with("../"sv)) { @@ -277,7 +277,7 @@ static void set_up_module_script_request(Fetch::Infrastructure::Request& request } // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-script -WebIDL::ExceptionOr fetch_classic_script(JS::NonnullGCPtr element, URL const& url, EnvironmentSettingsObject& settings_object, ScriptFetchOptions options, CORSSettingAttribute cors_setting, String character_encoding, OnFetchScriptComplete on_complete) +WebIDL::ExceptionOr fetch_classic_script(JS::NonnullGCPtr element, URL::URL const& url, EnvironmentSettingsObject& settings_object, ScriptFetchOptions options, CORSSettingAttribute cors_setting, String character_encoding, OnFetchScriptComplete on_complete) { auto& realm = element->realm(); auto& vm = realm.vm(); @@ -342,7 +342,7 @@ WebIDL::ExceptionOr fetch_classic_script(JS::NonnullGCPtr fetch_classic_worker_script(URL const& url, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook perform_fetch, OnFetchScriptComplete on_complete) +WebIDL::ExceptionOr fetch_classic_worker_script(URL::URL const& url, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook perform_fetch, OnFetchScriptComplete on_complete) { auto& realm = settings_object.realm(); auto& vm = realm.vm(); @@ -422,13 +422,13 @@ WebIDL::ExceptionOr fetch_classic_worker_script(URL const& url, Environmen } // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-module-worker-script-tree -WebIDL::ExceptionOr fetch_module_worker_script_graph(URL const& url, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook perform_fetch, OnFetchScriptComplete on_complete) +WebIDL::ExceptionOr fetch_module_worker_script_graph(URL::URL const& url, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook perform_fetch, OnFetchScriptComplete on_complete) { return fetch_worklet_module_worker_script_graph(url, fetch_client, destination, settings_object, move(perform_fetch), move(on_complete)); } // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-worklet/module-worker-script-graph -WebIDL::ExceptionOr fetch_worklet_module_worker_script_graph(URL const& url, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook perform_fetch, OnFetchScriptComplete on_complete) +WebIDL::ExceptionOr fetch_worklet_module_worker_script_graph(URL::URL const& url, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook perform_fetch, OnFetchScriptComplete on_complete) { auto& realm = settings_object.realm(); auto& vm = realm.vm(); @@ -593,7 +593,7 @@ void fetch_descendants_of_a_module_script(JS::Realm& realm, JavaScriptModuleScri // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script void fetch_single_module_script(JS::Realm& realm, - URL const& url, + URL::URL const& url, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination destination, ScriptFetchOptions const& options, @@ -713,7 +713,7 @@ void fetch_single_module_script(JS::Realm& realm, } // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-module-script-tree -void fetch_external_module_script_graph(JS::Realm& realm, URL const& url, EnvironmentSettingsObject& settings_object, ScriptFetchOptions const& options, OnFetchScriptComplete on_complete) +void fetch_external_module_script_graph(JS::Realm& realm, URL::URL const& url, EnvironmentSettingsObject& settings_object, ScriptFetchOptions const& options, OnFetchScriptComplete on_complete) { // 1. Disallow further import maps given settingsObject. settings_object.disallow_further_import_maps(); @@ -735,7 +735,7 @@ void fetch_external_module_script_graph(JS::Realm& realm, URL const& url, Enviro } // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-an-inline-module-script-graph -void fetch_inline_module_script_graph(JS::Realm& realm, ByteString const& filename, ByteString const& source_text, URL const& base_url, EnvironmentSettingsObject& settings_object, OnFetchScriptComplete on_complete) +void fetch_inline_module_script_graph(JS::Realm& realm, ByteString const& filename, ByteString const& source_text, URL::URL const& base_url, EnvironmentSettingsObject& settings_object, OnFetchScriptComplete on_complete) { // 1. Disallow further import maps given settingsObject. settings_object.disallow_further_import_maps(); @@ -755,7 +755,7 @@ void fetch_inline_module_script_graph(JS::Realm& realm, ByteString const& filena // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-imported-module-script void fetch_single_imported_module_script(JS::Realm& realm, - URL const& url, + URL::URL const& url, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination destination, ScriptFetchOptions const& options, diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.h b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.h index 2fd84ffde90053739385c1b97239a061b482cee2..2c9b3a575cddd158bddc0528e543bacd899751db 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.h @@ -82,22 +82,21 @@ private: }; ByteString module_type_from_module_request(JS::ModuleRequest const&); -WebIDL::ExceptionOr resolve_module_specifier(Optional referring_script, ByteString const& specifier); -WebIDL::ExceptionOr> resolve_imports_match(ByteString const& normalized_specifier, Optional as_url, ModuleSpecifierMap const&); -Optional resolve_url_like_module_specifier(ByteString const& specifier, URL const& base_url); - -WebIDL::ExceptionOr fetch_classic_script(JS::NonnullGCPtr, URL const&, EnvironmentSettingsObject& settings_object, ScriptFetchOptions options, CORSSettingAttribute cors_setting, String character_encoding, OnFetchScriptComplete on_complete); -WebIDL::ExceptionOr fetch_classic_worker_script(URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook, OnFetchScriptComplete); -WebIDL::ExceptionOr fetch_module_worker_script_graph(URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook, OnFetchScriptComplete); -WebIDL::ExceptionOr fetch_worklet_module_worker_script_graph(URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook, OnFetchScriptComplete); +WebIDL::ExceptionOr resolve_module_specifier(Optional referring_script, ByteString const& specifier); +WebIDL::ExceptionOr> resolve_imports_match(ByteString const& normalized_specifier, Optional as_url, ModuleSpecifierMap const&); +Optional resolve_url_like_module_specifier(ByteString const& specifier, URL::URL const& base_url); + +WebIDL::ExceptionOr fetch_classic_script(JS::NonnullGCPtr, URL::URL const&, EnvironmentSettingsObject& settings_object, ScriptFetchOptions options, CORSSettingAttribute cors_setting, String character_encoding, OnFetchScriptComplete on_complete); +WebIDL::ExceptionOr fetch_classic_worker_script(URL::URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook, OnFetchScriptComplete); +WebIDL::ExceptionOr fetch_module_worker_script_graph(URL::URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook, OnFetchScriptComplete); +WebIDL::ExceptionOr fetch_worklet_module_worker_script_graph(URL::URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, EnvironmentSettingsObject& settings_object, PerformTheFetchHook, OnFetchScriptComplete); void fetch_internal_module_script_graph(JS::Realm&, JS::ModuleRequest const& module_request, EnvironmentSettingsObject& fetch_client_settings_object, Fetch::Infrastructure::Request::Destination, ScriptFetchOptions const&, Script& referring_script, HashTable const& visited_set, PerformTheFetchHook, OnFetchScriptComplete on_complete); -void fetch_external_module_script_graph(JS::Realm&, URL const&, EnvironmentSettingsObject& settings_object, ScriptFetchOptions const&, OnFetchScriptComplete on_complete); -void fetch_inline_module_script_graph(JS::Realm&, ByteString const& filename, ByteString const& source_text, URL const& base_url, EnvironmentSettingsObject& settings_object, OnFetchScriptComplete on_complete); -void fetch_single_imported_module_script(JS::Realm&, URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, ScriptFetchOptions const&, EnvironmentSettingsObject& settings_object, Fetch::Infrastructure::Request::Referrer, JS::ModuleRequest const&, PerformTheFetchHook, OnFetchScriptComplete on_complete); +void fetch_external_module_script_graph(JS::Realm&, URL::URL const&, EnvironmentSettingsObject& settings_object, ScriptFetchOptions const&, OnFetchScriptComplete on_complete); +void fetch_inline_module_script_graph(JS::Realm&, ByteString const& filename, ByteString const& source_text, URL::URL const& base_url, EnvironmentSettingsObject& settings_object, OnFetchScriptComplete on_complete); +void fetch_single_imported_module_script(JS::Realm&, URL::URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, ScriptFetchOptions const&, EnvironmentSettingsObject& settings_object, Fetch::Infrastructure::Request::Referrer, JS::ModuleRequest const&, PerformTheFetchHook, OnFetchScriptComplete on_complete); void fetch_descendants_of_a_module_script(JS::Realm&, JavaScriptModuleScript& module_script, EnvironmentSettingsObject& fetch_client_settings_object, Fetch::Infrastructure::Request::Destination, HashTable visited_set, PerformTheFetchHook, OnFetchScriptComplete callback); void fetch_descendants_of_and_link_a_module_script(JS::Realm&, JavaScriptModuleScript&, EnvironmentSettingsObject&, Fetch::Infrastructure::Request::Destination, PerformTheFetchHook, OnFetchScriptComplete on_complete); -void fetch_single_module_script(JS::Realm&, URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, ScriptFetchOptions const&, EnvironmentSettingsObject& settings_object, Web::Fetch::Infrastructure::Request::ReferrerType const&, Optional const&, TopLevelModule, PerformTheFetchHook, OnFetchScriptComplete callback); - +void fetch_single_module_script(JS::Realm&, URL::URL const&, EnvironmentSettingsObject& fetch_client, Fetch::Infrastructure::Request::Destination, ScriptFetchOptions const&, EnvironmentSettingsObject& settings_object, Web::Fetch::Infrastructure::Request::ReferrerType const&, Optional const&, TopLevelModule, PerformTheFetchHook, OnFetchScriptComplete callback); } diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ImportMap.h b/Userland/Libraries/LibWeb/HTML/Scripting/ImportMap.h index e73a0ef42b040ef2ec634883b5ce0647ff68521e..09f8c9596e2cb825ff251afe84ddf8611559e747 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ImportMap.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ImportMap.h @@ -10,7 +10,7 @@ namespace Web::HTML { -using ModuleSpecifierMap = HashMap>; +using ModuleSpecifierMap = HashMap>; // https://html.spec.whatwg.org/multipage/webappapis.html#import-map class ImportMap { @@ -20,12 +20,12 @@ public: ModuleSpecifierMap const& imports() const { return m_imports; } ModuleSpecifierMap& imports() { return m_imports; } - HashMap const& scopes() const { return m_scopes; } - HashMap& scopes() { return m_scopes; } + HashMap const& scopes() const { return m_scopes; } + HashMap& scopes() { return m_scopes; } private: ModuleSpecifierMap m_imports; - HashMap m_scopes; + HashMap m_scopes; }; } diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleMap.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleMap.cpp index 9b0f8997df59e35f52667321bd9b2576bc42dba0..8de292bf33e03fa28b4a8dacd99d73740cd9dfa9 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleMap.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleMap.cpp @@ -21,17 +21,17 @@ void ModuleMap::visit_edges(Visitor& visitor) visitor.visit(callback); } -bool ModuleMap::is_fetching(URL const& url, ByteString const& type) const +bool ModuleMap::is_fetching(URL::URL const& url, ByteString const& type) const { return is(url, type, EntryType::Fetching); } -bool ModuleMap::is_failed(URL const& url, ByteString const& type) const +bool ModuleMap::is_failed(URL::URL const& url, ByteString const& type) const { return is(url, type, EntryType::Failed); } -bool ModuleMap::is(URL const& url, ByteString const& type, EntryType entry_type) const +bool ModuleMap::is(URL::URL const& url, ByteString const& type, EntryType entry_type) const { auto value = m_values.get({ url, type }); if (!value.has_value()) @@ -40,12 +40,12 @@ bool ModuleMap::is(URL const& url, ByteString const& type, EntryType entry_type) return value->type == entry_type; } -Optional ModuleMap::get(URL const& url, ByteString const& type) const +Optional ModuleMap::get(URL::URL const& url, ByteString const& type) const { return m_values.get({ url, type }); } -AK::HashSetResult ModuleMap::set(URL const& url, ByteString const& type, Entry entry) +AK::HashSetResult ModuleMap::set(URL::URL const& url, ByteString const& type, Entry entry) { // NOTE: Re-entering this function while firing wait_for_change callbacks is not allowed. VERIFY(!m_firing_callbacks); @@ -63,7 +63,7 @@ AK::HashSetResult ModuleMap::set(URL const& url, ByteString const& type, Entry e return value; } -void ModuleMap::wait_for_change(JS::Heap& heap, URL const& url, ByteString const& type, Function callback) +void ModuleMap::wait_for_change(JS::Heap& heap, URL::URL const& url, ByteString const& type, Function callback) { m_callbacks.ensure({ url, type }).append(JS::create_heap_function(heap, move(callback))); } diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleMap.h b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleMap.h index d30a3ce0fbb3e23632cf4bd5f02e3a28b33eb7cf..65d4a473dc4c9c7ade9d23dde8dadc9e58e4abb7 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleMap.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleMap.h @@ -6,22 +6,22 @@ #pragma once -#include #include #include +#include #include namespace Web::HTML { class ModuleLocationTuple { public: - ModuleLocationTuple(URL url, ByteString type) + ModuleLocationTuple(URL::URL url, ByteString type) : m_url(move(url)) , m_type(move(type)) { } - URL const& url() const { return m_url; } + URL::URL const& url() const { return m_url; } ByteString const& type() const { return m_type; } bool operator==(ModuleLocationTuple const& other) const @@ -30,7 +30,7 @@ public: } private: - URL m_url; + URL::URL m_url; ByteString m_type; }; @@ -56,16 +56,16 @@ public: using CallbackFunction = JS::NonnullGCPtr>; - bool is_fetching(URL const& url, ByteString const& type) const; - bool is_failed(URL const& url, ByteString const& type) const; + bool is_fetching(URL::URL const& url, ByteString const& type) const; + bool is_failed(URL::URL const& url, ByteString const& type) const; - bool is(URL const& url, ByteString const& type, EntryType) const; + bool is(URL::URL const& url, ByteString const& type, EntryType) const; - Optional get(URL const& url, ByteString const& type) const; + Optional get(URL::URL const& url, ByteString const& type) const; - AK::HashSetResult set(URL const& url, ByteString const& type, Entry); + AK::HashSetResult set(URL::URL const& url, ByteString const& type, Entry); - void wait_for_change(JS::Heap&, URL const& url, ByteString const& type, Function callback); + void wait_for_change(JS::Heap&, URL::URL const& url, ByteString const& type, Function callback); private: virtual void visit_edges(JS::Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp index bfcf0001f090944428fa69b2be8acd0c1ec691ce..111f75142ba545bca102c74a6c18c8c0e3428a36 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp @@ -17,20 +17,20 @@ JS_DEFINE_ALLOCATOR(JavaScriptModuleScript); ModuleScript::~ModuleScript() = default; -ModuleScript::ModuleScript(URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object) +ModuleScript::ModuleScript(URL::URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object) : Script(move(base_url), move(filename), environment_settings_object) { } JavaScriptModuleScript::~JavaScriptModuleScript() = default; -JavaScriptModuleScript::JavaScriptModuleScript(URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object) +JavaScriptModuleScript::JavaScriptModuleScript(URL::URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object) : ModuleScript(move(base_url), move(filename), environment_settings_object) { } // https://html.spec.whatwg.org/multipage/webappapis.html#creating-a-javascript-module-script -WebIDL::ExceptionOr> JavaScriptModuleScript::create(ByteString const& filename, StringView source, EnvironmentSettingsObject& settings_object, URL base_url) +WebIDL::ExceptionOr> JavaScriptModuleScript::create(ByteString const& filename, StringView source, EnvironmentSettingsObject& settings_object, URL::URL base_url) { // 1. If scripting is disabled for settings, then set source to the empty string. if (settings_object.is_scripting_disabled()) diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.h b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.h index 8467ffec10a07727174c4ea99b7957551da92118..8349af90b73ee3658643b118cece2ba053d0ab16 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.h @@ -19,7 +19,7 @@ public: virtual ~ModuleScript() override; protected: - ModuleScript(URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object); + ModuleScript(URL::URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object); }; class JavaScriptModuleScript final : public ModuleScript { @@ -29,7 +29,7 @@ class JavaScriptModuleScript final : public ModuleScript { public: virtual ~JavaScriptModuleScript() override; - static WebIDL::ExceptionOr> create(ByteString const& filename, StringView source, EnvironmentSettingsObject&, URL base_url); + static WebIDL::ExceptionOr> create(ByteString const& filename, StringView source, EnvironmentSettingsObject&, URL::URL base_url); enum class PreventErrorReporting { Yes, @@ -42,7 +42,7 @@ public: JS::SourceTextModule* record() { return m_record.ptr(); } protected: - JavaScriptModuleScript(URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object); + JavaScriptModuleScript(URL::URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object); private: virtual void visit_edges(JS::Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp index cc37d49949a3f99d98cd4a744fea1d6e3b7e5ace..415b3fe340e85ad821fd8ef88b3b7e1516dc71eb 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp @@ -11,7 +11,7 @@ namespace Web::HTML { JS_DEFINE_ALLOCATOR(Script); -Script::Script(URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object) +Script::Script(URL::URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object) : m_base_url(move(base_url)) , m_filename(move(filename)) , m_settings_object(environment_settings_object) diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Script.h b/Userland/Libraries/LibWeb/HTML/Scripting/Script.h index 31131741ffabab66c4f3441b33e6e3a23a0be4ca..f7e0598f1c3231899d421aaf35ab6bc4711ed10c 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Script.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Script.h @@ -6,9 +6,9 @@ #pragma once -#include #include #include +#include #include namespace Web::HTML { @@ -23,7 +23,7 @@ class Script public: virtual ~Script() override; - URL const& base_url() const { return m_base_url; } + URL::URL const& base_url() const { return m_base_url; } ByteString const& filename() const { return m_filename; } EnvironmentSettingsObject& settings_object() { return m_settings_object; } @@ -35,14 +35,14 @@ public: void set_parse_error(JS::Value value) { m_parse_error = value; } protected: - Script(URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object); + Script(URL::URL base_url, ByteString filename, EnvironmentSettingsObject& environment_settings_object); virtual void visit_edges(Visitor&) override; private: virtual void visit_host_defined_self(JS::Cell::Visitor&) override; - URL m_base_url; + URL::URL m_base_url; ByteString m_filename; JS::NonnullGCPtr m_settings_object; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.cpp index e0edb49ab674a46114cdf8ce4f719db3d94d8e52..0d1bb6fc8a8dcc1be6b10f55021f35dd94bb7df5 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.cpp @@ -32,11 +32,11 @@ ErrorOr decode(Decoder& decoder) Web::HTML::SerializedEnvironmentSettingsObject object {}; object.id = TRY(decoder.decode()); - object.creation_url = TRY(decoder.decode()); - object.top_level_creation_url = TRY(decoder.decode()); + object.creation_url = TRY(decoder.decode()); + object.top_level_creation_url = TRY(decoder.decode()); object.top_level_origin = TRY(decoder.decode()); object.api_url_character_encoding = TRY(decoder.decode()); - object.api_base_url = TRY(decoder.decode()); + object.api_base_url = TRY(decoder.decode()); object.origin = TRY(decoder.decode()); object.policy_container = TRY(decoder.decode()); object.cross_origin_isolated_capability = TRY(decoder.decode()); diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.h b/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.h index b55bdf24fed5f3122af5c565196ec69368a154ad..7a55ae46d948d3e8ec2868cdd2d194beec5dceba 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.h @@ -7,8 +7,8 @@ #pragma once #include -#include #include +#include #include #include @@ -21,12 +21,12 @@ enum class CanUseCrossOriginIsolatedAPIs { struct SerializedEnvironmentSettingsObject { String id; - URL creation_url; - URL top_level_creation_url; + URL::URL creation_url; + URL::URL top_level_creation_url; Origin top_level_origin; String api_url_character_encoding; - URL api_base_url; + URL::URL api_base_url; Origin origin; PolicyContainer policy_container; CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp index 5318457e825b94585f11bb60336559ec345d1e0b..14750f1d18c5cdc4fa25d151ab63588c52b637e9 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp @@ -29,7 +29,7 @@ void WindowEnvironmentSettingsObject::visit_edges(JS::Cell::Visitor& visitor) } // https://html.spec.whatwg.org/multipage/window-object.html#set-up-a-window-environment-settings-object -void WindowEnvironmentSettingsObject::setup(Page& page, URL const& creation_url, NonnullOwnPtr execution_context, Optional reserved_environment, URL top_level_creation_url, Origin top_level_origin) +void WindowEnvironmentSettingsObject::setup(Page& page, URL::URL const& creation_url, NonnullOwnPtr execution_context, Optional reserved_environment, URL::URL top_level_creation_url, Origin top_level_origin) { // 1. Let realm be the value of execution context's Realm component. auto realm = execution_context->realm; @@ -97,7 +97,7 @@ String WindowEnvironmentSettingsObject::api_url_character_encoding() } // https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:api-base-url -URL WindowEnvironmentSettingsObject::api_base_url() +URL::URL WindowEnvironmentSettingsObject::api_base_url() { // Return the current base URL of window's associated Document. return m_window->associated_document().base_url(); diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h index ce25c9fbaebdafd3e84e17c965f7ac0329778dfb..8a86d4fa8f83c172351d9ff5342a458dca7102f9 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h @@ -16,13 +16,13 @@ class WindowEnvironmentSettingsObject final : public EnvironmentSettingsObject { JS_DECLARE_ALLOCATOR(WindowEnvironmentSettingsObject); public: - static void setup(Page&, URL const& creation_url, NonnullOwnPtr, Optional, URL top_level_creation_url, Origin top_level_origin); + static void setup(Page&, URL::URL const& creation_url, NonnullOwnPtr, Optional, URL::URL top_level_creation_url, Origin top_level_origin); virtual ~WindowEnvironmentSettingsObject() override; virtual JS::GCPtr responsible_document() override; virtual String api_url_character_encoding() override; - virtual URL api_base_url() override; + virtual URL::URL api_base_url() override; virtual Origin origin() override; virtual PolicyContainer policy_container() override; virtual CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() override; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h index c129bc0d7350060b0a5313fffd826038dcc5bcea..645864d867a59b0c1ab043620156374889b7df7c 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -30,7 +30,7 @@ public: JS::GCPtr responsible_document() override { return nullptr; } String api_url_character_encoding() override { return m_api_url_character_encoding; } - URL api_base_url() override { return m_url; } + URL::URL api_base_url() override { return m_url; } Origin origin() override { return m_origin; } PolicyContainer policy_container() override { return m_policy_container; } CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() override { return CanUseCrossOriginIsolatedAPIs::No; } @@ -39,7 +39,7 @@ private: virtual void visit_edges(JS::Cell::Visitor&) override; String m_api_url_character_encoding; - URL m_url; + URL::URL m_url; HTML::Origin m_origin; HTML::PolicyContainer m_policy_container; diff --git a/Userland/Libraries/LibWeb/HTML/SessionHistoryEntry.h b/Userland/Libraries/LibWeb/HTML/SessionHistoryEntry.h index 24b0a03df78c3725b8ce46b4aacd15e51ad93770..ab8796e1a4cfeba173947d46fd0b71482c8ed51f 100644 --- a/Userland/Libraries/LibWeb/HTML/SessionHistoryEntry.h +++ b/Userland/Libraries/LibWeb/HTML/SessionHistoryEntry.h @@ -6,10 +6,10 @@ #pragma once -#include #include #include #include +#include #include #include #include @@ -46,7 +46,7 @@ struct SessionHistoryEntry final : public JS::Cell { // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-url // URL, a URL - URL url; + URL::URL url; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-document-state JS::GCPtr document_state; diff --git a/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp b/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp index 942af516cf5132fca749c566d0c3cccf7a0f1a6d..12dfe2857215577cb7efd2cca2e13f4ba00a6730 100644 --- a/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp +++ b/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp @@ -21,7 +21,7 @@ namespace Web::HTML { JS_DEFINE_ALLOCATOR(SharedImageRequest); -JS::NonnullGCPtr SharedImageRequest::get_or_create(JS::Realm& realm, JS::NonnullGCPtr page, URL const& url) +JS::NonnullGCPtr SharedImageRequest::get_or_create(JS::Realm& realm, JS::NonnullGCPtr page, URL::URL const& url) { auto document = Bindings::host_defined_environment_settings_object(realm).responsible_document(); VERIFY(document); @@ -33,7 +33,7 @@ JS::NonnullGCPtr SharedImageRequest::get_or_create(JS::Realm return request; } -SharedImageRequest::SharedImageRequest(JS::NonnullGCPtr page, URL url, JS::NonnullGCPtr document) +SharedImageRequest::SharedImageRequest(JS::NonnullGCPtr page, URL::URL url, JS::NonnullGCPtr document) : m_page(page) , m_url(move(url)) , m_document(document) @@ -134,7 +134,7 @@ void SharedImageRequest::add_callbacks(Function on_finish, Function #include -#include #include #include #include #include +#include #include namespace Web::HTML { @@ -22,11 +22,11 @@ class SharedImageRequest final : public JS::Cell { JS_DECLARE_ALLOCATOR(SharedImageRequest); public: - [[nodiscard]] static JS::NonnullGCPtr get_or_create(JS::Realm&, JS::NonnullGCPtr, URL const&); + [[nodiscard]] static JS::NonnullGCPtr get_or_create(JS::Realm&, JS::NonnullGCPtr, URL::URL const&); virtual ~SharedImageRequest() override; - URL const& url() const { return m_url; } + URL::URL const& url() const { return m_url; } [[nodiscard]] JS::GCPtr image_data() const; @@ -41,12 +41,12 @@ public: bool needs_fetching() const; private: - explicit SharedImageRequest(JS::NonnullGCPtr, URL, JS::NonnullGCPtr); + explicit SharedImageRequest(JS::NonnullGCPtr, URL::URL, JS::NonnullGCPtr); virtual void finalize() override; virtual void visit_edges(JS::Cell::Visitor&) override; - void handle_successful_fetch(URL const&, StringView mime_type, ByteBuffer data); + void handle_successful_fetch(URL::URL const&, StringView mime_type, ByteBuffer data); void handle_failed_fetch(); enum class State { @@ -66,7 +66,7 @@ private: }; Vector m_callbacks; - URL m_url; + URL::URL m_url; JS::GCPtr m_image_data; JS::GCPtr m_fetch_controller; diff --git a/Userland/Libraries/LibWeb/HTML/SourceSet.h b/Userland/Libraries/LibWeb/HTML/SourceSet.h index 16a75f6a322b6e985b5050aa00edf4180c1b5eb2..e4a1fe6885c8c6c4c23f8eeb8a413447f3550327 100644 --- a/Userland/Libraries/LibWeb/HTML/SourceSet.h +++ b/Userland/Libraries/LibWeb/HTML/SourceSet.h @@ -6,8 +6,8 @@ #pragma once -#include #include +#include #include namespace Web::HTML { diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index 4568c1c99154161dda4d12e1db07ea050fe7e3a0..e43a617e67359a036e8d7091a53ca893fdb29005 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -115,7 +115,7 @@ WebIDL::ExceptionOr> TraversableNavigable } // https://html.spec.whatwg.org/multipage/document-sequences.html#create-a-fresh-top-level-traversable -WebIDL::ExceptionOr> TraversableNavigable::create_a_fresh_top_level_traversable(JS::NonnullGCPtr page, URL const& initial_navigation_url, Variant initial_navigation_post_resource) +WebIDL::ExceptionOr> TraversableNavigable::create_a_fresh_top_level_traversable(JS::NonnullGCPtr page, URL::URL const& initial_navigation_url, Variant initial_navigation_post_resource) { // 1. Let traversable be the result of creating a new top-level traversable given null and the empty string. auto traversable = TRY(create_a_new_top_level_traversable(page, nullptr, {})); diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h index f867d59a01e22c277d35b458d3691d609cf5bed8..816274560123324454720abb71aaa66ecc52762a 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h @@ -20,7 +20,7 @@ class TraversableNavigable final : public Navigable { public: static WebIDL::ExceptionOr> create_a_new_top_level_traversable(JS::NonnullGCPtr, JS::GCPtr opener, String target_name); - static WebIDL::ExceptionOr> create_a_fresh_top_level_traversable(JS::NonnullGCPtr, URL const& initial_navigation_url, Variant = Empty {}); + static WebIDL::ExceptionOr> create_a_fresh_top_level_traversable(JS::NonnullGCPtr, URL::URL const& initial_navigation_url, Variant = Empty {}); virtual ~TraversableNavigable() override; diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 10c55fe018aab4e2f0fb39179de5fc337aad89d3..a6a5638069a90ed72f038a882b3599bc57546ec7 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -385,7 +385,7 @@ WebIDL::ExceptionOr> Window::open_impl(StringView url, St // NOTE: While this is not implemented yet, all of observable actions taken by this operation are optional (implementation-defined). // 3. Let urlRecord be the URL record about:blank. - auto url_record = URL("about:blank"sv); + auto url_record = URL::URL("about:blank"sv); // 4. If url is not the empty string, then set urlRecord to the result of encoding-parsing a URL given url, relative to the entry settings object. if (!url.is_empty()) { diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index 6f44b4a2e7d12089f2de489ff43c7763cba77383..c5811ff8e98f09d4df3544c4fa8957185cb551c6 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index ca5f5720f41fe0863a4cd91385b4cf9ded960bd4..febd8e5b9e8cdc4b37bf3cad102ebf0acc40d9a5 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -89,7 +89,7 @@ WebIDL::ExceptionOr> Worker::create(String const& scrip } // https://html.spec.whatwg.org/multipage/workers.html#run-a-worker -void Worker::run_a_worker(URL& url, EnvironmentSettingsObject& outside_settings, JS::GCPtr port, WorkerOptions const& options) +void Worker::run_a_worker(URL::URL& url, EnvironmentSettingsObject& outside_settings, JS::GCPtr port, WorkerOptions const& options) { // 1. Let is shared be true if worker is a SharedWorker object, and false otherwise. // FIXME: SharedWorker support diff --git a/Userland/Libraries/LibWeb/HTML/Worker.h b/Userland/Libraries/LibWeb/HTML/Worker.h index 2d25bbad1eb9fbd556e1caee7cfee4a55f087cdc..2057bf5da428c9faf95fe0b9249b9bae09f39d69 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.h +++ b/Userland/Libraries/LibWeb/HTML/Worker.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include #include @@ -69,7 +69,7 @@ private: JS::GCPtr m_agent; - void run_a_worker(URL& url, EnvironmentSettingsObject& outside_settings, JS::GCPtr outside_port, WorkerOptions const& options); + void run_a_worker(URL::URL& url, EnvironmentSettingsObject& outside_settings, JS::GCPtr outside_port, WorkerOptions const& options); }; } diff --git a/Userland/Libraries/LibWeb/HTML/WorkerAgent.cpp b/Userland/Libraries/LibWeb/HTML/WorkerAgent.cpp index 835d020d920c4f5390ca80e4869ddc00f36f7d48..2b8914bf4ee59e500ba695efe4a2ba54c9b581fa 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerAgent.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerAgent.cpp @@ -13,7 +13,7 @@ namespace Web::HTML { JS_DEFINE_ALLOCATOR(WorkerAgent); -WorkerAgent::WorkerAgent(URL url, WorkerOptions const& options, JS::GCPtr outside_port, JS::NonnullGCPtr outside_settings) +WorkerAgent::WorkerAgent(URL::URL url, WorkerOptions const& options, JS::GCPtr outside_port, JS::NonnullGCPtr outside_settings) : m_worker_options(options) , m_url(move(url)) , m_outside_port(outside_port) diff --git a/Userland/Libraries/LibWeb/HTML/WorkerAgent.h b/Userland/Libraries/LibWeb/HTML/WorkerAgent.h index 65b93242dcd715eeca4491150d512f752f69205b..694bdd11c3a511124fb0daa03cb4317cb86c7af8 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerAgent.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerAgent.h @@ -22,14 +22,14 @@ class WorkerAgent : public JS::Cell { JS_CELL(Agent, JS::Cell); JS_DECLARE_ALLOCATOR(WorkerAgent); - WorkerAgent(URL url, WorkerOptions const& options, JS::GCPtr outside_port, JS::NonnullGCPtr outside_settings); + WorkerAgent(URL::URL url, WorkerOptions const& options, JS::GCPtr outside_port, JS::NonnullGCPtr outside_settings); private: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; WorkerOptions m_worker_options; - URL m_url; + URL::URL m_url; JS::GCPtr m_message_port; JS::GCPtr m_outside_port; diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h index 38a2bf04d4ca90136de883a51581013b6145799b..3fc8ac5f5552c0db44c8b0fd0e3d88c0a3d088a8 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h @@ -8,8 +8,8 @@ #include #include -#include #include +#include #include #include #include @@ -77,8 +77,8 @@ public: // Non-IDL public methods - URL const& url() const { return m_url.value(); } - void set_url(URL const& url) { m_url = url; } + URL::URL const& url() const { return m_url.value(); } + void set_url(URL::URL const& url) { m_url = url; } // Spec note: While the WorkerLocation object is created after the WorkerGlobalScope object, // this is not problematic as it cannot be observed from script. @@ -114,7 +114,7 @@ private: // https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-url // A WorkerGlobalScope object has an associated url (null or a URL). It is initially null. - Optional m_url; + Optional m_url; // https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-name // A WorkerGlobalScope object has an associated name (a string). It is set during creation. diff --git a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp index 5826d5406ed8185ef6a7760c0b8c8d9be20646fc..4e287e0385ca2358910295786fd9190c72624efb 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include @@ -71,7 +71,7 @@ WebIDL::ExceptionOr WorkerLocation::hostname() const return String {}; // 3. Return host, serialized. - return TRY_OR_THROW_OOM(vm, URLParser::serialize_host(host)); + return TRY_OR_THROW_OOM(vm, URL::Parser::serialize_host(host)); } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-port diff --git a/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp b/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp index 9b5570e80c40037f74c1c9f333dbbd3e350863a8..d9a8c7cdf38b37a4b667b290433e23d7fe9d9fac 100644 --- a/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp +++ b/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp @@ -19,7 +19,7 @@ ContentFilter::ContentFilter() = default; ContentFilter::~ContentFilter() = default; -bool ContentFilter::is_filtered(const URL& url) const +bool ContentFilter::is_filtered(const URL::URL& url) const { if (url.scheme() == "data") return false; diff --git a/Userland/Libraries/LibWeb/Loader/ContentFilter.h b/Userland/Libraries/LibWeb/Loader/ContentFilter.h index c270bb1572089d7578da597792ab74e896fcb9c5..b485b5fb7686ba23fd9af057b15d41f317ed1671 100644 --- a/Userland/Libraries/LibWeb/Loader/ContentFilter.h +++ b/Userland/Libraries/LibWeb/Loader/ContentFilter.h @@ -7,8 +7,8 @@ #pragma once #include -#include #include +#include namespace Web { @@ -16,7 +16,7 @@ class ContentFilter { public: static ContentFilter& the(); - bool is_filtered(const URL&) const; + bool is_filtered(const URL::URL&) const; ErrorOr set_patterns(ReadonlySpan); private: diff --git a/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.cpp b/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.cpp index e60c27a01f200791c729a813147965cd3305b499..7391fed7b1e3f61fa3c08c6eec7c9d3957d57067 100644 --- a/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.cpp @@ -26,7 +26,7 @@ void set_chrome_process_executable_path(StringView executable_path) s_chrome_process_executable_path = MUST(String::from_utf8(executable_path)); } -ErrorOr load_error_page(URL const& url) +ErrorOr load_error_page(URL::URL const& url) { // Generate HTML error page from error template file // FIXME: Use an actual templating engine (our own one when it's built, preferably with a way to check these usages at compile time) @@ -38,7 +38,7 @@ ErrorOr load_error_page(URL const& url) return TRY(String::from_utf8(generator.as_string_view())); } -ErrorOr load_file_directory_page(URL const& url) +ErrorOr load_file_directory_page(URL::URL const& url) { // Generate HTML contents entries table auto lexical_path = LexicalPath(url.serialize_path()); diff --git a/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.h b/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.h index 637b8da2238fd7aa8c4e7a97be85f95aaa3fbe5f..855e307dee01a1b3dd9c0ec52e46783a47706199 100644 --- a/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.h +++ b/Userland/Libraries/LibWeb/Loader/GeneratedPagesLoader.h @@ -17,9 +17,9 @@ static String s_chrome_process_executable_path {}; void set_chrome_process_command_line(StringView command_line); void set_chrome_process_executable_path(StringView executable_path); -ErrorOr load_error_page(URL const&); +ErrorOr load_error_page(URL::URL const&); -ErrorOr load_file_directory_page(URL const&); +ErrorOr load_file_directory_page(URL::URL const&); ErrorOr load_about_version_page(); diff --git a/Userland/Libraries/LibWeb/Loader/LoadRequest.cpp b/Userland/Libraries/LibWeb/Loader/LoadRequest.cpp index d697fae57d319b2c0ac3adfeb7549e87088fbf06..8902427d3ba72dace259d3ab5c956e9b071f7a2d 100644 --- a/Userland/Libraries/LibWeb/Loader/LoadRequest.cpp +++ b/Userland/Libraries/LibWeb/Loader/LoadRequest.cpp @@ -10,7 +10,7 @@ namespace Web { -LoadRequest LoadRequest::create_for_url_on_page(const URL& url, Page* page) +LoadRequest LoadRequest::create_for_url_on_page(const URL::URL& url, Page* page) { LoadRequest request; request.set_url(url); diff --git a/Userland/Libraries/LibWeb/Loader/LoadRequest.h b/Userland/Libraries/LibWeb/Loader/LoadRequest.h index 303683276dc2af6b79a27c15f10df1fcfb53cec0..670b43215b7a51426cf49090efe61a8ccb8fab3c 100644 --- a/Userland/Libraries/LibWeb/Loader/LoadRequest.h +++ b/Userland/Libraries/LibWeb/Loader/LoadRequest.h @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include #include #include @@ -22,7 +22,7 @@ public: { } - static LoadRequest create_for_url_on_page(const URL& url, Page* page); + static LoadRequest create_for_url_on_page(const URL::URL& url, Page* page); // The main resource is the file being displayed in a frame (unlike subresources like images, scripts, etc.) // If a main resource fails with an HTTP error, we may still display its content if non-empty, e.g a custom 404 page. @@ -31,8 +31,8 @@ public: bool is_valid() const { return m_url.is_valid(); } - const URL& url() const { return m_url; } - void set_url(const URL& url) { m_url = url; } + const URL::URL& url() const { return m_url; } + void set_url(const URL::URL& url) { m_url = url; } ByteString const& method() const { return m_method; } void set_method(ByteString const& method) { m_method = method; } @@ -74,7 +74,7 @@ public: HashMap const& headers() const { return m_headers; } private: - URL m_url; + URL::URL m_url; ByteString m_method { "GET" }; HashMap m_headers; ByteBuffer m_body; diff --git a/Userland/Libraries/LibWeb/Loader/ProxyMappings.cpp b/Userland/Libraries/LibWeb/Loader/ProxyMappings.cpp index aa0b7a699d47ed130cc0c55feaf97c1e0bfffc6d..945f49d1bda0e55c167876b1dc4232b50ae9d619 100644 --- a/Userland/Libraries/LibWeb/Loader/ProxyMappings.cpp +++ b/Userland/Libraries/LibWeb/Loader/ProxyMappings.cpp @@ -12,7 +12,7 @@ Web::ProxyMappings& Web::ProxyMappings::the() return instance; } -Core::ProxyData Web::ProxyMappings::proxy_for_url(URL const& url) const +Core::ProxyData Web::ProxyMappings::proxy_for_url(URL::URL const& url) const { auto url_string = url.to_byte_string(); for (auto& it : m_mappings) { diff --git a/Userland/Libraries/LibWeb/Loader/ProxyMappings.h b/Userland/Libraries/LibWeb/Loader/ProxyMappings.h index 4ad396472268e963532ef315f263c63c8b2800e9..4d03c405feeed963222260ea64d3adbb4acfbcb6 100644 --- a/Userland/Libraries/LibWeb/Loader/ProxyMappings.h +++ b/Userland/Libraries/LibWeb/Loader/ProxyMappings.h @@ -7,9 +7,9 @@ #pragma once #include -#include #include #include +#include namespace Web { @@ -17,7 +17,7 @@ class ProxyMappings { public: static ProxyMappings& the(); - Core::ProxyData proxy_for_url(URL const&) const; + Core::ProxyData proxy_for_url(URL::URL const&) const; void set_mappings(Vector proxies, OrderedHashMap mappings); private: diff --git a/Userland/Libraries/LibWeb/Loader/Resource.h b/Userland/Libraries/LibWeb/Loader/Resource.h index 1308c5cbbe5dc8a63c6fe9edd27ac2e3205c1db4..1a27f5b5945900e8f24ea45a7fd112482a7e80cb 100644 --- a/Userland/Libraries/LibWeb/Loader/Resource.h +++ b/Userland/Libraries/LibWeb/Loader/Resource.h @@ -11,10 +11,10 @@ #include #include #include -#include #include #include #include +#include #include #include @@ -50,7 +50,7 @@ public: bool has_encoded_data() const { return !m_encoded_data.is_empty(); } - const URL& url() const { return m_request.url(); } + const URL::URL& url() const { return m_request.url(); } ByteBuffer const& encoded_data() const { return m_encoded_data; } HashMap const& response_headers() const { return m_response_headers; } diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index 39b56bf6e484a210a71776f9607bee82f1f68242..816dcda32fa1f957f36de9ffd58a37d5b6b03ff4 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -65,7 +65,7 @@ ResourceLoader::ResourceLoader(NonnullRefPtr connector) { } -void ResourceLoader::prefetch_dns(URL const& url) +void ResourceLoader::prefetch_dns(URL::URL const& url) { if (ContentFilter::the().is_filtered(url)) { dbgln("ResourceLoader: Refusing to prefetch DNS for '{}': \033[31;1mURL was filtered\033[0m", url); @@ -75,7 +75,7 @@ void ResourceLoader::prefetch_dns(URL const& url) m_connector->prefetch_dns(url); } -void ResourceLoader::preconnect(URL const& url) +void ResourceLoader::preconnect(URL::URL const& url) { if (url.scheme().is_one_of("file"sv, "data"sv)) return; @@ -126,7 +126,7 @@ RefPtr ResourceLoader::load_resource(Resource::Type type, LoadRequest& return resource; } -static ByteString sanitized_url_for_logging(URL const& url) +static ByteString sanitized_url_for_logging(URL::URL const& url) { if (url.scheme() == "data"sv) return "[data URL]"sv; @@ -144,7 +144,7 @@ static void emit_signpost(ByteString const& message, int id) #endif } -static void store_response_cookies(Page& page, URL const& url, ByteString const& cookies) +static void store_response_cookies(Page& page, URL::URL const& url, ByteString const& cookies) { auto set_cookie_json_value = MUST(JsonValue::from_string(cookies)); VERIFY(set_cookie_json_value.type() == JsonValue::Type::Array); @@ -196,7 +196,7 @@ void ResourceLoader::load(LoadRequest& request, SuccessCallback success_callback dbgln("ResourceLoader: Failed load of: \"{}\", \033[31;1mError: {}\033[0m, Duration: {}ms", url_for_logging, error_message, load_time_ms); }; - auto respond_directory_page = [log_success, log_failure](LoadRequest const& request, URL const& url, SuccessCallback const& success_callback, ErrorCallback const& error_callback) { + auto respond_directory_page = [log_success, log_failure](LoadRequest const& request, URL::URL const& url, SuccessCallback const& success_callback, ErrorCallback const& error_callback) { auto maybe_response = load_file_directory_page(url); if (maybe_response.is_error()) { log_failure(request, maybe_response.error()); diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h index 878dbb698b38cb4ba463e4697cf6ec763be46afe..a3b176a477f0e74e45be29455c32141d636d0ae6 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h @@ -10,9 +10,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -97,11 +97,11 @@ class ResourceLoaderConnector : public RefCounted { public: virtual ~ResourceLoaderConnector(); - virtual void prefetch_dns(URL const&) = 0; - virtual void preconnect(URL const&) = 0; + virtual void prefetch_dns(URL::URL const&) = 0; + virtual void preconnect(URL::URL const&) = 0; - virtual RefPtr start_request(ByteString const& method, URL const&, HashMap const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}) = 0; - virtual RefPtr websocket_connect(const URL&, ByteString const& origin, Vector const& protocols) = 0; + virtual RefPtr start_request(ByteString const& method, URL::URL const&, HashMap const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}) = 0; + virtual RefPtr websocket_connect(const URL::URL&, ByteString const& origin, Vector const& protocols) = 0; protected: explicit ResourceLoaderConnector(); @@ -123,8 +123,8 @@ public: ResourceLoaderConnector& connector() { return *m_connector; } - void prefetch_dns(URL const&); - void preconnect(URL const&); + void prefetch_dns(URL::URL const&); + void preconnect(URL::URL const&); Function on_load_counter_change; diff --git a/Userland/Libraries/LibWeb/Page/Page.cpp b/Userland/Libraries/LibWeb/Page/Page.cpp index da1f36908f1371631adb626ab5a42809374738e9..6bf9c87014bc2af750ca67319d02701c7e92f7b6 100644 --- a/Userland/Libraries/LibWeb/Page/Page.cpp +++ b/Userland/Libraries/LibWeb/Page/Page.cpp @@ -56,7 +56,7 @@ void Page::set_focused_browsing_context(Badge, HTML::BrowsingConte m_focused_context = browsing_context.make_weak_ptr(); } -void Page::load(const URL& url) +void Page::load(const URL::URL& url) { (void)top_level_traversable()->navigate({ .url = url, .source_document = *top_level_traversable()->active_document(), .user_involvement = HTML::UserNavigationInvolvement::BrowserUI }); } @@ -499,7 +499,7 @@ template<> ErrorOr IPC::decode(Decoder& decoder) { return Web::Page::MediaContextMenu { - .media_url = TRY(decoder.decode()), + .media_url = TRY(decoder.decode()), .is_video = TRY(decoder.decode()), .is_playing = TRY(decoder.decode()), .is_muted = TRY(decoder.decode()), diff --git a/Userland/Libraries/LibWeb/Page/Page.h b/Userland/Libraries/LibWeb/Page/Page.h index bc949cbf40bbefbb4abc0d2082081b79747bc083..89152869d7b335cd08d788c87dfeaf20138db285 100644 --- a/Userland/Libraries/LibWeb/Page/Page.h +++ b/Userland/Libraries/LibWeb/Page/Page.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -69,7 +69,7 @@ public: void set_focused_browsing_context(Badge, HTML::BrowsingContext&); - void load(const URL&); + void load(const URL::URL&); void load_html(StringView); @@ -149,7 +149,7 @@ public: }; struct MediaContextMenu { - URL media_url; + URL::URL media_url; bool is_video { false }; bool is_playing { false }; bool is_muted { false }; @@ -244,19 +244,19 @@ public: virtual Gfx::IntRect page_did_request_maximize_window() { return {}; } virtual Gfx::IntRect page_did_request_minimize_window() { return {}; } virtual Gfx::IntRect page_did_request_fullscreen_window() { return {}; } - virtual void page_did_start_loading(const URL&, bool is_redirect) { (void)is_redirect; } + virtual void page_did_start_loading(const URL::URL&, bool is_redirect) { (void)is_redirect; } virtual void page_did_create_new_document(Web::DOM::Document&) { } virtual void page_did_destroy_document(Web::DOM::Document&) { } - virtual void page_did_finish_loading(const URL&) { } + virtual void page_did_finish_loading(const URL::URL&) { } virtual void page_did_request_cursor_change(Gfx::StandardCursor) { } virtual void page_did_request_context_menu(CSSPixelPoint) { } - virtual void page_did_request_link_context_menu(CSSPixelPoint, URL const&, [[maybe_unused]] ByteString const& target, [[maybe_unused]] unsigned modifiers) { } - virtual void page_did_request_image_context_menu(CSSPixelPoint, URL const&, [[maybe_unused]] ByteString const& target, [[maybe_unused]] unsigned modifiers, Gfx::Bitmap const*) { } + virtual void page_did_request_link_context_menu(CSSPixelPoint, URL::URL const&, [[maybe_unused]] ByteString const& target, [[maybe_unused]] unsigned modifiers) { } + virtual void page_did_request_image_context_menu(CSSPixelPoint, URL::URL const&, [[maybe_unused]] ByteString const& target, [[maybe_unused]] unsigned modifiers, Gfx::Bitmap const*) { } virtual void page_did_request_media_context_menu(CSSPixelPoint, [[maybe_unused]] ByteString const& target, [[maybe_unused]] unsigned modifiers, Page::MediaContextMenu) { } - virtual void page_did_middle_click_link(const URL&, [[maybe_unused]] ByteString const& target, [[maybe_unused]] unsigned modifiers) { } + virtual void page_did_middle_click_link(const URL::URL&, [[maybe_unused]] ByteString const& target, [[maybe_unused]] unsigned modifiers) { } virtual void page_did_enter_tooltip_area(CSSPixelPoint, ByteString const&) { } virtual void page_did_leave_tooltip_area() { } - virtual void page_did_hover_link(const URL&) { } + virtual void page_did_hover_link(const URL::URL&) { } virtual void page_did_unhover_link() { } virtual void page_did_change_favicon(Gfx::Bitmap const&) { } virtual void page_did_layout() { } @@ -268,10 +268,10 @@ public: virtual void page_did_request_set_prompt_text(String const&) { } virtual void page_did_request_accept_dialog() { } virtual void page_did_request_dismiss_dialog() { } - virtual Vector page_did_request_all_cookies(URL const&) { return {}; } - virtual Optional page_did_request_named_cookie(URL const&, String const&) { return {}; } - virtual String page_did_request_cookie(const URL&, Cookie::Source) { return {}; } - virtual void page_did_set_cookie(const URL&, Cookie::ParsedCookie const&, Cookie::Source) { } + virtual Vector page_did_request_all_cookies(URL::URL const&) { return {}; } + virtual Optional page_did_request_named_cookie(URL::URL const&, String const&) { return {}; } + virtual String page_did_request_cookie(const URL::URL&, Cookie::Source) { return {}; } + virtual void page_did_set_cookie(const URL::URL&, Cookie::ParsedCookie const&, Cookie::Source) { } virtual void page_did_update_cookie(Web::Cookie::Cookie) { } virtual void page_did_update_resource_count(i32) { } struct NewWebViewResult { diff --git a/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.cpp b/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.cpp index 8611cdee6af5ef139a4e41f7ba3b132e43896f23..00d76be3280396aab09a3de3ef88d56418ed8af1 100644 --- a/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.cpp +++ b/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include @@ -73,7 +73,7 @@ ErrorOr AutoplayAllowlist::enable_for_origins(ReadonlySpan origins TRY(allowlist.try_ensure_capacity(origins.size())); for (auto const& origin : origins) { - URL url { origin }; + URL::URL url { origin }; if (!url.is_valid()) url = TRY(String::formatted("https://{}", origin)); diff --git a/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp b/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp index 05607a11941f628678795b67cb9e93863e714b85..072adedf21ed60ac5dc3be0e51653b6d3dfe88bf 100644 --- a/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -17,7 +17,7 @@ namespace Web::ReferrerPolicy { // https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer -Optional determine_requests_referrer(Fetch::Infrastructure::Request const& request) +Optional determine_requests_referrer(Fetch::Infrastructure::Request const& request) { // 1. Let policy be request’s referrer policy. auto const& policy = request.referrer_policy(); @@ -28,7 +28,7 @@ Optional determine_requests_referrer(Fetch::Infrastructure::Request const& // 3. Switch on request’s referrer: auto referrer_source = request.referrer().visit( // "client" - [&](Fetch::Infrastructure::Request::Referrer referrer) -> Optional { + [&](Fetch::Infrastructure::Request::Referrer referrer) -> Optional { // Note: If request’s referrer is "no-referrer", Fetch will not call into this algorithm. VERIFY(referrer == Fetch::Infrastructure::Request::Referrer::Client); @@ -56,7 +56,7 @@ Optional determine_requests_referrer(Fetch::Infrastructure::Request const& } }, // a URL - [&](URL const& url) -> Optional { + [&](URL::URL const& url) -> Optional { // Let referrerSource be request’s referrer. return url; }); @@ -164,7 +164,7 @@ Optional determine_requests_referrer(Fetch::Infrastructure::Request const& } } -Optional strip_url_for_use_as_referrer(Optional url, OriginOnly origin_only) +Optional strip_url_for_use_as_referrer(Optional url, OriginOnly origin_only) { // 1. If url is null, return no referrer. if (!url.has_value()) diff --git a/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.h b/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.h index f96b05b40db7f8e56ab13f866fae1ae88c182c3f..bc077f907680d9b1e88bd064a36fbcb1197a2bb2 100644 --- a/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.h +++ b/Userland/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.h @@ -16,7 +16,7 @@ enum class OriginOnly { No, }; -Optional determine_requests_referrer(Fetch::Infrastructure::Request const&); -Optional strip_url_for_use_as_referrer(Optional, OriginOnly origin_only = OriginOnly::No); +Optional determine_requests_referrer(Fetch::Infrastructure::Request const&); +Optional strip_url_for_use_as_referrer(Optional, OriginOnly origin_only = OriginOnly::No); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp index 6c335cabc7f6c4daf9f3dba64f218544d37a550d..cfac8accfa2b3370e3884957b22e8085111af0f7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp @@ -57,7 +57,7 @@ private: } }; -ErrorOr> SVGDecodedImageData::create(JS::Realm& realm, JS::NonnullGCPtr host_page, URL const& url, ByteBuffer data) +ErrorOr> SVGDecodedImageData::create(JS::Realm& realm, JS::NonnullGCPtr host_page, URL::URL const& url, ByteBuffer data) { auto page_client = SVGPageClient::create(Bindings::main_thread_vm(), host_page); auto page = Page::create(Bindings::main_thread_vm(), *page_client); diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h index aa34a05c09f185a1b537bb540b55b1e32bcbcf13..796ae6d33ff256ed8bc496129d6d657374034d23 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h +++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h @@ -16,7 +16,7 @@ class SVGDecodedImageData final : public HTML::DecodedImageData { JS_DECLARE_ALLOCATOR(SVGDecodedImageData); public: - static ErrorOr> create(JS::Realm&, JS::NonnullGCPtr, URL const&, ByteBuffer encoded_svg); + static ErrorOr> create(JS::Realm&, JS::NonnullGCPtr, URL::URL const&, ByteBuffer encoded_svg); virtual ~SVGDecodedImageData() override; virtual RefPtr bitmap(size_t frame_index, Gfx::IntSize) const override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h index 259dc7e0cb38f4cdbca6e93aa0aa1a121359a14c..86fdfb817c3ad378a1b5cbe270672d8febbe799f 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h @@ -62,7 +62,7 @@ protected: Gfx::AffineTransform m_transform = {}; template - JS::GCPtr try_resolve_url_to(URL const& url) const + JS::GCPtr try_resolve_url_to(URL::URL const& url) const { if (!url.fragment().has_value()) return {}; diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.cpp index ac9fe8b7ce7c3a1b80bcac831bc96d65f1efe0b7..576ed2b8aefbbee94bb8aaad3fa73d16cf2e2a74 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.cpp b/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.cpp index c76397c546ffb9a79dc722c168ab0d3ac305b979..03621c828c49dfa0c1acdfe0b9abcfae39755877 100644 --- a/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -68,7 +68,7 @@ Trustworthiness is_origin_potentially_trustworthy(HTML::Origin const& origin) } // https://w3c.github.io/webappsec-secure-contexts/#is-url-trustworthy -Trustworthiness is_url_potentially_trustworthy(URL const& url) +Trustworthiness is_url_potentially_trustworthy(URL::URL const& url) { // 1. If url is "about:blank" or "about:srcdoc", return "Potentially Trustworthy". if (url == "about:blank"sv || url == "about:srcdoc"sv) diff --git a/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.h b/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.h index c822b6bbde1846fd7d8d5487da52f3e411c93a8d..babf5491d35a78b9dff4f62ab578600d98665464 100644 --- a/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.h +++ b/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include namespace Web::SecureContexts { @@ -17,6 +18,6 @@ enum class Trustworthiness { }; [[nodiscard]] Trustworthiness is_origin_potentially_trustworthy(HTML::Origin const&); -[[nodiscard]] Trustworthiness is_url_potentially_trustworthy(URL const&); +[[nodiscard]] Trustworthiness is_url_potentially_trustworthy(URL::URL const&); } diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index 4feeed2f986ae59f137885059cfe5a3c431f456f..5348416f05613859877cccc561e281072083ee3b 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -118,7 +118,7 @@ void WebSocket::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(WebSocket); } -ErrorOr WebSocket::establish_web_socket_connection(URL& url_record, Vector& protocols, HTML::EnvironmentSettingsObject& client) +ErrorOr WebSocket::establish_web_socket_connection(URL::URL& url_record, Vector& protocols, HTML::EnvironmentSettingsObject& client) { // FIXME: Integrate properly with FETCH as per https://fetch.spec.whatwg.org/#websocket-opening-handshake diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h index 3c9737e5e7b62c05b2feb404333ad65703dc6bc2..c667e18eb0c2b33434b982c5b27c39fc8a2def68 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h @@ -8,8 +8,8 @@ #pragma once #include -#include #include +#include #include #include #include @@ -44,7 +44,7 @@ public: virtual ~WebSocket() override; WebIDL::ExceptionOr url() const { return TRY_OR_THROW_OOM(vm(), m_url.to_string()); } - void set_url(URL url) { m_url = move(url); } + void set_url(URL::URL url) { m_url = move(url); } #undef __ENUMERATE #define __ENUMERATE(attribute_name, event_name) \ @@ -73,9 +73,9 @@ private: virtual void initialize(JS::Realm&) override; - ErrorOr establish_web_socket_connection(URL& url_record, Vector& protocols, HTML::EnvironmentSettingsObject& client); + ErrorOr establish_web_socket_connection(URL::URL& url_record, Vector& protocols, HTML::EnvironmentSettingsObject& client); - URL m_url; + URL::URL m_url; String m_binary_type { "blob"_string }; RefPtr m_websocket; }; diff --git a/Userland/Libraries/LibWeb/Worker/WebWorkerServer.ipc b/Userland/Libraries/LibWeb/Worker/WebWorkerServer.ipc index eefcd92d09f764556443e549be02032e38353520..ecb5c036db575bfb38acc98c50e656ebc3717ffa 100644 --- a/Userland/Libraries/LibWeb/Worker/WebWorkerServer.ipc +++ b/Userland/Libraries/LibWeb/Worker/WebWorkerServer.ipc @@ -1,11 +1,11 @@ -#include +#include #include #include #include endpoint WebWorkerServer { - start_dedicated_worker(URL url, String type, String credentials, String name, Web::HTML::TransferDataHolder message_port, Web::HTML::SerializedEnvironmentSettingsObject outside_settings) =| + start_dedicated_worker(URL::URL url, String type, String credentials, String name, Web::HTML::TransferDataHolder message_port, Web::HTML::SerializedEnvironmentSettingsObject outside_settings) =| handle_file_return(i32 error, Optional file, i32 request_id) =| } diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h index 7b9d467254a06dd8c86d21ef358a1f01bee6fba8..d5b436d8dac3f3af9d863234efdaa0803e28b540 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include #include @@ -129,7 +129,7 @@ private: // https://xhr.spec.whatwg.org/#request-url // request URL // A URL. - URL m_request_url; + URL::URL m_request_url; // https://xhr.spec.whatwg.org/#author-request-headers // author request headers diff --git a/Userland/Libraries/LibWebSocket/CMakeLists.txt b/Userland/Libraries/LibWebSocket/CMakeLists.txt index dae1899fd6d1a83851adc5d3e4e62646cb8da5d8..f37687c82cf3f0af4542d250303be51194ac4e12 100644 --- a/Userland/Libraries/LibWebSocket/CMakeLists.txt +++ b/Userland/Libraries/LibWebSocket/CMakeLists.txt @@ -6,4 +6,4 @@ set(SOURCES ) serenity_lib(LibWebSocket websocket) -target_link_libraries(LibWebSocket PRIVATE LibCore LibCrypto LibTLS) +target_link_libraries(LibWebSocket PRIVATE LibCore LibCrypto LibTLS LibURL) diff --git a/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp b/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp index 7446f97dc3e97cb604d9e5eebaacdadddd87e4ae..5a8acf1ed8093a9e4a3c3f5be58942e9164f73b7 100644 --- a/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp +++ b/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp @@ -8,7 +8,7 @@ namespace WebSocket { -ConnectionInfo::ConnectionInfo(URL url) +ConnectionInfo::ConnectionInfo(URL::URL url) : m_url(move(url)) { } diff --git a/Userland/Libraries/LibWebSocket/ConnectionInfo.h b/Userland/Libraries/LibWebSocket/ConnectionInfo.h index c4764102d6c399a5e665bbdb00fb6ca7fe06e34b..0cf5d58ba8a32dc7a88bb7bc2b0563379f79c4f6 100644 --- a/Userland/Libraries/LibWebSocket/ConnectionInfo.h +++ b/Userland/Libraries/LibWebSocket/ConnectionInfo.h @@ -6,19 +6,19 @@ #pragma once -#include #include #include #include +#include #include namespace WebSocket { class ConnectionInfo final { public: - ConnectionInfo(URL); + ConnectionInfo(URL::URL); - URL const& url() const { return m_url; } + URL::URL const& url() const { return m_url; } ByteString const& origin() const { return m_origin; } void set_origin(ByteString origin) { m_origin = move(origin); } @@ -43,7 +43,7 @@ public: ByteString resource_name() const; private: - URL m_url; + URL::URL m_url; ByteString m_origin; Vector m_protocols {}; Vector m_extensions {}; diff --git a/Userland/Libraries/LibWebSocket/WebSocket.h b/Userland/Libraries/LibWebSocket/WebSocket.h index 11aefd870576bd5a4a8ca83678609edb8cb838b4..c695f23452045d3503285926642539f2f1390834 100644 --- a/Userland/Libraries/LibWebSocket/WebSocket.h +++ b/Userland/Libraries/LibWebSocket/WebSocket.h @@ -28,7 +28,7 @@ public: static NonnullRefPtr create(ConnectionInfo, RefPtr = nullptr); virtual ~WebSocket() override = default; - URL const& url() const { return m_connection.url(); } + URL::URL const& url() const { return m_connection.url(); } ReadyState ready_state(); diff --git a/Userland/Libraries/LibWebView/CMakeLists.txt b/Userland/Libraries/LibWebView/CMakeLists.txt index edcb3e1c4db09d2747bc9f812417a3badb194ba7..c5cee84b911111fdd1dc04aedaf17e4368aff1ce 100644 --- a/Userland/Libraries/LibWebView/CMakeLists.txt +++ b/Userland/Libraries/LibWebView/CMakeLists.txt @@ -44,7 +44,7 @@ set(GENERATED_SOURCES ) serenity_lib(LibWebView webview) -target_link_libraries(LibWebView PRIVATE LibCore LibFileSystem LibGfx LibIPC LibProtocol LibJS LibWeb LibSQL LibUnicode) +target_link_libraries(LibWebView PRIVATE LibCore LibFileSystem LibGfx LibIPC LibProtocol LibJS LibWeb LibSQL LibUnicode LibURL) target_compile_definitions(LibWebView PRIVATE ENABLE_PUBLIC_SUFFIX=$) if (SERENITYOS) diff --git a/Userland/Libraries/LibWebView/CookieJar.cpp b/Userland/Libraries/LibWebView/CookieJar.cpp index f204709d746118fb4ca521694c6790c7e5eea777..7b30a998f6a3665424e61a6c5e24280375eabab3 100644 --- a/Userland/Libraries/LibWebView/CookieJar.cpp +++ b/Userland/Libraries/LibWebView/CookieJar.cpp @@ -10,11 +10,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -84,7 +84,7 @@ CookieJar::CookieJar(TransientStorage storage) { } -String CookieJar::get_cookie(const URL& url, Web::Cookie::Source source) +String CookieJar::get_cookie(const URL::URL& url, Web::Cookie::Source source) { purge_expired_cookies(); @@ -107,7 +107,7 @@ String CookieJar::get_cookie(const URL& url, Web::Cookie::Source source) return MUST(builder.to_string()); } -void CookieJar::set_cookie(const URL& url, Web::Cookie::ParsedCookie const& parsed_cookie, Web::Cookie::Source source) +void CookieJar::set_cookie(const URL::URL& url, Web::Cookie::ParsedCookie const& parsed_cookie, Web::Cookie::Source source) { auto domain = canonicalize_domain(url); if (!domain.has_value()) @@ -181,7 +181,7 @@ Vector CookieJar::get_all_cookies() } // https://w3c.github.io/webdriver/#dfn-associated-cookies -Vector CookieJar::get_all_cookies(URL const& url) +Vector CookieJar::get_all_cookies(URL::URL const& url) { auto domain = canonicalize_domain(url); if (!domain.has_value()) @@ -190,7 +190,7 @@ Vector CookieJar::get_all_cookies(URL const& url) return get_matching_cookies(url, domain.value(), Web::Cookie::Source::Http, MatchingCookiesSpecMode::WebDriver); } -Optional CookieJar::get_named_cookie(URL const& url, StringView name) +Optional CookieJar::get_named_cookie(URL::URL const& url, StringView name) { auto domain = canonicalize_domain(url); if (!domain.has_value()) @@ -206,7 +206,7 @@ Optional CookieJar::get_named_cookie(URL const& url, String return {}; } -Optional CookieJar::canonicalize_domain(const URL& url) +Optional CookieJar::canonicalize_domain(const URL::URL& url) { // https://tools.ietf.org/html/rfc6265#section-5.1.2 if (!url.is_valid()) @@ -266,7 +266,7 @@ bool CookieJar::path_matches(StringView request_path, StringView cookie_path) return false; } -String CookieJar::default_path(const URL& url) +String CookieJar::default_path(const URL::URL& url) { // https://tools.ietf.org/html/rfc6265#section-5.1.4 @@ -288,7 +288,7 @@ String CookieJar::default_path(const URL& url) return MUST(String::from_utf8(uri_path.substring_view(0, last_separator))); } -void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, const URL& url, String canonicalized_domain, Web::Cookie::Source source) +void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, const URL::URL& url, String canonicalized_domain, Web::Cookie::Source source) { // https://tools.ietf.org/html/rfc6265#section-5.3 @@ -397,7 +397,7 @@ void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, con MUST(sync_promise->await()); } -Vector CookieJar::get_matching_cookies(const URL& url, StringView canonicalized_domain, Web::Cookie::Source source, MatchingCookiesSpecMode mode) +Vector CookieJar::get_matching_cookies(const URL::URL& url, StringView canonicalized_domain, Web::Cookie::Source source, MatchingCookiesSpecMode mode) { // https://tools.ietf.org/html/rfc6265#section-5.4 diff --git a/Userland/Libraries/LibWebView/CookieJar.h b/Userland/Libraries/LibWebView/CookieJar.h index 9d65f7d9f15fecdf25661dabd299d8a3684f7960..3762382b905ea7fd28691a43663920b45ec09c37 100644 --- a/Userland/Libraries/LibWebView/CookieJar.h +++ b/Userland/Libraries/LibWebView/CookieJar.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -50,30 +51,30 @@ public: static ErrorOr create(Database&); static CookieJar create(); - String get_cookie(const URL& url, Web::Cookie::Source source); - void set_cookie(const URL& url, Web::Cookie::ParsedCookie const& parsed_cookie, Web::Cookie::Source source); + String get_cookie(const URL::URL& url, Web::Cookie::Source source); + void set_cookie(const URL::URL& url, Web::Cookie::ParsedCookie const& parsed_cookie, Web::Cookie::Source source); void update_cookie(Web::Cookie::Cookie); void dump_cookies(); Vector get_all_cookies(); - Vector get_all_cookies(URL const& url); - Optional get_named_cookie(URL const& url, StringView name); + Vector get_all_cookies(URL::URL const& url); + Optional get_named_cookie(URL::URL const& url, StringView name); private: explicit CookieJar(PersistedStorage); explicit CookieJar(TransientStorage); - static Optional canonicalize_domain(const URL& url); + static Optional canonicalize_domain(const URL::URL& url); static bool domain_matches(StringView string, StringView domain_string); static bool path_matches(StringView request_path, StringView cookie_path); - static String default_path(const URL& url); + static String default_path(const URL::URL& url); enum class MatchingCookiesSpecMode { RFC6265, WebDriver, }; - void store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, const URL& url, String canonicalized_domain, Web::Cookie::Source source); - Vector get_matching_cookies(const URL& url, StringView canonicalized_domain, Web::Cookie::Source source, MatchingCookiesSpecMode mode = MatchingCookiesSpecMode::RFC6265); + void store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, const URL::URL& url, String canonicalized_domain, Web::Cookie::Source source); + Vector get_matching_cookies(const URL::URL& url, StringView canonicalized_domain, Web::Cookie::Source source, MatchingCookiesSpecMode mode = MatchingCookiesSpecMode::RFC6265); void insert_cookie_into_database(Web::Cookie::Cookie const& cookie); void update_cookie_in_database(Web::Cookie::Cookie const& cookie); diff --git a/Userland/Libraries/LibWebView/History.cpp b/Userland/Libraries/LibWebView/History.cpp index 1d82794ff3f5caf2d1bd3689a3658180ff8ffe11..23c87cd40318f6ed7ffd6ae476020105d16fb7da 100644 --- a/Userland/Libraries/LibWebView/History.cpp +++ b/Userland/Libraries/LibWebView/History.cpp @@ -23,7 +23,7 @@ Vector History::get_all_history_entries() return m_items; } -void History::push(const URL& url, ByteString const& title) +void History::push(const URL::URL& url, ByteString const& title) { if (!m_items.is_empty() && m_items[m_current].url == url) return; @@ -35,7 +35,7 @@ void History::push(const URL& url, ByteString const& title) m_current++; } -void History::replace_current(const URL& url, ByteString const& title) +void History::replace_current(const URL::URL& url, ByteString const& title) { if (m_current == -1) return; diff --git a/Userland/Libraries/LibWebView/History.h b/Userland/Libraries/LibWebView/History.h index 817e4c74d1f37bbc397f6c6c5cbdb92e1bc79c75..0635ea4188cda43a7aeb227f3d67be20afdd566a 100644 --- a/Userland/Libraries/LibWebView/History.h +++ b/Userland/Libraries/LibWebView/History.h @@ -6,22 +6,22 @@ #pragma once -#include #include +#include namespace WebView { class History { public: struct URLTitlePair { - URL url; + URL::URL url; ByteString title; }; void dump() const; Vector get_all_history_entries(); - void push(const URL& url, ByteString const& title); - void replace_current(const URL& url, ByteString const& title); + void push(const URL::URL& url, ByteString const& title); + void replace_current(const URL::URL& url, ByteString const& title); void update_title(ByteString const& title); URLTitlePair current() const; diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h index f8753c2bc26cfdb9e621d25b68d2fabcca1234ba..12879f2fcbbc115795f4fb054ba144ff063c2d73 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h @@ -7,9 +7,10 @@ #pragma once -#include +#include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWebView/RequestServerAdapter.cpp b/Userland/Libraries/LibWebView/RequestServerAdapter.cpp index 6c091295278ea5790db6546892a22f4ecda135ea..54be11ba66f01dea3638beabad0d0ddb10a77e0e 100644 --- a/Userland/Libraries/LibWebView/RequestServerAdapter.cpp +++ b/Userland/Libraries/LibWebView/RequestServerAdapter.cpp @@ -87,7 +87,7 @@ RequestServerAdapter::RequestServerAdapter(NonnullRefPtr RequestServerAdapter::start_request(ByteString const& method, URL const& url, HashMap const& headers, ReadonlyBytes body, Core::ProxyData const& proxy) +RefPtr RequestServerAdapter::start_request(ByteString const& method, URL::URL const& url, HashMap const& headers, ReadonlyBytes body, Core::ProxyData const& proxy) { auto protocol_request = m_protocol_client->start_request(method, url, headers, body, proxy); if (!protocol_request) @@ -95,7 +95,7 @@ RefPtr RequestServerAdapter::start_request( return RequestServerRequestAdapter::try_create(protocol_request.release_nonnull()).release_value_but_fixme_should_propagate_errors(); } -RefPtr RequestServerAdapter::websocket_connect(AK::URL const& url, AK::ByteString const& origin, Vector const& protocols) +RefPtr RequestServerAdapter::websocket_connect(URL::URL const& url, AK::ByteString const& origin, Vector const& protocols) { auto underlying_websocket = m_protocol_client->websocket_connect(url, origin, protocols); if (!underlying_websocket) @@ -103,12 +103,12 @@ RefPtr RequestServerAdapter::websocket_c return WebSocketClientSocketAdapter::create(underlying_websocket.release_nonnull()); } -void RequestServerAdapter::prefetch_dns(URL const& url) +void RequestServerAdapter::prefetch_dns(URL::URL const& url) { m_protocol_client->ensure_connection(url, RequestServer::CacheLevel::ResolveOnly); } -void RequestServerAdapter::preconnect(URL const& url) +void RequestServerAdapter::preconnect(URL::URL const& url) { m_protocol_client->ensure_connection(url, RequestServer::CacheLevel::CreateConnection); } diff --git a/Userland/Libraries/LibWebView/RequestServerAdapter.h b/Userland/Libraries/LibWebView/RequestServerAdapter.h index e1a4317aa99f49e1ed35a69418e64bde474f4d9a..393e47f307538b7376c40759afd0e4654f1e47bb 100644 --- a/Userland/Libraries/LibWebView/RequestServerAdapter.h +++ b/Userland/Libraries/LibWebView/RequestServerAdapter.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include @@ -43,11 +43,11 @@ public: static ErrorOr> try_create(); virtual ~RequestServerAdapter() override; - virtual void prefetch_dns(URL const& url) override; - virtual void preconnect(URL const& url) override; + virtual void prefetch_dns(URL::URL const& url) override; + virtual void preconnect(URL::URL const& url) override; - virtual RefPtr start_request(ByteString const& method, URL const&, HashMap const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}) override; - virtual RefPtr websocket_connect(const URL&, ByteString const& origin, Vector const& protocols) override; + virtual RefPtr start_request(ByteString const& method, URL::URL const&, HashMap const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}) override; + virtual RefPtr websocket_connect(const URL::URL&, ByteString const& origin, Vector const& protocols) override; private: RefPtr m_protocol_client; diff --git a/Userland/Libraries/LibWebView/SourceHighlighter.cpp b/Userland/Libraries/LibWebView/SourceHighlighter.cpp index 0807e210973542e4b642227290546634e88280a9..a4638a09bc45acfe6171cb608e3d3f53e518ed80 100644 --- a/Userland/Libraries/LibWebView/SourceHighlighter.cpp +++ b/Userland/Libraries/LibWebView/SourceHighlighter.cpp @@ -5,13 +5,13 @@ */ #include -#include +#include #include #include namespace WebView { -String highlight_source(URL const& url, StringView source) +String highlight_source(URL::URL const& url, StringView source) { Web::HTML::HTMLTokenizer tokenizer { source, "utf-8"sv }; StringBuilder builder; diff --git a/Userland/Libraries/LibWebView/SourceHighlighter.h b/Userland/Libraries/LibWebView/SourceHighlighter.h index 12d1c0852f71c4def3ea15b367f327b02aba92c0..1ab7cf4f4114896fc596b0efcf6b7da4fb0ee2ab 100644 --- a/Userland/Libraries/LibWebView/SourceHighlighter.h +++ b/Userland/Libraries/LibWebView/SourceHighlighter.h @@ -11,7 +11,7 @@ namespace WebView { -String highlight_source(URL const&, StringView); +String highlight_source(URL::URL const&, StringView); constexpr inline StringView HTML_HIGHLIGHTER_STYLE = R"~~~( .html { diff --git a/Userland/Libraries/LibWebView/URL.cpp b/Userland/Libraries/LibWebView/URL.cpp index 21abbf476696d27f6765f09d561a2af795451d43..7788c6f3b36cb4639ff731831b81e159ccbc00ad 100644 --- a/Userland/Libraries/LibWebView/URL.cpp +++ b/Userland/Libraries/LibWebView/URL.cpp @@ -18,7 +18,7 @@ namespace WebView { -static Optional create_url_with_url_or_path(String const& url_or_path) +static Optional create_url_with_url_or_path(String const& url_or_path) { auto url = Unicode::create_unicode_url(url_or_path); if (!url.is_error() && url.value().is_valid()) @@ -32,7 +32,7 @@ static Optional create_url_with_url_or_path(String const& url_or_path) return {}; } -static Optional query_public_suffix_list(StringView url_string) +static Optional query_public_suffix_list(StringView url_string) { auto out = MUST(String::from_utf8(url_string)); if (!out.starts_with_bytes("about:"sv) && !out.contains("://"sv)) @@ -81,7 +81,7 @@ Optional get_public_suffix([[maybe_unused]] StringView host) #endif } -Optional sanitize_url(StringView url, Optional search_engine, AppendTLD append_tld) +Optional sanitize_url(StringView url, Optional search_engine, AppendTLD append_tld) { if (FileSystem::exists(url)) { auto path = FileSystem::real_path(url); @@ -91,7 +91,7 @@ Optional sanitize_url(StringView url, Optional search_engine, A return URL::create_with_file_scheme(path.value()); } - auto format_search_engine = [&]() -> Optional { + auto format_search_engine = [&]() -> Optional { if (!search_engine.has_value()) return {}; @@ -115,7 +115,7 @@ Optional sanitize_url(StringView url, Optional search_engine, A return result.release_value(); } -static URLParts break_file_url_into_parts(URL const& url, StringView url_string) +static URLParts break_file_url_into_parts(URL::URL const& url, StringView url_string) { auto scheme = url_string.substring_view(0, url.scheme().bytes_as_string_view().length() + "://"sv.length()); auto path = url_string.substring_view(scheme.length()); @@ -123,7 +123,7 @@ static URLParts break_file_url_into_parts(URL const& url, StringView url_string) return URLParts { scheme, path, {} }; } -static URLParts break_web_url_into_parts(URL const& url, StringView url_string) +static URLParts break_web_url_into_parts(URL::URL const& url, StringView url_string) { auto scheme = url_string.substring_view(0, url.scheme().bytes_as_string_view().length() + "://"sv.length()); auto url_without_scheme = url_string.substring_view(scheme.length()); @@ -178,7 +178,7 @@ Optional break_url_into_parts(StringView url_string) return {}; } -URLType url_type(URL const& url) +URLType url_type(URL::URL const& url) { if (url.scheme() == "mailto"sv) return URLType::Email; @@ -187,7 +187,7 @@ URLType url_type(URL const& url) return URLType::Other; } -String url_text_to_copy(URL const& url) +String url_text_to_copy(URL::URL const& url) { auto url_text = MUST(url.to_string()); diff --git a/Userland/Libraries/LibWebView/URL.h b/Userland/Libraries/LibWebView/URL.h index 95997a7dfbffb6dd118bb177f72efdd0a184f774..580512a201cc56aaf699fda09dea23a18b095dbe 100644 --- a/Userland/Libraries/LibWebView/URL.h +++ b/Userland/Libraries/LibWebView/URL.h @@ -8,7 +8,7 @@ #include #include -#include +#include namespace WebView { @@ -19,7 +19,7 @@ enum class AppendTLD { No, Yes, }; -Optional sanitize_url(StringView, Optional search_engine = {}, AppendTLD = AppendTLD::No); +Optional sanitize_url(StringView, Optional search_engine = {}, AppendTLD = AppendTLD::No); struct URLParts { StringView scheme_and_subdomain; @@ -34,7 +34,7 @@ enum class URLType { Telephone, Other, }; -URLType url_type(URL const&); -String url_text_to_copy(URL const&); +URLType url_type(URL::URL const&); +String url_text_to_copy(URL::URL const&); } diff --git a/Userland/Libraries/LibWebView/ViewImplementation.cpp b/Userland/Libraries/LibWebView/ViewImplementation.cpp index bb59e7760585acc469b40f3d865f3241311ff355..168f6238722458c3b1af66c71660e5b08d03f925 100644 --- a/Userland/Libraries/LibWebView/ViewImplementation.cpp +++ b/Userland/Libraries/LibWebView/ViewImplementation.cpp @@ -74,7 +74,7 @@ void ViewImplementation::server_did_paint(Badge, i32 bitmap_id client().async_ready_to_paint(page_id()); } -void ViewImplementation::load(URL const& url) +void ViewImplementation::load(URL::URL const& url) { m_url = url; client().async_load_url(page_id(), url); diff --git a/Userland/Libraries/LibWebView/ViewImplementation.h b/Userland/Libraries/LibWebView/ViewImplementation.h index d620651c35a6c19051d398677ea63cc8e8bd3d58..164f89341d16c60457d6a6562ec286ad6915434f 100644 --- a/Userland/Libraries/LibWebView/ViewImplementation.h +++ b/Userland/Libraries/LibWebView/ViewImplementation.h @@ -38,14 +38,14 @@ public: String aria_properties_state_json; }; - void set_url(Badge, URL url) { m_url = move(url); } - URL const& url() const { return m_url; } + void set_url(Badge, URL::URL url) { m_url = move(url); } + URL::URL const& url() const { return m_url; } String const& handle() const { return m_client_state.client_handle; } void server_did_paint(Badge, i32 bitmap_id, Gfx::IntSize size); - void load(URL const&); + void load(URL::URL const&); void load_html(StringView); void load_empty_document(); @@ -123,16 +123,16 @@ public: Function on_activate_tab; Function on_close; Function on_context_menu_request; - Function on_link_context_menu_request; - Function on_image_context_menu_request; + Function on_link_context_menu_request; + Function on_image_context_menu_request; Function on_media_context_menu_request; - Function on_link_hover; + Function on_link_hover; Function on_link_unhover; - Function on_link_click; - Function on_link_middle_click; + Function on_link_click; + Function on_link_middle_click; Function on_title_change; - Function on_load_start; - Function on_load_finish; + Function on_load_start; + Function on_load_finish; Function on_request_file; Function on_navigate_back; Function on_navigate_forward; @@ -149,7 +149,7 @@ public: Function on_request_set_prompt_text; Function on_request_accept_dialog; Function on_request_dismiss_dialog; - Function on_received_source; + Function on_received_source; Function on_received_dom_tree; Function)> on_received_dom_node_properties; Function on_received_accessibility_tree; @@ -158,10 +158,10 @@ public: Function on_received_dom_node_html; Function on_received_console_message; Function const& message_types, Vector const& messages)> on_received_console_messages; - Function(URL const& url)> on_get_all_cookies; - Function(URL const& url, String const& name)> on_get_named_cookie; - Function on_get_cookie; - Function on_set_cookie; + Function(URL::URL const& url)> on_get_all_cookies; + Function(URL::URL const& url, String const& name)> on_get_named_cookie; + Function on_get_cookie; + Function on_set_cookie; Function on_update_cookie; Function on_resource_status_change; Function on_restore_window; @@ -235,7 +235,7 @@ protected: bool has_usable_bitmap { false }; } m_client_state; - URL m_url; + URL::URL m_url; float m_zoom_level { 1.0 }; float m_device_pixel_ratio { 1.0 }; diff --git a/Userland/Libraries/LibWebView/WebContentClient.cpp b/Userland/Libraries/LibWebView/WebContentClient.cpp index ffead277b71e0514b304a781424713f5f5a815c0..de0dd5c1520b250a1015b41ae1b7598d66d93eae 100644 --- a/Userland/Libraries/LibWebView/WebContentClient.cpp +++ b/Userland/Libraries/LibWebView/WebContentClient.cpp @@ -46,7 +46,7 @@ void WebContentClient::did_paint(u64 page_id, Gfx::IntRect const& rect, i32 bitm view.server_did_paint({}, bitmap_id, rect.size()); } -void WebContentClient::did_start_loading(u64 page_id, URL const& url, bool is_redirect) +void WebContentClient::did_start_loading(u64 page_id, URL::URL const& url, bool is_redirect) { auto maybe_view = m_views.get(page_id); if (!maybe_view.has_value()) { @@ -61,7 +61,7 @@ void WebContentClient::did_start_loading(u64 page_id, URL const& url, bool is_re view.on_load_start(url, is_redirect); } -void WebContentClient::did_finish_loading(u64 page_id, URL const& url) +void WebContentClient::did_finish_loading(u64 page_id, URL::URL const& url) { auto maybe_view = m_views.get(page_id); if (!maybe_view.has_value()) { @@ -231,7 +231,7 @@ void WebContentClient::did_leave_tooltip_area(u64 page_id) view.on_leave_tooltip_area(); } -void WebContentClient::did_hover_link(u64 page_id, URL const& url) +void WebContentClient::did_hover_link(u64 page_id, URL::URL const& url) { dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidHoverLink! url={}", url); auto maybe_view = m_views.get(page_id); @@ -259,7 +259,7 @@ void WebContentClient::did_unhover_link(u64 page_id) view.on_link_unhover(); } -void WebContentClient::did_click_link(u64 page_id, URL const& url, ByteString const& target, unsigned modifiers) +void WebContentClient::did_click_link(u64 page_id, URL::URL const& url, ByteString const& target, unsigned modifiers) { auto maybe_view = m_views.get(page_id); if (!maybe_view.has_value()) { @@ -272,7 +272,7 @@ void WebContentClient::did_click_link(u64 page_id, URL const& url, ByteString co view.on_link_click(url, target, modifiers); } -void WebContentClient::did_middle_click_link(u64 page_id, URL const& url, ByteString const& target, unsigned modifiers) +void WebContentClient::did_middle_click_link(u64 page_id, URL::URL const& url, ByteString const& target, unsigned modifiers) { auto maybe_view = m_views.get(page_id); if (!maybe_view.has_value()) { @@ -298,7 +298,7 @@ void WebContentClient::did_request_context_menu(u64 page_id, Gfx::IntPoint conte view.on_context_menu_request(view.to_widget_position(content_position)); } -void WebContentClient::did_request_link_context_menu(u64 page_id, Gfx::IntPoint content_position, URL const& url, ByteString const&, unsigned) +void WebContentClient::did_request_link_context_menu(u64 page_id, Gfx::IntPoint content_position, URL::URL const& url, ByteString const&, unsigned) { auto maybe_view = m_views.get(page_id); if (!maybe_view.has_value()) { @@ -311,7 +311,7 @@ void WebContentClient::did_request_link_context_menu(u64 page_id, Gfx::IntPoint view.on_link_context_menu_request(url, view.to_widget_position(content_position)); } -void WebContentClient::did_request_image_context_menu(u64 page_id, Gfx::IntPoint content_position, URL const& url, ByteString const&, unsigned, Gfx::ShareableBitmap const& bitmap) +void WebContentClient::did_request_image_context_menu(u64 page_id, Gfx::IntPoint content_position, URL::URL const& url, ByteString const&, unsigned, Gfx::ShareableBitmap const& bitmap) { auto maybe_view = m_views.get(page_id); if (!maybe_view.has_value()) { @@ -337,7 +337,7 @@ void WebContentClient::did_request_media_context_menu(u64 page_id, Gfx::IntPoint view.on_media_context_menu_request(view.to_widget_position(content_position), menu); } -void WebContentClient::did_get_source(u64 page_id, URL const& url, ByteString const& source) +void WebContentClient::did_get_source(u64 page_id, URL::URL const& url, ByteString const& source) { auto maybe_view = m_views.get(page_id); if (!maybe_view.has_value()) { @@ -576,7 +576,7 @@ void WebContentClient::did_change_favicon(u64 page_id, Gfx::ShareableBitmap cons view.on_favicon_change(*favicon.bitmap()); } -Messages::WebContentClient::DidRequestAllCookiesResponse WebContentClient::did_request_all_cookies(u64 page_id, URL const& url) +Messages::WebContentClient::DidRequestAllCookiesResponse WebContentClient::did_request_all_cookies(u64 page_id, URL::URL const& url) { auto maybe_view = m_views.get(page_id); if (!maybe_view.has_value()) { @@ -590,7 +590,7 @@ Messages::WebContentClient::DidRequestAllCookiesResponse WebContentClient::did_r return Vector {}; } -Messages::WebContentClient::DidRequestNamedCookieResponse WebContentClient::did_request_named_cookie(u64 page_id, URL const& url, String const& name) +Messages::WebContentClient::DidRequestNamedCookieResponse WebContentClient::did_request_named_cookie(u64 page_id, URL::URL const& url, String const& name) { auto maybe_view = m_views.get(page_id); if (!maybe_view.has_value()) { @@ -604,7 +604,7 @@ Messages::WebContentClient::DidRequestNamedCookieResponse WebContentClient::did_ return OptionalNone {}; } -Messages::WebContentClient::DidRequestCookieResponse WebContentClient::did_request_cookie(u64 page_id, URL const& url, Web::Cookie::Source source) +Messages::WebContentClient::DidRequestCookieResponse WebContentClient::did_request_cookie(u64 page_id, URL::URL const& url, Web::Cookie::Source source) { auto maybe_view = m_views.get(page_id); if (!maybe_view.has_value()) { @@ -618,7 +618,7 @@ Messages::WebContentClient::DidRequestCookieResponse WebContentClient::did_reque return String {}; } -void WebContentClient::did_set_cookie(u64 page_id, URL const& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) +void WebContentClient::did_set_cookie(u64 page_id, URL::URL const& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) { auto maybe_view = m_views.get(page_id); if (!maybe_view.has_value()) { diff --git a/Userland/Libraries/LibWebView/WebContentClient.h b/Userland/Libraries/LibWebView/WebContentClient.h index e183c055e3c18efe935f4b7033357d79fde7fe46..19cbf62107071af1994c90d8623b2dd30c77d6ce 100644 --- a/Userland/Libraries/LibWebView/WebContentClient.h +++ b/Userland/Libraries/LibWebView/WebContentClient.h @@ -36,7 +36,7 @@ private: virtual void die() override; virtual void did_paint(u64 page_id, Gfx::IntRect const&, i32) override; - virtual void did_finish_loading(u64 page_id, URL const&) override; + virtual void did_finish_loading(u64 page_id, URL::URL const&) override; virtual void did_request_navigate_back(u64 page_id) override; virtual void did_request_navigate_forward(u64 page_id) override; virtual void did_request_refresh(u64 page_id) override; @@ -47,16 +47,16 @@ private: virtual void did_request_scroll_to(u64 page_id, Gfx::IntPoint) override; virtual void did_enter_tooltip_area(u64 page_id, Gfx::IntPoint, ByteString const&) override; virtual void did_leave_tooltip_area(u64 page_id) override; - virtual void did_hover_link(u64 page_id, URL const&) override; + virtual void did_hover_link(u64 page_id, URL::URL const&) override; virtual void did_unhover_link(u64 page_id) override; - virtual void did_click_link(u64 page_id, URL const&, ByteString const&, unsigned) override; - virtual void did_middle_click_link(u64 page_id, URL const&, ByteString const&, unsigned) override; - virtual void did_start_loading(u64 page_id, URL const&, bool) override; + virtual void did_click_link(u64 page_id, URL::URL const&, ByteString const&, unsigned) override; + virtual void did_middle_click_link(u64 page_id, URL::URL const&, ByteString const&, unsigned) override; + virtual void did_start_loading(u64 page_id, URL::URL const&, bool) override; virtual void did_request_context_menu(u64 page_id, Gfx::IntPoint) override; - virtual void did_request_link_context_menu(u64 page_id, Gfx::IntPoint, URL const&, ByteString const&, unsigned) override; - virtual void did_request_image_context_menu(u64 page_id, Gfx::IntPoint, URL const&, ByteString const&, unsigned, Gfx::ShareableBitmap const&) override; + virtual void did_request_link_context_menu(u64 page_id, Gfx::IntPoint, URL::URL const&, ByteString const&, unsigned) override; + virtual void did_request_image_context_menu(u64 page_id, Gfx::IntPoint, URL::URL const&, ByteString const&, unsigned, Gfx::ShareableBitmap const&) override; virtual void did_request_media_context_menu(u64 page_id, Gfx::IntPoint, ByteString const&, unsigned, Web::Page::MediaContextMenu const&) override; - virtual void did_get_source(u64 page_id, URL const&, ByteString const&) override; + virtual void did_get_source(u64 page_id, URL::URL const&, ByteString const&) override; virtual void did_inspect_dom_tree(u64 page_id, ByteString const&) override; virtual void did_inspect_dom_node(u64 page_id, bool has_style, ByteString const& computed_style, ByteString const& resolved_style, ByteString const& custom_properties, ByteString const& node_box_sizing, ByteString const& aria_properties_state) override; virtual void did_inspect_accessibility_tree(u64 page_id, ByteString const&) override; @@ -73,10 +73,10 @@ private: virtual void did_request_set_prompt_text(u64 page_id, String const& message) override; virtual void did_request_accept_dialog(u64 page_id) override; virtual void did_request_dismiss_dialog(u64 page_id) override; - virtual Messages::WebContentClient::DidRequestAllCookiesResponse did_request_all_cookies(u64 page_id, URL const&) override; - virtual Messages::WebContentClient::DidRequestNamedCookieResponse did_request_named_cookie(u64 page_id, URL const&, String const&) override; - virtual Messages::WebContentClient::DidRequestCookieResponse did_request_cookie(u64 page_id, URL const&, Web::Cookie::Source) override; - virtual void did_set_cookie(u64 page_id, URL const&, Web::Cookie::ParsedCookie const&, Web::Cookie::Source) override; + virtual Messages::WebContentClient::DidRequestAllCookiesResponse did_request_all_cookies(u64 page_id, URL::URL const&) override; + virtual Messages::WebContentClient::DidRequestNamedCookieResponse did_request_named_cookie(u64 page_id, URL::URL const&, String const&) override; + virtual Messages::WebContentClient::DidRequestCookieResponse did_request_cookie(u64 page_id, URL::URL const&, Web::Cookie::Source) override; + virtual void did_set_cookie(u64 page_id, URL::URL const&, Web::Cookie::ParsedCookie const&, Web::Cookie::Source) override; virtual void did_update_cookie(u64 page_id, Web::Cookie::Cookie const&) override; virtual Messages::WebContentClient::DidRequestNewWebViewResponse did_request_new_web_view(u64 page_id, Web::HTML::ActivateTab const&, Web::HTML::WebViewHints const&, Optional const& page_index) override; virtual void did_request_activate_tab(u64 page_id) override; diff --git a/Userland/Services/FileSystemAccessServer/CMakeLists.txt b/Userland/Services/FileSystemAccessServer/CMakeLists.txt index a84ad1047c4a5068b8c5f99038bf1ec3d8234df8..851a127d6f7294452ea4ce283eff94dad7129673 100644 --- a/Userland/Services/FileSystemAccessServer/CMakeLists.txt +++ b/Userland/Services/FileSystemAccessServer/CMakeLists.txt @@ -18,5 +18,5 @@ set(GENERATED_SOURCES ) serenity_bin(FileSystemAccessServer) -target_link_libraries(FileSystemAccessServer PRIVATE LibCore LibFileSystem LibGfx LibGUI LibIPC LibMain) +target_link_libraries(FileSystemAccessServer PRIVATE LibCore LibFileSystem LibGfx LibGUI LibIPC LibMain LibURL) add_dependencies(FileSystemAccessServer WindowServer) diff --git a/Userland/Services/FileSystemAccessServer/FileSystemAccessServer.ipc b/Userland/Services/FileSystemAccessServer/FileSystemAccessServer.ipc index 62263e7232256b2aee317b2a08c636775ae0a69f..993b70eb3008d76fd8a98ca746d59aa30b860b6d 100644 --- a/Userland/Services/FileSystemAccessServer/FileSystemAccessServer.ipc +++ b/Userland/Services/FileSystemAccessServer/FileSystemAccessServer.ipc @@ -1,4 +1,4 @@ -#include +#include #include endpoint FileSystemAccessServer diff --git a/Userland/Services/LaunchServer/CMakeLists.txt b/Userland/Services/LaunchServer/CMakeLists.txt index f97bca1175ff15f5782f2632133c2c120b1ae53f..8ead20413ccb2ed55fcf504f8edfb854983e36db 100644 --- a/Userland/Services/LaunchServer/CMakeLists.txt +++ b/Userland/Services/LaunchServer/CMakeLists.txt @@ -19,4 +19,4 @@ set(GENERATED_SOURCES ) serenity_bin(LaunchServer) -target_link_libraries(LaunchServer PRIVATE LibCore LibIPC LibDesktop LibFileSystem LibMain) +target_link_libraries(LaunchServer PRIVATE LibCore LibIPC LibDesktop LibFileSystem LibMain LibURL) diff --git a/Userland/Services/LaunchServer/ConnectionFromClient.cpp b/Userland/Services/LaunchServer/ConnectionFromClient.cpp index 6dddf74174fa9ccd4f799aa60bdde64b1aa01cc9..9e13b80329e2f91f9318c3eb9117ffad5015cc09 100644 --- a/Userland/Services/LaunchServer/ConnectionFromClient.cpp +++ b/Userland/Services/LaunchServer/ConnectionFromClient.cpp @@ -7,8 +7,8 @@ #include "ConnectionFromClient.h" #include "Launcher.h" #include -#include #include +#include namespace LaunchServer { @@ -24,7 +24,7 @@ void ConnectionFromClient::die() s_connections.remove(client_id()); } -Messages::LaunchServer::OpenUrlResponse ConnectionFromClient::open_url(URL const& url, ByteString const& handler_name) +Messages::LaunchServer::OpenUrlResponse ConnectionFromClient::open_url(URL::URL const& url, ByteString const& handler_name) { if (!m_allowlist.is_empty()) { bool allowed = false; @@ -47,17 +47,17 @@ Messages::LaunchServer::OpenUrlResponse ConnectionFromClient::open_url(URL const return Launcher::the().open_url(url, handler_name); } -Messages::LaunchServer::GetHandlersForUrlResponse ConnectionFromClient::get_handlers_for_url(URL const& url) +Messages::LaunchServer::GetHandlersForUrlResponse ConnectionFromClient::get_handlers_for_url(URL::URL const& url) { return Launcher::the().handlers_for_url(url); } -Messages::LaunchServer::GetHandlersWithDetailsForUrlResponse ConnectionFromClient::get_handlers_with_details_for_url(URL const& url) +Messages::LaunchServer::GetHandlersWithDetailsForUrlResponse ConnectionFromClient::get_handlers_with_details_for_url(URL::URL const& url) { return Launcher::the().handlers_with_details_for_url(url); } -void ConnectionFromClient::add_allowed_url(URL const& url) +void ConnectionFromClient::add_allowed_url(URL::URL const& url) { if (m_allowlist_is_sealed) { did_misbehave("Got request to add more allowed handlers after list was sealed"); @@ -69,7 +69,7 @@ void ConnectionFromClient::add_allowed_url(URL const& url) return; } - m_allowlist.empend(ByteString(), false, Vector { url }); + m_allowlist.empend(ByteString(), false, Vector { url }); } void ConnectionFromClient::add_allowed_handler_with_any_url(ByteString const& handler_name) @@ -84,10 +84,10 @@ void ConnectionFromClient::add_allowed_handler_with_any_url(ByteString const& ha return; } - m_allowlist.empend(handler_name, true, Vector()); + m_allowlist.empend(handler_name, true, Vector()); } -void ConnectionFromClient::add_allowed_handler_with_only_specific_urls(ByteString const& handler_name, Vector const& urls) +void ConnectionFromClient::add_allowed_handler_with_only_specific_urls(ByteString const& handler_name, Vector const& urls) { if (m_allowlist_is_sealed) { did_misbehave("Got request to add more allowed handlers after list was sealed"); diff --git a/Userland/Services/LaunchServer/ConnectionFromClient.h b/Userland/Services/LaunchServer/ConnectionFromClient.h index 21905da5c63a6d0c304101c01cf6b57ab484c2c6..576f5b55037f5dd8fb4fc752cbadfd0ac69a5532 100644 --- a/Userland/Services/LaunchServer/ConnectionFromClient.h +++ b/Userland/Services/LaunchServer/ConnectionFromClient.h @@ -22,18 +22,18 @@ public: private: explicit ConnectionFromClient(NonnullOwnPtr, int client_id); - virtual Messages::LaunchServer::OpenUrlResponse open_url(URL const&, ByteString const&) override; - virtual Messages::LaunchServer::GetHandlersForUrlResponse get_handlers_for_url(URL const&) override; - virtual Messages::LaunchServer::GetHandlersWithDetailsForUrlResponse get_handlers_with_details_for_url(URL const&) override; - virtual void add_allowed_url(URL const&) override; + virtual Messages::LaunchServer::OpenUrlResponse open_url(URL::URL const&, ByteString const&) override; + virtual Messages::LaunchServer::GetHandlersForUrlResponse get_handlers_for_url(URL::URL const&) override; + virtual Messages::LaunchServer::GetHandlersWithDetailsForUrlResponse get_handlers_with_details_for_url(URL::URL const&) override; + virtual void add_allowed_url(URL::URL const&) override; virtual void add_allowed_handler_with_any_url(ByteString const&) override; - virtual void add_allowed_handler_with_only_specific_urls(ByteString const&, Vector const&) override; + virtual void add_allowed_handler_with_only_specific_urls(ByteString const&, Vector const&) override; virtual void seal_allowlist() override; struct AllowlistEntry { ByteString handler_name; bool any_url { false }; - Vector urls; + Vector urls; }; Vector m_allowlist; diff --git a/Userland/Services/LaunchServer/LaunchClient.ipc b/Userland/Services/LaunchServer/LaunchClient.ipc index 8899709d896bb504114b1ae741ec1314bac4a635..fc0280a775fb921783d1769f79aab684f930a835 100644 --- a/Userland/Services/LaunchServer/LaunchClient.ipc +++ b/Userland/Services/LaunchServer/LaunchClient.ipc @@ -1,4 +1,4 @@ -#include +#include endpoint LaunchClient { diff --git a/Userland/Services/LaunchServer/LaunchServer.ipc b/Userland/Services/LaunchServer/LaunchServer.ipc index 425eab0fe7380cba038ebc4497451d30d5417613..fb1d70b5d6c3dd96ef27e1f35e0660d0c931729e 100644 --- a/Userland/Services/LaunchServer/LaunchServer.ipc +++ b/Userland/Services/LaunchServer/LaunchServer.ipc @@ -1,13 +1,13 @@ -#include +#include endpoint LaunchServer { - open_url(URL url, ByteString handler_name) => (bool response) - get_handlers_for_url(URL url) => (Vector handlers) - get_handlers_with_details_for_url(URL url) => (Vector handlers_details) + open_url(URL::URL url, ByteString handler_name) => (bool response) + get_handlers_for_url(URL::URL url) => (Vector handlers) + get_handlers_with_details_for_url(URL::URL url) => (Vector handlers_details) - add_allowed_url(URL url) => () + add_allowed_url(URL::URL url) => () add_allowed_handler_with_any_url(ByteString handler_name) => () - add_allowed_handler_with_only_specific_urls(ByteString handler_name, Vector urls) => () + add_allowed_handler_with_only_specific_urls(ByteString handler_name, Vector urls) => () seal_allowlist() => () } diff --git a/Userland/Services/LaunchServer/Launcher.cpp b/Userland/Services/LaunchServer/Launcher.cpp index aaffa0c2890a452e50ebcb123fcdb162820940c0..d083aa04a426ef9b0238e1a82d82159a325e43f1 100644 --- a/Userland/Services/LaunchServer/Launcher.cpp +++ b/Userland/Services/LaunchServer/Launcher.cpp @@ -137,7 +137,7 @@ bool Launcher::has_mime_handlers(ByteString const& mime_type) return false; } -Vector Launcher::handlers_for_url(const URL& url) +Vector Launcher::handlers_for_url(const URL::URL& url) { Vector handlers; if (url.scheme() == "file") { @@ -157,7 +157,7 @@ Vector Launcher::handlers_for_url(const URL& url) return handlers; } -Vector Launcher::handlers_with_details_for_url(const URL& url) +Vector Launcher::handlers_with_details_for_url(const URL::URL& url) { Vector handlers; if (url.scheme() == "file") { @@ -186,7 +186,7 @@ Optional Launcher::mime_type_for_file(ByteString path) return Core::guess_mime_type_based_on_sniffed_bytes(*file_or_error.release_value()); } -bool Launcher::open_url(const URL& url, ByteString const& handler_name) +bool Launcher::open_url(const URL::URL& url, ByteString const& handler_name) { if (!handler_name.is_empty()) return open_with_handler_name(url, handler_name); @@ -197,7 +197,7 @@ bool Launcher::open_url(const URL& url, ByteString const& handler_name) return open_with_user_preferences(m_protocol_handlers, url.scheme().to_byte_string(), { url.to_byte_string() }); } -bool Launcher::open_with_handler_name(const URL& url, ByteString const& handler_name) +bool Launcher::open_with_handler_name(const URL::URL& url, ByteString const& handler_name) { auto handler_optional = m_handlers.get(handler_name); if (!handler_optional.has_value()) @@ -346,7 +346,7 @@ void Launcher::for_each_handler_for_path(ByteString const& path, Function #include -#include #include #include +#include namespace LaunchServer { @@ -40,9 +40,9 @@ public: void load_handlers(ByteString const& af_dir = Desktop::AppFile::APP_FILES_DIRECTORY); void load_config(Core::ConfigFile const&); - bool open_url(const URL&, ByteString const& handler_name); - Vector handlers_for_url(const URL&); - Vector handlers_with_details_for_url(const URL&); + bool open_url(const URL::URL&, ByteString const& handler_name); + Vector handlers_for_url(const URL::URL&); + Vector handlers_with_details_for_url(const URL::URL&); private: HashMap m_handlers; @@ -55,8 +55,8 @@ private: Handler get_handler_for_executable(Handler::Type, ByteString const&) const; size_t for_each_handler(ByteString const& key, HashMap const& user_preferences, Function f); void for_each_handler_for_path(ByteString const&, Function f); - bool open_file_url(const URL&); + bool open_file_url(const URL::URL&); bool open_with_user_preferences(HashMap const& user_preferences, ByteString const& key, Vector const& arguments, ByteString const& default_program = {}); - bool open_with_handler_name(const URL&, ByteString const& handler_name); + bool open_with_handler_name(const URL::URL&, ByteString const& handler_name); }; } diff --git a/Userland/Services/RequestServer/CMakeLists.txt b/Userland/Services/RequestServer/CMakeLists.txt index 3b990aa09f087f7a77414348b78aa3c9d408ab43..85711038409e767759174a048213f8816b4f0250 100644 --- a/Userland/Services/RequestServer/CMakeLists.txt +++ b/Userland/Services/RequestServer/CMakeLists.txt @@ -26,4 +26,4 @@ set(GENERATED_SOURCES ) serenity_bin(RequestServer) -target_link_libraries(RequestServer PRIVATE LibCore LibCrypto LibIPC LibGemini LibHTTP LibMain LibTLS LibWebSocket) +target_link_libraries(RequestServer PRIVATE LibCore LibCrypto LibIPC LibGemini LibHTTP LibMain LibTLS LibWebSocket LibURL) diff --git a/Userland/Services/RequestServer/ConnectionCache.cpp b/Userland/Services/RequestServer/ConnectionCache.cpp index 5ac71cdd9a1c6dc7495a7987dae89d4f2e267980..36858d8537468d117560502ec2fd390fbf5f79a2 100644 --- a/Userland/Services/RequestServer/ConnectionCache.cpp +++ b/Userland/Services/RequestServer/ConnectionCache.cpp @@ -15,7 +15,7 @@ HashMap>>>> g_tls_connection_cache {}; HashMap g_inferred_server_properties; -void request_did_finish(URL const& url, Core::Socket const* socket) +void request_did_finish(URL::URL const& url, Core::Socket const* socket) { if (!socket) { dbgln("Request with a null socket finished for URL {}", url); diff --git a/Userland/Services/RequestServer/ConnectionCache.h b/Userland/Services/RequestServer/ConnectionCache.h index cdfeffe0b8f1dd528ec6509327664abc165515c5..2e0c8b15ddf52b021dce998f62643268387d0ecd 100644 --- a/Userland/Services/RequestServer/ConnectionCache.h +++ b/Userland/Services/RequestServer/ConnectionCache.h @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -17,6 +16,7 @@ #include #include #include +#include namespace RequestServer { @@ -34,7 +34,7 @@ struct Proxy { OwnPtr proxy_client_storage {}; template - ErrorOr> tunnel(URL const& url, Args&&... args) + ErrorOr> tunnel(URL::URL const& url, Args&&... args) { if (data.type == Core::ProxyData::Direct) { return TRY(SocketType::connect(TRY(url.serialized_host()).to_byte_string(), url.port_or_default(), forward(args)...)); @@ -94,7 +94,7 @@ struct Connection { QueueType request_queue; NonnullRefPtr removal_timer; bool has_started { false }; - URL current_url {}; + URL::URL current_url {}; Core::ElapsedTimer timer {}; JobData job_data {}; Proxy proxy {}; @@ -129,14 +129,14 @@ extern HashMap>>>> g_tls_connection_cache; extern HashMap g_inferred_server_properties; -void request_did_finish(URL const&, Core::Socket const*); +void request_did_finish(URL::URL const&, Core::Socket const*); void dump_jobs(); constexpr static size_t MaxConcurrentConnectionsPerURL = 4; constexpr static size_t ConnectionKeepAliveTimeMilliseconds = 10'000; template -ErrorOr recreate_socket_if_needed(T& connection, URL const& url) +ErrorOr recreate_socket_if_needed(T& connection, URL::URL const& url) { using SocketType = typename T::SocketType; using SocketStorageType = typename T::StorageType; @@ -176,7 +176,7 @@ ErrorOr recreate_socket_if_needed(T& connection, URL const& url) return {}; } -decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto job, Core::ProxyData proxy_data = {}) +decltype(auto) get_or_create_connection(auto& cache, URL::URL const& url, auto job, Core::ProxyData proxy_data = {}) { using CacheEntryType = RemoveCVReferencevalue)>; diff --git a/Userland/Services/RequestServer/ConnectionFromClient.cpp b/Userland/Services/RequestServer/ConnectionFromClient.cpp index d7162d1fc491133c0fe50a0dfa10075920d76243..0bc2c26ed0fadd2cdda02eae2d13f8551ced9511 100644 --- a/Userland/Services/RequestServer/ConnectionFromClient.cpp +++ b/Userland/Services/RequestServer/ConnectionFromClient.cpp @@ -41,7 +41,7 @@ Messages::RequestServer::IsSupportedProtocolResponse ConnectionFromClient::is_su return supported; } -void ConnectionFromClient::start_request(i32 request_id, ByteString const& method, URL const& url, HashMap const& request_headers, ByteBuffer const& request_body, Core::ProxyData const& proxy_data) +void ConnectionFromClient::start_request(i32 request_id, ByteString const& method, URL::URL const& url, HashMap const& request_headers, ByteBuffer const& request_body, Core::ProxyData const& proxy_data) { if (!url.is_valid()) { dbgln("StartRequest: Invalid URL requested: '{}'", url); @@ -117,7 +117,7 @@ Messages::RequestServer::SetCertificateResponse ConnectionFromClient::set_certif class Job : public RefCounted , public Weakable { public: - static NonnullRefPtr ensure(URL const& url) + static NonnullRefPtr ensure(URL::URL const& url) { RefPtr job; if (auto it = s_jobs.find(url); it != s_jobs.end()) @@ -147,16 +147,16 @@ public: } private: - explicit Job(URL url) + explicit Job(URL::URL url) : m_url(move(url)) { } - URL m_url; - inline static HashMap> s_jobs {}; + URL::URL m_url; + inline static HashMap> s_jobs {}; }; -void ConnectionFromClient::ensure_connection(URL const& url, ::RequestServer::CacheLevel const& cache_level) +void ConnectionFromClient::ensure_connection(URL::URL const& url, ::RequestServer::CacheLevel const& cache_level) { if (!url.is_valid()) { dbgln("EnsureConnection: Invalid URL requested: '{}'", url); @@ -190,7 +190,7 @@ void ConnectionFromClient::ensure_connection(URL const& url, ::RequestServer::Ca } static i32 s_next_websocket_id = 1; -Messages::RequestServer::WebsocketConnectResponse ConnectionFromClient::websocket_connect(URL const& url, ByteString const& origin, Vector const& protocols, Vector const& extensions, HashMap const& additional_request_headers) +Messages::RequestServer::WebsocketConnectResponse ConnectionFromClient::websocket_connect(URL::URL const& url, ByteString const& origin, Vector const& protocols, Vector const& extensions, HashMap const& additional_request_headers) { if (!url.is_valid()) { dbgln("WebSocket::Connect: Invalid URL requested: '{}'", url); diff --git a/Userland/Services/RequestServer/ConnectionFromClient.h b/Userland/Services/RequestServer/ConnectionFromClient.h index 0e6314d3098a0586837809e07316fcc1daf5047b..c34ce44b2d0f45578596ba606dd963df2cfd4965 100644 --- a/Userland/Services/RequestServer/ConnectionFromClient.h +++ b/Userland/Services/RequestServer/ConnectionFromClient.h @@ -33,12 +33,12 @@ private: explicit ConnectionFromClient(NonnullOwnPtr); virtual Messages::RequestServer::IsSupportedProtocolResponse is_supported_protocol(ByteString const&) override; - virtual void start_request(i32 request_id, ByteString const&, URL const&, HashMap const&, ByteBuffer const&, Core::ProxyData const&) override; + virtual void start_request(i32 request_id, ByteString const&, URL::URL const&, HashMap const&, ByteBuffer const&, Core::ProxyData const&) override; virtual Messages::RequestServer::StopRequestResponse stop_request(i32) override; virtual Messages::RequestServer::SetCertificateResponse set_certificate(i32, ByteString const&, ByteString const&) override; - virtual void ensure_connection(URL const& url, ::RequestServer::CacheLevel const& cache_level) override; + virtual void ensure_connection(URL::URL const& url, ::RequestServer::CacheLevel const& cache_level) override; - virtual Messages::RequestServer::WebsocketConnectResponse websocket_connect(URL const&, ByteString const&, Vector const&, Vector const&, HashMap const&) override; + virtual Messages::RequestServer::WebsocketConnectResponse websocket_connect(URL::URL const&, ByteString const&, Vector const&, Vector const&, HashMap const&) override; virtual Messages::RequestServer::WebsocketReadyStateResponse websocket_ready_state(i32) override; virtual Messages::RequestServer::WebsocketSubprotocolInUseResponse websocket_subprotocol_in_use(i32) override; virtual void websocket_send(i32, bool, ByteBuffer const&) override; diff --git a/Userland/Services/RequestServer/GeminiProtocol.cpp b/Userland/Services/RequestServer/GeminiProtocol.cpp index 99b67daba838fb9f0f754e27c0c843c954a4eeaf..9c79d8ed3ee92a837a70b567fbee068d004107f0 100644 --- a/Userland/Services/RequestServer/GeminiProtocol.cpp +++ b/Userland/Services/RequestServer/GeminiProtocol.cpp @@ -17,7 +17,7 @@ GeminiProtocol::GeminiProtocol() { } -OwnPtr GeminiProtocol::start_request(i32 request_id, ConnectionFromClient& client, ByteString const&, const URL& url, HashMap const&, ReadonlyBytes, Core::ProxyData proxy_data) +OwnPtr GeminiProtocol::start_request(i32 request_id, ConnectionFromClient& client, ByteString const&, const URL::URL& url, HashMap const&, ReadonlyBytes, Core::ProxyData proxy_data) { Gemini::GeminiRequest request; request.set_url(url); diff --git a/Userland/Services/RequestServer/GeminiProtocol.h b/Userland/Services/RequestServer/GeminiProtocol.h index fff3142b597ad4c719ceb9f4787bf5968fce5ece..58389280863f6f6c2fe3b0281562f6a7a5d05869 100644 --- a/Userland/Services/RequestServer/GeminiProtocol.h +++ b/Userland/Services/RequestServer/GeminiProtocol.h @@ -19,7 +19,7 @@ public: private: GeminiProtocol(); - virtual OwnPtr start_request(i32, ConnectionFromClient&, ByteString const& method, const URL&, HashMap const&, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override; + virtual OwnPtr start_request(i32, ConnectionFromClient&, ByteString const& method, const URL::URL&, HashMap const&, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override; }; } diff --git a/Userland/Services/RequestServer/GeminiRequest.h b/Userland/Services/RequestServer/GeminiRequest.h index ca46e3710823e62075d8c5cb55bdead2ba8a50af..1a27b116a86399d77b54d7cff94c3a742c24cfaf 100644 --- a/Userland/Services/RequestServer/GeminiRequest.h +++ b/Userland/Services/RequestServer/GeminiRequest.h @@ -20,7 +20,7 @@ public: Gemini::Job const& job() const { return *m_job; } - virtual URL url() const override { return m_job->url(); } + virtual URL::URL url() const override { return m_job->url(); } private: explicit GeminiRequest(ConnectionFromClient&, NonnullRefPtr, NonnullOwnPtr&&, i32 request_id); diff --git a/Userland/Services/RequestServer/HttpCommon.h b/Userland/Services/RequestServer/HttpCommon.h index 77bed46dea465ea778d428fc6aab6bdbb6087c86..386991012a0055b1169ddc642df048cfd9966807 100644 --- a/Userland/Services/RequestServer/HttpCommon.h +++ b/Userland/Services/RequestServer/HttpCommon.h @@ -61,7 +61,7 @@ void init(TSelf* self, TJob job) } template -OwnPtr start_request(TBadgedProtocol&& protocol, i32 request_id, ConnectionFromClient& client, ByteString const& method, const URL& url, HashMap const& headers, ReadonlyBytes body, TPipeResult&& pipe_result, Core::ProxyData proxy_data = {}) +OwnPtr start_request(TBadgedProtocol&& protocol, i32 request_id, ConnectionFromClient& client, ByteString const& method, const URL::URL& url, HashMap const& headers, ReadonlyBytes body, TPipeResult&& pipe_result, Core::ProxyData proxy_data = {}) { using TJob = typename TBadgedProtocol::Type::JobType; using TRequest = typename TBadgedProtocol::Type::RequestType; diff --git a/Userland/Services/RequestServer/HttpProtocol.cpp b/Userland/Services/RequestServer/HttpProtocol.cpp index 726deb9c0c3b361a1acbd64429840ee35af19cd1..22b07fb907be5a15c71c1e50be7fe8ae3b4be24d 100644 --- a/Userland/Services/RequestServer/HttpProtocol.cpp +++ b/Userland/Services/RequestServer/HttpProtocol.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -22,7 +22,7 @@ HttpProtocol::HttpProtocol() { } -OwnPtr HttpProtocol::start_request(i32 request_id, ConnectionFromClient& client, ByteString const& method, const URL& url, HashMap const& headers, ReadonlyBytes body, Core::ProxyData proxy_data) +OwnPtr HttpProtocol::start_request(i32 request_id, ConnectionFromClient& client, ByteString const& method, const URL::URL& url, HashMap const& headers, ReadonlyBytes body, Core::ProxyData proxy_data) { return Detail::start_request(Badge {}, request_id, client, method, url, headers, body, get_pipe_for_request(), proxy_data); } diff --git a/Userland/Services/RequestServer/HttpProtocol.h b/Userland/Services/RequestServer/HttpProtocol.h index c868b78b42b759de82169991b59e185b5aaf7a19..aa791d26e72b8d8899607c30d296248dd18a83a1 100644 --- a/Userland/Services/RequestServer/HttpProtocol.h +++ b/Userland/Services/RequestServer/HttpProtocol.h @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -31,7 +31,7 @@ public: private: HttpProtocol(); - virtual OwnPtr start_request(i32, ConnectionFromClient&, ByteString const& method, const URL&, HashMap const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override; + virtual OwnPtr start_request(i32, ConnectionFromClient&, ByteString const& method, const URL::URL&, HashMap const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override; }; } diff --git a/Userland/Services/RequestServer/HttpRequest.h b/Userland/Services/RequestServer/HttpRequest.h index f91527820aaba91fe8e79229f765e9764e08becb..1f25d9dd7cdeca02f547043f97c3a843a3666e66 100644 --- a/Userland/Services/RequestServer/HttpRequest.h +++ b/Userland/Services/RequestServer/HttpRequest.h @@ -22,7 +22,7 @@ public: HTTP::Job& job() { return m_job; } HTTP::Job const& job() const { return m_job; } - virtual URL url() const override { return m_job->url(); } + virtual URL::URL url() const override { return m_job->url(); } private: explicit HttpRequest(ConnectionFromClient&, NonnullRefPtr, NonnullOwnPtr&&, i32); diff --git a/Userland/Services/RequestServer/HttpsProtocol.cpp b/Userland/Services/RequestServer/HttpsProtocol.cpp index 3524465e457e2ef5ac2372328738c3a3332d6111..4dcaf38d832e611cac6d1e3d717fe670291ce096 100644 --- a/Userland/Services/RequestServer/HttpsProtocol.cpp +++ b/Userland/Services/RequestServer/HttpsProtocol.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -22,7 +22,7 @@ HttpsProtocol::HttpsProtocol() { } -OwnPtr HttpsProtocol::start_request(i32 request_id, ConnectionFromClient& client, ByteString const& method, const URL& url, HashMap const& headers, ReadonlyBytes body, Core::ProxyData proxy_data) +OwnPtr HttpsProtocol::start_request(i32 request_id, ConnectionFromClient& client, ByteString const& method, const URL::URL& url, HashMap const& headers, ReadonlyBytes body, Core::ProxyData proxy_data) { return Detail::start_request(Badge {}, request_id, client, method, url, headers, body, get_pipe_for_request(), proxy_data); } diff --git a/Userland/Services/RequestServer/HttpsProtocol.h b/Userland/Services/RequestServer/HttpsProtocol.h index 34c7350aded0ec7cedf39c85cf05b09f4a2479b0..572f1c0a10387b028dca115704787e5141a5806a 100644 --- a/Userland/Services/RequestServer/HttpsProtocol.h +++ b/Userland/Services/RequestServer/HttpsProtocol.h @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -31,7 +31,7 @@ public: private: HttpsProtocol(); - virtual OwnPtr start_request(i32, ConnectionFromClient&, ByteString const& method, const URL&, HashMap const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override; + virtual OwnPtr start_request(i32, ConnectionFromClient&, ByteString const& method, const URL::URL&, HashMap const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override; }; } diff --git a/Userland/Services/RequestServer/HttpsRequest.h b/Userland/Services/RequestServer/HttpsRequest.h index eff62c607bd73d60ee8e3e8213cbd12e4e8e096f..146d1d8a8db385fd70f2155428b114b8604f4aff 100644 --- a/Userland/Services/RequestServer/HttpsRequest.h +++ b/Userland/Services/RequestServer/HttpsRequest.h @@ -21,7 +21,7 @@ public: HTTP::HttpsJob& job() { return m_job; } HTTP::HttpsJob const& job() const { return m_job; } - virtual URL url() const override { return m_job->url(); } + virtual URL::URL url() const override { return m_job->url(); } private: explicit HttpsRequest(ConnectionFromClient&, NonnullRefPtr, NonnullOwnPtr&&, i32); diff --git a/Userland/Services/RequestServer/Protocol.h b/Userland/Services/RequestServer/Protocol.h index 0637a6810b189464e1b1b44573885a2369790cbd..5883f5051815b7e70a519b76533eabfad1d8068d 100644 --- a/Userland/Services/RequestServer/Protocol.h +++ b/Userland/Services/RequestServer/Protocol.h @@ -7,8 +7,8 @@ #pragma once #include -#include #include +#include #include namespace RequestServer { @@ -18,7 +18,7 @@ public: virtual ~Protocol() = default; ByteString const& name() const { return m_name; } - virtual OwnPtr start_request(i32, ConnectionFromClient&, ByteString const& method, const URL&, HashMap const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) = 0; + virtual OwnPtr start_request(i32, ConnectionFromClient&, ByteString const& method, const URL::URL&, HashMap const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) = 0; static Protocol* find_by_name(ByteString const&); diff --git a/Userland/Services/RequestServer/Request.h b/Userland/Services/RequestServer/Request.h index 364ed1219e853881c1d71bb580a0c668526665b8..4d0001a7657d54b9a3eb0c9510dc030bc4fb080d 100644 --- a/Userland/Services/RequestServer/Request.h +++ b/Userland/Services/RequestServer/Request.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include namespace RequestServer { @@ -20,7 +20,7 @@ public: virtual ~Request() = default; i32 id() const { return m_id; } - virtual URL url() const = 0; + virtual URL::URL url() const = 0; Optional status_code() const { return m_status_code; } Optional total_size() const { return m_total_size; } diff --git a/Userland/Services/RequestServer/RequestClient.ipc b/Userland/Services/RequestServer/RequestClient.ipc index de7f08e15ec0ec02d8979485fbe9e28016fe613e..50ba3e7d3932875f9fb73a20b19039107dd53ae3 100644 --- a/Userland/Services/RequestServer/RequestClient.ipc +++ b/Userland/Services/RequestServer/RequestClient.ipc @@ -1,4 +1,4 @@ -#include +#include endpoint RequestClient { diff --git a/Userland/Services/RequestServer/RequestServer.ipc b/Userland/Services/RequestServer/RequestServer.ipc index 2be236f11f5da62bfa57fbb65a669f2763bff303..ae0bccc68d3c1a80bf102c351d5fbfcc6a960346 100644 --- a/Userland/Services/RequestServer/RequestServer.ipc +++ b/Userland/Services/RequestServer/RequestServer.ipc @@ -1,4 +1,4 @@ -#include +#include #include endpoint RequestServer @@ -6,14 +6,14 @@ endpoint RequestServer // Test if a specific protocol is supported, e.g "http" is_supported_protocol(ByteString protocol) => (bool supported) - start_request(i32 request_id, ByteString method, URL url, HashMap request_headers, ByteBuffer request_body, Core::ProxyData proxy_data) =| + start_request(i32 request_id, ByteString method, URL::URL url, HashMap request_headers, ByteBuffer request_body, Core::ProxyData proxy_data) =| stop_request(i32 request_id) => (bool success) set_certificate(i32 request_id, ByteString certificate, ByteString key) => (bool success) - ensure_connection(URL url, ::RequestServer::CacheLevel cache_level) =| + ensure_connection(URL::URL url, ::RequestServer::CacheLevel cache_level) =| // Websocket Connection API - websocket_connect(URL url, ByteString origin, Vector protocols, Vector extensions, HashMap additional_request_headers) => (i32 connection_id) + websocket_connect(URL::URL url, ByteString origin, Vector protocols, Vector extensions, HashMap additional_request_headers) => (i32 connection_id) websocket_ready_state(i32 connection_id) => (u32 ready_state) websocket_subprotocol_in_use(i32 connection_id) => (ByteString subprotocol_in_use) websocket_send(i32 connection_id, bool is_text, ByteBuffer data) =| diff --git a/Userland/Services/SpiceAgent/CMakeLists.txt b/Userland/Services/SpiceAgent/CMakeLists.txt index 9702ef01d475dae1b2532c904c5b8a9455608a54..fc5315c14ad5cd41d9a4b078ed2bcc8b2298cea7 100644 --- a/Userland/Services/SpiceAgent/CMakeLists.txt +++ b/Userland/Services/SpiceAgent/CMakeLists.txt @@ -11,5 +11,5 @@ set(SOURCES ) serenity_bin(SpiceAgent) -target_link_libraries(SpiceAgent PRIVATE LibCore LibDesktop LibFileSystem LibGfx LibGUI LibMain) +target_link_libraries(SpiceAgent PRIVATE LibCore LibDesktop LibFileSystem LibGfx LibGUI LibMain LibURL) add_dependencies(SpiceAgent Clipboard) diff --git a/Userland/Services/SpiceAgent/FileTransferOperation.cpp b/Userland/Services/SpiceAgent/FileTransferOperation.cpp index b1fde1134d531204dbe11f01dace586960eb5b77..54f2eaaec200215310870b93500d204fc122364a 100644 --- a/Userland/Services/SpiceAgent/FileTransferOperation.cpp +++ b/Userland/Services/SpiceAgent/FileTransferOperation.cpp @@ -6,10 +6,10 @@ #include "FileTransferOperation.h" #include "SpiceAgent.h" -#include #include #include #include +#include namespace SpiceAgent { diff --git a/Userland/Services/SpiceAgent/main.cpp b/Userland/Services/SpiceAgent/main.cpp index e897172fbfd73013ddc0dc353631cf61e18ac2f8..c0a1c22f0ea0ce51993b697285292a9efd8b1028 100644 --- a/Userland/Services/SpiceAgent/main.cpp +++ b/Userland/Services/SpiceAgent/main.cpp @@ -6,7 +6,6 @@ */ #include "SpiceAgent.h" -#include #include #include #include @@ -15,6 +14,7 @@ #include #include #include +#include #include static constexpr auto SPICE_DEVICE = "/dev/hvc0p1"sv; diff --git a/Userland/Services/Taskbar/CMakeLists.txt b/Userland/Services/Taskbar/CMakeLists.txt index 21927d3cc522e8816aec480f705cf2d107e47148..e362030ec6c124d557e677cd9484c2a213cff937 100644 --- a/Userland/Services/Taskbar/CMakeLists.txt +++ b/Userland/Services/Taskbar/CMakeLists.txt @@ -15,5 +15,5 @@ set(SOURCES ) serenity_bin(Taskbar) -target_link_libraries(Taskbar PRIVATE LibCore LibGfx LibGUI LibDesktop LibConfig LibIPC LibMain) +target_link_libraries(Taskbar PRIVATE LibCore LibGfx LibGUI LibDesktop LibConfig LibIPC LibMain LibURL) serenity_install_headers(Services/Taskbar) diff --git a/Userland/Services/WebContent/CMakeLists.txt b/Userland/Services/WebContent/CMakeLists.txt index ca4f95f73286ac12d5d47c398ff0738feb89ca3f..c4c618295d9003b548d23b7959741e00b89a26ec 100644 --- a/Userland/Services/WebContent/CMakeLists.txt +++ b/Userland/Services/WebContent/CMakeLists.txt @@ -31,7 +31,7 @@ set(GENERATED_SOURCES ) serenity_bin(WebContent) -target_link_libraries(WebContent PRIVATE LibCore LibFileSystem LibIPC LibGfx LibAudio LibImageDecoderClient LibJS LibWebView LibWeb LibLocale LibMain) +target_link_libraries(WebContent PRIVATE LibCore LibFileSystem LibIPC LibGfx LibAudio LibImageDecoderClient LibJS LibWebView LibWeb LibLocale LibMain LibURL) link_with_locale_data(WebContent) if (HAS_ACCELERATED_GRAPHICS) diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index 5f077ac5ddca9ffd399df550734b930d4481a8a0..1b9dbfbd31b750f6f7dc1427a818359a823983a7 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -148,7 +148,7 @@ void ConnectionFromClient::update_screen_rects(u64 page_id, Vector const&, u32) override; - virtual void load_url(u64 page_id, URL const&) override; + virtual void load_url(u64 page_id, URL::URL const&) override; virtual void load_html(u64 page_id, ByteString const&) override; virtual void set_viewport_rect(u64 page_id, Web::DevicePixelRect const&) override; virtual void key_event(u64 page_id, Web::KeyEvent const&) override; diff --git a/Userland/Services/WebContent/PageClient.cpp b/Userland/Services/WebContent/PageClient.cpp index cc7d5ccdf2f4e0c46c478c41530048efcf3eaa98..5420ac63e46844a6e2823a0f3ec7cf09aeb73bc7 100644 --- a/Userland/Services/WebContent/PageClient.cpp +++ b/Userland/Services/WebContent/PageClient.cpp @@ -318,7 +318,7 @@ void PageClient::page_did_leave_tooltip_area() client().async_did_leave_tooltip_area(m_id); } -void PageClient::page_did_hover_link(const URL& url) +void PageClient::page_did_hover_link(const URL::URL& url) { client().async_did_hover_link(m_id, url); } @@ -328,12 +328,12 @@ void PageClient::page_did_unhover_link() client().async_did_unhover_link(m_id); } -void PageClient::page_did_middle_click_link(const URL& url, [[maybe_unused]] ByteString const& target, [[maybe_unused]] unsigned modifiers) +void PageClient::page_did_middle_click_link(const URL::URL& url, [[maybe_unused]] ByteString const& target, [[maybe_unused]] unsigned modifiers) { client().async_did_middle_click_link(m_id, url, target, modifiers); } -void PageClient::page_did_start_loading(const URL& url, bool is_redirect) +void PageClient::page_did_start_loading(const URL::URL& url, bool is_redirect) { client().async_did_start_loading(m_id, url, is_redirect); } @@ -348,7 +348,7 @@ void PageClient::page_did_destroy_document(Web::DOM::Document& document) destroy_js_console(document); } -void PageClient::page_did_finish_loading(const URL& url) +void PageClient::page_did_finish_loading(const URL::URL& url) { client().async_did_finish_loading(m_id, url); } @@ -363,12 +363,12 @@ void PageClient::page_did_request_context_menu(Web::CSSPixelPoint content_positi client().async_did_request_context_menu(m_id, page().css_to_device_point(content_position).to_type()); } -void PageClient::page_did_request_link_context_menu(Web::CSSPixelPoint content_position, URL const& url, ByteString const& target, unsigned modifiers) +void PageClient::page_did_request_link_context_menu(Web::CSSPixelPoint content_position, URL::URL const& url, ByteString const& target, unsigned modifiers) { client().async_did_request_link_context_menu(m_id, page().css_to_device_point(content_position).to_type(), url, target, modifiers); } -void PageClient::page_did_request_image_context_menu(Web::CSSPixelPoint content_position, URL const& url, ByteString const& target, unsigned modifiers, Gfx::Bitmap const* bitmap_pointer) +void PageClient::page_did_request_image_context_menu(Web::CSSPixelPoint content_position, URL::URL const& url, ByteString const& target, unsigned modifiers, Gfx::Bitmap const* bitmap_pointer) { auto bitmap = bitmap_pointer ? bitmap_pointer->to_shareable_bitmap() : Gfx::ShareableBitmap(); client().async_did_request_image_context_menu(m_id, page().css_to_device_point(content_position).to_type(), url, target, modifiers, bitmap); @@ -464,17 +464,17 @@ void PageClient::page_did_change_favicon(Gfx::Bitmap const& favicon) client().async_did_change_favicon(m_id, favicon.to_shareable_bitmap()); } -Vector PageClient::page_did_request_all_cookies(URL const& url) +Vector PageClient::page_did_request_all_cookies(URL::URL const& url) { return client().did_request_all_cookies(m_id, url); } -Optional PageClient::page_did_request_named_cookie(URL const& url, String const& name) +Optional PageClient::page_did_request_named_cookie(URL::URL const& url, String const& name) { return client().did_request_named_cookie(m_id, url, name); } -String PageClient::page_did_request_cookie(const URL& url, Web::Cookie::Source source) +String PageClient::page_did_request_cookie(const URL::URL& url, Web::Cookie::Source source) { auto response = client().send_sync_but_allow_failure(m_id, move(url), source); if (!response) { @@ -484,7 +484,7 @@ String PageClient::page_did_request_cookie(const URL& url, Web::Cookie::Source s return response->take_cookie(); } -void PageClient::page_did_set_cookie(const URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) +void PageClient::page_did_set_cookie(const URL::URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) { auto response = client().send_sync_but_allow_failure(m_id, url, cookie, source); if (!response) { diff --git a/Userland/Services/WebContent/PageClient.h b/Userland/Services/WebContent/PageClient.h index 2faffb90b7fa5e1086003957c81294bc0bded319..fa30eed1e820eb13d836c73795b5d0aa224cb91b 100644 --- a/Userland/Services/WebContent/PageClient.h +++ b/Userland/Services/WebContent/PageClient.h @@ -105,17 +105,17 @@ private: virtual void page_did_request_scroll_to(Web::CSSPixelPoint) override; virtual void page_did_enter_tooltip_area(Web::CSSPixelPoint, ByteString const&) override; virtual void page_did_leave_tooltip_area() override; - virtual void page_did_hover_link(const URL&) override; + virtual void page_did_hover_link(const URL::URL&) override; virtual void page_did_unhover_link() override; - virtual void page_did_middle_click_link(const URL&, ByteString const& target, unsigned modifiers) override; + virtual void page_did_middle_click_link(const URL::URL&, ByteString const& target, unsigned modifiers) override; virtual void page_did_request_context_menu(Web::CSSPixelPoint) override; - virtual void page_did_request_link_context_menu(Web::CSSPixelPoint, URL const&, ByteString const& target, unsigned modifiers) override; - virtual void page_did_request_image_context_menu(Web::CSSPixelPoint, const URL&, ByteString const& target, unsigned modifiers, Gfx::Bitmap const*) override; + virtual void page_did_request_link_context_menu(Web::CSSPixelPoint, URL::URL const&, ByteString const& target, unsigned modifiers) override; + virtual void page_did_request_image_context_menu(Web::CSSPixelPoint, const URL::URL&, ByteString const& target, unsigned modifiers, Gfx::Bitmap const*) override; virtual void page_did_request_media_context_menu(Web::CSSPixelPoint, ByteString const& target, unsigned modifiers, Web::Page::MediaContextMenu) override; - virtual void page_did_start_loading(const URL&, bool) override; + virtual void page_did_start_loading(const URL::URL&, bool) override; virtual void page_did_create_new_document(Web::DOM::Document&) override; virtual void page_did_destroy_document(Web::DOM::Document&) override; - virtual void page_did_finish_loading(const URL&) override; + virtual void page_did_finish_loading(const URL::URL&) override; virtual void page_did_request_alert(String const&) override; virtual void page_did_request_confirm(String const&) override; virtual void page_did_request_prompt(String const&, String const&) override; @@ -123,10 +123,10 @@ private: virtual void page_did_request_accept_dialog() override; virtual void page_did_request_dismiss_dialog() override; virtual void page_did_change_favicon(Gfx::Bitmap const&) override; - virtual Vector page_did_request_all_cookies(URL const&) override; - virtual Optional page_did_request_named_cookie(URL const&, String const&) override; - virtual String page_did_request_cookie(const URL&, Web::Cookie::Source) override; - virtual void page_did_set_cookie(const URL&, Web::Cookie::ParsedCookie const&, Web::Cookie::Source) override; + virtual Vector page_did_request_all_cookies(URL::URL const&) override; + virtual Optional page_did_request_named_cookie(URL::URL const&, String const&) override; + virtual String page_did_request_cookie(const URL::URL&, Web::Cookie::Source) override; + virtual void page_did_set_cookie(const URL::URL&, Web::Cookie::ParsedCookie const&, Web::Cookie::Source) override; virtual void page_did_update_cookie(Web::Cookie::Cookie) override; virtual void page_did_update_resource_count(i32) override; virtual NewWebViewResult page_did_request_new_web_view(Web::HTML::ActivateTab, Web::HTML::WebViewHints, Web::HTML::TokenizedFeature::NoOpener) override; diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index 09473f6c8fc31461c5035eac30e79743bfed19d0..d1044ca2f812d731931f4e205feff35333bc2e85 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -19,7 +19,7 @@ PageHost::PageHost(ConnectionFromClient& client) : m_client(client) { auto& first_page = create_page(); - Web::HTML::TraversableNavigable::create_a_fresh_top_level_traversable(first_page.page(), URL("about:blank")).release_value_but_fixme_should_propagate_errors(); + Web::HTML::TraversableNavigable::create_a_fresh_top_level_traversable(first_page.page(), URL::URL("about:blank")).release_value_but_fixme_should_propagate_errors(); } PageClient& PageHost::create_page() diff --git a/Userland/Services/WebContent/WebContentClient.ipc b/Userland/Services/WebContent/WebContentClient.ipc index 853ecbd4fa4a677973db9d285c480f456a828e6d..7da0fec32a19fee1e4db4c05a2d31aec685ce6e5 100644 --- a/Userland/Services/WebContent/WebContentClient.ipc +++ b/Userland/Services/WebContent/WebContentClient.ipc @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -16,8 +16,8 @@ endpoint WebContentClient { - did_start_loading(u64 page_id, URL url, bool is_redirect) =| - did_finish_loading(u64 page_id, URL url) =| + did_start_loading(u64 page_id, URL::URL url, bool is_redirect) =| + did_finish_loading(u64 page_id, URL::URL url) =| did_request_navigate_back(u64 page_id) =| did_request_navigate_forward(u64 page_id) =| did_request_refresh(u64 page_id) =| @@ -29,13 +29,13 @@ endpoint WebContentClient did_request_scroll_to(u64 page_id, Gfx::IntPoint scroll_position) =| did_enter_tooltip_area(u64 page_id, Gfx::IntPoint content_position, ByteString title) =| did_leave_tooltip_area(u64 page_id) =| - did_hover_link(u64 page_id, URL url) =| + did_hover_link(u64 page_id, URL::URL url) =| did_unhover_link(u64 page_id) =| - did_click_link(u64 page_id, URL url, ByteString target, unsigned modifiers) =| - did_middle_click_link(u64 page_id, URL url, ByteString target, unsigned modifiers) =| + did_click_link(u64 page_id, URL::URL url, ByteString target, unsigned modifiers) =| + did_middle_click_link(u64 page_id, URL::URL url, ByteString target, unsigned modifiers) =| did_request_context_menu(u64 page_id, Gfx::IntPoint content_position) =| - did_request_link_context_menu(u64 page_id, Gfx::IntPoint content_position, URL url, ByteString target, unsigned modifiers) =| - did_request_image_context_menu(u64 page_id, Gfx::IntPoint content_position, URL url, ByteString target, unsigned modifiers, Gfx::ShareableBitmap bitmap) =| + did_request_link_context_menu(u64 page_id, Gfx::IntPoint content_position, URL::URL url, ByteString target, unsigned modifiers) =| + did_request_image_context_menu(u64 page_id, Gfx::IntPoint content_position, URL::URL url, ByteString target, unsigned modifiers, Gfx::ShareableBitmap bitmap) =| did_request_media_context_menu(u64 page_id, Gfx::IntPoint content_position, ByteString target, unsigned modifiers, Web::Page::MediaContextMenu menu) =| did_request_alert(u64 page_id, String message) =| did_request_confirm(u64 page_id, String message) =| @@ -43,7 +43,7 @@ endpoint WebContentClient did_request_set_prompt_text(u64 page_id, String message) =| did_request_accept_dialog(u64 page_id) =| did_request_dismiss_dialog(u64 page_id) =| - did_get_source(u64 page_id, URL url, ByteString source) =| + did_get_source(u64 page_id, URL::URL url, ByteString source) =| did_inspect_dom_tree(u64 page_id, ByteString dom_tree) =| did_inspect_dom_node(u64 page_id, bool has_style, ByteString computed_style, ByteString resolved_style, ByteString custom_properties, ByteString node_box_sizing, ByteString aria_properties_state) =| @@ -55,10 +55,10 @@ endpoint WebContentClient did_take_screenshot(u64 page_id, Gfx::ShareableBitmap screenshot) =| did_change_favicon(u64 page_id, Gfx::ShareableBitmap favicon) =| - did_request_all_cookies(u64 page_id, URL url) => (Vector cookies) - did_request_named_cookie(u64 page_id, URL url, String name) => (Optional cookie) - did_request_cookie(u64 page_id, URL url, Web::Cookie::Source source) => (String cookie) - did_set_cookie(u64 page_id, URL url, Web::Cookie::ParsedCookie cookie, Web::Cookie::Source source) => () + did_request_all_cookies(u64 page_id, URL::URL url) => (Vector cookies) + did_request_named_cookie(u64 page_id, URL::URL url, String name) => (Optional cookie) + did_request_cookie(u64 page_id, URL::URL url, Web::Cookie::Source source) => (String cookie) + did_set_cookie(u64 page_id, URL::URL url, Web::Cookie::ParsedCookie cookie, Web::Cookie::Source source) => () did_update_cookie(u64 page_id, Web::Cookie::Cookie cookie) =| did_update_resource_count(u64 page_id, i32 count_waiting) =| did_request_new_web_view(u64 page_id, Web::HTML::ActivateTab activate_tab, Web::HTML::WebViewHints hints, Optional page_index) => (String handle) diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc index 6479244f31f0650aa1fbd0b2dade2185dc52ad3e..94bf06292fad4bbdd802e8bc63ed7d1138fdbfa4 100644 --- a/Userland/Services/WebContent/WebContentServer.ipc +++ b/Userland/Services/WebContent/WebContentServer.ipc @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -22,7 +22,7 @@ endpoint WebContentServer update_system_fonts(u64 page_id, ByteString default_font_query, ByteString fixed_width_font_query, ByteString window_title_font_query) =| update_screen_rects(u64 page_id, Vector rects, u32 main_screen_index) =| - load_url(u64 page_id, URL url) =| + load_url(u64 page_id, URL::URL url) =| load_html(u64 page_id, ByteString html) =| add_backing_store(u64 page_id, i32 front_bitmap_id, Gfx::ShareableBitmap front_bitmap, i32 back_bitmap_id, Gfx::ShareableBitmap back_bitmap) =| diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index 663007ff425122b660162267a20050c2a083df29..72abfda48886d08f36331cb6270cebc8d580944c 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -403,7 +403,7 @@ Messages::WebDriverClient::NavigateToResponse WebDriverConnection::navigate_to(J // 2. Let url be the result of getting the property url from the parameters argument. if (!payload.is_object() || !payload.as_object().has_string("url"sv)) return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload doesn't have a string `url`"sv); - URL url(payload.as_object().get_byte_string("url"sv).value()); + URL::URL url(payload.as_object().get_byte_string("url"sv).value()); // FIXME: 3. If url is not an absolute URL or is not an absolute URL with fragment or not a local scheme, return error with error code invalid argument. diff --git a/Userland/Services/WebDriver/CMakeLists.txt b/Userland/Services/WebDriver/CMakeLists.txt index e4650956f3e6da706ccdf065fd4e4436faaa9758..9d5d01605590a1527365bc9fde21b959687ac14c 100644 --- a/Userland/Services/WebDriver/CMakeLists.txt +++ b/Userland/Services/WebDriver/CMakeLists.txt @@ -17,4 +17,4 @@ set(GENERATED_SOURCES ) serenity_bin(WebDriver) -target_link_libraries(WebDriver PRIVATE LibCore LibHTTP LibMain LibIPC LibWeb LibGfx LibWebView) +target_link_libraries(WebDriver PRIVATE LibCore LibHTTP LibMain LibIPC LibWeb LibGfx LibWebView LibURL) diff --git a/Userland/Services/WebServer/CMakeLists.txt b/Userland/Services/WebServer/CMakeLists.txt index d788dec1e4d60af90a80949132c7af7400df86c6..313590acfc4d5adda7fa19d37943cd5caa34567a 100644 --- a/Userland/Services/WebServer/CMakeLists.txt +++ b/Userland/Services/WebServer/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_bin(WebServer) -target_link_libraries(WebServer PRIVATE LibCore LibFileSystem LibHTTP LibMain) +target_link_libraries(WebServer PRIVATE LibCore LibFileSystem LibHTTP LibMain LibURL) diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp index ebc56823e99740fcba8723244e2f11b087b1bac4..4ca4996c3874e682250f58e5b5c1972d444e4399 100644 --- a/Userland/Services/WebServer/Client.cpp +++ b/Userland/Services/WebServer/Client.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Services/WebWorker/CMakeLists.txt b/Userland/Services/WebWorker/CMakeLists.txt index 2e706f5eca8bfdb4625826a44e4b52daba46980f..71829d3408531b8a4981e6b99105d37b742ea6ca 100644 --- a/Userland/Services/WebWorker/CMakeLists.txt +++ b/Userland/Services/WebWorker/CMakeLists.txt @@ -17,5 +17,5 @@ set(GENERATED_SOURCES ) serenity_bin(WebWorker) -target_link_libraries(WebWorker PRIVATE LibCore LibFileSystem LibGfx LibIPC LibJS LibWeb LibWebView LibLocale LibMain) +target_link_libraries(WebWorker PRIVATE LibCore LibFileSystem LibGfx LibIPC LibJS LibWeb LibWebView LibLocale LibMain LibURL) link_with_locale_data(WebWorker) diff --git a/Userland/Services/WebWorker/ConnectionFromClient.cpp b/Userland/Services/WebWorker/ConnectionFromClient.cpp index df923a8100fd7581e3e4793245d3a52e4a5ec994..4110e4a557a3275f268e71aa495359386b55608f 100644 --- a/Userland/Services/WebWorker/ConnectionFromClient.cpp +++ b/Userland/Services/WebWorker/ConnectionFromClient.cpp @@ -52,7 +52,7 @@ Web::Page const& ConnectionFromClient::page() const return m_page_host->page(); } -void ConnectionFromClient::start_dedicated_worker(URL const& url, String const& type, String const&, String const&, Web::HTML::TransferDataHolder const& implicit_port, Web::HTML::SerializedEnvironmentSettingsObject const& outside_settings) +void ConnectionFromClient::start_dedicated_worker(URL::URL const& url, String const& type, String const&, String const&, Web::HTML::TransferDataHolder const& implicit_port, Web::HTML::SerializedEnvironmentSettingsObject const& outside_settings) { m_worker_host = make_ref_counted(url, type); // FIXME: Yikes, const_cast to move? Feels like a LibIPC bug. diff --git a/Userland/Services/WebWorker/ConnectionFromClient.h b/Userland/Services/WebWorker/ConnectionFromClient.h index cf240a2d244a3e5e863823767865281b8d522f6f..f74b0e9b4212fa5a5b94bb236c4d5bbc28109e09 100644 --- a/Userland/Services/WebWorker/ConnectionFromClient.h +++ b/Userland/Services/WebWorker/ConnectionFromClient.h @@ -39,7 +39,7 @@ private: Web::Page& page(); Web::Page const& page() const; - virtual void start_dedicated_worker(URL const& url, String const&, String const&, String const&, Web::HTML::TransferDataHolder const&, Web::HTML::SerializedEnvironmentSettingsObject const&) override; + virtual void start_dedicated_worker(URL::URL const& url, String const&, String const&, String const&, Web::HTML::TransferDataHolder const&, Web::HTML::SerializedEnvironmentSettingsObject const&) override; virtual void handle_file_return(i32 error, Optional const& file, i32 request_id) override; JS::Handle m_page_host; diff --git a/Userland/Services/WebWorker/DedicatedWorkerHost.cpp b/Userland/Services/WebWorker/DedicatedWorkerHost.cpp index efa239b108c14ddde866605768ce57fdcfacd120..5560a9fde4ba1583ab2fd9f79b15f5916ef34def 100644 --- a/Userland/Services/WebWorker/DedicatedWorkerHost.cpp +++ b/Userland/Services/WebWorker/DedicatedWorkerHost.cpp @@ -19,7 +19,7 @@ namespace WebWorker { -DedicatedWorkerHost::DedicatedWorkerHost(URL url, String type) +DedicatedWorkerHost::DedicatedWorkerHost(URL::URL url, String type) : m_url(move(url)) , m_type(move(type)) { diff --git a/Userland/Services/WebWorker/DedicatedWorkerHost.h b/Userland/Services/WebWorker/DedicatedWorkerHost.h index 706d80a8a86a914aaf94381509331ded98985973..d448dae21f0f220364a857b4450808fa242b6500 100644 --- a/Userland/Services/WebWorker/DedicatedWorkerHost.h +++ b/Userland/Services/WebWorker/DedicatedWorkerHost.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include #include @@ -17,7 +17,7 @@ namespace WebWorker { class DedicatedWorkerHost : public RefCounted { public: - explicit DedicatedWorkerHost(URL url, String type); + explicit DedicatedWorkerHost(URL::URL url, String type); ~DedicatedWorkerHost(); void run(JS::NonnullGCPtr, Web::HTML::TransferDataHolder message_port_data, Web::HTML::SerializedEnvironmentSettingsObject const&); @@ -25,7 +25,7 @@ public: private: RefPtr m_console; - URL m_url; + URL::URL m_url; String m_type; }; diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index edd944668ec048511de9d29aafd8674f577dbdd3..36e51e8b18b5a0c5c722e37b053c1add24a33ace 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -12,9 +12,9 @@ #include #include #include -#include #include #include +#include #include #include #include diff --git a/Userland/Shell/CMakeLists.txt b/Userland/Shell/CMakeLists.txt index 54099af2869d6af95a0eec94c5020267b83c9fa2..9c14cf83e3470b32fbc2aae573651a39720d18b3 100644 --- a/Userland/Shell/CMakeLists.txt +++ b/Userland/Shell/CMakeLists.txt @@ -18,7 +18,7 @@ set(SOURCES ) serenity_lib(LibShell shell) -target_link_libraries(LibShell PRIVATE LibCore LibFileSystem LibLine LibSyntax LibRegex) +target_link_libraries(LibShell PRIVATE LibCore LibFileSystem LibLine LibSyntax LibRegex LibURL) if (SERENITYOS) target_sources(LibShell PRIVATE SyntaxHighlighter.cpp) diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 05a26e8d41a089702816c9b0617ad88ceae885d4..af25f898c7aef2ee2f6853be396439ec49ee9d3e 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -31,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 4ef7098cd5117a31922d61c713314dfaf0f5affd..73112470e3cb49b20e3a99829a0d305877d397a3 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -76,7 +76,7 @@ target_link_libraries(abench PRIVATE LibAudio LibFileSystem) target_link_libraries(aconv PRIVATE LibAudio LibFileSystem) target_link_libraries(aplay PRIVATE LibAudio LibFileSystem LibIPC) target_link_libraries(asctl PRIVATE LibAudio LibIPC) -target_link_libraries(bt PRIVATE LibSymbolication) +target_link_libraries(bt PRIVATE LibSymbolication LibURL) target_link_libraries(checksum PRIVATE LibCrypto) target_link_libraries(chres PRIVATE LibGUI LibIPC) target_link_libraries(cksum PRIVATE LibCrypto) @@ -93,15 +93,15 @@ target_link_libraries(drain PRIVATE LibFileSystem) target_link_libraries(expr PRIVATE LibRegex) target_link_libraries(fdtdump PRIVATE LibDeviceTree) target_link_libraries(file PRIVATE LibGfx LibIPC LibArchive LibCompress LibAudio) -target_link_libraries(find PRIVATE LibFileSystem LibRegex) +target_link_libraries(find PRIVATE LibFileSystem LibRegex LibURL) target_link_libraries(functrace PRIVATE LibDebug LibX86) target_link_libraries(glsl-compiler PRIVATE LibGLSL) target_link_libraries(gml-format PRIVATE LibGUI) -target_link_libraries(grep PRIVATE LibFileSystem LibRegex) +target_link_libraries(grep PRIVATE LibFileSystem LibRegex LibURL) target_link_libraries(gunzip PRIVATE LibCompress) target_link_libraries(gzip PRIVATE LibCompress) -target_link_libraries(headless-browser PRIVATE LibCrypto LibFileSystem LibGemini LibGfx LibHTTP LibImageDecoderClient LibTLS LibWeb LibWebView LibWebSocket LibIPC LibJS LibDiff) -target_link_libraries(icc PRIVATE LibGfx LibVideo) +target_link_libraries(headless-browser PRIVATE LibCrypto LibFileSystem LibGemini LibGfx LibHTTP LibImageDecoderClient LibTLS LibWeb LibWebView LibWebSocket LibIPC LibJS LibDiff LibURL) +target_link_libraries(icc PRIVATE LibGfx LibVideo LibURL) target_link_libraries(image PRIVATE LibGfx) target_link_libraries(image2bin PRIVATE LibGfx) target_link_libraries(ini PRIVATE LibFileSystem) @@ -111,19 +111,19 @@ target_link_libraries(js PRIVATE LibCrypto LibJS LibLine LibLocale LibTextCodec) link_with_locale_data(js) target_link_libraries(keymap PRIVATE LibKeyboard) target_link_libraries(less PRIVATE LibLine) -target_link_libraries(ls PRIVATE LibFileSystem) +target_link_libraries(ls PRIVATE LibFileSystem LibURL) target_link_libraries(lspci PRIVATE LibPCIDB) target_link_libraries(lsusb PRIVATE LibUSBDB) target_link_libraries(lzcat PRIVATE LibCompress) target_link_libraries(man PRIVATE LibMarkdown LibManual) -target_link_libraries(markdown-check PRIVATE LibFileSystem LibMarkdown LibManual) +target_link_libraries(markdown-check PRIVATE LibFileSystem LibMarkdown LibManual LibURL) target_link_libraries(matroska PRIVATE LibVideo) target_link_libraries(md PRIVATE LibMarkdown) target_link_libraries(mkfs.fat PRIVATE LibFileSystem) target_link_libraries(mktemp PRIVATE LibFileSystem) target_link_libraries(mv PRIVATE LibFileSystem) target_link_libraries(notify PRIVATE LibGfx LibGUI) -target_link_libraries(open PRIVATE LibDesktop LibFileSystem) +target_link_libraries(open PRIVATE LibDesktop LibFileSystem LibURL) target_link_libraries(passwd PRIVATE LibCrypt) target_link_libraries(paste PRIVATE LibGUI) target_link_libraries(patch PRIVATE LibDiff LibFileSystem) @@ -132,20 +132,20 @@ target_link_libraries(pgrep PRIVATE LibRegex) target_link_libraries(pixelflut PRIVATE LibImageDecoderClient LibIPC LibGfx) target_link_libraries(pkill PRIVATE LibRegex) target_link_libraries(pls PRIVATE LibCrypt) -target_link_libraries(pro PRIVATE LibFileSystem LibProtocol LibHTTP) +target_link_libraries(pro PRIVATE LibFileSystem LibProtocol LibHTTP LibURL) target_link_libraries(readlink PRIVATE LibFileSystem) target_link_libraries(realpath PRIVATE LibFileSystem) target_link_libraries(run-tests PRIVATE LibCoredump LibDebug LibFileSystem LibRegex) target_link_libraries(rm PRIVATE LibFileSystem) target_link_libraries(sed PRIVATE LibRegex LibFileSystem) -target_link_libraries(shot PRIVATE LibFileSystem LibGfx LibGUI LibIPC) +target_link_libraries(shot PRIVATE LibFileSystem LibGfx LibGUI LibIPC LibURL) target_link_libraries(slugify PRIVATE LibUnicode) target_link_libraries(sql PRIVATE LibFileSystem LibIPC LibLine LibSQL) target_link_libraries(su PRIVATE LibCrypt) target_link_libraries(syscall PRIVATE LibSystem) target_link_libraries(ttfdisasm PRIVATE LibGfx) target_link_libraries(tar PRIVATE LibArchive LibCompress LibFileSystem) -target_link_libraries(telws PRIVATE LibProtocol LibLine) +target_link_libraries(telws PRIVATE LibProtocol LibLine LibURL) target_link_libraries(test-imap PRIVATE LibIMAP) target_link_libraries(test-jpeg-roundtrip PRIVATE LibGfx) target_link_libraries(test-pthread PRIVATE LibThreading) @@ -159,7 +159,7 @@ target_link_libraries(wallpaper PRIVATE LibGfx LibGUI) target_link_libraries(wasm PRIVATE LibFileSystem LibJS LibLine LibWasm) target_link_libraries(watch PRIVATE LibFileSystem) target_link_libraries(wsctl PRIVATE LibGUI LibIPC) -target_link_libraries(xml PRIVATE LibFileSystem LibXML) +target_link_libraries(xml PRIVATE LibFileSystem LibXML LibURL) target_link_libraries(xxd PRIVATE LibUnicode) target_link_libraries(xzcat PRIVATE LibCompress) target_link_libraries(zip PRIVATE LibArchive LibFileSystem) diff --git a/Userland/Utilities/bt.cpp b/Userland/Utilities/bt.cpp index 4ed54691db6ade57fd1f4bcf8ac25bba3e32c5b1..9e63e6adddd1a2c0942d5b024d2e107272f1c547 100644 --- a/Userland/Utilities/bt.cpp +++ b/Userland/Utilities/bt.cpp @@ -6,13 +6,13 @@ */ #include -#include #include #include #include #include #include #include +#include #include ErrorOr serenity_main(Main::Arguments arguments) diff --git a/Userland/Utilities/find.cpp b/Userland/Utilities/find.cpp index ed2d2beaa1cc30040594aef93e56c39a6ce404db..bf0286a9921f98eaabfd70f3cb70714bef74fe22 100644 --- a/Userland/Utilities/find.cpp +++ b/Userland/Utilities/find.cpp @@ -10,13 +10,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp index 11bd3a00b3e00218bc752f08ee0be311006e795d..833dbd2a028bcc4057146e24ea4af071fee9eed5 100644 --- a/Userland/Utilities/grep.cpp +++ b/Userland/Utilities/grep.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -19,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index b5a86de144c5427b82c7235ad966a5c8ebbdb222..2965b56972e7907e9e35d00e80eea0bf3639cf46 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -42,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -285,7 +285,7 @@ static ErrorOr run_dump_test(HeadlessWebContentView& view, StringVie if (mode == TestMode::Layout) { view.on_load_finish = [&](auto const& loaded_url) { // This callback will be called for 'about:blank' first, then for the URL we actually want to dump - VERIFY(url.equals(loaded_url, URL::ExcludeFragment::Yes) || loaded_url.equals(URL("about:blank"))); + VERIFY(url.equals(loaded_url, URL::ExcludeFragment::Yes) || loaded_url.equals(URL::URL("about:blank"))); if (url.equals(loaded_url, URL::ExcludeFragment::Yes)) { // NOTE: We take a screenshot here to force the lazy layout of SVG-as-image documents to happen. @@ -477,7 +477,7 @@ static ErrorOr run_test(HeadlessWebContentView& view, StringView inp view.file_picker_closed(move(selected_files)); }; - view.load(URL("about:blank"sv)); + view.load(URL::URL("about:blank"sv)); MUST(promise->await()); s_current_test_path = input_path; diff --git a/Userland/Utilities/icc.cpp b/Userland/Utilities/icc.cpp index 0c6316e29adbf0d66a50044ffabcb11777e29b67..6665e09a26865a83c8bf60cdba56c39c47f9e18d 100644 --- a/Userland/Utilities/icc.cpp +++ b/Userland/Utilities/icc.cpp @@ -20,7 +20,7 @@ #include template -static ErrorOr hyperlink(URL const& target, T const& label) +static ErrorOr hyperlink(URL::URL const& target, T const& label) { return String::formatted("\033]8;;{}\033\\{}\033]8;;\033\\", target, label); } diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp index e9e1718a3df5b8da77c96686be836d073fc6f4ab..42df331431d8a2e25a331f666b645516c91fa997 100644 --- a/Userland/Utilities/ls.cpp +++ b/Userland/Utilities/ls.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -19,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Utilities/markdown-check.cpp b/Userland/Utilities/markdown-check.cpp index 19a820dd2f6ea2c664fe7a3e6ef8080b54d95885..9bf733613d1646e7b2b2235c6e6a3034e99ac6f0 100644 --- a/Userland/Utilities/markdown-check.cpp +++ b/Userland/Utilities/markdown-check.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -27,6 +26,7 @@ #include #include #include +#include #include static bool is_missing_file_acceptable(String const& filename) diff --git a/Userland/Utilities/open.cpp b/Userland/Utilities/open.cpp index 561996d3ca8227b362c5005a277446baff1c4c1f..783648708ad4057f83fa2234386727058e9329f6 100644 --- a/Userland/Utilities/open.cpp +++ b/Userland/Utilities/open.cpp @@ -5,13 +5,13 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include #include #include #include #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { @@ -26,7 +26,7 @@ ErrorOr serenity_main(Main::Arguments arguments) for (auto& url_or_path : urls_or_paths) { auto path_or_error = FileSystem::real_path(url_or_path); - URL url; + URL::URL url; if (path_or_error.is_error()) { url = url_or_path; if (!url.is_valid()) { diff --git a/Userland/Utilities/pkg/AvailablePort.cpp b/Userland/Utilities/pkg/AvailablePort.cpp index 79f0c4a66c1d703e671cba99bd3b85a96508b32b..640002cd8f815e7c136d195558b3710865562fa0 100644 --- a/Userland/Utilities/pkg/AvailablePort.cpp +++ b/Userland/Utilities/pkg/AvailablePort.cpp @@ -102,7 +102,7 @@ ErrorOr AvailablePort::update_available_ports_list_file() auto output_stream = TRY(Core::File::open("/usr/Ports/AvailablePorts.md"sv, Core::File::OpenMode::ReadWrite, 0644)); Core::EventLoop loop; - URL url("https://raw.githubusercontent.com/SerenityOS/serenity/master/Ports/AvailablePorts.md"); + URL::URL url("https://raw.githubusercontent.com/SerenityOS/serenity/master/Ports/AvailablePorts.md"); ByteString method = "GET"; outln("pkg: Syncing packages database..."); request = protocol_client->start_request(method, url, request_headers, ReadonlyBytes {}, proxy_data); diff --git a/Userland/Utilities/pkg/CMakeLists.txt b/Userland/Utilities/pkg/CMakeLists.txt index 88fcdcacf5a1e25ab7c6c883b630673ba4a799b4..09f396819e043bd6f7e34c9a66f38892a9728e7c 100644 --- a/Userland/Utilities/pkg/CMakeLists.txt +++ b/Userland/Utilities/pkg/CMakeLists.txt @@ -12,4 +12,4 @@ set(SOURCES ) serenity_app(PackageManager ICON app-assistant) -target_link_libraries(PackageManager PRIVATE LibCore LibSemVer LibMain LibFileSystem LibProtocol LibHTTP LibMarkdown LibShell) +target_link_libraries(PackageManager PRIVATE LibCore LibSemVer LibMain LibFileSystem LibProtocol LibHTTP LibMarkdown LibShell LibURL) diff --git a/Userland/Utilities/pro.cpp b/Userland/Utilities/pro.cpp index ce9cbe1779f863a5e69405debd6f5296e30e437a..8b0d042042b7e9d768cdecec5b23f202de7c62db 100644 --- a/Userland/Utilities/pro.cpp +++ b/Userland/Utilities/pro.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -21,6 +20,7 @@ #include #include #include +#include #include #include @@ -215,7 +215,7 @@ ErrorOr serenity_main(Main::Arguments arguments) // FIXME: Content-Type? } - URL url(url_str); + URL::URL url(url_str); if (!url.is_valid()) { warnln("'{}' is not a valid URL", url_str); return 1; diff --git a/Userland/Utilities/shot.cpp b/Userland/Utilities/shot.cpp index 51fd4302d8c7b8793e0f88223e5cf5c92444597c..6feb22422f2e30ca01847816561267d87983f3c8 100644 --- a/Userland/Utilities/shot.cpp +++ b/Userland/Utilities/shot.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -22,6 +21,7 @@ #include #include #include +#include #include class SelectableLayover final : public GUI::Widget { diff --git a/Userland/Utilities/telws.cpp b/Userland/Utilities/telws.cpp index 398c01c993537ed5b1f7fce20864a37e53766bb3..d00c37aff78a372edbd9f8635d4602bd1112e9a8 100644 --- a/Userland/Utilities/telws.cpp +++ b/Userland/Utilities/telws.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -14,6 +13,7 @@ #include #include #include +#include ErrorOr serenity_main(Main::Arguments arguments) { @@ -29,7 +29,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); - URL url(url_string); + URL::URL url(url_string); if (!url.is_valid()) { warnln("The given URL is not valid"); diff --git a/Userland/Utilities/xml.cpp b/Userland/Utilities/xml.cpp index 444cfabb8a2d57c710033451edb9d218069eb18f..9b1eae56049edb498b31feb1a9d0b2e9476605de 100644 --- a/Userland/Utilities/xml.cpp +++ b/Userland/Utilities/xml.cpp @@ -6,12 +6,12 @@ #include #include -#include -#include #include #include #include #include +#include +#include #include #include #include @@ -364,7 +364,7 @@ static auto parse(StringView contents) .preserve_comments = true, .resolve_external_resource = [&](XML::SystemID const& system_id, Optional const&) -> ErrorOr { auto base = URL::create_with_file_scheme(s_path); - auto url = URLParser::basic_parse(system_id.system_literal, base); + auto url = URL::Parser::basic_parse(system_id.system_literal, base); if (!url.is_valid()) return Error::from_string_literal("Invalid URL");