From b1ccead0f66ada772ee2e0e5f76dfdd8b9473340 Mon Sep 17 00:00:00 2001 From: Matthias Grandl <50196894+MatthiasGrandl@users.noreply.github.com> Date: Sun, 31 Mar 2024 17:17:09 +0200 Subject: [PATCH] gpui: fix #9931 img object-fit regression (#10006) PR: #9931 broke image scaling, such that it ignores the object-fit parameter and instead always scales the image to fit the bounds. This fixes the regression. --- crates/gpui/src/elements/img.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/elements/img.rs b/crates/gpui/src/elements/img.rs index cb41010cf61da1..e02146e29c56ca 100644 --- a/crates/gpui/src/elements/img.rs +++ b/crates/gpui/src/elements/img.rs @@ -239,7 +239,8 @@ impl Element for Img { let corner_radii = style.corner_radii.to_pixels(bounds.size, cx.rem_size()); if let Some(data) = source.data(cx) { - cx.paint_image(bounds, corner_radii, data.clone(), self.grayscale) + let new_bounds = self.object_fit.get_bounds(bounds, data.size()); + cx.paint_image(new_bounds, corner_radii, data.clone(), self.grayscale) .log_err(); }