Переглянути джерело

LibWeb: Add list-style-type: upper-latin and upper-alpha support

Tobias Christiansen 4 роки тому
батько
коміт
889e1d3db9

+ 2 - 0
Userland/Libraries/LibWeb/CSS/Identifiers.json

@@ -160,6 +160,8 @@
   "text",
   "text",
   "underline",
   "underline",
   "uppercase",
   "uppercase",
+  "upper-alpha",
+  "upper-latin",
   "visible",
   "visible",
   "vertical-text",
   "vertical-text",
   "wait",
   "wait",

+ 4 - 0
Userland/Libraries/LibWeb/CSS/StyleProperties.cpp

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

+ 2 - 0
Userland/Libraries/LibWeb/CSS/StyleValue.h

@@ -162,6 +162,8 @@ enum class ListStyleType {
     DecimalLeadingZero,
     DecimalLeadingZero,
     LowerAlpha,
     LowerAlpha,
     LowerLatin,
     LowerLatin,
+    UpperAlpha,
+    UpperLatin,
 };
 };
 
 
 enum class Overflow : u8 {
 enum class Overflow : u8 {

+ 5 - 0
Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp

@@ -12,6 +12,7 @@
 namespace Web::Layout {
 namespace Web::Layout {
 
 
 constexpr auto lower_alpha = "abcdefghijklmnopqrstuvwxyz";
 constexpr auto lower_alpha = "abcdefghijklmnopqrstuvwxyz";
+constexpr auto upper_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())
@@ -81,6 +82,10 @@ void ListItemMarkerBox::paint(PaintContext& context, PaintPhase phase)
     case CSS::ListStyleType::LowerLatin:
     case CSS::ListStyleType::LowerLatin:
         context.painter().draw_text(enclosing, number_to_alphabet(m_index, lower_alpha), Gfx::TextAlignment::Center);
         context.painter().draw_text(enclosing, number_to_alphabet(m_index, lower_alpha), Gfx::TextAlignment::Center);
         break;
         break;
+    case CSS::ListStyleType::UpperAlpha:
+    case CSS::ListStyleType::UpperLatin:
+        context.painter().draw_text(enclosing, number_to_alphabet(m_index, upper_alpha), Gfx::TextAlignment::Center);
+        break;
     case CSS::ListStyleType::None:
     case CSS::ListStyleType::None:
         return;
         return;