-
Notifications
You must be signed in to change notification settings - Fork 114
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
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
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.
@@ -687,7 +707,7 @@ fn expand_flexible_tracks( | |||
AvailableSpace::Definite(available_space) => { | |||
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!
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_size
parameter was added tocompute_node_layout
all top-level algorithm functions. This is unfortunately necessary to make percentage sizing work correctly as percentage nodesPossible future changes
available_space
parameter tocompute_node_layout
tosizing_constraint
which aSize<SizingConstraint>
where SizingConstraint isenum { MinContent, MaxContent, Definite }
. Currently the available_space parameter is duplicating information from theparent_size
parameter when it isDefinite
.parent_size
to measure_funcs.Feedback wanted
Should the future changes block this PR being merged?