From 64d805a027f3ae7bdd6a29ae1f7bf9bbf72fd1fa Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 11 Nov 2021 16:25:45 +0000 Subject: [PATCH] LibWeb: Stop 'no-repeat' from expanding the background area Previously, a `background-repeat` value of `no-repeat` in a direction would cause the image to be drawn at exactly that size. This was fine if the image was smaller than the element, but if it was larger, it would draw outside its bounds. Now, it behaves itself. :^) --- Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp b/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp index bcbbc987984..c538c9d6208 100644 --- a/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp @@ -27,7 +27,7 @@ void paint_background(PaintContext& context, Gfx::IntRect const& background_rect // The background rect is already sized to align with 'repeat'. break; case CSS::Repeat::NoRepeat: - image_rect.set_width(background_data.image->width()); + image_rect.set_width(min(image_rect.width(), background_data.image->width())); break; } @@ -39,7 +39,7 @@ void paint_background(PaintContext& context, Gfx::IntRect const& background_rect // The background rect is already sized to align with 'repeat'. break; case CSS::Repeat::NoRepeat: - image_rect.set_height(background_data.image->height()); + image_rect.set_height(min(image_rect.height(), background_data.image->height())); break; }