mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 18:00:16 +00:00
LibWeb: Support strings as list-style-types
We've long claimed to support this, but then silently ignored string
values, until 4cb2063577
which would
not-so-silently crash instead. (Oops)
So, actually pass the string value along and use it in the list marker.
As part of this, rename our `list-style-type` enum to
`counter-style-name-keyword`. This is an awkward name, attempting to be
spec-based. (The spec says `<counter-style>`, which is either a
`<counter-style-name>` or a function, and the `<counter-style-name>` is
a `<custom-ident>` that also has a few predefined values. So this is the
best I could come up with.)
Unfortunately only one WPT test for this passes - the others fail
because we produce a different layout when text is in `::before` than
when it's in `::marker`, and similar issues.
This commit is contained in:
parent
b987d53926
commit
0fd0596dbf
Notes:
github-actions[bot]
2025-02-11 09:40:22 +00:00
Author: https://github.com/AtkinsSJ
Commit: 0fd0596dbf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3528
10 changed files with 201 additions and 132 deletions
|
@ -53,35 +53,34 @@ static String generate_a_counter_representation(CSSStyleValue const& counter_sty
|
|||
auto counter_style_name = counter_style.as_custom_ident().custom_ident();
|
||||
auto keyword = keyword_from_string(counter_style_name);
|
||||
if (keyword.has_value()) {
|
||||
auto list_style_type = keyword_to_list_style_type(*keyword);
|
||||
if (list_style_type.has_value()) {
|
||||
if (auto list_style_type = keyword_to_counter_style_name_keyword(*keyword); list_style_type.has_value()) {
|
||||
switch (*list_style_type) {
|
||||
case ListStyleType::Square:
|
||||
case CounterStyleNameKeyword::Square:
|
||||
return "▪"_string;
|
||||
case ListStyleType::Circle:
|
||||
case CounterStyleNameKeyword::Circle:
|
||||
return "◦"_string;
|
||||
case ListStyleType::Disc:
|
||||
case CounterStyleNameKeyword::Disc:
|
||||
return "•"_string;
|
||||
case ListStyleType::DisclosureClosed:
|
||||
case CounterStyleNameKeyword::DisclosureClosed:
|
||||
return "▸"_string;
|
||||
case ListStyleType::DisclosureOpen:
|
||||
case CounterStyleNameKeyword::DisclosureOpen:
|
||||
return "▾"_string;
|
||||
case ListStyleType::Decimal:
|
||||
case CounterStyleNameKeyword::Decimal:
|
||||
return MUST(String::formatted("{}", value));
|
||||
case ListStyleType::DecimalLeadingZero:
|
||||
case CounterStyleNameKeyword::DecimalLeadingZero:
|
||||
// This is weird, but in accordance to spec.
|
||||
if (value < 10)
|
||||
return MUST(String::formatted("0{}", value));
|
||||
return MUST(String::formatted("{}", value));
|
||||
case ListStyleType::LowerAlpha:
|
||||
case ListStyleType::LowerLatin:
|
||||
case CounterStyleNameKeyword::LowerAlpha:
|
||||
case CounterStyleNameKeyword::LowerLatin:
|
||||
return String::bijective_base_from(value - 1, String::Case::Lower);
|
||||
case ListStyleType::UpperAlpha:
|
||||
case ListStyleType::UpperLatin:
|
||||
case CounterStyleNameKeyword::UpperAlpha:
|
||||
case CounterStyleNameKeyword::UpperLatin:
|
||||
return String::bijective_base_from(value - 1, String::Case::Upper);
|
||||
case ListStyleType::LowerRoman:
|
||||
case CounterStyleNameKeyword::LowerRoman:
|
||||
return String::roman_number_from(value, String::Case::Lower);
|
||||
case ListStyleType::UpperRoman:
|
||||
case CounterStyleNameKeyword::UpperRoman:
|
||||
return String::roman_number_from(value, String::Case::Upper);
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue