mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +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
|
@ -184,7 +184,7 @@ WebIDL::ExceptionOr<void> Element::set_attribute(FlyString const& name, String c
|
|||
// 4. If attribute is null, create an attribute whose local name is qualifiedName, value is value, and node document
|
||||
// is this’s node document, then append this attribute to this, and then return.
|
||||
if (!attribute) {
|
||||
auto new_attribute = Attr::create(document(), insert_as_lowercase ? MUST(Infra::to_ascii_lowercase(name)) : name, value);
|
||||
auto new_attribute = Attr::create(document(), insert_as_lowercase ? name.to_ascii_lowercase() : name, value);
|
||||
m_attributes->append_attribute(new_attribute);
|
||||
|
||||
return {};
|
||||
|
@ -354,7 +354,7 @@ WebIDL::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optio
|
|||
// 1. If force is not given or is true, create an attribute whose local name is qualifiedName, value is the empty
|
||||
// string, and node document is this’s node document, then append this attribute to this, and then return true.
|
||||
if (!force.has_value() || force.value()) {
|
||||
auto new_attribute = Attr::create(document(), insert_as_lowercase ? MUST(Infra::to_ascii_lowercase(name)) : name.to_string(), String {});
|
||||
auto new_attribute = Attr::create(document(), insert_as_lowercase ? name.to_ascii_lowercase() : name.to_string(), String {});
|
||||
m_attributes->append_attribute(new_attribute);
|
||||
|
||||
return true;
|
||||
|
@ -891,7 +891,7 @@ void Element::make_html_uppercased_qualified_name()
|
|||
{
|
||||
// This is allowed by the spec: "User agents could optimize qualified name and HTML-uppercased qualified name by storing them in internal slots."
|
||||
if (namespace_uri() == Namespace::HTML && document().document_type() == Document::Type::HTML)
|
||||
m_html_uppercased_qualified_name = MUST(Infra::to_ascii_uppercase(qualified_name()));
|
||||
m_html_uppercased_qualified_name = qualified_name().to_ascii_uppercase();
|
||||
else
|
||||
m_html_uppercased_qualified_name = qualified_name();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue