From e800605ad3e4e9dfdc320c137e1beef1a66d2eb0 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Mon, 18 Mar 2024 16:22:27 +1300 Subject: [PATCH] AK+LibURL: Move AK::URL into a new URL library This URL library ends up being a relatively fundamental base library of the system, as LibCore depends on LibURL. This change has two main benefits: * Moving AK back more towards being an agnostic library that can be used between the kernel and userspace. URL has never really fit that description - and is not used in the kernel. * URL _should_ depend on LibUnicode, as it needs punnycode support. However, it's not really possible to do this inside of AK as it can't depend on any external library. This change brings us a little closer to being able to do that, but unfortunately we aren't there quite yet, as the code generators depend on LibCore. --- AK/CMakeLists.txt | 2 - AK/Forward.h | 2 - .../AppKit/Application/ApplicationDelegate.h | 10 +- .../AppKit/Application/ApplicationDelegate.mm | 14 +- Ladybird/AppKit/UI/LadybirdWebView.h | 13 +- Ladybird/AppKit/UI/LadybirdWebView.mm | 6 +- Ladybird/AppKit/UI/Tab.mm | 14 +- Ladybird/AppKit/UI/TabController.h | 8 +- Ladybird/AppKit/UI/TabController.mm | 6 +- Ladybird/AppKit/main.mm | 4 +- Ladybird/CMakeLists.txt | 4 +- Ladybird/Qt/AutoComplete.cpp | 2 +- Ladybird/Qt/BrowserWindow.cpp | 4 +- Ladybird/Qt/BrowserWindow.h | 4 +- Ladybird/Qt/LocationEdit.cpp | 2 +- Ladybird/Qt/RequestManagerQt.cpp | 6 +- Ladybird/Qt/RequestManagerQt.h | 10 +- Ladybird/Qt/SettingsDialog.cpp | 6 +- Ladybird/Qt/StringUtils.cpp | 6 +- Ladybird/Qt/StringUtils.h | 6 +- Ladybird/Qt/Tab.cpp | 12 +- Ladybird/Qt/Tab.h | 14 +- Ladybird/Qt/WebContentView.h | 4 +- Ladybird/Qt/main.cpp | 4 +- Ladybird/RequestServer/CMakeLists.txt | 2 +- Ladybird/WebContent/CMakeLists.txt | 2 +- Ladybird/WebWorker/CMakeLists.txt | 2 +- Meta/Lagom/CMakeLists.txt | 9 +- Meta/Lagom/Fuzzers/FuzzGemini.cpp | 1 - Meta/Lagom/Fuzzers/FuzzURL.cpp | 4 +- Meta/Lagom/Fuzzers/fuzzers.cmake | 1 + Tests/AK/CMakeLists.txt | 1 - Tests/CMakeLists.txt | 1 + Tests/LibURL/CMakeLists.txt | 7 + Tests/{AK => LibURL}/TestURL.cpp | 172 +++++++++--------- Tests/LibWebView/CMakeLists.txt | 2 +- .../Applications/3DFileViewer/CMakeLists.txt | 2 +- .../Applications/Assistant/CMakeLists.txt | 2 +- Userland/Applications/Assistant/Providers.cpp | 4 +- Userland/Applications/Assistant/Providers.h | 4 +- .../Applications/Browser/BrowserWindow.cpp | 8 +- Userland/Applications/Browser/BrowserWindow.h | 6 +- Userland/Applications/Browser/CMakeLists.txt | 2 +- .../Applications/Browser/DownloadWidget.cpp | 2 +- .../Applications/Browser/DownloadWidget.h | 6 +- Userland/Applications/Browser/Tab.cpp | 12 +- Userland/Applications/Browser/Tab.h | 22 +-- Userland/Applications/Browser/URLBox.cpp | 2 +- Userland/Applications/Browser/main.cpp | 2 +- .../BrowserSettings/BrowserSettingsWidget.cpp | 4 +- .../BrowserSettings/CMakeLists.txt | 2 +- .../Applications/Calculator/CMakeLists.txt | 2 +- Userland/Applications/Calculator/main.cpp | 2 +- Userland/Applications/Calendar/CMakeLists.txt | 2 +- .../Applications/CharacterMap/CMakeLists.txt | 2 +- Userland/Applications/CharacterMap/main.cpp | 2 +- .../Applications/CrashReporter/CMakeLists.txt | 2 +- Userland/Applications/CrashReporter/main.cpp | 2 +- .../DisplaySettings/CMakeLists.txt | 2 +- .../Applications/FileManager/CMakeLists.txt | 2 +- .../FileManager/DirectoryView.cpp | 4 +- .../Applications/FileManager/DirectoryView.h | 6 +- Userland/Applications/FileManager/main.cpp | 4 +- .../Applications/FontEditor/CMakeLists.txt | 2 +- Userland/Applications/FontEditor/main.cpp | 2 +- Userland/Applications/Help/CMakeLists.txt | 2 +- Userland/Applications/Help/MainWidget.cpp | 8 +- Userland/Applications/Help/MainWidget.h | 4 +- Userland/Applications/Help/main.cpp | 2 +- .../Applications/HexEditor/CMakeLists.txt | 2 +- .../Applications/ImageViewer/CMakeLists.txt | 4 +- Userland/Applications/ImageViewer/main.cpp | 2 +- .../Applications/Magnifier/CMakeLists.txt | 2 +- Userland/Applications/Mail/CMakeLists.txt | 2 +- Userland/Applications/Mail/MailWidget.h | 4 +- Userland/Applications/Maps/CMakeLists.txt | 2 +- Userland/Applications/Maps/MapWidget.cpp | 16 +- Userland/Applications/Maps/MapWidget.h | 6 +- Userland/Applications/Maps/SearchPanel.cpp | 2 +- Userland/Applications/Maps/UsersMapWidget.cpp | 2 +- .../Applications/MapsSettings/CMakeLists.txt | 2 +- .../Applications/PDFViewer/CMakeLists.txt | 2 +- .../Applications/PixelPaint/CMakeLists.txt | 2 +- .../Applications/Presenter/CMakeLists.txt | 2 +- .../Applications/Presenter/SlideObject.cpp | 2 +- Userland/Applications/Run/CMakeLists.txt | 2 +- Userland/Applications/Run/RunWindow.cpp | 2 +- .../Applications/SoundPlayer/CMakeLists.txt | 2 +- .../Applications/SpaceAnalyzer/CMakeLists.txt | 2 +- Userland/Applications/SpaceAnalyzer/main.cpp | 2 +- .../Applications/Spreadsheet/CMakeLists.txt | 2 +- Userland/Applications/Spreadsheet/Position.h | 4 +- .../Applications/Spreadsheet/Spreadsheet.cpp | 10 +- .../Applications/Spreadsheet/Spreadsheet.h | 6 +- .../Spreadsheet/SpreadsheetModel.cpp | 2 +- .../Spreadsheet/SpreadsheetView.cpp | 2 +- Userland/Applications/Terminal/CMakeLists.txt | 2 +- Userland/Applications/Terminal/main.cpp | 2 +- .../Applications/TextEditor/CMakeLists.txt | 2 +- .../Applications/TextEditor/MainWidget.cpp | 2 +- .../Applications/ThemeEditor/CMakeLists.txt | 2 +- .../Applications/VideoPlayer/CMakeLists.txt | 2 +- Userland/Applications/Welcome/CMakeLists.txt | 2 +- Userland/BuggieBox/CMakeLists.txt | 2 +- Userland/Demos/Eyes/CMakeLists.txt | 2 +- Userland/Demos/Eyes/main.cpp | 2 +- .../DevTools/GMLPlayground/CMakeLists.txt | 2 +- Userland/DevTools/GMLPlayground/main.cpp | 2 +- Userland/DevTools/HackStudio/CMakeLists.txt | 2 +- Userland/DevTools/Profiler/CMakeLists.txt | 2 +- Userland/DevTools/SQLStudio/CMakeLists.txt | 2 +- Userland/Games/2048/CMakeLists.txt | 2 +- Userland/Games/2048/main.cpp | 2 +- Userland/Games/BrickGame/CMakeLists.txt | 2 +- Userland/Games/BrickGame/main.cpp | 2 +- Userland/Games/Chess/CMakeLists.txt | 2 +- Userland/Games/ColorLines/CMakeLists.txt | 2 +- Userland/Games/ColorLines/main.cpp | 2 +- Userland/Games/FlappyBug/CMakeLists.txt | 2 +- Userland/Games/FlappyBug/main.cpp | 2 +- Userland/Games/Flood/CMakeLists.txt | 2 +- Userland/Games/Flood/main.cpp | 2 +- Userland/Games/GameOfLife/CMakeLists.txt | 2 +- Userland/Games/GameOfLife/main.cpp | 2 +- Userland/Games/Hearts/CMakeLists.txt | 2 +- Userland/Games/Hearts/main.cpp | 2 +- Userland/Games/MasterWord/CMakeLists.txt | 2 +- Userland/Games/MasterWord/main.cpp | 2 +- Userland/Games/Minesweeper/CMakeLists.txt | 2 +- Userland/Games/Minesweeper/main.cpp | 2 +- Userland/Games/Snake/CMakeLists.txt | 2 +- Userland/Games/Snake/main.cpp | 2 +- Userland/Games/Solitaire/CMakeLists.txt | 2 +- Userland/Games/Solitaire/main.cpp | 2 +- Userland/Games/Spider/CMakeLists.txt | 2 +- Userland/Games/Spider/main.cpp | 2 +- Userland/Libraries/CMakeLists.txt | 1 + Userland/Libraries/LibCore/CMakeLists.txt | 2 +- Userland/Libraries/LibCore/MimeData.cpp | 8 +- Userland/Libraries/LibCore/MimeData.h | 6 +- Userland/Libraries/LibCore/Proxy.h | 4 +- Userland/Libraries/LibDesktop/CMakeLists.txt | 2 +- Userland/Libraries/LibDesktop/Launcher.cpp | 14 +- Userland/Libraries/LibDesktop/Launcher.h | 13 +- Userland/Libraries/LibGUI/CMakeLists.txt | 2 +- Userland/Libraries/LibGemini/CMakeLists.txt | 2 +- Userland/Libraries/LibGemini/Document.cpp | 2 +- Userland/Libraries/LibGemini/Document.h | 12 +- .../Libraries/LibGemini/GeminiRequest.cpp | 4 +- Userland/Libraries/LibGemini/GeminiRequest.h | 8 +- Userland/Libraries/LibGemini/Job.h | 2 +- Userland/Libraries/LibGfx/CMakeLists.txt | 2 +- Userland/Libraries/LibGfx/ICC/Profile.cpp | 8 +- Userland/Libraries/LibGfx/ICC/Profile.h | 6 +- Userland/Libraries/LibHTTP/CMakeLists.txt | 2 +- Userland/Libraries/LibHTTP/HttpRequest.cpp | 4 +- Userland/Libraries/LibHTTP/HttpRequest.h | 10 +- Userland/Libraries/LibHTTP/Job.h | 2 +- Userland/Libraries/LibIPC/CMakeLists.txt | 2 +- Userland/Libraries/LibIPC/Decoder.cpp | 6 +- Userland/Libraries/LibIPC/Decoder.h | 3 +- Userland/Libraries/LibIPC/Encoder.cpp | 4 +- Userland/Libraries/LibIPC/Encoder.h | 3 +- Userland/Libraries/LibManual/CMakeLists.txt | 2 +- Userland/Libraries/LibManual/Node.cpp | 4 +- Userland/Libraries/LibManual/Node.h | 3 +- .../Libraries/LibProtocol/RequestClient.cpp | 10 +- .../Libraries/LibProtocol/RequestClient.h | 6 +- Userland/Libraries/LibURL/CMakeLists.txt | 6 + Userland/Libraries/LibURL/Forward.h | 12 ++ .../Libraries/LibURL/Parser.cpp | 80 ++++---- .../Libraries/LibURL/Parser.h | 16 +- {AK => Userland/Libraries/LibURL}/URL.cpp | 78 ++++---- {AK => Userland/Libraries/LibURL}/URL.h | 140 +++++++------- Userland/Libraries/LibUnicode/CMakeLists.txt | 2 + Userland/Libraries/LibUnicode/URL.cpp | 8 +- Userland/Libraries/LibUnicode/URL.h | 4 +- Userland/Libraries/LibVT/CMakeLists.txt | 2 +- Userland/Libraries/LibVT/TerminalWidget.cpp | 4 +- Userland/Libraries/LibWeb/CMakeLists.txt | 2 +- .../Libraries/LibWeb/CSS/CSSFontFaceRule.cpp | 4 +- .../Libraries/LibWeb/CSS/CSSImportRule.cpp | 6 +- Userland/Libraries/LibWeb/CSS/CSSImportRule.h | 10 +- .../Libraries/LibWeb/CSS/CSSStyleSheet.cpp | 8 +- Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h | 10 +- .../Libraries/LibWeb/CSS/ComputedValues.h | 14 +- Userland/Libraries/LibWeb/CSS/FontFace.h | 4 +- .../Libraries/LibWeb/CSS/Parser/Helpers.cpp | 2 +- .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 10 +- Userland/Libraries/LibWeb/CSS/Parser/Parser.h | 10 +- .../LibWeb/CSS/Parser/ParsingContext.cpp | 4 +- .../LibWeb/CSS/Parser/ParsingContext.h | 6 +- .../Libraries/LibWeb/CSS/SelectorEngine.cpp | 2 +- .../Libraries/LibWeb/CSS/StyleComputer.cpp | 10 +- Userland/Libraries/LibWeb/CSS/StyleValue.h | 2 +- .../CSS/StyleValues/ImageStyleValue.cpp | 2 +- .../LibWeb/CSS/StyleValues/ImageStyleValue.h | 8 +- .../LibWeb/CSS/StyleValues/URLStyleValue.h | 10 +- Userland/Libraries/LibWeb/DOM/Document.cpp | 20 +- Userland/Libraries/LibWeb/DOM/Document.h | 28 +-- .../Libraries/LibWeb/DOM/DocumentLoading.h | 4 +- Userland/Libraries/LibWeb/DOM/XMLDocument.cpp | 4 +- Userland/Libraries/LibWeb/DOM/XMLDocument.h | 4 +- Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp | 42 ++--- Userland/Libraries/LibWeb/DOMURL/DOMURL.h | 12 +- .../LibWeb/DOMURL/URLSearchParams.cpp | 10 +- .../Libraries/LibWeb/DOMURL/URLSearchParams.h | 2 +- Userland/Libraries/LibWeb/Dump.cpp | 4 +- .../LibWeb/Fetch/Fetching/Fetching.cpp | 4 +- .../Fetch/Infrastructure/HTTP/Requests.cpp | 12 +- .../Fetch/Infrastructure/HTTP/Requests.h | 22 +-- .../Fetch/Infrastructure/HTTP/Responses.cpp | 10 +- .../Fetch/Infrastructure/HTTP/Responses.h | 24 +-- .../LibWeb/Fetch/Infrastructure/URL.cpp | 2 +- .../LibWeb/Fetch/Infrastructure/URL.h | 4 +- Userland/Libraries/LibWeb/Fetch/Request.cpp | 2 +- .../Libraries/LibWeb/FileAPI/BlobURLStore.cpp | 4 +- .../Libraries/LibWeb/HTML/BrowsingContext.cpp | 14 +- .../Libraries/LibWeb/HTML/BrowsingContext.h | 8 +- ...CrossOriginOpenerPolicyEnforcementResult.h | 4 +- .../Libraries/LibWeb/HTML/DocumentState.h | 8 +- .../Libraries/LibWeb/HTML/HTMLBaseElement.h | 4 +- .../Libraries/LibWeb/HTML/HTMLDocument.cpp | 4 +- Userland/Libraries/LibWeb/HTML/HTMLDocument.h | 4 +- .../Libraries/LibWeb/HTML/HTMLFormElement.cpp | 12 +- .../Libraries/LibWeb/HTML/HTMLFormElement.h | 12 +- .../LibWeb/HTML/HTMLHyperlinkElementUtils.cpp | 18 +- .../LibWeb/HTML/HTMLHyperlinkElementUtils.h | 4 +- .../LibWeb/HTML/HTMLIFrameElement.cpp | 4 +- .../LibWeb/HTML/HTMLImageElement.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLImageElement.h | 4 +- .../Libraries/LibWeb/HTML/HTMLLinkElement.cpp | 6 +- .../Libraries/LibWeb/HTML/HTMLLinkElement.h | 2 +- .../LibWeb/HTML/HTMLMediaElement.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLMediaElement.h | 2 +- Userland/Libraries/LibWeb/HTML/History.cpp | 2 +- Userland/Libraries/LibWeb/HTML/History.h | 2 +- .../Libraries/LibWeb/HTML/ImageRequest.cpp | 4 +- Userland/Libraries/LibWeb/HTML/ImageRequest.h | 8 +- .../LibWeb/HTML/ListOfAvailableImages.cpp | 2 +- .../LibWeb/HTML/ListOfAvailableImages.h | 4 +- Userland/Libraries/LibWeb/HTML/Location.cpp | 8 +- Userland/Libraries/LibWeb/HTML/Location.h | 6 +- Userland/Libraries/LibWeb/HTML/Navigable.cpp | 20 +- Userland/Libraries/LibWeb/HTML/Navigable.h | 12 +- .../LibWeb/HTML/NavigableContainer.cpp | 6 +- .../LibWeb/HTML/NavigableContainer.h | 4 +- Userland/Libraries/LibWeb/HTML/Navigation.cpp | 4 +- Userland/Libraries/LibWeb/HTML/Navigation.h | 4 +- .../LibWeb/HTML/NavigationDestination.h | 8 +- .../Libraries/LibWeb/HTML/NavigationParams.h | 4 +- .../Libraries/LibWeb/HTML/NavigatorBeacon.cpp | 2 +- Userland/Libraries/LibWeb/HTML/Origin.h | 11 +- .../LibWeb/HTML/Parser/HTMLParser.cpp | 2 +- .../Libraries/LibWeb/HTML/Parser/HTMLParser.h | 2 +- .../LibWeb/HTML/PotentialCORSRequest.cpp | 2 +- .../LibWeb/HTML/PotentialCORSRequest.h | 4 +- .../LibWeb/HTML/Scripting/ClassicScript.cpp | 4 +- .../LibWeb/HTML/Scripting/ClassicScript.h | 4 +- .../Scripting/EnvironmentSettingsSnapshot.h | 4 +- .../LibWeb/HTML/Scripting/Environments.cpp | 2 +- .../LibWeb/HTML/Scripting/Environments.h | 10 +- .../LibWeb/HTML/Scripting/Fetching.cpp | 26 +-- .../LibWeb/HTML/Scripting/Fetching.h | 23 ++- .../LibWeb/HTML/Scripting/ImportMap.h | 8 +- .../LibWeb/HTML/Scripting/ModuleMap.cpp | 12 +- .../LibWeb/HTML/Scripting/ModuleMap.h | 20 +- .../LibWeb/HTML/Scripting/ModuleScript.cpp | 6 +- .../LibWeb/HTML/Scripting/ModuleScript.h | 6 +- .../LibWeb/HTML/Scripting/Script.cpp | 2 +- .../Libraries/LibWeb/HTML/Scripting/Script.h | 8 +- .../SerializedEnvironmentSettingsObject.cpp | 6 +- .../SerializedEnvironmentSettingsObject.h | 8 +- .../WindowEnvironmentSettingsObject.cpp | 4 +- .../WindowEnvironmentSettingsObject.h | 4 +- .../WorkerEnvironmentSettingsObject.h | 6 +- .../LibWeb/HTML/SessionHistoryEntry.h | 4 +- .../LibWeb/HTML/SharedImageRequest.cpp | 6 +- .../LibWeb/HTML/SharedImageRequest.h | 12 +- Userland/Libraries/LibWeb/HTML/SourceSet.h | 2 +- .../LibWeb/HTML/TraversableNavigable.cpp | 2 +- .../LibWeb/HTML/TraversableNavigable.h | 2 +- Userland/Libraries/LibWeb/HTML/Window.cpp | 2 +- Userland/Libraries/LibWeb/HTML/Window.h | 2 +- Userland/Libraries/LibWeb/HTML/Worker.cpp | 2 +- Userland/Libraries/LibWeb/HTML/Worker.h | 4 +- .../Libraries/LibWeb/HTML/WorkerAgent.cpp | 2 +- Userland/Libraries/LibWeb/HTML/WorkerAgent.h | 4 +- .../Libraries/LibWeb/HTML/WorkerGlobalScope.h | 8 +- .../Libraries/LibWeb/HTML/WorkerLocation.cpp | 4 +- .../Libraries/LibWeb/Loader/ContentFilter.cpp | 2 +- .../Libraries/LibWeb/Loader/ContentFilter.h | 4 +- .../LibWeb/Loader/GeneratedPagesLoader.cpp | 4 +- .../LibWeb/Loader/GeneratedPagesLoader.h | 4 +- .../Libraries/LibWeb/Loader/LoadRequest.cpp | 2 +- .../Libraries/LibWeb/Loader/LoadRequest.h | 10 +- .../Libraries/LibWeb/Loader/ProxyMappings.cpp | 2 +- .../Libraries/LibWeb/Loader/ProxyMappings.h | 4 +- Userland/Libraries/LibWeb/Loader/Resource.h | 4 +- .../LibWeb/Loader/ResourceLoader.cpp | 10 +- .../Libraries/LibWeb/Loader/ResourceLoader.h | 14 +- Userland/Libraries/LibWeb/Page/Page.cpp | 4 +- Userland/Libraries/LibWeb/Page/Page.h | 26 +-- .../PermissionsPolicy/AutoplayAllowlist.cpp | 4 +- .../ReferrerPolicy/AbstractOperations.cpp | 10 +- .../ReferrerPolicy/AbstractOperations.h | 4 +- .../LibWeb/SVG/SVGDecodedImageData.cpp | 2 +- .../LibWeb/SVG/SVGDecodedImageData.h | 2 +- .../Libraries/LibWeb/SVG/SVGGraphicsElement.h | 2 +- .../LibWeb/SVG/SVGTextPathElement.cpp | 2 +- .../SecureContexts/AbstractOperations.cpp | 4 +- .../SecureContexts/AbstractOperations.h | 3 +- .../Libraries/LibWeb/WebSockets/WebSocket.cpp | 2 +- .../Libraries/LibWeb/WebSockets/WebSocket.h | 8 +- .../LibWeb/Worker/WebWorkerServer.ipc | 4 +- .../Libraries/LibWeb/XHR/XMLHttpRequest.h | 4 +- .../Libraries/LibWebSocket/CMakeLists.txt | 2 +- .../Libraries/LibWebSocket/ConnectionInfo.cpp | 2 +- .../Libraries/LibWebSocket/ConnectionInfo.h | 8 +- Userland/Libraries/LibWebSocket/WebSocket.h | 2 +- Userland/Libraries/LibWebView/CMakeLists.txt | 2 +- Userland/Libraries/LibWebView/CookieJar.cpp | 18 +- Userland/Libraries/LibWebView/CookieJar.h | 17 +- Userland/Libraries/LibWebView/History.cpp | 4 +- Userland/Libraries/LibWebView/History.h | 8 +- .../LibWebView/OutOfProcessWebView.h | 3 +- .../LibWebView/RequestServerAdapter.cpp | 8 +- .../LibWebView/RequestServerAdapter.h | 10 +- .../LibWebView/SourceHighlighter.cpp | 4 +- .../Libraries/LibWebView/SourceHighlighter.h | 2 +- Userland/Libraries/LibWebView/URL.cpp | 16 +- Userland/Libraries/LibWebView/URL.h | 8 +- .../LibWebView/ViewImplementation.cpp | 2 +- .../Libraries/LibWebView/ViewImplementation.h | 32 ++-- .../Libraries/LibWebView/WebContentClient.cpp | 24 +-- .../Libraries/LibWebView/WebContentClient.h | 24 +-- .../FileSystemAccessServer/CMakeLists.txt | 2 +- .../FileSystemAccessServer.ipc | 2 +- Userland/Services/LaunchServer/CMakeLists.txt | 2 +- .../LaunchServer/ConnectionFromClient.cpp | 16 +- .../LaunchServer/ConnectionFromClient.h | 12 +- .../Services/LaunchServer/LaunchClient.ipc | 2 +- .../Services/LaunchServer/LaunchServer.ipc | 12 +- Userland/Services/LaunchServer/Launcher.cpp | 10 +- Userland/Services/LaunchServer/Launcher.h | 12 +- .../Services/RequestServer/CMakeLists.txt | 2 +- .../RequestServer/ConnectionCache.cpp | 2 +- .../Services/RequestServer/ConnectionCache.h | 12 +- .../RequestServer/ConnectionFromClient.cpp | 14 +- .../RequestServer/ConnectionFromClient.h | 6 +- .../Services/RequestServer/GeminiProtocol.cpp | 2 +- .../Services/RequestServer/GeminiProtocol.h | 2 +- .../Services/RequestServer/GeminiRequest.h | 2 +- Userland/Services/RequestServer/HttpCommon.h | 2 +- .../Services/RequestServer/HttpProtocol.cpp | 4 +- .../Services/RequestServer/HttpProtocol.h | 4 +- Userland/Services/RequestServer/HttpRequest.h | 2 +- .../Services/RequestServer/HttpsProtocol.cpp | 4 +- .../Services/RequestServer/HttpsProtocol.h | 4 +- .../Services/RequestServer/HttpsRequest.h | 2 +- Userland/Services/RequestServer/Protocol.h | 4 +- Userland/Services/RequestServer/Request.h | 4 +- .../Services/RequestServer/RequestClient.ipc | 2 +- .../Services/RequestServer/RequestServer.ipc | 8 +- Userland/Services/SpiceAgent/CMakeLists.txt | 2 +- .../SpiceAgent/FileTransferOperation.cpp | 2 +- Userland/Services/SpiceAgent/main.cpp | 2 +- Userland/Services/Taskbar/CMakeLists.txt | 2 +- Userland/Services/WebContent/CMakeLists.txt | 2 +- .../WebContent/ConnectionFromClient.cpp | 2 +- .../WebContent/ConnectionFromClient.h | 2 +- Userland/Services/WebContent/PageClient.cpp | 20 +- Userland/Services/WebContent/PageClient.h | 20 +- Userland/Services/WebContent/PageHost.cpp | 2 +- .../Services/WebContent/WebContentClient.ipc | 26 +-- .../Services/WebContent/WebContentServer.ipc | 4 +- .../WebContent/WebDriverConnection.cpp | 2 +- Userland/Services/WebDriver/CMakeLists.txt | 2 +- Userland/Services/WebServer/CMakeLists.txt | 2 +- Userland/Services/WebServer/Client.cpp | 2 +- Userland/Services/WebWorker/CMakeLists.txt | 2 +- .../WebWorker/ConnectionFromClient.cpp | 2 +- .../Services/WebWorker/ConnectionFromClient.h | 2 +- .../WebWorker/DedicatedWorkerHost.cpp | 2 +- .../Services/WebWorker/DedicatedWorkerHost.h | 6 +- Userland/Shell/AST.cpp | 2 +- Userland/Shell/CMakeLists.txt | 2 +- Userland/Shell/Shell.cpp | 2 +- Userland/Utilities/CMakeLists.txt | 24 +-- Userland/Utilities/bt.cpp | 2 +- Userland/Utilities/find.cpp | 2 +- Userland/Utilities/grep.cpp | 2 +- Userland/Utilities/headless-browser.cpp | 6 +- Userland/Utilities/icc.cpp | 2 +- Userland/Utilities/ls.cpp | 2 +- Userland/Utilities/markdown-check.cpp | 2 +- Userland/Utilities/open.cpp | 4 +- Userland/Utilities/pkg/AvailablePort.cpp | 2 +- Userland/Utilities/pkg/CMakeLists.txt | 2 +- Userland/Utilities/pro.cpp | 4 +- Userland/Utilities/shot.cpp | 2 +- Userland/Utilities/telws.cpp | 4 +- Userland/Utilities/xml.cpp | 6 +- 403 files changed, 1336 insertions(+), 1305 deletions(-) create mode 100644 Tests/LibURL/CMakeLists.txt rename Tests/{AK => LibURL}/TestURL.cpp (73%) create mode 100644 Userland/Libraries/LibURL/CMakeLists.txt create mode 100644 Userland/Libraries/LibURL/Forward.h rename AK/URLParser.cpp => Userland/Libraries/LibURL/Parser.cpp (95%) rename AK/URLParser.h => Userland/Libraries/LibURL/Parser.h (86%) rename {AK => Userland/Libraries/LibURL}/URL.cpp (86%) rename {AK => Userland/Libraries/LibURL}/URL.h (63%) diff --git a/AK/CMakeLists.txt b/AK/CMakeLists.txt index 235a5498332..e7fb9e485e1 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 997ae19549d..afc4e18dbdb 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 b9fcc48dd6a..e76a3a05b43 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 d109cfe3f6a..046b07c4c67 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 67150c7d8c0..ccfeef84ca7 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 e55f08b9c3e..3eadce27fc8 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 0d8a2263a45..108e1acc6ab 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 f18fb187913..8194da3be20 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 ba8afb9e738..7886e316b23 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 f8ee5969903..0034f56aa5e 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 172799216a4..0f6f978a330 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 ae35e4acf57..480d32a726e 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 fcd5601fc6c..7c8c04c3c6f 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 d5508c94679..bf2d83831e7 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 fac2ba5fade..2fe4c09f112 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 83810ee4b9b..e9155292973 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 61087de8918..1e090b26393 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 11e61273605..342836df7bd 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 09cd5cbdee7..1f7e7dbdfe5 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 70a1040e923..93d492893c2 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 28dca89f8eb..b67a4fc7465 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 954d8702499..ce97eba64f4 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 95442e6994c..3a943bd3fa9 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 9bed495a00c..b02eb7db42c 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 128dc1dbd4f..798d7715fae 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 6f7e9accbbb..d09de4361b7 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 dd435fbf9bd..5be2980545a 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 71b98ef0933..86387fccbde 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 c624d7b6c96..b6a9ad5b76d 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 136a504ce15..68206f190f9 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 66f025f3390..bb05b408663 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 845415b7026..5346d366e89 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 de523f1280f..74c86c32a11 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 00000000000..944d65cdc84 --- /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 61b5499b05a..77a0fd64b75 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 3022b1113a4..86aea611a07 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 49d8c45bf00..0f856a7d0b4 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 06a3367897d..0f852677b54 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 348ed0e13cd..e51dfc92d47 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 47659ae462e..4cf5292b1e1 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 86c4df4f060..6269b842902 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 95a40e7f75d..ceff5c1512a 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 82e68c5d834..9b35f991e85 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 4d15dc3375c..761e239e409 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 882233ac982..a428775068f 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 e6b7c08af3a..ba24230d5d7 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 a05eb096ca1..29249fbfc5c 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 77f1c68038d..0ea8e780b45 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 42929210dd5..cef9c099163 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 94c348a1df4..620a2b5e562 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 676e8389317..4429ffe4aa7 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 3f366010721..0a67ba196fc 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 fc0b5ee2242..a435011dc28 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 053bce24d2c..42d1f29121b 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 afb939850b1..faf9716c944 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 5430fc3a216..4c6a8f6c305 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 d513d80afe5..c2ec437d240 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 469f10dc7ad..c150c66b448 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 d9aa0e3e7b4..1bd19be091e 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 541667669ef..535e2cf2273 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 3ef39a48000..bcfffb384ac 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 7cadff815de..4c85c59a410 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 9d03e0796c7..0f5d0a00cba 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 6d85f83415a..bdeb396c4ac 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 7b958012c4f..e5f516321c0 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 de19b104972..cecd7d87345 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 f56c0c2c0e4..d6adbf6f935 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 0afc99cd0fa..f0513d01988 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 d63e3a1cb86..212bc5d5875 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 66718d6ff12..1d09b71fa9e 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 f9789a2e965..2e65d8e578b 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 2b2b039b01f..21ae179cd3e 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 cd8ba0c12a2..dfab2b0a95a 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 bfd4cc4f257..3b25b93e92e 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 6494d152acd..132fb5be559 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 6a6ce5bfea4..9df7b7b0e4b 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 ae721bd4c6e..ca08cfc8a73 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 82cf13330cb..6376f54e7e4 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 aa66a446dec..ab962ba0344 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 488f36e5962..b88391153dc 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 e9c235e7b4a..5b58772f3fc 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 c741105ac81..d19a485d44d 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 40938869ed5..13d6192b6ba 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 44d31d4fb71..a3cb7afd909 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 dbaee6f6b00..46af0a3f2a6 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 459cd21889e..00db397147f 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 568698bbe43..b2cf2edbd27 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 5ae1961511a..4be9dd2eb9e 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 456b974ecf7..738a175f586 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 1c03f149bfc..3613ce0d86e 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 2c7d4feae0f..04558f4b838 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 2285c759405..70e6ef97d6a 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 72d6a4fec31..20e441a939e 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 f1c17af961d..964755e2195 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 e447b40db59..0a052ca9d3a 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 f4622cf2ff2..f6884b73ca1 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 a2a9f4063b4..a7ef2f9bf69 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 331f89673f8..fab90b141c7 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 08ddcd5a1cb..fae57c30aca 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 aa9c49ac629..acbcb9927fa 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 16ed2217362..eb24ff91e1d 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 92936a78b1f..39f2f791a3b 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 66714a6ae3a..9f36bedb5b8 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 cd8a53a74e0..d16e83e7a0c 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 bf4892ff81d..40946232292 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 e31e5562e9b..775ebe52328 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 47d3c9081be..0422e6d1924 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 949402cb125..65f95da95d0 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 bf3aa6b4cf8..bce613fd9e9 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 8aeff8436bc..94580ecf49f 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 f8efada2645..983d8036fcb 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 47b7920eb3c..0454430dabc 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 a016f0a30dc..0602a6335ed 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 cfd00d6179f..cfd42623939 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 e1bc90fd2b6..21ed49fd56e 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 12ee78ddb5a..b51e0067718 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 846a02c62e9..61d5112ca82 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 0ae866786ea..2dc62c1e34d 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 874e8531db7..b3345d4077c 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 6737cb6c272..9c466e6b1db 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 2ad60f0ea70..62807f62cc5 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 51f6ece7dba..50a060af8ef 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 95ca1ff172c..f5958d1d887 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 ef6832b69e4..384324bc395 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 33f78127317..ccb14f990ed 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 3d8b757ad88..c4948473c9f 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 823c003fbc6..a00c43a3375 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 665903d122a..10d5d00251b 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 04b63578991..a3620c2105b 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 a888a00509f..8fab6c6efb5 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 c53b3df9d2b..c9aa392de45 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 cff7e507607..c486c05cdc3 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 d2b7bb84f09..32ffb49eeac 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 b4314ee202a..5fc369f400d 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 52876b27be1..28087385aee 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 a78830232da..65462af2b7e 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 e4c248d6a6d..f8194a56c62 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 cc919511f59..8398c72a9b5 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 5811e940813..03a530e27ce 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 cf8c9a7a67b..6a0688dc4cb 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 072c64cc4e4..5320eb54a39 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 c30d2c520f2..84b75376a8c 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 2ddddd306d4..5de48012926 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 b10a2d79644..7c1842173b2 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 6c5bbeb22d5..2955e8dd2e0 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 df43088374e..88b98ac1f1b 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 d7957a98f9f..09edf65c3ed 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 ea59f8a06dd..bc811111901 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 d4e0179bf98..e76d59c147e 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 c5eb28cd2e0..89c23142cad 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 619936626f8..1fb695f601a 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 ca29a63de1c..20c30780dd5 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 2c35680176b..a96981741ab 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 6ab67b4b7d6..483d7729e71 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 b600e163afa..d0f5ef61a58 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 f41cbc2803c..ba2d3a23c68 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 9734776d348..4da1c9be45e 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 9e2b2138977..a6c508d8a34 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 f659897dd5e..3e2ac066776 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 108b43e2a05..dd6c6b9b379 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 13de3bea0cb..0469eba2e14 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 075de49a82f..d3364f9cfbc 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 20359709a51..af1d08d87dc 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 237b96f054e..20d81155996 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 947d8e8ff5a..58b0e4a47f3 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 d9cb3f7a34c..4489dd4277d 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 05fb4f1119c..e390123ec18 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 00000000000..547dc63fa6a --- /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 00000000000..5cfe7221487 --- /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 1062937e242..7ab1826b7a4 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 e43ed9a52ee..185e2a2126f 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 fa843e4cbe9..37dc8075d7e 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 2aeee6365ff..98492f95f92 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 45ac83182c4..38b0cc989c2 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 5c69f447d5c..d9c382453bd 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 ab19cdd7d9a..1e410da10e6 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 01d7ec90d9e..6d07972f4c4 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 5de996a4cdc..861c86700c8 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 8fec889536c..01f143fa340 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 a17284f7726..7711f44b1c9 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 6449393d516..8e60d649808 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 d3fd12f4199..a59fecb254e 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 34a9c7850e6..06a45f9ddfb 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 fc102319eaa..7d67d7dd552 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 e0257373ecd..da2b39385b0 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 561374d0756..c415b40ab9d 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 0ee97f00a7d..5ea096f70c6 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 0b06e86952f..501ecaa663a 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 2f5c6276421..64ba9bfab2f 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 bd4585250c6..e3e6f897df4 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 fef3d7e6d9c..becc800257f 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 a796400619d..7d06318f6d8 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 36539ccded0..396dd3d39e8 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 9896131a631..addd269ff10 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 b88253d37b0..991f04096c7 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 b237a26e37f..a67467cdf43 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 573ae5215da..2287b22b10f 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 aa8c4b9e158..12588a4048d 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 378321185f7..fc4e0bf352e 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 e249be31f65..093ce1351b2 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 4c58d3d8d4c..2d1fcce7683 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 1f715df2826..e1b2000cdb9 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 099c104431c..c1c0620703f 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 62df78f46b5..b69ce044160 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 4ce11ff2424..59922dbc4e1 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 26f73a7db9a..a4c86e9fbf0 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 48e67100b3b..bfa0ec5834d 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 7804304d26e..83b03905084 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 10bd89b0bd1..e391e410379 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 6f790e8fd75..de57845e729 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 bb508de114a..4249bab2ae1 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 21896567f5d..ec35fc1e633 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 d9caad07d82..d789fb6fe3e 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 4a4cbb61807..a8fc1fd83e7 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 ef9dd3e9a61..7bb21874094 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 fafadab99a0..08e2adb9e7b 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 84a3965e724..703a0ae9f05 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 a46a3b39977..9a765b7a397 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 45f17d755f8..14178111e77 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 e30efb40c72..82e0186bdfe 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 8311204f49a..e2a5c44315e 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 601a70ee978..be4d961aa4a 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 9d481e80c79..8c025a97e96 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 a43dbe46a93..30312dc6188 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 aa05ba82123..a770a9a73cd 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 9895983da2c..fad05dfa242 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 c0467a9dd3b..62f73329ed3 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 842b2b8cf0e..24ca3786947 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 2b2723de317..14a687a017b 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 cfb0c85f430..cc86b848387 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 9a5e25a5633..d406d674e4f 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 3b453745394..55c58235702 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 0b4265808bc..bf6ab8a3f7b 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 7ad753eded4..7f908424da3 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 5e6b8a7eaf3..4fd3ecdc086 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 6135583cb84..b70f6bcd724 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 eaa37cbc994..a3128d160d5 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 20ddb1a9ac4..9741fc81e88 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 34b945904eb..e98ac2b5cfa 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 af2f9d6c44a..f2bace9ae6a 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 c03e199bde4..b0fb8ea22e0 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 b1b3272aa04..1b9ce40064a 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 e5050104e07..7e442aef091 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 2d143474858..e3dbfcce156 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 4e72b1a0d04..32f040ee2d9 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 3277a9430c7..1c9f7e729ad 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 b0ab3321d05..b9e9f43534c 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 231e5002883..d352030402c 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 18a6506e32f..9a9597c7347 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 f1f2b556903..b9d8b949911 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 543a09d4633..9cc67a81f06 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 ad6c4089e8a..18adeb561ca 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 527562be1e6..62901d05bbc 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 3a56b7614bb..9fcb3a0a74d 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 60f79b6171e..7810b85a5cf 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 c2e348dc4b1..20ec9197b88 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 1a41984f99c..6b89a9c0bdc 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 10a13d15dc4..36651101ffb 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 8581535a92a..a9894898205 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 f9f4cfa299a..8dfeffc4d8e 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 13a1dc60a08..94d680a217b 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 2fd84ffde90..2c9b3a575cd 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 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 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 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 e73a0ef42b0..09f8c9596e2 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 9b0f8997df5..8de292bf33e 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 d30a3ce0fbb..65d4a473dc4 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 bfcf0001f09..111f75142ba 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 8467ffec10a..8349af90b73 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 cc37d49949a..415b3fe340e 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 31131741ffa..f7e0598f1c3 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 e0edb49ab67..0d1bb6fc8a8 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 b55bdf24fed..7a55ae46d94 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 5318457e825..14750f1d18c 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 ce25c9fbaeb..8a86d4fa8f8 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 c129bc0d735..645864d867a 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 24b0a03df78..ab8796e1a4c 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 942af516cf5..12dfe285721 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 16a75f6a322..e4a1fe6885c 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 4568c1c9915..e43a617e673 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 f867d59a01e..81627456012 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 10c55fe018a..a6a5638069a 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 6f44b4a2e7d..c5811ff8e98 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 ca5f5720f41..febd8e5b9e8 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 2d25bbad1eb..2057bf5da42 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 835d020d920..2b8914bf4ee 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 65b93242dcd..694bdd11c3a 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 38a2bf04d4c..3fc8ac5f555 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 5826d5406ed..4e287e0385c 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 9b5570e80c4..d9a8c7cdf38 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 c270bb15720..b485b5fb768 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 e60c27a01f2..7391fed7b1e 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 637b8da2238..855e307dee0 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 d697fae57d3..8902427d3ba 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 303683276dc..670b43215b7 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 aa0b7a699d4..945f49d1bda 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 4ad39647226..4d03c405fee 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 1308c5cbbe5..1a27f5b5945 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 39b56bf6e48..816dcda32fa 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 878dbb698b3..a3b176a477f 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 da1f36908f1..6bf9c87014b 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 bc949cbf40b..89152869d7b 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 8611cdee6af..00d76be3280 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 05607a11941..072adedf21e 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 f96b05b40db..bc077f90768 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 6c335cabc7f..cfac8accfa2 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 aa34a05c09f..796ae6d33ff 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 259dc7e0cb3..86fdfb817c3 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 ac9fe8b7ce7..576ed2b8aef 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 c76397c546f..03621c828c4 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 c822b6bbde1..babf5491d35 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 4feeed2f986..5348416f056 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 3c9737e5e7b..c667e18eb0c 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 eefcd92d09f..ecb5c036db5 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 7b9d467254a..d5b436d8dac 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 dae1899fd6d..f37687c82cf 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 7446f97dc3e..5a8acf1ed80 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 c4764102d6c..0cf5d58ba8a 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 11aefd87057..c695f234520 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 edcb3e1c4db..c5cee84b911 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 f204709d746..7b30a998f6a 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 9d65f7d9f15..3762382b905 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 1d82794ff3f..23c87cd4031 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 817e4c74d1f..0635ea4188c 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 f8753c2bc26..12879f2fcbb 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 6c091295278..54be11ba66f 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 e1a4317aa99..393e47f3075 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 0807e210973..a4638a09bc4 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 12d1c0852f7..1ab7cf4f411 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 21abbf47669..7788c6f3b36 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 95997a7dfbf..580512a201c 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 bb59e776058..168f6238722 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 d620651c35a..164f89341d1 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 ffead277b71..de0dd5c1520 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 e183c055e3c..19cbf621070 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 a84ad1047c4..851a127d6f7 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 62263e72322..993b70eb300 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 f97bca1175f..8ead20413cc 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 6dddf74174f..9e13b80329e 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 21905da5c63..576f5b55037 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 8899709d896..fc0280a775f 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 425eab0fe73..fb1d70b5d6c 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 aaffa0c2890..d083aa04a42 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 3b990aa09f0..85711038409 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 5ac71cdd9a1..36858d85374 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 cdfeffe0b8f..2e0c8b15ddf 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 d7162d1fc49..0bc2c26ed0f 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 0e6314d3098..c34ce44b2d0 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 99b67daba83..9c79d8ed3ee 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 fff3142b597..58389280863 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 ca46e371082..1a27b116a86 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 77bed46dea4..386991012a0 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 726deb9c0c3..22b07fb907b 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 c868b78b42b..aa791d26e72 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 f91527820aa..1f25d9dd7cd 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 3524465e457..4dcaf38d832 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 34c7350aded..572f1c0a103 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 eff62c607bd..146d1d8a8db 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 0637a6810b1..5883f505181 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 364ed1219e8..4d0001a7657 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 de7f08e15ec..50ba3e7d393 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 2be236f11f5..ae0bccc68d3 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 9702ef01d47..fc5315c14ad 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 b1fde1134d5..54f2eaaec20 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 e897172fbfd..c0a1c22f0ea 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 21927d3cc52..e362030ec6c 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 ca4f95f7328..c4c618295d9 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 5f077ac5ddc..1b9dbfbd31b 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 cc7d5ccdf2f..5420ac63e46 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 2faffb90b7f..fa30eed1e82 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 09473f6c8fc..d1044ca2f81 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 853ecbd4fa4..7da0fec32a1 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 6479244f31f..94bf06292fa 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 663007ff425..72abfda4888 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 e4650956f3e..9d5d0160559 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 d788dec1e4d..313590acfc4 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 ebc56823e99..4ca4996c387 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 2e706f5eca8..71829d34085 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 df923a8100f..4110e4a557a 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 cf240a2d244..f74b0e9b421 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 efa239b108c..5560a9fde4b 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 706d80a8a86..d448dae21f0 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 edd944668ec..36e51e8b18b 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 54099af2869..9c14cf83e34 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 05a26e8d41a..af25f898c7a 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 4ef7098cd51..73112470e3c 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 4ed54691db6..9e63e6adddd 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 ed2d2beaa1c..bf0286a9921 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 11bd3a00b3e..833dbd2a028 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 b5a86de144c..2965b56972e 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 0c6316e29ad..6665e09a268 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 e9e1718a3df..42df331431d 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 19a820dd2f6..9bf733613d1 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 561996d3ca8..783648708ad 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 79f0c4a66c1..640002cd8f8 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 88fcdcacf5a..09f396819e0 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 ce9cbe1779f..8b0d042042b 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 51fd4302d8c..6feb22422f2 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 398c01c9935..d00c37aff78 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 444cfabb8a2..9b1eae56049 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");