diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index ac621463fea..29ebb28cd7a 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -4656,6 +4656,7 @@ void generate_prototype_implementation(IDL::Interface const& interface, StringBu #include #include #include +#include #include #include #include @@ -4665,7 +4666,6 @@ void generate_prototype_implementation(IDL::Interface const& interface, StringBu #include #include #include -#include #include #include #include @@ -4930,6 +4930,7 @@ void generate_global_mixin_implementation(IDL::Interface const& interface, Strin #include #include #include +#include #include #include #include @@ -4939,7 +4940,6 @@ void generate_global_mixin_implementation(IDL::Interface const& interface, Strin #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibIPC/Decoder.cpp b/Userland/Libraries/LibIPC/Decoder.cpp index dc14235dbbf..1eee8c0275a 100644 --- a/Userland/Libraries/LibIPC/Decoder.cpp +++ b/Userland/Libraries/LibIPC/Decoder.cpp @@ -96,6 +96,16 @@ ErrorOr decode(Decoder& decoder) return url; } +template<> +ErrorOr decode(Decoder& decoder) +{ + auto scheme = TRY(decoder.decode()); + auto host = TRY(decoder.decode()); + u16 port = TRY(decoder.decode()); + + return URL::Origin { move(scheme), move(host), port }; +} + template<> ErrorOr decode(Decoder& decoder) { diff --git a/Userland/Libraries/LibIPC/Decoder.h b/Userland/Libraries/LibIPC/Decoder.h index dee1afbe987..af730c46f74 100644 --- a/Userland/Libraries/LibIPC/Decoder.h +++ b/Userland/Libraries/LibIPC/Decoder.h @@ -23,6 +23,7 @@ #include #include #include +#include #include namespace IPC { @@ -104,6 +105,9 @@ ErrorOr decode(Decoder&); template<> ErrorOr decode(Decoder&); +template<> +ErrorOr decode(Decoder&); + template<> ErrorOr decode(Decoder&); diff --git a/Userland/Libraries/LibIPC/Encoder.cpp b/Userland/Libraries/LibIPC/Encoder.cpp index ab547b40598..fee330495dc 100644 --- a/Userland/Libraries/LibIPC/Encoder.cpp +++ b/Userland/Libraries/LibIPC/Encoder.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include namespace IPC { @@ -114,6 +115,16 @@ ErrorOr encode(Encoder& encoder, URL::URL const& value) return {}; } +template<> +ErrorOr encode(Encoder& encoder, URL::Origin const& origin) +{ + TRY(encoder.encode(origin.scheme())); + TRY(encoder.encode(origin.host())); + TRY(encoder.encode(origin.port())); + + return {}; +} + template<> ErrorOr encode(Encoder& encoder, File const& file) { diff --git a/Userland/Libraries/LibIPC/Encoder.h b/Userland/Libraries/LibIPC/Encoder.h index 1888a093c05..3900e07d0c4 100644 --- a/Userland/Libraries/LibIPC/Encoder.h +++ b/Userland/Libraries/LibIPC/Encoder.h @@ -104,6 +104,9 @@ ErrorOr encode(Encoder&, UnixDateTime const&); template<> ErrorOr encode(Encoder&, URL::URL const&); +template<> +ErrorOr encode(Encoder&, URL::Origin const&); + template<> ErrorOr encode(Encoder&, File const&); diff --git a/Userland/Libraries/LibURL/Forward.h b/Userland/Libraries/LibURL/Forward.h index 10c8c5a70c0..ec9da1963cb 100644 --- a/Userland/Libraries/LibURL/Forward.h +++ b/Userland/Libraries/LibURL/Forward.h @@ -7,6 +7,7 @@ #pragma once namespace URL { +class Origin; class URL; class Parser; diff --git a/Userland/Libraries/LibWeb/HTML/Origin.h b/Userland/Libraries/LibURL/Origin.h similarity index 85% rename from Userland/Libraries/LibWeb/HTML/Origin.h rename to Userland/Libraries/LibURL/Origin.h index acc0459b39c..f0f561ed9a8 100644 --- a/Userland/Libraries/LibWeb/HTML/Origin.h +++ b/Userland/Libraries/LibURL/Origin.h @@ -8,17 +8,15 @@ #pragma once #include -#include -#include #include #include -namespace Web::HTML { +namespace URL { class Origin { public: Origin() = default; - Origin(Optional const& scheme, URL::Host const& host, u16 port) + Origin(Optional const& scheme, Host const& host, u16 port) : m_scheme(scheme) , m_host(host) , m_port(port) @@ -32,7 +30,7 @@ public: { return m_scheme.map([](auto& str) { return str.view(); }).value_or(StringView {}); } - URL::Host const& host() const { return m_host; } + Host const& host() const { return m_host; } u16 port() const { return m_port; } // https://html.spec.whatwg.org/multipage/origin.html#same-origin @@ -88,7 +86,7 @@ public: result.append("://"sv); // 4. Append origin's host, serialized, to result. - result.append(URL::Parser::serialize_host(host()).release_value_but_fixme_should_propagate_errors().to_byte_string()); + result.append(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) { @@ -100,7 +98,7 @@ public: } // https://html.spec.whatwg.org/multipage/origin.html#concept-origin-effective-domain - Optional effective_domain() const + Optional effective_domain() const { // 1. If origin is an opaque origin, then return null. if (is_opaque()) @@ -116,7 +114,7 @@ public: private: Optional m_scheme; - URL::Host m_host; + Host m_host; u16 m_port { 0 }; }; @@ -124,8 +122,8 @@ private: namespace AK { template<> -struct Traits : public DefaultTraits { - static unsigned hash(Web::HTML::Origin const& origin) +struct Traits : public DefaultTraits { + static unsigned hash(URL::Origin const& origin) { auto hash_without_host = pair_int_hash(origin.scheme().hash(), origin.port()); if (origin.host().has()) @@ -134,11 +132,3 @@ struct Traits : public DefaultTraits { } }; } // namespace AK - -namespace IPC { -template<> -ErrorOr encode(Encoder&, Web::HTML::Origin const&); - -template<> -ErrorOr decode(Decoder&); -} diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index e948a8f5bad..15eb9bc2b56 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -418,7 +418,6 @@ set(SOURCES HTML/NavigatorBeacon.cpp HTML/NavigatorID.cpp HTML/Numbers.cpp - HTML/Origin.cpp HTML/PageTransitionEvent.cpp HTML/PolicyContainers.cpp HTML/PopStateEvent.cpp diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp index 16474301734..462ffcf1880 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp @@ -5,6 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -14,7 +15,6 @@ #include #include #include -#include #include namespace Web::DOM { diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index f544f525ac6..90c65742d0b 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -98,7 +99,6 @@ #include #include #include -#include #include #include #include @@ -723,12 +723,12 @@ JS::GCPtr Document::default_view() const return const_cast(this)->default_view(); } -HTML::Origin Document::origin() const +URL::Origin Document::origin() const { return m_origin; } -void Document::set_origin(HTML::Origin const& origin) +void Document::set_origin(URL::Origin const& origin) { m_origin = origin; } diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index e84fd5da946..b9ba83cfd2b 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -32,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -148,8 +148,8 @@ public: String url_string() const { return MUST(m_url.to_string()); } String document_uri() const { return url_string(); } - HTML::Origin origin() const; - void set_origin(HTML::Origin const& origin); + URL::Origin origin() const; + void set_origin(URL::Origin const& origin); HTML::OpenerPolicy const& opener_policy() const { return m_opener_policy; } void set_opener_policy(HTML::OpenerPolicy policy) { m_opener_policy = move(policy); } @@ -877,7 +877,7 @@ private: String m_referrer; // https://dom.spec.whatwg.org/#concept-document-origin - HTML::Origin m_origin; + URL::Origin m_origin; JS::GCPtr m_applets; JS::GCPtr m_anchors; diff --git a/Userland/Libraries/LibWeb/DOM/DocumentLoading.h b/Userland/Libraries/LibWeb/DOM/DocumentLoading.h index 6a91a0e40f6..ec272f109a6 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentLoading.h +++ b/Userland/Libraries/LibWeb/DOM/DocumentLoading.h @@ -23,7 +23,7 @@ JS::NonnullGCPtr create_document_for_inline_content(JS::GCPtrvm(); // 1. Let origin be a new opaque origin. - HTML::Origin origin {}; + URL::Origin origin {}; // 2. Let coop be a new opener policy. auto coop = HTML::OpenerPolicy {}; diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index ade83a5e271..9a86ac68918 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -38,7 +39,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp b/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp index 0e494a94f88..911f232a325 100644 --- a/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp +++ b/Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp @@ -479,7 +479,7 @@ void DOMURL::set_hash(String const& hash) } // https://url.spec.whatwg.org/#concept-url-origin -HTML::Origin url_origin(URL::URL const& url) +URL::Origin url_origin(URL::URL const& url) { // FIXME: We should probably have an extended version of URL::URL for LibWeb instead of standalone functions like this. @@ -497,14 +497,14 @@ HTML::Origin url_origin(URL::URL const& url) // 3. If pathURL is failure, then return a new opaque origin. if (!path_url.is_valid()) - return HTML::Origin {}; + return URL::Origin {}; // 4. If pathURL’s scheme is "http", "https", or "file", then return pathURL’s origin. if (path_url.scheme().is_one_of("http"sv, "https"sv, "file"sv)) return url_origin(path_url); // 5. Return a new opaque origin. - return HTML::Origin {}; + return URL::Origin {}; } // -> "ftp" @@ -514,7 +514,7 @@ HTML::Origin url_origin(URL::URL const& url) // -> "wss" if (url.scheme().is_one_of("ftp"sv, "http"sv, "https"sv, "ws"sv, "wss"sv)) { // Return the tuple origin (url’s scheme, url’s host, url’s port, null). - return HTML::Origin(url.scheme().to_byte_string(), url.host(), url.port().value_or(0)); + return URL::Origin(url.scheme().to_byte_string(), url.host(), url.port().value_or(0)); } // -> "file" @@ -522,12 +522,12 @@ HTML::Origin url_origin(URL::URL const& url) if (url.scheme() == "file"sv || url.scheme() == "resource"sv) { // Unfortunate as it is, this is left as an exercise to the reader. When in doubt, return a new opaque origin. // Note: We must return an origin with the `file://' protocol for `file://' iframes to work from `file://' pages. - return HTML::Origin(url.scheme().to_byte_string(), String {}, 0); + return URL::Origin(url.scheme().to_byte_string(), String {}, 0); } // -> Otherwise // Return a new opaque origin. - return HTML::Origin {}; + return URL::Origin {}; } // https://url.spec.whatwg.org/#concept-domain diff --git a/Userland/Libraries/LibWeb/DOMURL/DOMURL.h b/Userland/Libraries/LibWeb/DOMURL/DOMURL.h index 7c786f809e0..942fe10a04e 100644 --- a/Userland/Libraries/LibWeb/DOMURL/DOMURL.h +++ b/Userland/Libraries/LibWeb/DOMURL/DOMURL.h @@ -92,7 +92,7 @@ private: JS::NonnullGCPtr m_query; }; -HTML::Origin url_origin(URL::URL const&); +URL::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 diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Checks.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Checks.cpp index 39dfec4e578..26123a3f1a6 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Checks.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Checks.cpp @@ -69,8 +69,8 @@ bool tao_check(Infrastructure::Request const& request, Infrastructure::Response // validates the results of the TAO check, the nested document would still have access to the full timing // information, but the container document would not. if (request.mode() == Infrastructure::Request::Mode::Navigate - && request.origin().has() - && !DOMURL::url_origin(request.current_url()).is_same_origin(request.origin().get())) { + && request.origin().has() + && !DOMURL::url_origin(request.current_url()).is_same_origin(request.origin().get())) { return false; } diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index 42828780e69..0a6cb239ce5 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -152,7 +152,7 @@ WebIDL::ExceptionOr> fetch(JS: // - request’s unsafe-request flag is not set or request’s header list is empty && (!request.unsafe_request() || request.header_list()->is_empty())) { // 1. Assert: request’s origin is same origin with request’s client’s origin. - VERIFY(request.origin().has() && request.origin().get().is_same_origin(request.client()->origin())); + VERIFY(request.origin().has() && request.origin().get().is_same_origin(request.client()->origin())); // 2. Let onPreloadedResponseAvailable be an algorithm that runs the following step given a response // response: set fetchParams’s preloaded response candidate to response. @@ -353,7 +353,7 @@ WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Inf // -> request’s current URL’s scheme is "data" // -> request’s mode is "navigate" or "websocket" else if ( - (request->origin().has() && DOMURL::url_origin(request->current_url()).is_same_origin(request->origin().get()) && request->response_tainting() == Infrastructure::Request::ResponseTainting::Basic) + (request->origin().has() && DOMURL::url_origin(request->current_url()).is_same_origin(request->origin().get()) && 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 request’s response tainting to "basic". @@ -919,7 +919,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& r else if (request->current_url().scheme() == "file"sv || request->current_url().scheme() == "resource"sv) { // For now, unfortunate as it is, file: URLs are left as an exercise for the reader. // When in doubt, return a network error. - if (request->origin().has() && (request->origin().get().is_opaque() || request->origin().get().scheme() == "file"sv || request->origin().get().scheme() == "resource"sv)) + if (request->origin().has() && (request->origin().get().is_opaque() || request->origin().get().scheme() == "file"sv || request->origin().get().scheme() == "resource"sv)) return TRY(nonstandard_resource_loader_file_or_http_network_fetch(realm, fetch_params)); else return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'file:' or 'resource:' URL blocked"sv)); @@ -1200,8 +1200,8 @@ WebIDL::ExceptionOr> http_redirect_fetch(JS::Realm& r // locationURL’s origin, then return a network error. if (request->mode() == Infrastructure::Request::Mode::CORS && location_url.includes_credentials() - && request->origin().has() - && !request->origin().get().is_same_origin(DOMURL::url_origin(location_url))) { + && request->origin().has() + && !request->origin().get().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)); } diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp index 4c96a919a68..e9228114a7f 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp @@ -172,7 +172,7 @@ bool Request::has_redirect_tainted_origin() const } // 2. If url’s origin is not same origin with lastURL’s origin and request’s origin is not same origin with lastURL’s origin, then return true. - auto const* request_origin = m_origin.get_pointer(); + auto const* request_origin = m_origin.get_pointer(); 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; @@ -194,7 +194,7 @@ String Request::serialize_origin() const return "null"_string; // 2. Return request’s origin, serialized. - return MUST(String::from_byte_string(m_origin.get().serialize())); + return MUST(String::from_byte_string(m_origin.get().serialize())); } // https://fetch.spec.whatwg.org/#byte-serializing-a-request-origin @@ -321,14 +321,14 @@ void Request::add_origin_header() case ReferrerPolicy::ReferrerPolicy::StrictOriginWhenCrossOrigin: // If request’s origin is a tuple origin, its scheme is "https", and request’s current URL’s scheme is // not "https", then set serializedOrigin to `null`. - if (m_origin.has() && m_origin.get().scheme() == "https"sv && current_url().scheme() != "https"sv) + if (m_origin.has() && m_origin.get().scheme() == "https"sv && current_url().scheme() != "https"sv) serialized_origin = MUST(ByteBuffer::copy("null"sv.bytes())); break; // -> "same-origin" case ReferrerPolicy::ReferrerPolicy::SameOrigin: // If request’s origin is not same origin with request’s current URL’s origin, then set serializedOrigin // to `null`. - if (m_origin.has() && !m_origin.get().is_same_origin(DOMURL::url_origin(current_url()))) + if (m_origin.has() && !m_origin.get().is_same_origin(DOMURL::url_origin(current_url()))) serialized_origin = MUST(ByteBuffer::copy("null"sv.bytes())); break; // -> Otherwise @@ -364,7 +364,7 @@ bool Request::cross_origin_embedder_policy_allows_credentials() const // 4. If request’s origin is same origin with request’s current URL’s origin and request does not have a redirect-tainted origin, then return true. // 5. Return false. - auto const* request_origin = m_origin.get_pointer(); + auto const* request_origin = m_origin.get_pointer(); if (request_origin == nullptr) return false; diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h index f002ce2b0ca..873e6114b37 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h @@ -17,10 +17,10 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -170,7 +170,7 @@ public: struct InternalPriority { }; using BodyType = Variant>; - using OriginType = Variant; + using OriginType = Variant; using PolicyContainerType = Variant; using ReferrerType = Variant; using ReservedClientType = JS::GCPtr; diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/NetworkPartitionKey.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/NetworkPartitionKey.h index bbd053b63dc..c334b525f64 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/NetworkPartitionKey.h +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/NetworkPartitionKey.h @@ -6,14 +6,14 @@ #pragma once +#include #include -#include namespace Web::Fetch::Infrastructure { // https://fetch.spec.whatwg.org/#network-partition-key struct NetworkPartitionKey { - HTML::Origin top_level_origin; + URL::Origin top_level_origin; // FIXME: See https://github.com/whatwg/fetch/issues/1035 // This is the document origin in other browsers void* second_key = nullptr; @@ -32,6 +32,6 @@ class AK::Traits : public Defau public: static unsigned hash(Web::Fetch::Infrastructure::NetworkPartitionKey const& partition_key) { - return ::AK::Traits::hash(partition_key.top_level_origin); + return ::AK::Traits::hash(partition_key.top_level_origin); } }; diff --git a/Userland/Libraries/LibWeb/FileAPI/BlobURLStore.cpp b/Userland/Libraries/LibWeb/FileAPI/BlobURLStore.cpp index a1872461d15..9b2648aaaa0 100644 --- a/Userland/Libraries/LibWeb/FileAPI/BlobURLStore.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/BlobURLStore.cpp @@ -7,12 +7,12 @@ */ #include +#include #include #include #include #include #include -#include #include namespace Web::FileAPI { diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 0154fb1610c..454d0f92f58 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -484,7 +484,6 @@ class NavigationDestination; class NavigationHistoryEntry; class NavigationTransition; class Navigator; -class Origin; class PageTransitionEvent; class Path2D; class Plugin; diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index e56300454c3..cda3bf058a8 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -59,16 +59,16 @@ bool url_matches_about_srcdoc(URL::URL const& url) } // https://html.spec.whatwg.org/multipage/document-sequences.html#determining-the-origin -HTML::Origin determine_the_origin(Optional const& url, SandboxingFlagSet sandbox_flags, Optional source_origin) +URL::Origin determine_the_origin(Optional 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)) { - return HTML::Origin {}; + return URL::Origin {}; } // 2. If url is null, then return a new opaque origin. if (!url.has_value()) { - return HTML::Origin {}; + return URL::Origin {}; } // 3. If url is about:srcdoc, then: @@ -144,7 +144,7 @@ WebIDL::ExceptionOr BrowsingContext [[maybe_unused]] auto unsafe_context_creation_time = HighResolutionTime::unsafe_shared_current_time(); // 3. Let creatorOrigin be null. - Optional creator_origin = {}; + Optional creator_origin = {}; // 4. Let creatorBaseURL be null. Optional creator_base_url = {}; diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h index 4fa78c1a09b..1e75d9d3552 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h @@ -15,10 +15,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -145,7 +145,7 @@ private: JS::GCPtr m_opener_browsing_context; // https://html.spec.whatwg.org/multipage/document-sequences.html#opener-origin-at-creation - Optional m_opener_origin_at_creation; + Optional m_opener_origin_at_creation; // https://html.spec.whatwg.org/multipage/browsers.html#is-popup TokenizedFeature::Popup m_is_popup { TokenizedFeature::Popup::No }; @@ -168,7 +168,7 @@ private: JS::GCPtr m_previous_sibling; }; -HTML::Origin determine_the_origin(Optional const&, SandboxingFlagSet, Optional source_origin); +URL::Origin determine_the_origin(Optional const&, SandboxingFlagSet, Optional source_origin); SandboxingFlagSet determine_the_creation_sandboxing_flags(BrowsingContext const&, JS::GCPtr embedder); diff --git a/Userland/Libraries/LibWeb/HTML/CrossOrigin/OpenerPolicyEnforcementResult.h b/Userland/Libraries/LibWeb/HTML/CrossOrigin/OpenerPolicyEnforcementResult.h index f179767c2bf..2a385c06a9a 100644 --- a/Userland/Libraries/LibWeb/HTML/CrossOrigin/OpenerPolicyEnforcementResult.h +++ b/Userland/Libraries/LibWeb/HTML/CrossOrigin/OpenerPolicyEnforcementResult.h @@ -6,9 +6,9 @@ #pragma once +#include #include #include -#include namespace Web::HTML { @@ -24,7 +24,7 @@ struct OpenerPolicyEnforcementResult { URL::URL url; // An origin origin. - Origin origin; + URL::Origin origin; // An opener policy. OpenerPolicy opener_policy; diff --git a/Userland/Libraries/LibWeb/HTML/CrossOrigin/Reporting.cpp b/Userland/Libraries/LibWeb/HTML/CrossOrigin/Reporting.cpp index ec3477254fc..c899b3f303f 100644 --- a/Userland/Libraries/LibWeb/HTML/CrossOrigin/Reporting.cpp +++ b/Userland/Libraries/LibWeb/HTML/CrossOrigin/Reporting.cpp @@ -7,11 +7,11 @@ #include #include #include +#include #include #include #include #include -#include namespace Web::HTML { @@ -38,7 +38,7 @@ void check_if_access_between_two_browsing_contexts_should_be_reported( auto* accessor_top_document = accessor.top_level_browsing_context()->active_document(); // 4. Let accessorInclusiveAncestorOrigins be the list obtained by taking the origin of the active document of each of accessor's active document's inclusive ancestor navigables. - Vector accessor_inclusive_ancestor_origins = {}; + Vector accessor_inclusive_ancestor_origins = {}; auto accessor_inclusive_ancestors = accessor.active_document()->ancestor_navigables(); accessor_inclusive_ancestor_origins.ensure_capacity(accessor_inclusive_ancestors.size()); for (auto const& ancestor : accessor_inclusive_ancestors) { @@ -52,7 +52,7 @@ void check_if_access_between_two_browsing_contexts_should_be_reported( auto* accessed_top_document = accessed->top_level_browsing_context()->active_document(); // 6. Let accessedInclusiveAncestorOrigins be the list obtained by taking the origin of the active document of each of accessed's active document's inclusive ancestor navigables. - Vector accessed_inclusive_ancestor_origins = {}; + Vector accessed_inclusive_ancestor_origins = {}; auto accessed_inclusive_ancestors = accessed->active_document()->ancestor_navigables(); accessed_inclusive_ancestor_origins.ensure_capacity(accessed_inclusive_ancestors.size()); for (auto const& ancestor : accessed_inclusive_ancestors) { diff --git a/Userland/Libraries/LibWeb/HTML/DocumentState.h b/Userland/Libraries/LibWeb/HTML/DocumentState.h index fe6103aa338..a1d6798f730 100644 --- a/Userland/Libraries/LibWeb/HTML/DocumentState.h +++ b/Userland/Libraries/LibWeb/HTML/DocumentState.h @@ -8,10 +8,10 @@ #pragma once #include +#include #include #include #include -#include #include #include #include @@ -49,11 +49,11 @@ public: [[nodiscard]] ReferrerPolicy::ReferrerPolicy request_referrer_policy() const { return m_request_referrer_policy; } void set_request_referrer_policy(ReferrerPolicy::ReferrerPolicy request_referrer_policy) { m_request_referrer_policy = move(request_referrer_policy); } - [[nodiscard]] Optional initiator_origin() const { return m_initiator_origin; } - void set_initiator_origin(Optional initiator_origin) { m_initiator_origin = move(initiator_origin); } + [[nodiscard]] Optional initiator_origin() const { return m_initiator_origin; } + void set_initiator_origin(Optional initiator_origin) { m_initiator_origin = move(initiator_origin); } - [[nodiscard]] Optional origin() const { return m_origin; } - void set_origin(Optional origin) { m_origin = move(origin); } + [[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); } @@ -91,10 +91,10 @@ private: ReferrerPolicy::ReferrerPolicy m_request_referrer_policy { ReferrerPolicy::DEFAULT_REFERRER_POLICY }; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-initiator-origin - Optional m_initiator_origin; + Optional m_initiator_origin; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-origin - Optional m_origin; + Optional m_origin; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-about-base-url Optional m_about_base_url = {}; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 9be850287f9..a52570ae2fd 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -5,13 +5,13 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include #include #include #include -#include #include #include diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h index e4f17dc1cb6..d890ff88f5c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -86,7 +86,7 @@ private: URL::URL base_url; // origin // An origin - HTML::Origin origin; + URL::Origin origin; // environment // An environment JS::GCPtr environment; diff --git a/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.cpp b/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.cpp index 98fb8ecff13..a63ca26460c 100644 --- a/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.cpp +++ b/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.cpp @@ -26,7 +26,7 @@ u32 ListOfAvailableImages::Key::hash() const u32 mode_hash = static_cast(mode); u32 origin_hash = 0; if (origin.has_value()) - origin_hash = Traits::hash(origin.value()); + origin_hash = Traits::hash(origin.value()); cached_hash = pair_int_hash(url_hash, pair_int_hash(mode_hash, origin_hash)); } return cached_hash.value(); diff --git a/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.h b/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.h index ba36dab5355..5c718da32b7 100644 --- a/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.h +++ b/Userland/Libraries/LibWeb/HTML/ListOfAvailableImages.h @@ -8,10 +8,10 @@ #include #include +#include #include #include #include -#include namespace Web::HTML { @@ -24,7 +24,7 @@ public: struct Key { URL::URL url; HTML::CORSSettingAttribute mode; - Optional origin; + Optional origin; [[nodiscard]] bool operator==(Key const& other) const; [[nodiscard]] u32 hash() const; diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.h b/Userland/Libraries/LibWeb/HTML/MessagePort.h index dea1ad09b10..2f47ace9ad0 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.h +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp index 238a7aff23d..e8c505fbf91 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp @@ -779,7 +779,7 @@ static WebIDL::ExceptionOr create_navigation auto response_holder = ResponseHolder::create(vm); // 10. Let responseOrigin be null. - Optional response_origin; + Optional response_origin; // 11. Let fetchController be null. JS::GCPtr fetch_controller = nullptr; @@ -1537,7 +1537,7 @@ WebIDL::ExceptionOr Navigable::navigate_to_a_fragment(URL::URL const& url, } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#evaluate-a-javascript:-url -WebIDL::ExceptionOr> Navigable::evaluate_javascript_url(URL::URL const& url, Origin const& new_document_origin, String navigation_id) +WebIDL::ExceptionOr> Navigable::evaluate_javascript_url(URL::URL const& url, URL::Origin const& new_document_origin, String navigation_id) { auto& vm = this->vm(); auto& realm = active_window()->realm(); @@ -1640,7 +1640,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::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, URL::Origin const& initiator_origin, CSPNavigationType csp_navigation_type, String navigation_id) { // 1. Assert: historyHandling is "replace". VERIFY(history_handling == HistoryHandlingBehavior::Replace); diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.h b/Userland/Libraries/LibWeb/HTML/Navigable.h index 4e61792b909..4b2122f65b4 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.h +++ b/Userland/Libraries/LibWeb/HTML/Navigable.h @@ -150,8 +150,8 @@ public: WebIDL::ExceptionOr navigate_to_a_fragment(URL::URL const&, HistoryHandlingBehavior, UserNavigationInvolvement, Optional navigation_api_state, 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); + WebIDL::ExceptionOr> evaluate_javascript_url(URL::URL const&, URL::Origin const& new_document_origin, String navigation_id); + WebIDL::ExceptionOr navigate_to_a_javascript_url(URL::URL const&, HistoryHandlingBehavior, URL::Origin const& initiator_origin, CSPNavigationType csp_navigation_type, String navigation_id); bool allowed_by_sandboxing_to_navigate(Navigable const& target, SourceSnapshotParams const&); diff --git a/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp index 05912330006..b67a2890a6b 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp +++ b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp @@ -6,6 +6,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -17,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibWeb/HTML/NavigationParams.h b/Userland/Libraries/LibWeb/HTML/NavigationParams.h index b1e1364c565..fe617d40cd4 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigationParams.h +++ b/Userland/Libraries/LibWeb/HTML/NavigationParams.h @@ -9,12 +9,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include @@ -50,7 +50,7 @@ struct NavigationParams : JS::Cell { Fetch::Infrastructure::Request::ReservedClientType reserved_environment; // an origin to use for the new Document - Origin origin; + URL::Origin origin; // a policy container to use for the new Document PolicyContainer policy_container; @@ -90,7 +90,7 @@ struct NonFetchSchemeNavigationParams : JS::Cell { bool source_snapshot_has_transient_activation = { false }; // an origin possibly for use in a user-facing prompt to confirm the invocation of an external software package - Origin initiator_origin; + URL::Origin initiator_origin; // FIXME: a NavigationTimingType used for creating the navigation timing entry for the new Document diff --git a/Userland/Libraries/LibWeb/HTML/Origin.cpp b/Userland/Libraries/LibWeb/HTML/Origin.cpp deleted file mode 100644 index bae4412c0fc..00000000000 --- a/Userland/Libraries/LibWeb/HTML/Origin.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2024, Andrew Kaster - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include -#include -#include - -namespace IPC { -template<> -ErrorOr encode(Encoder& encoder, Web::HTML::Origin const& origin) -{ - TRY(encoder.encode(origin.scheme())); - TRY(encoder.encode(origin.host())); - TRY(encoder.encode(origin.port())); - - return {}; -} - -template<> -ErrorOr decode(Decoder& decoder) -{ - auto scheme = TRY(decoder.decode()); - auto host = TRY(decoder.decode()); - u16 port = TRY(decoder.decode()); - - return Web::HTML::Origin { move(scheme), move(host), port }; -} - -} diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/EnvironmentSettingsSnapshot.h b/Userland/Libraries/LibWeb/HTML/Scripting/EnvironmentSettingsSnapshot.h index 36651101ffb..f55c87cfd5a 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/EnvironmentSettingsSnapshot.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/EnvironmentSettingsSnapshot.h @@ -25,14 +25,14 @@ public: JS::GCPtr responsible_document() override { return nullptr; } String api_url_character_encoding() override { return m_api_url_character_encoding; } URL::URL api_base_url() override { return m_url; } - Origin origin() override { return m_origin; } + 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::URL m_url; - HTML::Origin m_origin; + URL::Origin m_origin; HTML::PolicyContainer m_policy_container; }; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h index 57ab5cd7b19..8b360306d34 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.h @@ -8,10 +8,10 @@ #pragma once #include +#include #include #include #include -#include #include #include @@ -34,7 +34,7 @@ public: URL::URL top_level_creation_url; // https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-top-level-origin - Origin top_level_origin; + URL::Origin top_level_origin; // https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-target-browsing-context JS::GCPtr target_browsing_context; @@ -77,7 +77,7 @@ public: virtual URL::URL api_base_url() = 0; // https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-origin - virtual Origin origin() = 0; + virtual URL::Origin origin() = 0; // A policy container https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-policy-container virtual PolicyContainer policy_container() = 0; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.cpp index 0d1bb6fc8a8..02acfefc343 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.cpp @@ -34,10 +34,10 @@ ErrorOr decode(Decoder& decoder) object.id = 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.top_level_origin = TRY(decoder.decode()); object.api_url_character_encoding = TRY(decoder.decode()); object.api_base_url = TRY(decoder.decode()); - object.origin = 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 7a55ae46d94..6e107490bd1 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/SerializedEnvironmentSettingsObject.h @@ -8,8 +8,8 @@ #include #include +#include #include -#include #include namespace Web::HTML { @@ -23,11 +23,11 @@ struct SerializedEnvironmentSettingsObject { String id; URL::URL creation_url; URL::URL top_level_creation_url; - Origin top_level_origin; + URL::Origin top_level_origin; String api_url_character_encoding; URL::URL api_base_url; - Origin origin; + 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 992fc879abe..d8299782125 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::URL const& creation_url, NonnullOwnPtr execution_context, JS::GCPtr reserved_environment, URL::URL top_level_creation_url, Origin top_level_origin) +void WindowEnvironmentSettingsObject::setup(Page& page, URL::URL const& creation_url, NonnullOwnPtr execution_context, JS::GCPtr reserved_environment, URL::URL top_level_creation_url, URL::Origin top_level_origin) { // 1. Let realm be the value of execution context's Realm component. auto realm = execution_context->realm; @@ -104,7 +104,7 @@ URL::URL WindowEnvironmentSettingsObject::api_base_url() } // https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:concept-settings-object-origin -Origin WindowEnvironmentSettingsObject::origin() +URL::Origin WindowEnvironmentSettingsObject::origin() { // Return the origin of window's associated Document. return m_window->associated_document().origin(); diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h index 13fe29b000e..fee0c15559d 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h @@ -16,14 +16,14 @@ class WindowEnvironmentSettingsObject final : public EnvironmentSettingsObject { JS_DECLARE_ALLOCATOR(WindowEnvironmentSettingsObject); public: - static void setup(Page&, URL::URL const& creation_url, NonnullOwnPtr, JS::GCPtr, URL::URL top_level_creation_url, Origin top_level_origin); + static void setup(Page&, URL::URL const& creation_url, NonnullOwnPtr, JS::GCPtr, URL::URL top_level_creation_url, URL::Origin top_level_origin); virtual ~WindowEnvironmentSettingsObject() override; virtual JS::GCPtr responsible_document() override; virtual String api_url_character_encoding() override; virtual URL::URL api_base_url() override; - virtual Origin origin() override; + virtual URL::Origin origin() override; virtual PolicyContainer policy_container() override; virtual CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() override; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp index b92f3720fae..3177d7c1cc0 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp @@ -61,7 +61,7 @@ URL::URL WorkerEnvironmentSettingsObject::api_base_url() return m_global_scope->url(); } -Origin WorkerEnvironmentSettingsObject::origin() +URL::Origin WorkerEnvironmentSettingsObject::origin() { // FIXME: Return a unique opaque origin if worker global scope's url's scheme is "data", and inherited origin otherwise. return m_origin; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h index 169fcf8f62c..989859cd055 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h @@ -31,7 +31,7 @@ public: JS::GCPtr responsible_document() override { return nullptr; } String api_url_character_encoding() override { return m_api_url_character_encoding; } URL::URL api_base_url() override; - Origin origin() override; + URL::Origin origin() override; PolicyContainer policy_container() override; CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() override; @@ -39,7 +39,7 @@ private: virtual void visit_edges(JS::Cell::Visitor&) override; String m_api_url_character_encoding; - HTML::Origin m_origin; + URL::Origin m_origin; JS::NonnullGCPtr m_global_scope; }; diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index ed3bc80f9ad..54ee97d77b4 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -99,7 +99,7 @@ WebIDL::ExceptionOr> TraversableNavigable document_state->set_document(document); // initiator origin: null if opener is null; otherwise, document's origin - document_state->set_initiator_origin(opener ? Optional {} : document->origin()); + document_state->set_initiator_origin(opener ? Optional {} : document->origin()); // origin: document's origin document_state->set_origin(document->origin()); diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 7d942172478..fcb75e6ba5f 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -415,7 +415,7 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers WebIDL::ExceptionOr> Window::local_storage() { // FIXME: Implement according to spec. - static HashMap> local_storage_per_origin; + static HashMap> local_storage_per_origin; auto storage = local_storage_per_origin.ensure(associated_document().origin(), [this]() -> JS::Handle { return Storage::create(realm()); }); @@ -426,7 +426,7 @@ WebIDL::ExceptionOr> Window::local_storage() WebIDL::ExceptionOr> Window::session_storage() { // FIXME: Implement according to spec. - static HashMap> session_storage_per_origin; + static HashMap> session_storage_per_origin; auto storage = session_storage_per_origin.ensure(associated_document().origin(), [this]() -> JS::Handle { return Storage::create(realm()); }); @@ -1017,7 +1017,7 @@ WebIDL::ExceptionOr Window::window_post_message_steps(JS::Value message, W auto& incumbent_settings = incumbent_settings_object(); // 3. Let targetOrigin be options["targetOrigin"]. - Variant target_origin = options.target_origin; + Variant target_origin = options.target_origin; // 4. If targetOrigin is a single U+002F SOLIDUS character (/), then set targetOrigin to incumbentSettings's origin. if (options.target_origin == "/"sv) { @@ -1048,7 +1048,7 @@ WebIDL::ExceptionOr Window::window_post_message_steps(JS::Value message, W // associated Document's origin is not same origin with targetOrigin, then return. // NOTE: Due to step 4 and 5 above, the only time it's not '*' is if target_origin contains an Origin. if (!target_origin.has()) { - auto const& actual_target_origin = target_origin.get(); + auto const& actual_target_origin = target_origin.get(); if (!document()->origin().is_same_origin(actual_target_origin)) return; } diff --git a/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.cpp b/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.cpp index 00d76be3280..46a928732c2 100644 --- a/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.cpp +++ b/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.cpp @@ -5,10 +5,10 @@ */ #include +#include #include #include #include -#include #include // FIXME: This is an ad-hoc implementation of the "autoplay" policy-controlled feature: @@ -26,7 +26,7 @@ AutoplayAllowlist::AutoplayAllowlist() = default; AutoplayAllowlist::~AutoplayAllowlist() = default; // https://w3c.github.io/webappsec-permissions-policy/#is-feature-enabled -Decision AutoplayAllowlist::is_allowed_for_origin(DOM::Document const& document, HTML::Origin const& origin) const +Decision AutoplayAllowlist::is_allowed_for_origin(DOM::Document const& document, URL::Origin const& origin) const { // FIXME: 1. Let policy be document’s Permissions Policy // FIXME: 2. If policy’s inherited policy for feature is Disabled, return "Disabled". diff --git a/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.h b/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.h index 25e89bf45f4..4fcdb30b55a 100644 --- a/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.h +++ b/Userland/Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.h @@ -18,7 +18,7 @@ class AutoplayAllowlist { public: static AutoplayAllowlist& the(); - Decision is_allowed_for_origin(DOM::Document const&, HTML::Origin const&) const; + Decision is_allowed_for_origin(DOM::Document const&, URL::Origin const&) const; void enable_globally(); ErrorOr enable_for_origins(ReadonlySpan); @@ -27,7 +27,7 @@ private: AutoplayAllowlist(); ~AutoplayAllowlist(); - using Patterns = Vector; + using Patterns = Vector; struct Global { }; Optional> m_allowlist; diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp index 581fef270b7..6f9f45da5c0 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp @@ -38,7 +38,7 @@ ErrorOr> SVGDecodedImageData::create(JS::R auto navigation_params = navigable->heap().allocate_without_realm(); navigation_params->navigable = navigable; navigation_params->response = response; - navigation_params->origin = HTML::Origin {}; + navigation_params->origin = URL::Origin {}; navigation_params->policy_container = HTML::PolicyContainer {}; navigation_params->final_sandboxing_flag_set = HTML::SandboxingFlagSet {}; navigation_params->opener_policy = HTML::OpenerPolicy {}; diff --git a/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.cpp b/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.cpp index 04560ff5ba0..448c39657ca 100644 --- a/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.cpp @@ -6,15 +6,15 @@ #include #include +#include #include #include -#include #include namespace Web::SecureContexts { // https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy -Trustworthiness is_origin_potentially_trustworthy(HTML::Origin const& origin) +Trustworthiness is_origin_potentially_trustworthy(URL::Origin const& origin) { // 1. If origin is an opaque origin, return "Not Trustworthy". if (origin.is_opaque()) diff --git a/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.h b/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.h index babf5491d35..d5360b980c3 100644 --- a/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.h +++ b/Userland/Libraries/LibWeb/SecureContexts/AbstractOperations.h @@ -17,7 +17,7 @@ enum class Trustworthiness { NotTrustworthy, }; -[[nodiscard]] Trustworthiness is_origin_potentially_trustworthy(HTML::Origin const&); +[[nodiscard]] Trustworthiness is_origin_potentially_trustworthy(URL::Origin const&); [[nodiscard]] Trustworthiness is_url_potentially_trustworthy(URL::URL const&); } diff --git a/Userland/Libraries/LibWeb/StorageAPI/StorageKey.h b/Userland/Libraries/LibWeb/StorageAPI/StorageKey.h index e8a4051500a..b9d4a8bb0ae 100644 --- a/Userland/Libraries/LibWeb/StorageAPI/StorageKey.h +++ b/Userland/Libraries/LibWeb/StorageAPI/StorageKey.h @@ -7,8 +7,8 @@ #pragma once #include +#include #include -#include namespace Web::StorageAPI { @@ -17,7 +17,7 @@ struct StorageKey { // A storage key is a tuple consisting of an origin (an origin). [HTML] // NOTE: This is expected to change; see Client-Side Storage Partitioning https://privacycg.github.io/storage-partitioning/. - HTML::Origin origin; + URL::Origin origin; friend bool operator==(StorageKey const& a, StorageKey const& b) { diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index 8b136dac847..4938ab28c2d 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index de25f8e5759..0901cb288cb 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include #include -#include #include #include #include