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

This commit is contained in:
Linus Groh 2020-05-08 22:02:27 +01:00 committed by Andreas Kling
parent 5bfd893292
commit f8c7ab55f8
Notes: sideshowbarker 2024-07-19 06:49:42 +09:00

View file

@ -84,7 +84,14 @@ void LayoutText::render_fragment(RenderingContext& context, const LineBoxFragmen
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_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>