diff --git a/Base/home/anon/www/borders.html b/Base/home/anon/www/borders.html index a5b841d7dd..32447b0721 100644 --- a/Base/home/anon/www/borders.html +++ b/Base/home/anon/www/borders.html @@ -3,6 +3,9 @@ CSS borders lookin' good @@ -102,5 +139,12 @@
double width solo
double style solo
double color solo
+
dotted (1px)
+
dotted (5px)
+
dotted (20px)
+
dashed (1px)
+
dashed (5px)
+
dashed (20px)
+
mixed
diff --git a/Libraries/LibWeb/Layout/LayoutBox.cpp b/Libraries/LibWeb/Layout/LayoutBox.cpp index 7fe66dd9b0..e73e4900b6 100644 --- a/Libraries/LibWeb/Layout/LayoutBox.cpp +++ b/Libraries/LibWeb/Layout/LayoutBox.cpp @@ -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) {