mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +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:
parent
637f2f2ed6
commit
c79bac70f4
12 changed files with 23 additions and 24 deletions
|
@ -559,7 +559,7 @@ after_step_7:
|
|||
request->set_initiator(Fetch::Infrastructure::Request::Initiator::ImageSet);
|
||||
|
||||
// 21. Set request's referrer policy to the current state of the element's referrerpolicy attribute.
|
||||
request->set_referrer_policy(ReferrerPolicy::from_string(get_attribute_value(HTML::AttributeNames::referrerpolicy)));
|
||||
request->set_referrer_policy(ReferrerPolicy::from_string(get_attribute_value(HTML::AttributeNames::referrerpolicy)).value_or(ReferrerPolicy::ReferrerPolicy::EmptyString));
|
||||
|
||||
// FIXME: 22. Set request's priority to the current state of the element's fetchpriority attribute.
|
||||
|
||||
|
@ -774,7 +774,7 @@ void HTMLImageElement::react_to_changes_in_the_environment()
|
|||
request->set_initiator(Fetch::Infrastructure::Request::Initiator::ImageSet);
|
||||
|
||||
// 3. Set request's referrer policy to the current state of the element's referrerpolicy attribute.
|
||||
request->set_referrer_policy(ReferrerPolicy::from_string(get_attribute_value(HTML::AttributeNames::referrerpolicy)));
|
||||
request->set_referrer_policy(ReferrerPolicy::from_string(get_attribute_value(HTML::AttributeNames::referrerpolicy)).value_or(ReferrerPolicy::ReferrerPolicy::EmptyString));
|
||||
|
||||
// FIXME: 4. Set request's priority to the current state of the element's fetchpriority attribute.
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
CORSSettingAttribute crossorigin { CORSSettingAttribute::NoCORS };
|
||||
// referrer policy (default the empty string)
|
||||
// A referrer policy
|
||||
Optional<ReferrerPolicy::ReferrerPolicy> referrer_policy {};
|
||||
ReferrerPolicy::ReferrerPolicy referrer_policy { ReferrerPolicy::ReferrerPolicy::EmptyString };
|
||||
// FIXME: source set (default null)
|
||||
// Null or a source set
|
||||
// base URL
|
||||
|
|
|
@ -54,10 +54,7 @@ void HTMLScriptElement::attribute_changed(FlyString const& name, Optional<String
|
|||
if (name == HTML::AttributeNames::crossorigin) {
|
||||
m_crossorigin = cors_setting_attribute_from_keyword(value);
|
||||
} else if (name == HTML::AttributeNames::referrerpolicy) {
|
||||
if (!value.has_value())
|
||||
m_referrer_policy.clear();
|
||||
else
|
||||
m_referrer_policy = ReferrerPolicy::from_string(*value);
|
||||
m_referrer_policy = ReferrerPolicy::from_string(value.value_or(""_string)).value_or(ReferrerPolicy::ReferrerPolicy::EmptyString);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ private:
|
|||
CORSSettingAttribute m_crossorigin { CORSSettingAttribute::NoCORS };
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#attr-script-referrerpolicy
|
||||
Optional<ReferrerPolicy::ReferrerPolicy> m_referrer_policy;
|
||||
ReferrerPolicy::ReferrerPolicy m_referrer_policy { ReferrerPolicy::ReferrerPolicy::EmptyString };
|
||||
|
||||
bool m_failed_to_load { false };
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ struct ScriptFetchOptions {
|
|||
Fetch::Infrastructure::Request::CredentialsMode credentials_mode { Fetch::Infrastructure::Request::CredentialsMode::SameOrigin };
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-referrer-policy
|
||||
Optional<ReferrerPolicy::ReferrerPolicy> referrer_policy;
|
||||
ReferrerPolicy::ReferrerPolicy referrer_policy { ReferrerPolicy::ReferrerPolicy::EmptyString };
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-fetch-options-render-blocking
|
||||
bool render_blocking { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue