mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00: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",
|
"line-through",
|
||||||
"list-item",
|
"list-item",
|
||||||
"lowercase",
|
"lowercase",
|
||||||
|
"lower-alpha",
|
||||||
|
"lower-latin",
|
||||||
"medium",
|
"medium",
|
||||||
"move",
|
"move",
|
||||||
"ne-resize",
|
"ne-resize",
|
||||||
|
|
|
@ -578,6 +578,10 @@ Optional<CSS::ListStyleType> StyleProperties::list_style_type() const
|
||||||
return CSS::ListStyleType::Decimal;
|
return CSS::ListStyleType::Decimal;
|
||||||
case CSS::ValueID::DecimalLeadingZero:
|
case CSS::ValueID::DecimalLeadingZero:
|
||||||
return CSS::ListStyleType::DecimalLeadingZero;
|
return CSS::ListStyleType::DecimalLeadingZero;
|
||||||
|
case CSS::ValueID::LowerAlpha:
|
||||||
|
return CSS::ListStyleType::LowerAlpha;
|
||||||
|
case CSS::ValueID::LowerLatin:
|
||||||
|
return CSS::ListStyleType::LowerLatin;
|
||||||
default:
|
default:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,8 @@ enum class ListStyleType {
|
||||||
Square,
|
Square,
|
||||||
Decimal,
|
Decimal,
|
||||||
DecimalLeadingZero,
|
DecimalLeadingZero,
|
||||||
|
LowerAlpha,
|
||||||
|
LowerLatin,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Overflow : u8 {
|
enum class Overflow : u8 {
|
||||||
|
|
|
@ -5,11 +5,14 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/StringBuilder.h>
|
||||||
#include <LibGfx/Painter.h>
|
#include <LibGfx/Painter.h>
|
||||||
#include <LibWeb/Layout/ListItemMarkerBox.h>
|
#include <LibWeb/Layout/ListItemMarkerBox.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
constexpr auto lower_alpha = "abcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType style_type, size_t index)
|
ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType style_type, size_t index)
|
||||||
: Box(document, nullptr, CSS::StyleProperties::create())
|
: Box(document, nullptr, CSS::StyleProperties::create())
|
||||||
, m_list_style_type(style_type)
|
, 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),
|
m_index < 10 ? String::formatted("0{}.", m_index) : String::formatted("{}.", m_index),
|
||||||
Gfx::TextAlignment::Center);
|
Gfx::TextAlignment::Center);
|
||||||
break;
|
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:
|
case CSS::ListStyleType::None:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue