LibWeb/Infra: Rename to_ascii_{{lower,upper}_case => {lower,upper}case}

This commit is contained in:
Linus Groh 2023-03-04 22:41:57 +00:00
parent 85507b34d7
commit f65cbeef5c
Notes: sideshowbarker 2024-07-17 02:22:23 +09:00
5 changed files with 12 additions and 12 deletions

View File

@ -169,7 +169,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::create(JS::Realm& realm, Optio
// 2. Convert every character in t to ASCII lowercase.
if (!type.is_empty())
type = TRY_OR_THROW_OOM(vm, Infra::to_ascii_lower_case(type));
type = TRY_OR_THROW_OOM(vm, Infra::to_ascii_lowercase(type));
}
// 4. Return a Blob object referring to bytes as its associated byte sequence, with its size set to the length of bytes, and its type set to the value of t from the substeps above.
@ -233,7 +233,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::slice(Optional<i64> start, Opt
// FIXME: 1. If relativeContentType contains any characters outside the range of U+0020 to U+007E, then set relativeContentType to the empty string and return from these substeps.
// 2. Convert every character in relativeContentType to ASCII lowercase.
relative_content_type = TRY_OR_THROW_OOM(vm, Infra::to_ascii_lower_case(content_type.value()));
relative_content_type = TRY_OR_THROW_OOM(vm, Infra::to_ascii_lowercase(content_type.value()));
}
// 4. Let span be max((relativeEnd - relativeStart), 0).

View File

@ -55,7 +55,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> File::create(JS::Realm& realm, Vecto
// 2. Convert every character in t to ASCII lowercase.
if (!type.is_empty())
type = TRY_OR_THROW_OOM(vm, Infra::to_ascii_lower_case(type));
type = TRY_OR_THROW_OOM(vm, Infra::to_ascii_lowercase(type));
// 3. If the lastModified member is provided, let d be set to the lastModified dictionary member. If it is not provided, set d to the current date and time represented as the number of milliseconds since the Unix Epoch (which is the equivalent of Date.now() [ECMA-262]).
// Note: Since ECMA-262 Date objects convert to long long values representing the number of milliseconds since the Unix Epoch, the lastModified member could be a Date object [ECMA-262].

View File

@ -33,7 +33,7 @@ bool is_ascii_case_insensitive_match(StringView a, StringView b)
auto b_char = *b_iterator;
++b_iterator;
if (to_ascii_lowercase(a_char) != to_ascii_lowercase(b_char))
if (AK::to_ascii_lowercase(a_char) != AK::to_ascii_lowercase(b_char))
return false;
}
@ -107,28 +107,28 @@ ErrorOr<String> convert_to_scalar_value_string(StringView string)
}
// https://infra.spec.whatwg.org/#ascii-lowercase
ErrorOr<String> to_ascii_lower_case(StringView string)
ErrorOr<String> to_ascii_lowercase(StringView string)
{
// To ASCII lowercase a string, replace all ASCII upper alphas in the string with their
// corresponding code point in ASCII lower alpha.
StringBuilder string_builder;
auto utf8_view = Utf8View { string };
for (u32 code_point : utf8_view) {
code_point = to_ascii_lowercase(code_point);
code_point = AK::to_ascii_lowercase(code_point);
TRY(string_builder.try_append(code_point));
}
return string_builder.to_string();
}
// https://infra.spec.whatwg.org/#ascii-uppercase
ErrorOr<String> to_ascii_upper_case(StringView string)
ErrorOr<String> to_ascii_uppercase(StringView string)
{
// To ASCII uppercase a string, replace all ASCII lower alphas in the string with their
// corresponding code point in ASCII upper alpha.
StringBuilder string_builder;
auto utf8_view = Utf8View { string };
for (u32 code_point : utf8_view) {
code_point = to_ascii_uppercase(code_point);
code_point = AK::to_ascii_uppercase(code_point);
TRY(string_builder.try_append(code_point));
}
return string_builder.to_string();

View File

@ -17,7 +17,7 @@ bool is_ascii_case_insensitive_match(StringView a, StringView b);
DeprecatedString strip_and_collapse_whitespace(StringView string);
bool is_code_unit_prefix(StringView potential_prefix, StringView input);
ErrorOr<String> convert_to_scalar_value_string(StringView string);
ErrorOr<String> to_ascii_lower_case(StringView string);
ErrorOr<String> to_ascii_upper_case(StringView string);
ErrorOr<String> to_ascii_lowercase(StringView string);
ErrorOr<String> to_ascii_uppercase(StringView string);
}

View File

@ -105,7 +105,7 @@ ErrorOr<Optional<MimeType>> MimeType::parse(StringView string)
return OptionalNone {};
// 10. Let mimeType be a new MIME type record whose type is type, in ASCII lowercase, and subtype is subtype, in ASCII lowercase.
auto mime_type = TRY(MimeType::create(TRY(Infra::to_ascii_lower_case(type)), TRY(Infra::to_ascii_lower_case(subtype))));
auto mime_type = TRY(MimeType::create(TRY(Infra::to_ascii_lowercase(type)), TRY(Infra::to_ascii_lowercase(subtype))));
// 11. While position is not past the end of input:
while (!lexer.is_eof()) {
@ -121,7 +121,7 @@ ErrorOr<Optional<MimeType>> MimeType::parse(StringView string)
});
// 4. Set parameterName to parameterName, in ASCII lowercase.
auto parameter_name = TRY(Infra::to_ascii_lower_case(parameter_name_view));
auto parameter_name = TRY(Infra::to_ascii_lowercase(parameter_name_view));
// 5. If position is not past the end of input, then:
if (!lexer.is_eof()) {