1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

LibWeb: Consistently use the EmptyString state of ReferrerPolicy

We previously used an empty optional to denote that a ReferrerPolicy is
in the default empty string state. However, later additions added an
explicit EmptyString state. This patch moves all users to the explicit
state, and stops using `Optional<ReferrerPolicy>` everywhere except for
when an option not being passed from JavaScript has meaning.
This commit is contained in:
Andrew Kaster 2024-03-05 09:35:25 -07:00 committed by Andreas Kling
parent 637f2f2ed6
commit c79bac70f4
12 changed files with 23 additions and 24 deletions

View file

@ -23,11 +23,11 @@ namespace Web::Fetch {
// - Fetch has use-cases beyond its JS interface, so having to refer to the 'Bindings' namespace
// constantly is irritating.
Optional<ReferrerPolicy::ReferrerPolicy> from_bindings_enum(Bindings::ReferrerPolicy referrer_policy)
ReferrerPolicy::ReferrerPolicy from_bindings_enum(Bindings::ReferrerPolicy referrer_policy)
{
switch (referrer_policy) {
case Bindings::ReferrerPolicy::Empty:
return {};
return ReferrerPolicy::ReferrerPolicy::EmptyString;
case Bindings::ReferrerPolicy::NoReferrer:
return ReferrerPolicy::ReferrerPolicy::NoReferrer;
case Bindings::ReferrerPolicy::NoReferrerWhenDowngrade:
@ -113,11 +113,11 @@ Infrastructure::Request::RedirectMode from_bindings_enum(Bindings::RequestRedire
}
}
Bindings::ReferrerPolicy to_bindings_enum(Optional<ReferrerPolicy::ReferrerPolicy> const& referrer_policy)
Bindings::ReferrerPolicy to_bindings_enum(ReferrerPolicy::ReferrerPolicy referrer_policy)
{
if (!referrer_policy.has_value())
switch (referrer_policy) {
case ReferrerPolicy::ReferrerPolicy::EmptyString:
return Bindings::ReferrerPolicy::Empty;
switch (*referrer_policy) {
case ReferrerPolicy::ReferrerPolicy::NoReferrer:
return Bindings::ReferrerPolicy::NoReferrer;
case ReferrerPolicy::ReferrerPolicy::NoReferrerWhenDowngrade: