1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-23 18:45:07 +00:00

LibWeb: Use is_ascii_case_insensitive_match() where the spec says to

This commit is contained in:
Sam Atkins 2023-02-17 15:21:32 +00:00 committed by Linus Groh
parent f0b72b819e
commit 2026ea557e
10 changed files with 59 additions and 44 deletions

View file

@ -22,6 +22,7 @@
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HTML/WindowProxy.h>
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
#include <LibWeb/Infra/Strings.h>
#include <LibWeb/Layout/BreakNode.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/TextNode.h>
@ -627,13 +628,13 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex
auto sandboxing_flag_set = active_document()->active_sandboxing_flag_set();
// 4. If name is the empty string or an ASCII case-insensitive match for "_self", then set chosen to current.
if (name.is_empty() || name.equals_ignoring_case("_self"sv)) {
if (name.is_empty() || Infra::is_ascii_case_insensitive_match(name, "_self"sv)) {
chosen = this;
}
// 5. Otherwise, if name is an ASCII case-insensitive match for "_parent", set chosen to current's parent browsing
// context, if any, and current otherwise.
else if (name.equals_ignoring_case("_parent"sv)) {
else if (Infra::is_ascii_case_insensitive_match(name, "_parent"sv)) {
if (auto parent = this->parent())
chosen = parent;
else
@ -642,7 +643,7 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex
// 6. Otherwise, if name is an ASCII case-insensitive match for "_top", set chosen to current's top-level browsing
// context, if any, and current otherwise.
else if (name.equals_ignoring_case("_top"sv)) {
else if (Infra::is_ascii_case_insensitive_match(name, "_top"sv)) {
chosen = &top_level_browsing_context();
}
@ -652,7 +653,7 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex
// set chosen to that browsing context. If there are multiple matching browsing contexts, the user agent
// should set chosen to one in some arbitrary consistent manner, such as the most recently opened, most
// recently focused, or more closely related.
else if (!name.equals_ignoring_case("_blank"sv)) {
else if (!Infra::is_ascii_case_insensitive_match(name, "_blank"sv)) {
dbgln("FIXME: Find matching browser context for name {}", name);
chosen = this;
} else {
@ -715,7 +716,7 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex
// FIXME: Our BrowsingContexts do not have SandboxingFlagSets yet, only documents do
// 6. If name is not an ASCII case-insensitive match for "_blank", then set chosen's name to name.
if (!name.equals_ignoring_case("_blank"sv))
if (!Infra::is_ascii_case_insensitive_match(name, "_blank"sv))
chosen->set_name(name);
}