-
Notifications
You must be signed in to change notification settings - Fork 155
Grid: Fix percent sizing #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grid: Fix percent sizing #306
Conversation
f716b26 to
2c95146
Compare
No, IMO we should fix the bug here ASAP and then break things later with these tests in place. |
fa7e932 to
a5e3df3
Compare
Weibye
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let used_space: f32 = axis_tracks.iter().map(|track| track.base_size).sum(); | ||
| let free_space = available_space - used_space; | ||
| if free_space == 0.0 { | ||
| if free_space <= 0.0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can free space ever be negative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can yeah. This would be the case if the containing node has a fixed size (set with the width/height property), and the contents of the the container had minimum sizes that sum to total greater than the size of the container (so the contents overflow). I hadn't considered this case either, but it came up when debugging a test, hence the fix!
alice-i-cecile
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code quality LGTM, and I trust you + the tests to steer us right here.
Objective
This PR addresses bugs with percentage sizing (particularly of margins and padding) found when testing the CSS Grid implementation.
Changes made
parent_sizeparameter was added tocompute_node_layoutall top-level algorithm functions. This is unfortunately necessary to make percentage sizing work correctly as percentage nodesPossible future changes
available_spaceparameter tocompute_node_layouttosizing_constraintwhich aSize<SizingConstraint>where SizingConstraint isenum { MinContent, MaxContent, Definite }. Currently the available_space parameter is duplicating information from theparent_sizeparameter when it isDefinite.parent_sizeto measure_funcs.Feedback wanted
Should the future changes block this PR being merged?