summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-11-11 16:25:45 +0000
committerAndreas Kling <kling@serenityos.org>2021-11-17 22:20:01 +0100
commit64d805a027f3ae7bdd6a29ae1f7bf9bbf72fd1fa (patch)
tree14b00907d9e8c6f886e46443f25ab446a7d07130
parentecf1b7f977232a5d532ddd11c4f51767aec5d1a2 (diff)
downloadserenity-64d805a027f3ae7bdd6a29ae1f7bf9bbf72fd1fa.zip
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. :^)
-rw-r--r--Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp b/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp
index bcbbc98798..c538c9d620 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;
}