LibWeb: Add roman numerals as a list-style for ol's

This patch adds support for the identifiers upper-roman and lower-roman
of the list-style property.
This commit is contained in:
Tobias Christiansen 2021-07-04 17:17:23 +02:00 committed by Andreas Kling
parent 87033ce7d1
commit e18e2af826
Notes: sideshowbarker 2024-07-18 10:27:18 +09:00
4 changed files with 17 additions and 0 deletions

View File

@ -107,6 +107,7 @@
"lowercase",
"lower-alpha",
"lower-latin",
"lower-roman",
"medium",
"move",
"ne-resize",
@ -163,6 +164,7 @@
"uppercase",
"upper-alpha",
"upper-latin",
"upper-roman",
"visible",
"vertical-text",
"wait",

View File

@ -645,6 +645,10 @@ Optional<CSS::ListStyleType> StyleProperties::list_style_type() const
return CSS::ListStyleType::UpperAlpha;
case CSS::ValueID::UpperLatin:
return CSS::ListStyleType::UpperLatin;
case CSS::ValueID::UpperRoman:
return CSS::ListStyleType::UpperRoman;
case CSS::ValueID::LowerRoman:
return CSS::ListStyleType::LowerRoman;
default:
return {};
}

View File

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Tobias Christiansen <tobi@tobyase.de>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -173,8 +174,10 @@ enum class ListStyleType {
DecimalLeadingZero,
LowerAlpha,
LowerLatin,
LowerRoman,
UpperAlpha,
UpperLatin,
UpperRoman,
};
enum class Overflow : u8 {

View File

@ -36,6 +36,12 @@ ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType
case CSS::ListStyleType::UpperLatin:
m_text = String::bijective_base_from(m_index - 1);
break;
case CSS::ListStyleType::LowerRoman:
m_text = String::roman_number_from(m_index).to_lowercase();
break;
case CSS::ListStyleType::UpperRoman:
m_text = String::roman_number_from(m_index);
break;
case CSS::ListStyleType::None:
break;
@ -88,8 +94,10 @@ void ListItemMarkerBox::paint(PaintContext& context, PaintPhase phase)
case CSS::ListStyleType::DecimalLeadingZero:
case CSS::ListStyleType::LowerAlpha:
case CSS::ListStyleType::LowerLatin:
case CSS::ListStyleType::LowerRoman:
case CSS::ListStyleType::UpperAlpha:
case CSS::ListStyleType::UpperLatin:
case CSS::ListStyleType::UpperRoman:
if (m_text.is_null())
break;
context.painter().draw_text(enclosing, m_text, Gfx::TextAlignment::Center);