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

@ -76,7 +76,7 @@ WebIDL::ExceptionOr<JS::GCPtr<DataTransferItem>> DataTransferItemList::add(Strin
// method's first argument.
auto item = m_data_transfer->add_item({
.kind = HTML::DragDataStoreItem::Kind::Text,
.type_string = MUST(Infra::to_ascii_lowercase(type)),
.type_string = type.to_ascii_lowercase(),
.data = MUST(ByteBuffer::copy(data.bytes())),
.file_name = {},
});
@ -100,7 +100,7 @@ JS::GCPtr<DataTransferItem> DataTransferItemList::add(JS::NonnullGCPtr<FileAPI::
// converted to ASCII lowercase, and whose data is the same as the File's data.
auto item = m_data_transfer->add_item({
.kind = HTML::DragDataStoreItem::Kind::File,
.type_string = MUST(Infra::to_ascii_lowercase(file->type())),
.type_string = file->type().to_ascii_lowercase(),
.data = MUST(ByteBuffer::copy(file->raw_bytes())),
.file_name = file->name().to_byte_string(),
});