LibWeb: Prefer using equals_ignoring_ascii_case

Which has an optmization if both size of the string being passed
through are FlyStrings, which actually ends up being the case
in some places during selector matching comparing attribute names.
Instead of maintaining more overloads of
Infra::is_ascii_case_insensitive_match, switch
everything over to equals_ignoring_ascii_case instead.
This commit is contained in:
Shannon Booth 2025-05-18 15:04:56 +12:00 committed by Sam Atkins
parent cfc241f61d
commit 579730d861
Notes: github-actions[bot] 2025-05-21 12:46:04 +00:00
24 changed files with 78 additions and 87 deletions

View file

@ -229,12 +229,12 @@ void HTMLScriptElement::prepare_script()
m_script_type = ScriptType::Classic;
}
// 10. Otherwise, if the script block's type string is an ASCII case-insensitive match for the string "module",
else if (Infra::is_ascii_case_insensitive_match(script_block_type, "module"sv)) {
else if (script_block_type.equals_ignoring_ascii_case("module"sv)) {
// then set el's type to "module".
m_script_type = ScriptType::Module;
}
// 11. Otherwise, if the script block's type string is an ASCII case-insensitive match for the string "importmap",
else if (Infra::is_ascii_case_insensitive_match(script_block_type, "importmap"sv)) {
else if (script_block_type.equals_ignoring_ascii_case("importmap"sv)) {
// then set el's type to "importmap".
m_script_type = ScriptType::ImportMap;
}
@ -290,14 +290,14 @@ void HTMLScriptElement::prepare_script()
event = MUST(event.trim(Infra::ASCII_WHITESPACE));
// 4. If for is not an ASCII case-insensitive match for the string "window", then return.
if (!Infra::is_ascii_case_insensitive_match(for_, "window"sv)) {
if (!for_.equals_ignoring_ascii_case("window"sv)) {
dbgln("HTMLScriptElement: Refusing to run classic script because the provided 'for' attribute is not equal to 'window'");
return;
}
// 5. If event is not an ASCII case-insensitive match for either the string "onload" or the string "onload()", then return.
if (!Infra::is_ascii_case_insensitive_match(event, "onload"sv)
&& !Infra::is_ascii_case_insensitive_match(event, "onload()"sv)) {
if (!event.equals_ignoring_ascii_case("onload"sv)
&& !event.equals_ignoring_ascii_case("onload()"sv)) {
dbgln("HTMLScriptElement: Refusing to run classic script because the provided 'event' attribute is not equal to 'onload' or 'onload()'");
return;
}