LibHTML: Respect the CSS "color" property for text

Also remove the color values from the ComputedStyle object and get them
via StyleProperties instead.

At the moment, we only handle colors that Color::from_string() parses.
This commit is contained in:
Andreas Kling 2019-09-28 22:18:19 +02:00
commit 62cbaa74f3
Notes: sideshowbarker 2024-07-19 11:54:23 +09:00
7 changed files with 56 additions and 10 deletions

View file

@ -227,6 +227,8 @@ void LayoutText::render(RenderingContext& context)
auto& painter = context.painter();
painter.set_font(*m_font);
auto color = style_properties().color_or_fallback("color", Color::Black);
for (auto& run : m_runs) {
Rect rect {
run.pos.x(),
@ -234,6 +236,6 @@ void LayoutText::render(RenderingContext& context)
m_font->width(run.text),
m_font->glyph_height()
};
painter.draw_text(rect, run.text);
painter.draw_text(rect, run.text, TextAlignment::TopLeft, color);
}
}