LibWeb: Make property/media-feature name matching ASCII case-insensitive

https://www.w3.org/TR/css-conditional-3/#dom-css-supports specifically
asks for this when calling `CSS::property_id_from_string()`, but in
general, CSS property and media-feature names can only contain ASCII.
This commit is contained in:
Sam Atkins 2023-02-17 16:43:28 +00:00 committed by Linus Groh
parent 05b5a3bfba
commit f0b72b819e
Notes: sideshowbarker 2024-07-17 00:04:17 +09:00
2 changed files with 6 additions and 3 deletions

View file

@ -88,7 +88,9 @@ ErrorOr<void> generate_implementation_file(JsonObject& media_feature_data, Core:
{
StringBuilder builder;
SourceGenerator generator { builder };
generator.append(R"~~~(#include <LibWeb/CSS/MediaFeatureID.h>
generator.append(R"~~~(
#include <LibWeb/CSS/MediaFeatureID.h>
#include <LibWeb/Infra/Strings.h>
namespace Web::CSS {
@ -100,7 +102,7 @@ Optional<MediaFeatureID> media_feature_id_from_string(StringView string)
member_generator.set("name", name);
member_generator.set("name:titlecase", title_casify(name));
member_generator.append(R"~~~(
if (string.equals_ignoring_case("@name@"sv))
if (Infra::is_ascii_case_insensitive_match(string, "@name@"sv))
return MediaFeatureID::@name:titlecase@;
)~~~");
});

View file

@ -154,6 +154,7 @@ ErrorOr<void> generate_implementation_file(JsonObject& properties, Core::File& f
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/CSS/StyleValue.h>
#include <LibWeb/Infra/Strings.h>
namespace Web::CSS {
@ -189,7 +190,7 @@ PropertyID property_id_from_string(StringView string)
member_generator.set("name", name);
member_generator.set("name:titlecase", title_casify(name));
member_generator.append(R"~~~(
if (string.equals_ignoring_case("@name@"sv))
if (Infra::is_ascii_case_insensitive_match(string, "@name@"sv))
return PropertyID::@name:titlecase@;
)~~~");
});