1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

LibWeb: Change the "noreferrer" storage type to a named enum

This commit is contained in:
Timothy Flynn 2023-03-21 06:58:09 -04:00 committed by Andreas Kling
parent 1b811191cd
commit bff109ee50
Notes: sideshowbarker 2024-07-16 23:34:49 +09:00
2 changed files with 6 additions and 5 deletions

View file

@ -15,5 +15,6 @@ namespace Web::HTML::TokenizedFeature {
}
TOKENIZED_FEATURE(NoOpener);
TOKENIZED_FEATURE(NoReferrer);
}

View file

@ -336,7 +336,7 @@ WebIDL::ExceptionOr<JS::GCPtr<WindowProxy>> Window::open_impl(StringView url, St
// 5. Let noopener and noreferrer be false.
auto no_opener = TokenizedFeature::NoOpener::No;
auto no_referrer = false;
auto no_referrer = TokenizedFeature::NoReferrer::No;
// 6. If tokenizedFeatures["noopener"] exists, then:
if (auto no_opener_feature = tokenized_features.get("noopener"sv); no_opener_feature.has_value()) {
@ -350,14 +350,14 @@ WebIDL::ExceptionOr<JS::GCPtr<WindowProxy>> Window::open_impl(StringView url, St
// 7. If tokenizedFeatures["noreferrer"] exists, then:
if (auto no_referrer_feature = tokenized_features.get("noreferrer"sv); no_referrer_feature.has_value()) {
// 1. Set noreferrer to the result of parsing tokenizedFeatures["noreferrer"] as a boolean feature.
no_referrer = parse_boolean_feature(*no_referrer_feature);
no_referrer = parse_boolean_feature<TokenizedFeature::NoReferrer>(*no_referrer_feature);
// 2. Remove tokenizedFeatures["noreferrer"].
tokenized_features.remove("noreferrer"sv);
}
// 8. If noreferrer is true, then set noopener to true.
if (no_referrer)
if (no_referrer == TokenizedFeature::NoReferrer::Yes)
no_opener = TokenizedFeature::NoOpener::Yes;
// 9. Let target browsing context and windowType be the result of applying the rules for choosing a browsing context given target, source browsing context, and noopener.
@ -394,7 +394,7 @@ WebIDL::ExceptionOr<JS::GCPtr<WindowProxy>> Window::open_impl(StringView url, St
request->set_url(url_record);
// 2. If noreferrer is true, then set request's referrer to "no-referrer".
if (no_referrer)
if (no_referrer == TokenizedFeature::NoReferrer::Yes)
request->set_referrer(Fetch::Infrastructure::Request::Referrer::NoReferrer);
// 3. Navigate target browsing context to request, with exceptionsEnabled set to true and the source browsing context set to source browsing context.
@ -419,7 +419,7 @@ WebIDL::ExceptionOr<JS::GCPtr<WindowProxy>> Window::open_impl(StringView url, St
request->set_url(url_record);
// 4. If noreferrer is true, then set request's referrer to "noreferrer".
if (no_referrer)
if (no_referrer == TokenizedFeature::NoReferrer::Yes)
request->set_referrer(Fetch::Infrastructure::Request::Referrer::NoReferrer);
// 5. Navigate target browsing context to request, with exceptionsEnabled set to true and the source browsing context set to source browsing context.