1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

LibWeb: Rename URL platform object to DOMURL

Along with putting functions in the URL namespace into a DOMURL
namespace.

This is done as LibWeb is in an awkward situation where it needs
two URL classes. AK::URL is the general purpose URL class which
is all that is needed in 95% of cases. URL in the Web namespace
is needed predominantly for interfacing with the javascript
interfaces.

Because of two URLs in the same namespace, AK::URL has had to be
used throughout LibWeb. If we move AK::URL into a URL namespace,
this becomes more painful - where ::URL::URL is required to
specify the constructor (and something like
::URL::create_with_url_or_path in other places).

To fix this problem - rename the class in LibWeb implementing the
URL IDL interface to DOMURL, along with moving the other Web URL
related classes into this DOMURL folder.

One could argue that this name also makes the situation a little
more clear in LibWeb for why these two URL classes need be used
in the first place.
This commit is contained in:
Shannon Booth 2024-02-11 19:48:56 +13:00 committed by Andreas Kling
parent 1b6346ee1c
commit f9e5b43b7a
30 changed files with 125 additions and 125 deletions

View file

@ -3422,6 +3422,7 @@ using namespace Web::Animations;
using namespace Web::CSS;
using namespace Web::DOM;
using namespace Web::DOMParsing;
using namespace Web::DOMURL;
using namespace Web::Encoding;
using namespace Web::Fetch;
using namespace Web::FileAPI;
@ -3435,7 +3436,6 @@ using namespace Web::ResizeObserver;
using namespace Web::Selection;
using namespace Web::Streams;
using namespace Web::UIEvents;
using namespace Web::URL;
using namespace Web::XHR;
using namespace Web::WebAssembly;
using namespace Web::WebAudio;
@ -3614,8 +3614,8 @@ void generate_constructor_implementation(IDL::Interface const& interface, String
# include <LibWeb/WebSockets/@name@.h>
#elif __has_include(<LibWeb/XHR/@name@.h>)
# include <LibWeb/XHR/@name@.h>
#elif __has_include(<LibWeb/URL/@name@.h>)
# include <LibWeb/URL/@name@.h>
#elif __has_include(<LibWeb/DOMURL/@name@.h>)
# include <LibWeb/DOMURL/@name@.h>
#endif
#include <LibWeb/HTML/WindowProxy.h>
#include <LibWeb/WebIDL/AbstractOperations.h>
@ -3650,6 +3650,7 @@ using namespace Web::Animations;
using namespace Web::CSS;
using namespace Web::DOM;
using namespace Web::DOMParsing;
using namespace Web::DOMURL;
using namespace Web::Encoding;
using namespace Web::Fetch;
using namespace Web::FileAPI;
@ -3665,7 +3666,6 @@ using namespace Web::Selection;
using namespace Web::Streams;
using namespace Web::UIEvents;
using namespace Web::UserTiming;
using namespace Web::URL;
using namespace Web::XHR;
using namespace Web::WebAssembly;
using namespace Web::WebAudio;
@ -4130,6 +4130,7 @@ using namespace Web::Crypto;
using namespace Web::CSS;
using namespace Web::DOM;
using namespace Web::DOMParsing;
using namespace Web::DOMURL;
using namespace Web::Encoding;
using namespace Web::Fetch;
using namespace Web::FileAPI;
@ -4146,7 +4147,6 @@ using namespace Web::Selection;
using namespace Web::Streams;
using namespace Web::SVG;
using namespace Web::UIEvents;
using namespace Web::URL;
using namespace Web::UserTiming;
using namespace Web::WebSockets;
using namespace Web::XHR;
@ -4282,6 +4282,7 @@ using namespace Web::Animations;
using namespace Web::CSS;
using namespace Web::DOM;
using namespace Web::DOMParsing;
using namespace Web::DOMURL;
using namespace Web::Encoding;
using namespace Web::Fetch;
using namespace Web::FileAPI;
@ -4297,7 +4298,6 @@ using namespace Web::ResizeObserver;
using namespace Web::Selection;
using namespace Web::XHR;
using namespace Web::UIEvents;
using namespace Web::URL;
using namespace Web::UserTiming;
using namespace Web::WebAudio;
using namespace Web::WebGL;
@ -4420,6 +4420,7 @@ using namespace Web::Crypto;
using namespace Web::CSS;
using namespace Web::DOM;
using namespace Web::DOMParsing;
using namespace Web::DOMURL;
using namespace Web::Encoding;
using namespace Web::Fetch;
using namespace Web::FileAPI;
@ -4436,7 +4437,6 @@ using namespace Web::Selection;
using namespace Web::Streams;
using namespace Web::SVG;
using namespace Web::UIEvents;
using namespace Web::URL;
using namespace Web::UserTiming;
using namespace Web::WebAudio;
using namespace Web::WebSockets;

View file

@ -18,6 +18,7 @@ static constexpr Array libweb_interface_namespaces = {
"Crypto"sv,
"DOM"sv,
"DOMParsing"sv,
"DOMURL"sv,
"Encoding"sv,
"Fetch"sv,
"FileAPI"sv,
@ -33,7 +34,6 @@ static constexpr Array libweb_interface_namespaces = {
"SVG"sv,
"Selection"sv,
"UIEvents"sv,
"URL"sv,
"WebAudio"sv,
"WebGL"sv,
"WebIDL"sv,

View file

@ -184,6 +184,9 @@ set(SOURCES
DOM/XMLDocument.cpp
DOMParsing/InnerHTML.cpp
DOMParsing/XMLSerializer.cpp
DOMURL/DOMURL.cpp
DOMURL/URLSearchParams.cpp
DOMURL/URLSearchParamsIterator.cpp
Dump.cpp
Encoding/TextDecoder.cpp
Encoding/TextEncoder.cpp
@ -610,9 +613,6 @@ set(SOURCES
UIEvents/MouseEvent.cpp
UIEvents/UIEvent.cpp
UIEvents/WheelEvent.cpp
URL/URL.cpp
URL/URLSearchParams.cpp
URL/URLSearchParamsIterator.cpp
UserTiming/PerformanceMark.cpp
UserTiming/PerformanceMeasure.cpp
WebAssembly/Instance.cpp

View file

@ -10,17 +10,17 @@
#include <AK/IPv6Address.h>
#include <AK/URLParser.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/FileAPI/Blob.h>
#include <LibWeb/FileAPI/BlobURLStore.h>
#include <LibWeb/URL/URL.h>
namespace Web::URL {
namespace Web::DOMURL {
JS_DEFINE_ALLOCATOR(URL);
JS_DEFINE_ALLOCATOR(DOMURL);
JS::NonnullGCPtr<URL> URL::create(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query)
JS::NonnullGCPtr<DOMURL> DOMURL::create(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query)
{
return realm.heap().allocate<URL>(realm, realm, move(url), move(query));
return realm.heap().allocate<DOMURL>(realm, realm, move(url), move(query));
}
// https://url.spec.whatwg.org/#api-url-parser
@ -50,7 +50,7 @@ static Optional<AK::URL> parse_api_url(String const& url, Optional<String> const
}
// https://url.spec.whatwg.org/#dom-url-url
WebIDL::ExceptionOr<JS::NonnullGCPtr<URL>> URL::construct_impl(JS::Realm& realm, String const& url, Optional<String> const& base)
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMURL>> DOMURL::construct_impl(JS::Realm& realm, String const& url, Optional<String> const& base)
{
// 1. Let parsedURL be the result of running the API URL parser on url with base, if given.
auto parsed_url = parse_api_url(url, base);
@ -67,7 +67,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<URL>> URL::construct_impl(JS::Realm& realm,
auto query_object = MUST(URLSearchParams::construct_impl(realm, query));
// 6. Initialize thiss query object with query.
auto result_url = URL::create(realm, parsed_url.release_value(), move(query_object));
auto result_url = DOMURL::create(realm, parsed_url.release_value(), move(query_object));
// 7. Set thiss query objects URL object to this.
result_url->m_query->m_url = result_url;
@ -75,36 +75,36 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<URL>> URL::construct_impl(JS::Realm& realm,
return result_url;
}
URL::URL(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query)
DOMURL::DOMURL(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query)
: PlatformObject(realm)
, m_url(move(url))
, m_query(move(query))
{
}
URL::~URL() = default;
DOMURL::~DOMURL() = default;
void URL::initialize(JS::Realm& realm)
void DOMURL::initialize(JS::Realm& realm)
{
Base::initialize(realm);
set_prototype(&Bindings::ensure_web_prototype<Bindings::URLPrototype>(realm, "URL"_fly_string));
set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMURLPrototype>(realm, "URL"_fly_string));
}
void URL::visit_edges(Cell::Visitor& visitor)
void DOMURL::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_query);
}
// https://w3c.github.io/FileAPI/#dfn-createObjectURL
WebIDL::ExceptionOr<String> URL::create_object_url(JS::VM& vm, JS::NonnullGCPtr<FileAPI::Blob> object)
WebIDL::ExceptionOr<String> DOMURL::create_object_url(JS::VM& vm, JS::NonnullGCPtr<FileAPI::Blob> object)
{
// The createObjectURL(obj) static method must return the result of adding an entry to the blob URL store for obj.
return TRY_OR_THROW_OOM(vm, FileAPI::add_entry_to_blob_url_store(object));
}
// https://w3c.github.io/FileAPI/#dfn-revokeObjectURL
WebIDL::ExceptionOr<void> URL::revoke_object_url(JS::VM& vm, StringView url)
WebIDL::ExceptionOr<void> DOMURL::revoke_object_url(JS::VM& vm, StringView url)
{
// 1. Let url record be the result of parsing url.
auto url_record = parse(url);
@ -129,7 +129,7 @@ WebIDL::ExceptionOr<void> URL::revoke_object_url(JS::VM& vm, StringView url)
}
// https://url.spec.whatwg.org/#dom-url-canparse
bool URL::can_parse(JS::VM&, String const& url, Optional<String> const& base)
bool DOMURL::can_parse(JS::VM&, String const& url, Optional<String> const& base)
{
// 1. Let parsedURL be the result of running the API URL parser on url with base, if given.
auto parsed_url = parse_api_url(url, base);
@ -143,7 +143,7 @@ bool URL::can_parse(JS::VM&, String const& url, Optional<String> const& base)
}
// https://url.spec.whatwg.org/#dom-url-href
WebIDL::ExceptionOr<String> URL::href() const
WebIDL::ExceptionOr<String> DOMURL::href() const
{
auto& vm = realm().vm();
@ -152,7 +152,7 @@ WebIDL::ExceptionOr<String> URL::href() const
}
// https://url.spec.whatwg.org/#dom-url-tojson
WebIDL::ExceptionOr<String> URL::to_json() const
WebIDL::ExceptionOr<String> DOMURL::to_json() const
{
auto& vm = realm().vm();
@ -161,7 +161,7 @@ WebIDL::ExceptionOr<String> URL::to_json() const
}
// https://url.spec.whatwg.org/#ref-for-dom-url-href②
WebIDL::ExceptionOr<void> URL::set_href(String const& href)
WebIDL::ExceptionOr<void> DOMURL::set_href(String const& href)
{
auto& vm = realm().vm();
@ -188,7 +188,7 @@ WebIDL::ExceptionOr<void> URL::set_href(String const& href)
}
// https://url.spec.whatwg.org/#dom-url-origin
WebIDL::ExceptionOr<String> URL::origin() const
WebIDL::ExceptionOr<String> DOMURL::origin() const
{
auto& vm = realm().vm();
@ -197,7 +197,7 @@ WebIDL::ExceptionOr<String> URL::origin() const
}
// https://url.spec.whatwg.org/#dom-url-protocol
WebIDL::ExceptionOr<String> URL::protocol() const
WebIDL::ExceptionOr<String> DOMURL::protocol() const
{
auto& vm = realm().vm();
@ -206,7 +206,7 @@ WebIDL::ExceptionOr<String> URL::protocol() const
}
// https://url.spec.whatwg.org/#ref-for-dom-url-protocol%E2%91%A0
WebIDL::ExceptionOr<void> URL::set_protocol(String const& protocol)
WebIDL::ExceptionOr<void> DOMURL::set_protocol(String const& protocol)
{
auto& vm = realm().vm();
@ -219,7 +219,7 @@ WebIDL::ExceptionOr<void> URL::set_protocol(String const& protocol)
}
// https://url.spec.whatwg.org/#dom-url-username
WebIDL::ExceptionOr<String> URL::username() const
WebIDL::ExceptionOr<String> DOMURL::username() const
{
auto& vm = realm().vm();
@ -228,7 +228,7 @@ WebIDL::ExceptionOr<String> URL::username() const
}
// https://url.spec.whatwg.org/#ref-for-dom-url-username%E2%91%A0
void URL::set_username(String const& username)
void DOMURL::set_username(String const& username)
{
// 1. If thiss URL cannot have a username/password/port, then return.
if (m_url.cannot_have_a_username_or_password_or_port())
@ -239,7 +239,7 @@ void URL::set_username(String const& username)
}
// https://url.spec.whatwg.org/#dom-url-password
WebIDL::ExceptionOr<String> URL::password() const
WebIDL::ExceptionOr<String> DOMURL::password() const
{
auto& vm = realm().vm();
@ -248,7 +248,7 @@ WebIDL::ExceptionOr<String> URL::password() const
}
// https://url.spec.whatwg.org/#ref-for-dom-url-password%E2%91%A0
void URL::set_password(String const& password)
void DOMURL::set_password(String const& password)
{
// 1. If thiss URL cannot have a username/password/port, then return.
if (m_url.cannot_have_a_username_or_password_or_port())
@ -259,7 +259,7 @@ void URL::set_password(String const& password)
}
// https://url.spec.whatwg.org/#dom-url-host
WebIDL::ExceptionOr<String> URL::host() const
WebIDL::ExceptionOr<String> DOMURL::host() const
{
auto& vm = realm().vm();
@ -279,7 +279,7 @@ WebIDL::ExceptionOr<String> URL::host() const
}
// https://url.spec.whatwg.org/#dom-url-hostref-for-dom-url-host%E2%91%A0
void URL::set_host(String const& host)
void DOMURL::set_host(String const& host)
{
// 1. If thiss URLs cannot-be-a-base-URL is true, then return.
if (m_url.cannot_be_a_base_url())
@ -292,7 +292,7 @@ void URL::set_host(String const& host)
}
// https://url.spec.whatwg.org/#dom-url-hostname
WebIDL::ExceptionOr<String> URL::hostname() const
WebIDL::ExceptionOr<String> DOMURL::hostname() const
{
auto& vm = realm().vm();
@ -305,7 +305,7 @@ WebIDL::ExceptionOr<String> URL::hostname() const
}
// https://url.spec.whatwg.org/#ref-for-dom-url-hostname①
void URL::set_hostname(String const& hostname)
void DOMURL::set_hostname(String const& hostname)
{
// 1. If thiss URLs cannot-be-a-base-URL is true, then return.
if (m_url.cannot_be_a_base_url())
@ -318,7 +318,7 @@ void URL::set_hostname(String const& hostname)
}
// https://url.spec.whatwg.org/#dom-url-port
WebIDL::ExceptionOr<String> URL::port() const
WebIDL::ExceptionOr<String> DOMURL::port() const
{
auto& vm = realm().vm();
@ -331,7 +331,7 @@ WebIDL::ExceptionOr<String> URL::port() const
}
// https://url.spec.whatwg.org/#ref-for-dom-url-port%E2%91%A0
void URL::set_port(String const& port)
void DOMURL::set_port(String const& port)
{
// 1. If thiss URL cannot have a username/password/port, then return.
if (m_url.cannot_have_a_username_or_password_or_port())
@ -350,7 +350,7 @@ void URL::set_port(String const& port)
}
// https://url.spec.whatwg.org/#dom-url-pathname
WebIDL::ExceptionOr<String> URL::pathname() const
WebIDL::ExceptionOr<String> DOMURL::pathname() const
{
auto& vm = realm().vm();
@ -359,7 +359,7 @@ WebIDL::ExceptionOr<String> URL::pathname() const
}
// https://url.spec.whatwg.org/#ref-for-dom-url-pathname%E2%91%A0
void URL::set_pathname(String const& pathname)
void DOMURL::set_pathname(String const& pathname)
{
// FIXME: These steps no longer match the speci.
// 1. If thiss URLs cannot-be-a-base-URL is true, then return.
@ -377,7 +377,7 @@ void URL::set_pathname(String const& pathname)
}
// https://url.spec.whatwg.org/#dom-url-search
WebIDL::ExceptionOr<String> URL::search() const
WebIDL::ExceptionOr<String> DOMURL::search() const
{
auto& vm = realm().vm();
@ -390,7 +390,7 @@ WebIDL::ExceptionOr<String> URL::search() const
}
// https://url.spec.whatwg.org/#ref-for-dom-url-search%E2%91%A0
WebIDL::ExceptionOr<void> URL::set_search(String const& search)
WebIDL::ExceptionOr<void> DOMURL::set_search(String const& search)
{
auto& vm = realm().vm();
@ -433,14 +433,14 @@ WebIDL::ExceptionOr<void> URL::set_search(String const& search)
}
// https://url.spec.whatwg.org/#dom-url-searchparams
JS::NonnullGCPtr<URLSearchParams const> URL::search_params() const
JS::NonnullGCPtr<URLSearchParams const> DOMURL::search_params() const
{
// The searchParams getter steps are to return thiss query object.
return m_query;
}
// https://url.spec.whatwg.org/#dom-url-hash
WebIDL::ExceptionOr<String> URL::hash() const
WebIDL::ExceptionOr<String> DOMURL::hash() const
{
auto& vm = realm().vm();
@ -453,7 +453,7 @@ WebIDL::ExceptionOr<String> URL::hash() const
}
// https://url.spec.whatwg.org/#ref-for-dom-url-hash%E2%91%A0
void URL::set_hash(String const& hash)
void DOMURL::set_hash(String const& hash)
{
// 1. If the given value is the empty string:
if (hash.is_empty()) {
@ -540,7 +540,7 @@ bool host_is_domain(AK::URL::Host const& host)
}
// https://url.spec.whatwg.org/#potentially-strip-trailing-spaces-from-an-opaque-path
void strip_trailing_spaces_from_an_opaque_path(URL& url)
void strip_trailing_spaces_from_an_opaque_path(DOMURL& url)
{
// 1. If urls URL does not have an opaque path, then return.
// FIXME: Reimplement this step once we modernize the URL implementation to meet the spec.

View file

@ -10,20 +10,20 @@
#include <AK/URL.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/URL/URLSearchParams.h>
#include <LibWeb/DOMURL/URLSearchParams.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::URL {
namespace Web::DOMURL {
class URL : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(URL, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(URL);
class DOMURL : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DOMURL, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMURL);
public:
[[nodiscard]] static JS::NonnullGCPtr<URL> create(JS::Realm&, AK::URL, JS::NonnullGCPtr<URLSearchParams> query);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<URL>> construct_impl(JS::Realm&, String const& url, Optional<String> const& base = {});
[[nodiscard]] static JS::NonnullGCPtr<DOMURL> create(JS::Realm&, URL, JS::NonnullGCPtr<URLSearchParams> query);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMURL>> construct_impl(JS::Realm&, String const& url, Optional<String> const& base = {});
virtual ~URL() override;
virtual ~DOMURL() override;
static WebIDL::ExceptionOr<String> create_object_url(JS::VM&, JS::NonnullGCPtr<FileAPI::Blob> object);
static WebIDL::ExceptionOr<void> revoke_object_url(JS::VM&, StringView url);
@ -79,7 +79,7 @@ public:
void set_query(Badge<URLSearchParams>, Optional<String> query) { m_url.set_query(move(query)); }
private:
URL(JS::Realm&, AK::URL, JS::NonnullGCPtr<URLSearchParams> query);
DOMURL(JS::Realm&, AK::URL, JS::NonnullGCPtr<URLSearchParams> query);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
@ -92,7 +92,7 @@ HTML::Origin url_origin(AK::URL const&);
bool host_is_domain(AK::URL::Host const&);
// https://url.spec.whatwg.org/#potentially-strip-trailing-spaces-from-an-opaque-path
void strip_trailing_spaces_from_an_opaque_path(URL& url);
void strip_trailing_spaces_from_an_opaque_path(DOMURL& url);
// https://url.spec.whatwg.org/#concept-url-parser
AK::URL parse(StringView input, Optional<AK::URL> const& base_url = {});

View file

@ -1,8 +1,8 @@
#import <FileAPI/Blob.idl>
#import <URL/URLSearchParams.idl>
#import <DOMURL/URLSearchParams.idl>
// https://url.spec.whatwg.org/#url
[Exposed=*, LegacyWindowAlias=webkitURL]
[Exposed=*, LegacyWindowAlias=webkitURL, ImplementedAs=DOMURL]
interface URL {
constructor(USVString url, optional USVString base);

View file

@ -12,10 +12,10 @@
#include <LibTextCodec/Decoder.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/URL/URL.h>
#include <LibWeb/URL/URLSearchParams.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/DOMURL/URLSearchParams.h>
namespace Web::URL {
namespace Web::DOMURL {
JS_DEFINE_ALLOCATOR(URLSearchParams);

View file

@ -10,7 +10,7 @@
#include <AK/Vector.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::URL {
namespace Web::DOMURL {
struct QueryParam {
String name;
@ -45,7 +45,7 @@ public:
JS::ThrowCompletionOr<void> for_each(ForEachCallback);
private:
friend class URL;
friend class DOMURL;
friend class URLSearchParamsIterator;
URLSearchParams(JS::Realm&, Vector<QueryParam> list);
@ -56,7 +56,7 @@ private:
WebIDL::ExceptionOr<void> update();
Vector<QueryParam> m_list;
JS::GCPtr<URL> m_url;
JS::GCPtr<DOMURL> m_url;
};
}

View file

@ -8,7 +8,7 @@
#include <LibJS/Runtime/Iterator.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/URLSearchParamsIteratorPrototype.h>
#include <LibWeb/URL/URLSearchParamsIterator.h>
#include <LibWeb/DOMURL/URLSearchParamsIterator.h>
namespace Web::Bindings {
@ -21,7 +21,7 @@ void Intrinsics::create_web_prototype_and_constructor<URLSearchParamsIteratorPro
}
namespace Web::URL {
namespace Web::DOMURL {
JS_DEFINE_ALLOCATOR(URLSearchParamsIterator);

View file

@ -7,9 +7,9 @@
#pragma once
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/URL/URLSearchParams.h>
#include <LibWeb/DOMURL/URLSearchParams.h>
namespace Web::URL {
namespace Web::DOMURL {
class URLSearchParamsIterator : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(URLSearchParamsIterator, Bindings::PlatformObject);

View file

@ -6,13 +6,13 @@
*/
#include <LibJS/Runtime/Completion.h>
#include <LibWeb/DOMURL/URLSearchParams.h>
#include <LibWeb/Fetch/BodyInit.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
#include <LibWeb/FileAPI/Blob.h>
#include <LibWeb/HTML/FormControlInfrastructure.h>
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
#include <LibWeb/Streams/AbstractOperations.h>
#include <LibWeb/URL/URLSearchParams.h>
#include <LibWeb/WebIDL/AbstractOperations.h>
#include <LibWeb/WebIDL/Buffers.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@ -103,7 +103,7 @@ WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm,
type = TRY_OR_THROW_OOM(vm, ByteBuffer::copy(TRY_OR_THROW_OOM(vm, String::formatted("multipart/form-data; boundary={}"sv, serialized_form_data.boundary)).bytes()));
return {};
},
[&](JS::Handle<URL::URLSearchParams> const& url_search_params) -> WebIDL::ExceptionOr<void> {
[&](JS::Handle<DOMURL::URLSearchParams> const& url_search_params) -> WebIDL::ExceptionOr<void> {
// Set source to the result of running the application/x-www-form-urlencoded serializer with objects list.
auto search_params_bytes = TRY(url_search_params->to_string()).bytes();
source = TRY_OR_THROW_OOM(vm, ByteBuffer::copy(search_params_bytes));

View file

@ -14,9 +14,9 @@
namespace Web::Fetch {
// https://fetch.spec.whatwg.org/#bodyinit
using BodyInit = Variant<JS::Handle<Streams::ReadableStream>, JS::Handle<FileAPI::Blob>, JS::Handle<WebIDL::BufferSource>, JS::Handle<XHR::FormData>, JS::Handle<URL::URLSearchParams>, String>;
using BodyInit = Variant<JS::Handle<Streams::ReadableStream>, JS::Handle<FileAPI::Blob>, JS::Handle<WebIDL::BufferSource>, JS::Handle<XHR::FormData>, JS::Handle<DOMURL::URLSearchParams>, String>;
using BodyInitOrReadableBytes = Variant<JS::Handle<Streams::ReadableStream>, JS::Handle<FileAPI::Blob>, JS::Handle<WebIDL::BufferSource>, JS::Handle<XHR::FormData>, JS::Handle<URL::URLSearchParams>, String, ReadonlyBytes>;
using BodyInitOrReadableBytes = Variant<JS::Handle<Streams::ReadableStream>, JS::Handle<FileAPI::Blob>, JS::Handle<WebIDL::BufferSource>, JS::Handle<XHR::FormData>, JS::Handle<DOMURL::URLSearchParams>, String, ReadonlyBytes>;
WebIDL::ExceptionOr<Infrastructure::BodyWithType> safely_extract_body(JS::Realm&, BodyInitOrReadableBytes const&);
WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm&, BodyInitOrReadableBytes const&, bool keepalive = false);

View file

@ -1,6 +1,6 @@
#import <FileAPI/Blob.idl>
#import <Streams/ReadableStream.idl>
#import <URL/URLSearchParams.idl>
#import <DOMURL/URLSearchParams.idl>
#import <XHR/FormData.idl>
// https://fetch.spec.whatwg.org/#typedefdef-xmlhttprequestbodyinit

View file

@ -4,10 +4,10 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/Fetch/Fetching/Checks.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
#include <LibWeb/URL/URL.h>
namespace Web::Fetch::Fetching {
@ -70,7 +70,7 @@ ErrorOr<bool> tao_check(Infrastructure::Request const& request, Infrastructure::
// information, but the container document would not.
if (request.mode() == Infrastructure::Request::Mode::Navigate
&& request.origin().has<HTML::Origin>()
&& !URL::url_origin(request.current_url()).is_same_origin(request.origin().get<HTML::Origin>())) {
&& !DOMURL::url_origin(request.current_url()).is_same_origin(request.origin().get<HTML::Origin>())) {
return false;
}

View file

@ -13,6 +13,7 @@
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/Cookie/Cookie.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/Fetch/BodyInit.h>
#include <LibWeb/Fetch/Fetching/Checks.h>
#include <LibWeb/Fetch/Fetching/Fetching.h>
@ -43,7 +44,6 @@
#include <LibWeb/Platform/EventLoopPlugin.h>
#include <LibWeb/ReferrerPolicy/AbstractOperations.h>
#include <LibWeb/SRI/SRI.h>
#include <LibWeb/URL/URL.h>
#include <LibWeb/WebIDL/DOMException.h>
namespace Web::Fetch::Fetching {
@ -259,7 +259,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
// - requests current URLs scheme is "http"
request->current_url().scheme() == "http"sv
// - requests current URLs host is a domain
&& URL::host_is_domain(request->current_url().host())
&& DOMURL::host_is_domain(request->current_url().host())
// FIXME: - Matching requests current URLs host per Known HSTS Host Domain Name Matching results in either a
// superdomain match with an asserted includeSubDomains directive or a congruent match (with or without an
// asserted includeSubDomains directive) [HSTS]; or DNS resolution for the request finds a matching HTTPS RR
@ -291,7 +291,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
// -> requests current URLs scheme is "data"
// -> requests mode is "navigate" or "websocket"
else if (
(request->origin().has<HTML::Origin>() && URL::url_origin(request->current_url()).is_same_origin(request->origin().get<HTML::Origin>()) && request->response_tainting() == Infrastructure::Request::ResponseTainting::Basic)
(request->origin().has<HTML::Origin>() && DOMURL::url_origin(request->current_url()).is_same_origin(request->origin().get<HTML::Origin>()) && request->response_tainting() == Infrastructure::Request::ResponseTainting::Basic)
|| request->current_url().scheme() == "data"sv
|| (request->mode() == Infrastructure::Request::Mode::Navigate || request->mode() == Infrastructure::Request::Mode::WebSocket)) {
// 1. Set requests response tainting to "basic".
@ -1113,7 +1113,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> http_redirect_f
if (request->mode() == Infrastructure::Request::Mode::CORS
&& location_url.includes_credentials()
&& request->origin().has<HTML::Origin>()
&& !request->origin().get<HTML::Origin>().is_same_origin(URL::url_origin(location_url))) {
&& !request->origin().get<HTML::Origin>().is_same_origin(DOMURL::url_origin(location_url))) {
return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'cors' mode and different URL and request origin must not include credentials in redirect URL"sv));
}
@ -1156,7 +1156,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> http_redirect_f
// 13. If requests current URLs origin is not same origin with locationURLs origin, then for each headerName of
// CORS non-wildcard request-header name, delete headerName from requests header list.
// NOTE: I.e., the moment another origin is seen after the initial request, the `Authorization` header is removed.
if (!URL::url_origin(request->current_url()).is_same_origin(URL::url_origin(location_url))) {
if (!DOMURL::url_origin(request->current_url()).is_same_origin(DOMURL::url_origin(location_url))) {
static constexpr Array cors_non_wildcard_request_header_names {
"Authorization"sv
};

View file

@ -7,9 +7,9 @@
#include <AK/Array.h>
#include <LibJS/Heap/Heap.h>
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/Fetch/Fetching/PendingResponse.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
#include <LibWeb/URL/URL.h>
namespace Web::Fetch::Infrastructure {
@ -175,8 +175,8 @@ bool Request::has_redirect_tainted_origin() const
// 2. If urls origin is not same origin with lastURLs origin and requests origin is not same origin with lastURLs origin, then return true.
auto const* request_origin = m_origin.get_pointer<HTML::Origin>();
if (!URL::url_origin(url).is_same_origin(URL::url_origin(*last_url))
&& (request_origin == nullptr || !request_origin->is_same_origin(URL::url_origin(*last_url)))) {
if (!DOMURL::url_origin(url).is_same_origin(DOMURL::url_origin(*last_url))
&& (request_origin == nullptr || !request_origin->is_same_origin(DOMURL::url_origin(*last_url)))) {
return true;
}
@ -331,7 +331,7 @@ ErrorOr<void> Request::add_origin_header()
case ReferrerPolicy::ReferrerPolicy::SameOrigin:
// If requests origin is not same origin with requests current URLs origin, then set serializedOrigin
// to `null`.
if (m_origin.has<HTML::Origin>() && !m_origin.get<HTML::Origin>().is_same_origin(URL::url_origin(current_url())))
if (m_origin.has<HTML::Origin>() && !m_origin.get<HTML::Origin>().is_same_origin(DOMURL::url_origin(current_url())))
serialized_origin = MUST(ByteBuffer::copy("null"sv.bytes()));
break;
// -> Otherwise
@ -371,7 +371,7 @@ bool Request::cross_origin_embedder_policy_allows_credentials() const
if (request_origin == nullptr)
return false;
return request_origin->is_same_origin(URL::url_origin(current_url())) && !has_redirect_tainted_origin();
return request_origin->is_same_origin(DOMURL::url_origin(current_url())) && !has_redirect_tainted_origin();
}
}

View file

@ -10,10 +10,10 @@
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/VM.h>
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/Fetch/Infrastructure/FetchParams.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
#include <LibWeb/URL/URL.h>
namespace Web::Fetch::Infrastructure {
@ -133,7 +133,7 @@ ErrorOr<Optional<AK::URL>> Response::location_url(Optional<String> const& reques
return Optional<AK::URL> {};
// 3. If location is a header value, then set location to the result of parsing location with responses URL.
auto location = URL::parse(location_values.first(), url());
auto location = DOMURL::parse(location_values.first(), url());
if (!location.is_valid())
return Error::from_string_view("Invalid 'Location' header URL"sv);

View file

@ -8,6 +8,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/RequestPrototype.h>
#include <LibWeb/DOM/AbortSignal.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/Fetch/Enums.h>
#include <LibWeb/Fetch/Headers.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
@ -17,7 +18,6 @@
#include <LibWeb/Fetch/Request.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/ReferrerPolicy/ReferrerPolicy.h>
#include <LibWeb/URL/URL.h>
namespace Web::Fetch {
@ -121,7 +121,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
// 5. If input is a string, then:
if (input.has<String>()) {
// 1. Let parsedURL be the result of parsing input with baseURL.
auto parsed_url = URL::parse(input.get<String>(), base_url);
auto parsed_url = DOMURL::parse(input.get<String>(), base_url);
// 2. If parsedURL is failure, then throw a TypeError.
if (!parsed_url.is_valid())
@ -299,7 +299,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
// 3. Otherwise:
else {
// 1. Let parsedReferrer be the result of parsing referrer with baseURL.
auto parsed_referrer = URL::parse(referrer, base_url);
auto parsed_referrer = DOMURL::parse(referrer, base_url);
// 2. If parsedReferrer is failure, then throw a TypeError.
if (!parsed_referrer.is_valid())
@ -309,7 +309,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
// - parsedReferrers scheme is "about" and path is the string "client"
// - parsedReferrers origin is not same origin with origin
// then set requests referrer to "client".
auto parsed_referrer_origin = URL::url_origin(parsed_referrer);
auto parsed_referrer_origin = DOMURL::url_origin(parsed_referrer);
if ((parsed_referrer.scheme() == "about"sv && parsed_referrer.serialize_path() == "client"sv) || !parsed_referrer_origin.is_same_origin(origin)) {
request->set_referrer(Infrastructure::Request::Referrer::Client);
}

View file

@ -7,6 +7,7 @@
#include <LibJS/Runtime/Completion.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/Fetch/Enums.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
@ -14,7 +15,6 @@
#include <LibWeb/Fetch/Response.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/Infra/JSON.h>
#include <LibWeb/URL/URL.h>
namespace Web::Fetch {
@ -170,7 +170,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> Response::redirect(JS::VM& vm, S
// 1. Let parsedURL be the result of parsing url with current settings objects API base URL.
auto api_base_url = HTML::current_settings_object().api_base_url();
auto parsed_url = URL::parse(url, api_base_url);
auto parsed_url = DOMURL::parse(url, api_base_url);
// 2. If parsedURL is failure, then throw a TypeError.
if (!parsed_url.is_valid())

View file

@ -654,8 +654,8 @@ class MouseEvent;
class UIEvents;
}
namespace Web::URL {
class URL;
namespace Web::DOMURL {
class DOMURL;
class URLSearchParams;
class URLSearchParamsIterator;
}

View file

@ -10,6 +10,7 @@
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/HTMLCollection.h>
#include <LibWeb/DOM/Range.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/BrowsingContextGroup.h>
#include <LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicy.h>
@ -29,7 +30,6 @@
#include <LibWeb/Namespace.h>
#include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/Paintable.h>
#include <LibWeb/URL/URL.h>
namespace Web::HTML {
@ -83,7 +83,7 @@ HTML::Origin determine_the_origin(AK::URL const& url, SandboxingFlagSet sandbox_
return source_origin.release_value();
// 5. Return url's origin.
return URL::url_origin(url);
return DOMURL::url_origin(url);
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-auxiliary-browsing-context

View file

@ -13,6 +13,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/HTMLFormControlsCollection.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/FormControlInfrastructure.h>
@ -30,7 +31,6 @@
#include <LibWeb/Infra/CharacterTypes.h>
#include <LibWeb/Infra/Strings.h>
#include <LibWeb/Page/Page.h>
#include <LibWeb/URL/URL.h>
namespace Web::HTML {
@ -649,10 +649,10 @@ ErrorOr<String> HTMLFormElement::pick_an_encoding() const
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#convert-to-a-list-of-name-value-pairs
static ErrorOr<Vector<URL::QueryParam>> convert_to_list_of_name_value_pairs(Vector<XHR::FormDataEntry> const& entry_list)
static ErrorOr<Vector<DOMURL::QueryParam>> convert_to_list_of_name_value_pairs(Vector<XHR::FormDataEntry> const& entry_list)
{
// 1. Let list be an empty list of name-value pairs.
Vector<URL::QueryParam> list;
Vector<DOMURL::QueryParam> list;
// 2. For each entry of entry list:
for (auto const& entry : entry_list) {
@ -675,7 +675,7 @@ static ErrorOr<Vector<URL::QueryParam>> convert_to_list_of_name_value_pairs(Vect
auto normalized_value = TRY(normalize_line_breaks(value));
// 4. Append to list a new name-value pair whose name is name and whose value is value.
TRY(list.try_append(URL::QueryParam { .name = move(name), .value = move(normalized_value) }));
TRY(list.try_append(DOMURL::QueryParam { .name = move(name), .value = move(normalized_value) }));
}
// 3. Return list.
@ -683,7 +683,7 @@ static ErrorOr<Vector<URL::QueryParam>> convert_to_list_of_name_value_pairs(Vect
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#text/plain-encoding-algorithm
static ErrorOr<String> plain_text_encode(Vector<URL::QueryParam> const& pairs)
static ErrorOr<String> plain_text_encode(Vector<DOMURL::QueryParam> const& pairs)
{
// 1. Let result be the empty string.
StringBuilder result;

View file

@ -8,6 +8,7 @@
#include <LibJS/Runtime/ModuleRequest.h>
#include <LibTextCodec/Decoder.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/Fetch/Fetching/Fetching.h>
#include <LibWeb/Fetch/Infrastructure/FetchAlgorithms.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Headers.h>
@ -24,7 +25,6 @@
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Infra/Strings.h>
#include <LibWeb/MimeSniff/MimeType.h>
#include <LibWeb/URL/URL.h>
namespace Web::HTML {
@ -195,7 +195,7 @@ WebIDL::ExceptionOr<Optional<AK::URL>> resolve_imports_match(ByteString const& n
VERIFY(resolution_result->serialize().ends_with("/"sv));
// 5. Let url be the result of URL parsing afterPrefix with resolutionResult.
auto url = URL::parse(after_prefix, *resolution_result);
auto url = DOMURL::parse(after_prefix, *resolution_result);
// 6. If url is failure, then throw a TypeError indicating that resolution of normalizedSpecifier was blocked since the afterPrefix portion
// could not be URL-parsed relative to the resolutionResult mapped to by the specifierKey prefix.
@ -225,7 +225,7 @@ Optional<AK::URL> resolve_url_like_module_specifier(ByteString const& specifier,
// 1. If specifier starts with "/", "./", or "../", then:
if (specifier.starts_with("/"sv) || specifier.starts_with("./"sv) || specifier.starts_with("../"sv)) {
// 1. Let url be the result of URL parsing specifier with baseURL.
auto url = URL::parse(specifier, base_url);
auto url = DOMURL::parse(specifier, base_url);
// 2. If url is failure, then return null.
if (!url.is_valid())
@ -236,7 +236,7 @@ Optional<AK::URL> resolve_url_like_module_specifier(ByteString const& specifier,
}
// 2. Let url be the result of URL parsing specifier (with no base URL).
auto url = URL::parse(specifier);
auto url = DOMURL::parse(specifier);
// 3. If url is failure, then return null.
if (!url.is_valid())

View file

@ -32,6 +32,7 @@
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/EventDispatcher.h>
#include <LibWeb/DOM/HTMLCollection.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/CustomElements/CustomElementRegistry.h>
#include <LibWeb/HTML/DocumentState.h>
@ -68,7 +69,6 @@
#include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/RequestIdleCallback/IdleDeadline.h>
#include <LibWeb/Selection/Selection.h>
#include <LibWeb/URL/URL.h>
#include <LibWeb/WebIDL/AbstractOperations.h>
namespace Web::HTML {
@ -1064,14 +1064,14 @@ WebIDL::ExceptionOr<void> Window::window_post_message_steps(JS::Value message, W
// 5. Otherwise, if targetOrigin is not a single U+002A ASTERISK character (*), then:
else if (options.target_origin != "*"sv) {
// 1. Let parsedURL be the result of running the URL parser on targetOrigin.
auto parsed_url = URL::parse(options.target_origin);
auto parsed_url = DOMURL::parse(options.target_origin);
// 2. If parsedURL is failure, then throw a "SyntaxError" DOMException.
if (!parsed_url.is_valid())
return WebIDL::SyntaxError::create(target_realm, MUST(String::formatted("Invalid URL for targetOrigin: '{}'", options.target_origin)));
// 3. Set targetOrigin to parsedURL's origin.
target_origin = URL::url_origin(parsed_url);
target_origin = DOMURL::url_origin(parsed_url);
}
// 6. Let transfer be options["transfer"].

View file

@ -7,9 +7,9 @@
#include <AK/String.h>
#include <AK/URL.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
#include <LibWeb/URL/URL.h>
// FIXME: This is an ad-hoc implementation of the "autoplay" policy-controlled feature:
// https://w3c.github.io/webappsec-permissions-policy/#policy-controlled-feature
@ -82,7 +82,7 @@ ErrorOr<void> AutoplayAllowlist::enable_for_origins(ReadonlySpan<String> origins
continue;
}
TRY(allowlist.try_append(URL::url_origin(url)));
TRY(allowlist.try_append(DOMURL::url_origin(url)));
}
return {};

View file

@ -6,13 +6,13 @@
#include <AK/URL.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
#include <LibWeb/Fetch/Infrastructure/URL.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/ReferrerPolicy/AbstractOperations.h>
#include <LibWeb/ReferrerPolicy/ReferrerPolicy.h>
#include <LibWeb/SecureContexts/AbstractOperations.h>
#include <LibWeb/URL/URL.h>
namespace Web::ReferrerPolicy {
@ -112,7 +112,7 @@ Optional<AK::URL> determine_requests_referrer(Fetch::Infrastructure::Request con
case ReferrerPolicy::StrictOriginWhenCrossOrigin:
// 1. If the origin of referrerURL and the origin of requests current URL are the same, then return
// referrerURL.
if (referrer_url.has_value() && URL::url_origin(*referrer_url).is_same_origin(URL::url_origin(request.current_url())))
if (referrer_url.has_value() && DOMURL::url_origin(*referrer_url).is_same_origin(DOMURL::url_origin(request.current_url())))
return referrer_url;
// 2. If referrerURL is a potentially trustworthy URL and requests current URL is not a potentially
@ -130,7 +130,7 @@ Optional<AK::URL> determine_requests_referrer(Fetch::Infrastructure::Request con
// 1. If the origin of referrerURL and the origin of requests current URL are the same, then return
// referrerURL.
if (referrer_url.has_value()
&& URL::url_origin(*referrer_url).is_same_origin(URL::url_origin(request.current_url()))) {
&& DOMURL::url_origin(*referrer_url).is_same_origin(DOMURL::url_origin(request.current_url()))) {
return referrer_url;
}
@ -141,7 +141,7 @@ Optional<AK::URL> determine_requests_referrer(Fetch::Infrastructure::Request con
// 1. If the origin of referrerURL and the origin of requests current URL are the same, then return
// referrerURL.
if (referrer_url.has_value()
&& URL::url_origin(*referrer_url).is_same_origin(URL::url_origin(request.current_url()))) {
&& DOMURL::url_origin(*referrer_url).is_same_origin(DOMURL::url_origin(request.current_url()))) {
return referrer_url;
}

View file

@ -7,9 +7,9 @@
#include <AK/IPv4Address.h>
#include <AK/IPv6Address.h>
#include <AK/URL.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/SecureContexts/AbstractOperations.h>
#include <LibWeb/URL/URL.h>
namespace Web::SecureContexts {
@ -79,7 +79,7 @@ Trustworthiness is_url_potentially_trustworthy(AK::URL const& url)
return Trustworthiness::PotentiallyTrustworthy;
// 3. Return the result of executing §3.1 Is origin potentially trustworthy? on urls origin.
return is_origin_potentially_trustworthy(URL::url_origin(url));
return is_origin_potentially_trustworthy(DOMURL::url_origin(url));
}
}

View file

@ -13,20 +13,20 @@
#include <AK/URL.h>
#include <AK/Weakable.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/DOMURL/URLSearchParams.h>
#include <LibWeb/Fetch/BodyInit.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Headers.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Statuses.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/MimeSniff/MimeType.h>
#include <LibWeb/URL/URLSearchParams.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
#include <LibWeb/XHR/XMLHttpRequestEventTarget.h>
namespace Web::XHR {
// https://fetch.spec.whatwg.org/#typedefdef-xmlhttprequestbodyinit
using DocumentOrXMLHttpRequestBodyInit = Variant<JS::Handle<Web::DOM::Document>, JS::Handle<Web::FileAPI::Blob>, JS::Handle<WebIDL::BufferSource>, JS::Handle<XHR::FormData>, JS::Handle<Web::URL::URLSearchParams>, AK::String>;
using DocumentOrXMLHttpRequestBodyInit = Variant<JS::Handle<Web::DOM::Document>, JS::Handle<Web::FileAPI::Blob>, JS::Handle<WebIDL::BufferSource>, JS::Handle<XHR::FormData>, JS::Handle<Web::DOMURL::URLSearchParams>, AK::String>;
class XMLHttpRequest final : public XMLHttpRequestEventTarget {
WEB_PLATFORM_OBJECT(XMLHttpRequest, XMLHttpRequestEventTarget);

View file

@ -69,6 +69,8 @@ libweb_js_bindings(DOM/Text)
libweb_js_bindings(DOM/TreeWalker)
libweb_js_bindings(DOM/XMLDocument)
libweb_js_bindings(DOMParsing/XMLSerializer)
libweb_js_bindings(DOMURL/DOMURL)
libweb_js_bindings(DOMURL/URLSearchParams ITERABLE)
libweb_js_bindings(Encoding/TextDecoder)
libweb_js_bindings(Encoding/TextEncoder)
libweb_js_bindings(Fetch/Headers ITERABLE)
@ -271,8 +273,6 @@ libweb_js_bindings(UIEvents/KeyboardEvent)
libweb_js_bindings(UIEvents/MouseEvent)
libweb_js_bindings(UIEvents/UIEvent)
libweb_js_bindings(UIEvents/WheelEvent)
libweb_js_bindings(URL/URL)
libweb_js_bindings(URL/URLSearchParams ITERABLE)
libweb_js_bindings(UserTiming/PerformanceMark)
libweb_js_bindings(UserTiming/PerformanceMeasure)
libweb_js_bindings(WebAssembly/Instance)