From 2b40dbfb30b06895d9a32242c22373eb98d63cf2 Mon Sep 17 00:00:00 2001 From: MacDue Date: Sun, 12 Jun 2022 15:24:17 +0100 Subject: [PATCH] LibWeb: Support elliptical background corners --- .../Libraries/LibWeb/Painting/BackgroundPainting.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp b/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp index 4fe69905cc..7cc71d6eb8 100644 --- a/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp @@ -42,9 +42,16 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet if (background_layers && !background_layers->is_empty()) color_rect = get_box(background_layers->last().clip); + auto border_radius_to_corner = [&](BorderRadiusData const& border_radius) { + return Gfx::AntiAliasingPainter::CornerRadius { + static_cast(border_radius.horizontal_radius), + static_cast(border_radius.vertical_radius) + }; + }; + Gfx::AntiAliasingPainter aa_painter { painter }; aa_painter.fill_rect_with_rounded_corners(color_rect.to_rounded(), - background_color, border_radii.top_left.horizontal_radius, border_radii.top_right.horizontal_radius, border_radii.bottom_right.horizontal_radius, border_radii.bottom_left.horizontal_radius); + background_color, border_radius_to_corner(border_radii.top_left), border_radius_to_corner(border_radii.top_right), border_radius_to_corner(border_radii.bottom_right), border_radius_to_corner(border_radii.bottom_left)); if (!background_layers) return;