1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:37:34 +00:00

LibWeb: Add basic support for "border-style: {dotted,dashed}"

This commit is contained in:
Linus Groh 2020-05-10 18:08:02 +01:00 committed by Andreas Kling
parent 0669dbcf5d
commit 4c1a765076
2 changed files with 69 additions and 0 deletions

View file

@ -106,6 +106,31 @@ void LayoutBox::paint_border(RenderingContext& context, Edge edge, const Gfx::Fl
if (border_style.has_value()) {
if (border_style.value()->to_string() == "dotted")
line_style = Gfx::Painter::LineStyle::Dotted;
if (border_style.value()->to_string() == "dashed")
line_style = Gfx::Painter::LineStyle::Dashed;
}
if (line_style != Gfx::Painter::LineStyle::Solid) {
switch (edge) {
case Edge::Top:
p1.move_by(int_width / 2, int_width / 2);
p2.move_by(-int_width / 2, int_width / 2);
break;
case Edge::Right:
p1.move_by(-int_width / 2, int_width / 2);
p2.move_by(-int_width / 2, -int_width / 2);
break;
case Edge::Bottom:
p1.move_by(int_width / 2, -int_width / 2);
p2.move_by(-int_width / 2, -int_width / 2);
break;
case Edge::Left:
p1.move_by(int_width / 2, int_width / 2);
p2.move_by(int_width / 2, -int_width / 2);
break;
}
context.painter().draw_line({ (int)p1.x(), (int)p1.y() }, { (int)p2.x(), (int)p2.y() }, color, int_width, line_style);
return;
}
auto draw_line = [&](auto& p1, auto& p2) {