mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibHTML: Implement basic support for "text-decoration: underline"
This commit is contained in:
parent
62cbaa74f3
commit
8271ad40a5
Notes:
sideshowbarker
2024-07-19 11:54:21 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8271ad40a5b
2 changed files with 7 additions and 1 deletions
|
@ -63,7 +63,7 @@ StyleProperties StyleResolver::resolve_style(const Element& element, const Style
|
|||
if (parent_properties) {
|
||||
parent_properties->for_each_property([&](const StringView& name, auto& value) {
|
||||
// TODO: proper inheritance
|
||||
if (name.starts_with("font") || name == "white-space" || name == "color")
|
||||
if (name.starts_with("font") || name == "white-space" || name == "color" || name == "text-decoration")
|
||||
style_properties.set_property(name, value);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -228,6 +228,9 @@ void LayoutText::render(RenderingContext& context)
|
|||
painter.set_font(*m_font);
|
||||
|
||||
auto color = style_properties().color_or_fallback("color", Color::Black);
|
||||
auto text_decoration = style_properties().string_or_fallback("text-decoration", "none");
|
||||
|
||||
bool is_underline = text_decoration == "underline";
|
||||
|
||||
for (auto& run : m_runs) {
|
||||
Rect rect {
|
||||
|
@ -237,5 +240,8 @@ void LayoutText::render(RenderingContext& context)
|
|||
m_font->glyph_height()
|
||||
};
|
||||
painter.draw_text(rect, run.text, TextAlignment::TopLeft, color);
|
||||
|
||||
if (is_underline)
|
||||
painter.draw_line(rect.bottom_left().translated(0, 1), rect.bottom_right().translated(0, 1), color);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue