gpui: Keep explicitly sized images at their given size - #63103
Open
nolight132 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
imgsets the image's intrinsic aspect ratio on the element style whenever the caller didn't set one. When the element also has an explicit width and height, the intrinsic ratio still participates in layout and can resize the element.This also defeats
ObjectFit::Cover(#61383): once the element grows to match the image's ratio, there is nothing left to crop, so the image renders whole and rounded corners are computed against the inflated rectangle.Solution
Only assign the intrinsic aspect ratio when at least one dimension of the element is
Auto, i.e. when the ratio is actually needed to derive a missing size. The element now keeps its given size with both dimensions definite.Testing
image_object_fit_cover_crops_portrait_to_fixed_element_bounds, a portrait counterpart of the existing cover test that uses an absolute.size(px(100.))instead ofsize_full(). It fails on main (sprite bounds come out 100x200) and passes with this change.cargo test -p gpuipasses.Self-Review Checklist:
Showcase
A 300x400 portrait image rendered at a fixed square size: