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.
This commit is contained in:
Matthias Grandl 2024-03-31 17:17:09 +02:00 committed by GitHub
parent 3c8b376764
commit b1ccead0f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();
}