From 1b15144e78a0553ca049f14e90bbe7ec954cbbec Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 24 Jan 2022 02:36:33 +0100 Subject: [PATCH] LibWeb: Make sure painted CSS borders are snapped to integer pixels This is a bit of a hack to get box content to stop bleeding 1px outside the border sometimes. We will need to come up with a more general solution for this problem eventually. --- Userland/Libraries/LibWeb/Painting/BorderPainting.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp b/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp index 767673305f..d69281649e 100644 --- a/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp @@ -37,8 +37,12 @@ BorderRadiusData normalized_border_radius_data(Layout::Node const& node, Gfx::Fl return BorderRadiusData { top_left_radius_px, top_right_radius_px, bottom_right_radius_px, bottom_left_radius_px }; } -void paint_border(PaintContext& context, BorderEdge edge, Gfx::FloatRect const& rect, BorderRadiusData const& border_radius_data, BordersData const& borders_data) +void paint_border(PaintContext& context, BorderEdge edge, Gfx::FloatRect const& a_rect, BorderRadiusData const& border_radius_data, BordersData const& borders_data) { + // FIXME: This is a hack that snaps the incoming rect to integer pixel values before painting each side. + // This needs a more general solution. + auto rect = enclosing_int_rect(a_rect).to_type(); + const auto& border_data = [&] { switch (edge) { case BorderEdge::Top: