mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 18:50:50 +00:00
LibURL+LibWeb: Make URL::Origin default constructor private
Instead, porting over all users to use the newly created Origin::create_opaque factory function. This also requires porting over some users of Origin to avoid default construction.
This commit is contained in:
parent
5deb8ba2f8
commit
e0d7278820
Notes:
github-actions[bot]
2025-06-17 18:55:18 +00:00
Author: https://github.com/shannonbooth
Commit: e0d7278820
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5094
Reviewed-by: https://github.com/gmta ✅
16 changed files with 70 additions and 66 deletions
|
@ -56,12 +56,12 @@ URL::Origin determine_the_origin(Optional<URL::URL const&> url, SandboxingFlagSe
|
|||
{
|
||||
// 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 URL::Origin {};
|
||||
return URL::Origin::create_opaque();
|
||||
}
|
||||
|
||||
// 2. If url is null, then return a new opaque origin.
|
||||
if (!url.has_value()) {
|
||||
return URL::Origin {};
|
||||
return URL::Origin::create_opaque();
|
||||
}
|
||||
|
||||
// 3. If url is about:srcdoc, then:
|
||||
|
|
|
@ -263,26 +263,27 @@ HTMLLinkElement::LinkProcessingOptions HTMLLinkElement::create_link_options()
|
|||
auto& document = this->document();
|
||||
|
||||
// 2. Let options be a new link processing options with
|
||||
LinkProcessingOptions options;
|
||||
// FIXME: destination the result of translating the state of el's as attribute
|
||||
// crossorigin the state of el's crossorigin content attribute
|
||||
options.crossorigin = cors_setting_attribute_from_keyword(get_attribute(AttributeNames::crossorigin));
|
||||
// referrer policy the state of el's referrerpolicy content attribute
|
||||
options.referrer_policy = ReferrerPolicy::from_string(get_attribute(AttributeNames::referrerpolicy).value_or(""_string)).value_or(ReferrerPolicy::ReferrerPolicy::EmptyString);
|
||||
// FIXME: source set el's source set
|
||||
// base URL document's document base URL
|
||||
options.base_url = document.base_url();
|
||||
// origin document's origin
|
||||
options.origin = document.origin();
|
||||
// environment document's relevant settings object
|
||||
options.environment = &document.relevant_settings_object();
|
||||
// policy container document's policy container
|
||||
options.policy_container = document.policy_container();
|
||||
// document document
|
||||
options.document = &document;
|
||||
// FIXME: cryptographic nonce metadata the current value of el's [[CryptographicNonce]] internal slot
|
||||
// fetch priority the state of el's fetchpriority content attribute
|
||||
options.fetch_priority = Fetch::Infrastructure::request_priority_from_string(get_attribute_value(HTML::AttributeNames::fetchpriority)).value_or(Fetch::Infrastructure::Request::Priority::Auto);
|
||||
LinkProcessingOptions options {
|
||||
// FIXME: destination the result of translating the state of el's as attribute
|
||||
// crossorigin the state of el's crossorigin content attribute
|
||||
.crossorigin = cors_setting_attribute_from_keyword(get_attribute(AttributeNames::crossorigin)),
|
||||
// referrer policy the state of el's referrerpolicy content attribute
|
||||
.referrer_policy = ReferrerPolicy::from_string(get_attribute(AttributeNames::referrerpolicy).value_or(""_string)).value_or(ReferrerPolicy::ReferrerPolicy::EmptyString),
|
||||
// FIXME: source set el's source set
|
||||
// base URL document's document base URL
|
||||
.base_url = document.base_url(),
|
||||
// origin document's origin
|
||||
.origin = document.origin(),
|
||||
// environment document's relevant settings object
|
||||
.environment = &document.relevant_settings_object(),
|
||||
// policy container document's policy container
|
||||
.policy_container = document.policy_container(),
|
||||
// document document
|
||||
.document = &document,
|
||||
// FIXME: cryptographic nonce metadata the current value of el's [[CryptographicNonce]] internal slot
|
||||
// fetch priority the state of el's fetchpriority content attribute
|
||||
.fetch_priority = Fetch::Infrastructure::request_priority_from_string(get_attribute_value(HTML::AttributeNames::fetchpriority)).value_or(Fetch::Infrastructure::Request::Priority::Auto),
|
||||
};
|
||||
|
||||
// 3. If el has an href attribute, then set options's href to the value of el's href attribute.
|
||||
if (auto maybe_href = get_attribute(AttributeNames::href); maybe_href.has_value())
|
||||
|
|
|
@ -4573,7 +4573,7 @@ Vector<GC::Root<DOM::Node>> HTMLParser::parse_html_fragment(DOM::Element& contex
|
|||
// AD-HOC: The origin is not otherwise set for the document, but it may be accessed during parsing
|
||||
// script. For now, let's just use an opaque origin, but it is likely that the spec is
|
||||
// missing setting this origin.
|
||||
temp_document->set_origin(URL::Origin {});
|
||||
temp_document->set_origin(URL::Origin::create_opaque());
|
||||
|
||||
// 2. If context's node document is in quirks mode, then set document's mode to "quirks".
|
||||
if (context_element.document().in_quirks_mode())
|
||||
|
|
|
@ -30,20 +30,18 @@ ErrorOr<void> encode(Encoder& encoder, Web::HTML::SerializedEnvironmentSettingsO
|
|||
template<>
|
||||
ErrorOr<Web::HTML::SerializedEnvironmentSettingsObject> decode(Decoder& decoder)
|
||||
{
|
||||
Web::HTML::SerializedEnvironmentSettingsObject object {};
|
||||
|
||||
object.id = TRY(decoder.decode<String>());
|
||||
object.creation_url = TRY(decoder.decode<URL::URL>());
|
||||
object.top_level_creation_url = TRY(decoder.decode<Optional<URL::URL>>());
|
||||
object.top_level_origin = TRY(decoder.decode<Optional<URL::Origin>>());
|
||||
object.api_url_character_encoding = TRY(decoder.decode<String>());
|
||||
object.api_base_url = TRY(decoder.decode<URL::URL>());
|
||||
object.origin = TRY(decoder.decode<URL::Origin>());
|
||||
object.policy_container = TRY(decoder.decode<Web::HTML::SerializedPolicyContainer>());
|
||||
object.cross_origin_isolated_capability = TRY(decoder.decode<Web::HTML::CanUseCrossOriginIsolatedAPIs>());
|
||||
object.time_origin = TRY(decoder.decode<double>());
|
||||
|
||||
return object;
|
||||
return Web::HTML::SerializedEnvironmentSettingsObject {
|
||||
.id = TRY(decoder.decode<String>()),
|
||||
.creation_url = TRY(decoder.decode<URL::URL>()),
|
||||
.top_level_creation_url = TRY(decoder.decode<Optional<URL::URL>>()),
|
||||
.top_level_origin = TRY(decoder.decode<Optional<URL::Origin>>()),
|
||||
.api_url_character_encoding = TRY(decoder.decode<String>()),
|
||||
.api_base_url = TRY(decoder.decode<URL::URL>()),
|
||||
.origin = TRY(decoder.decode<URL::Origin>()),
|
||||
.policy_container = TRY(decoder.decode<Web::HTML::SerializedPolicyContainer>()),
|
||||
.cross_origin_isolated_capability = TRY(decoder.decode<Web::HTML::CanUseCrossOriginIsolatedAPIs>()),
|
||||
.time_origin = TRY(decoder.decode<double>()),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,9 +30,8 @@ GC::Ref<WorkerEnvironmentSettingsObject> WorkerEnvironmentSettingsObject::setup(
|
|||
|
||||
// 4. Let settings object be a new environment settings object whose algorithms are defined as follows:
|
||||
// NOTE: See the functions defined for this class.
|
||||
auto settings_object = realm->create<WorkerEnvironmentSettingsObject>(move(execution_context), worker, unsafe_worker_creation_time);
|
||||
auto settings_object = realm->create<WorkerEnvironmentSettingsObject>(move(execution_context), worker, move(inherited_origin), unsafe_worker_creation_time);
|
||||
settings_object->target_browsing_context = nullptr;
|
||||
settings_object->m_origin = move(inherited_origin);
|
||||
|
||||
// FIXME: 5. Set settings object's id to a new unique opaque string, creation URL to worker global scope's url, top-level creation URL to null, target browsing context to null, and active service worker to null.
|
||||
// 6. If worker global scope is a DedicatedWorkerGlobalScope object, then set settings object's top-level origin to outside settings's top-level origin.
|
||||
|
@ -64,7 +63,7 @@ URL::Origin WorkerEnvironmentSettingsObject::origin() const
|
|||
{
|
||||
// Return a unique opaque origin if worker global scope's url's scheme is "data", and inherited origin otherwise.
|
||||
if (m_global_scope->url().scheme() == "data")
|
||||
return URL::Origin {};
|
||||
return URL::Origin::create_opaque();
|
||||
return m_origin;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,9 @@ class WorkerEnvironmentSettingsObject final
|
|||
GC_DECLARE_ALLOCATOR(WorkerEnvironmentSettingsObject);
|
||||
|
||||
public:
|
||||
WorkerEnvironmentSettingsObject(NonnullOwnPtr<JS::ExecutionContext> execution_context, GC::Ref<WorkerGlobalScope> global_scope, HighResolutionTime::DOMHighResTimeStamp unsafe_worker_creation_time)
|
||||
WorkerEnvironmentSettingsObject(NonnullOwnPtr<JS::ExecutionContext> execution_context, GC::Ref<WorkerGlobalScope> global_scope, URL::Origin origin, HighResolutionTime::DOMHighResTimeStamp unsafe_worker_creation_time)
|
||||
: EnvironmentSettingsObject(move(execution_context))
|
||||
, m_origin(move(origin))
|
||||
, m_global_scope(global_scope)
|
||||
, m_unsafe_worker_creation_time(unsafe_worker_creation_time)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
virtual ~SharedWorkerGlobalScope() override;
|
||||
|
||||
void set_constructor_origin(URL::Origin origin) { m_constructor_origin = move(origin); }
|
||||
URL::Origin const& constructor_origin() const { return m_constructor_origin; }
|
||||
URL::Origin const& constructor_origin() const { return m_constructor_origin.value(); }
|
||||
|
||||
void set_constructor_url(URL::URL url) { m_constructor_url = move(url); }
|
||||
URL::URL const& constructor_url() const { return m_constructor_url; }
|
||||
|
@ -48,7 +48,7 @@ private:
|
|||
virtual void initialize_web_interfaces_impl() override;
|
||||
virtual void finalize() override;
|
||||
|
||||
URL::Origin m_constructor_origin;
|
||||
Optional<URL::Origin> m_constructor_origin;
|
||||
URL::URL m_constructor_url;
|
||||
Fetch::Infrastructure::Request::CredentialsMode m_credentials;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue