AK+LibWeb/CSS: Add lower-greek counter style

This commit is contained in:
dmaivel 2025-07-18 17:08:27 -04:00 committed by Sam Atkins
commit 52a23dc02e
Notes: github-actions[bot] 2025-07-21 14:19:45 +00:00
8 changed files with 27 additions and 3 deletions

View file

@ -492,6 +492,21 @@ String String::bijective_base_from(size_t value, Case target_case, unsigned base
return MUST(from_utf8(ReadonlyBytes(buffer.data(), i)));
}
String String::greek_letter_from(size_t value)
{
static StringView const map = "αβγδεζηθικλμνξοπρστυφχψω"sv;
static unsigned const base = 24;
StringBuilder builder;
while (value > 0) {
value--;
builder.append(map.substring_view((value % base) * 2, 2));
value /= base;
}
return MUST(builder.to_string_without_validation().reverse());
}
String String::roman_number_from(size_t value, Case target_case)
{
if (value > 3999)

View file

@ -102,6 +102,7 @@ public:
Lower,
};
[[nodiscard]] static String bijective_base_from(size_t value, Case, unsigned base = 26, StringView map = {});
[[nodiscard]] static String greek_letter_from(size_t value);
[[nodiscard]] static String roman_number_from(size_t value, Case);
// Creates a new String by case-transforming this String. Using these methods require linking LibUnicode into your application.

View file

@ -138,6 +138,7 @@
"disclosure-closed",
"disclosure-open",
"lower-alpha",
"lower-greek",
"lower-latin",
"lower-roman",
"none",

View file

@ -304,6 +304,7 @@
"local",
"longer",
"lower-alpha",
"lower-greek",
"lower-latin",
"lower-roman",
"lowercase",

View file

@ -79,6 +79,8 @@ static String generate_a_counter_representation(CSSStyleValue const& counter_sty
case CounterStyleNameKeyword::UpperAlpha:
case CounterStyleNameKeyword::UpperLatin:
return String::bijective_base_from(value - 1, String::Case::Upper);
case CounterStyleNameKeyword::LowerGreek:
return String::greek_letter_from(value);
case CounterStyleNameKeyword::LowerRoman:
return String::roman_number_from(value, String::Case::Lower);
case CounterStyleNameKeyword::UpperRoman:

View file

@ -52,6 +52,9 @@ Optional<String> ListItemMarkerBox::text() const
case CSS::CounterStyleNameKeyword::UpperLatin:
text = String::bijective_base_from(index - 1, String::Case::Upper);
break;
case CSS::CounterStyleNameKeyword::LowerGreek:
text = String::greek_letter_from(index);
break;
case CSS::CounterStyleNameKeyword::LowerRoman:
text = String::roman_number_from(index, String::Case::Lower);
break;

View file

@ -108,6 +108,7 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const
case CSS::CounterStyleNameKeyword::Decimal:
case CSS::CounterStyleNameKeyword::DecimalLeadingZero:
case CSS::CounterStyleNameKeyword::LowerAlpha:
case CSS::CounterStyleNameKeyword::LowerGreek:
case CSS::CounterStyleNameKeyword::LowerLatin:
case CSS::CounterStyleNameKeyword::LowerRoman:
case CSS::CounterStyleNameKeyword::UpperAlpha:

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 687 tests
658 Pass
29 Fail
659 Pass
28 Fail
Pass background-attachment: scroll
Pass background-attachment: fixed
Pass background-attachment: inherit
@ -468,7 +468,7 @@ Pass list-style-type: decimal
Pass list-style-type: decimal-leading-zero
Pass list-style-type: lower-roman
Pass list-style-type: upper-roman
Fail list-style-type: lower-greek
Pass list-style-type: lower-greek
Pass list-style-type: lower-latin
Pass list-style-type: upper-latin
Fail list-style-type: armenian