mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
LibWeb: Add list-style-type: lower-alpha and lower-latin support
They achieve the same, a list which markers are lowercase (latin) characters.
This commit is contained in:
parent
7dd0fb0086
commit
cb34775c83
4 changed files with 15 additions and 0 deletions
|
@ -104,6 +104,8 @@
|
|||
"line-through",
|
||||
"list-item",
|
||||
"lowercase",
|
||||
"lower-alpha",
|
||||
"lower-latin",
|
||||
"medium",
|
||||
"move",
|
||||
"ne-resize",
|
||||
|
|
|
@ -578,6 +578,10 @@ Optional<CSS::ListStyleType> StyleProperties::list_style_type() const
|
|||
return CSS::ListStyleType::Decimal;
|
||||
case CSS::ValueID::DecimalLeadingZero:
|
||||
return CSS::ListStyleType::DecimalLeadingZero;
|
||||
case CSS::ValueID::LowerAlpha:
|
||||
return CSS::ListStyleType::LowerAlpha;
|
||||
case CSS::ValueID::LowerLatin:
|
||||
return CSS::ListStyleType::LowerLatin;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -160,6 +160,8 @@ enum class ListStyleType {
|
|||
Square,
|
||||
Decimal,
|
||||
DecimalLeadingZero,
|
||||
LowerAlpha,
|
||||
LowerLatin,
|
||||
};
|
||||
|
||||
enum class Overflow : u8 {
|
||||
|
|
|
@ -5,11 +5,14 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibWeb/Layout/ListItemMarkerBox.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
constexpr auto lower_alpha = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType style_type, size_t index)
|
||||
: Box(document, nullptr, CSS::StyleProperties::create())
|
||||
, m_list_style_type(style_type)
|
||||
|
@ -74,6 +77,10 @@ void ListItemMarkerBox::paint(PaintContext& context, PaintPhase phase)
|
|||
m_index < 10 ? String::formatted("0{}.", m_index) : String::formatted("{}.", m_index),
|
||||
Gfx::TextAlignment::Center);
|
||||
break;
|
||||
case CSS::ListStyleType::LowerAlpha:
|
||||
case CSS::ListStyleType::LowerLatin:
|
||||
context.painter().draw_text(enclosing, number_to_alphabet(m_index, lower_alpha), Gfx::TextAlignment::Center);
|
||||
break;
|
||||
case CSS::ListStyleType::None:
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue