Browse Source

LibWeb: Implement "text-transform: {upper,lower}case"

Linus Groh 5 years ago
parent
commit
f8c7ab55f8
1 changed files with 8 additions and 1 deletions
  1. 8 1
      Libraries/LibWeb/Layout/LayoutText.cpp

+ 8 - 1
Libraries/LibWeb/Layout/LayoutText.cpp

@@ -84,7 +84,14 @@ void LayoutText::render_fragment(RenderingContext& context, const LineBoxFragmen
     if (is_underline)
     if (is_underline)
         painter.draw_line(enclosing_int_rect(fragment.rect()).bottom_left().translated(0, 1), enclosing_int_rect(fragment.rect()).bottom_right().translated(0, 1), color);
         painter.draw_line(enclosing_int_rect(fragment.rect()).bottom_left().translated(0, 1), enclosing_int_rect(fragment.rect()).bottom_right().translated(0, 1), color);
 
 
-    painter.draw_text(enclosing_int_rect(fragment.rect()), m_text_for_rendering.substring_view(fragment.start(), fragment.length()), Gfx::TextAlignment::TopLeft, color);
+    auto text = m_text_for_rendering;
+    auto text_transform = style().string_or_fallback(CSS::PropertyID::TextTransform, "none");
+    if (text_transform == "uppercase")
+        text = m_text_for_rendering.to_uppercase();
+    if (text_transform == "lowercase")
+        text = m_text_for_rendering.to_lowercase();
+
+    painter.draw_text(enclosing_int_rect(fragment.rect()), text.substring_view(fragment.start(), fragment.length()), Gfx::TextAlignment::TopLeft, color);
 }
 }
 
 
 template<typename Callback>
 template<typename Callback>