AK+LibWeb: Add {Fly,}String::to_ascii_{upper,lower}_case()

These don't have to worry about the input not being valid UTF-8 and
so can be infallible (and can even return self if no changes needed.)

We use this instead of Infra::to_ascii_{upper,lower}_case in LibWeb.
This commit is contained in:
Andreas Kling 2024-10-14 10:51:15 +02:00 committed by Andreas Kling
commit 073bcfd386
Notes: github-actions[bot] 2024-10-14 18:49:00 +00:00
16 changed files with 147 additions and 13 deletions

View file

@ -137,7 +137,7 @@ void HTMLLinkElement::attribute_changed(FlyString const& name, Optional<String>
if (name == HTML::AttributeNames::rel) {
m_relationship = 0;
// Keywords are always ASCII case-insensitive, and must be compared as such.
auto lowercased_value = MUST(Infra::to_ascii_lowercase(value.value_or(String {})));
auto lowercased_value = value.value_or(String {}).to_ascii_lowercase();
// To determine which link types apply to a link, a, area, or form element,
// the element's rel attribute must be split on ASCII whitespace.
// The resulting tokens are the keywords for the link types that apply to that element.