mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-01 15:18:06 +00:00
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:
parent
dd419b5a8d
commit
073bcfd386
Notes:
github-actions[bot]
2024-10-14 18:49:00 +00:00
Author: https://github.com/awesomekling
Commit: 073bcfd386
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1796
16 changed files with 147 additions and 13 deletions
|
@ -142,7 +142,7 @@ String DataTransfer::get_data(String const& format_argument) const
|
|||
return {};
|
||||
|
||||
// 3. Let format be the first argument, converted to ASCII lowercase.
|
||||
auto format = MUST(Infra::to_ascii_lowercase(format_argument));
|
||||
auto format = format_argument.to_ascii_lowercase();
|
||||
|
||||
// 4. Let convert-to-URL be false.
|
||||
[[maybe_unused]] bool convert_to_url = false;
|
||||
|
|
|
@ -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(),
|
||||
});
|
||||
|
|
|
@ -1506,7 +1506,7 @@ String HTMLInputElement::value_sanitization_algorithm(String const& value) const
|
|||
// https://html.spec.whatwg.org/multipage/input.html#color-state-(type=color):value-sanitization-algorithm
|
||||
// If the value of the element is a valid simple color, then set it to the value of the element converted to ASCII lowercase;
|
||||
if (is_valid_simple_color(value))
|
||||
return MUST(Infra::to_ascii_lowercase(value));
|
||||
return value.to_ascii_lowercase();
|
||||
// otherwise, set it to the string "#000000".
|
||||
return "#000000"_string;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue