mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibWeb: Use new way of generating list-style-type: *-alpha
Removed the local conversion from number to alphabet and used the one offered in AK/String instead.
This commit is contained in:
parent
ef8f97635e
commit
22d6fbeb12
Notes:
sideshowbarker
2024-07-18 18:50:50 +09:00
Author: https://github.com/TobyAsE Commit: https://github.com/SerenityOS/serenity/commit/22d6fbeb123 Pull-request: https://github.com/SerenityOS/serenity/pull/6765 Reviewed-by: https://github.com/bgianfo
1 changed files with 2 additions and 17 deletions
|
@ -25,21 +25,6 @@ ListItemMarkerBox::~ListItemMarkerBox()
|
|||
{
|
||||
}
|
||||
|
||||
static const String number_to_alphabet(unsigned int number, const String alphabet)
|
||||
{
|
||||
auto base = alphabet.length();
|
||||
StringBuilder output_string;
|
||||
while (number > base) {
|
||||
number--;
|
||||
auto remainder = number % base;
|
||||
number -= remainder;
|
||||
output_string.append(alphabet[remainder]);
|
||||
number /= base;
|
||||
};
|
||||
output_string.append(alphabet[number - 1]);
|
||||
return output_string.to_string().reverse();
|
||||
}
|
||||
|
||||
void ListItemMarkerBox::paint(PaintContext& context, PaintPhase phase)
|
||||
{
|
||||
if (phase != PaintPhase::Foreground)
|
||||
|
@ -80,11 +65,11 @@ void ListItemMarkerBox::paint(PaintContext& context, PaintPhase phase)
|
|||
break;
|
||||
case CSS::ListStyleType::LowerAlpha:
|
||||
case CSS::ListStyleType::LowerLatin:
|
||||
context.painter().draw_text(enclosing, number_to_alphabet(m_index, lower_alpha), Gfx::TextAlignment::Center);
|
||||
context.painter().draw_text(enclosing, String::bijective_base_from(m_index).to_lowercase(), Gfx::TextAlignment::Center);
|
||||
break;
|
||||
case CSS::ListStyleType::UpperAlpha:
|
||||
case CSS::ListStyleType::UpperLatin:
|
||||
context.painter().draw_text(enclosing, number_to_alphabet(m_index, upper_alpha), Gfx::TextAlignment::Center);
|
||||
context.painter().draw_text(enclosing, String::bijective_base_from(m_index), Gfx::TextAlignment::Center);
|
||||
break;
|
||||
case CSS::ListStyleType::None:
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue