LibWeb: Implement CounterStyleValue

This is `counter(name, style?)` or `counters(name, link, style?)`. The
difference being, `counter()` matches only the nearest level (eg, "1"),
and `counters()` combines all the levels in the tree (eg, "3.4.1").
This commit is contained in:
Sam Atkins 2024-07-24 14:56:16 +01:00
commit 576a431408
Notes: github-actions[bot] 2024-07-26 10:05:34 +00:00
11 changed files with 274 additions and 3 deletions

View file

@ -22,9 +22,28 @@ bool is_animatable_property(JsonObject& properties, StringView property_name);
static bool type_name_is_enum(StringView type_name)
{
return !AK::first_is_one_of(type_name,
"angle"sv, "background-position"sv, "basic-shape"sv, "color"sv, "custom-ident"sv, "easing-function"sv, "flex"sv, "frequency"sv, "image"sv,
"integer"sv, "length"sv, "number"sv, "paint"sv, "percentage"sv, "position"sv, "ratio"sv, "rect"sv,
"resolution"sv, "string"sv, "time"sv, "url"sv);
"angle"sv,
"background-position"sv,
"basic-shape"sv,
"color"sv,
"counter"sv,
"custom-ident"sv,
"easing-function"sv,
"flex"sv,
"frequency"sv,
"image"sv,
"integer"sv,
"length"sv,
"number"sv,
"paint"sv,
"percentage"sv,
"position"sv,
"ratio"sv,
"rect"sv,
"resolution"sv,
"string"sv,
"time"sv,
"url"sv);
}
ErrorOr<int> serenity_main(Main::Arguments arguments)
@ -183,6 +202,7 @@ enum class ValueType {
BackgroundPosition,
BasicShape,
Color,
Counter,
CustomIdent,
EasingFunction,
FilterValueList,
@ -732,6 +752,8 @@ bool property_accepts_type(PropertyID property_id, ValueType value_type)
property_generator.appendln(" case ValueType::BasicShape:");
} else if (type_name == "color") {
property_generator.appendln(" case ValueType::Color:");
} else if (type_name == "counter") {
property_generator.appendln(" case ValueType::Counter:");
} else if (type_name == "custom-ident") {
property_generator.appendln(" case ValueType::CustomIdent:");
} else if (type_name == "easing-function") {