Grid: Fix percent sizing#306
Merged
alice-i-cecile merged 12 commits intoDioxusLabs:mainfrom Dec 30, 2022
Merged
Conversation
f716b26 to
2c95146
Compare
Collaborator
No, IMO we should fix the bug here ASAP and then break things later with these tests in place. |
fa7e932 to
a5e3df3
Compare
Weibye
approved these changes
Dec 30, 2022
| 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 { |
Collaborator
There was a problem hiding this comment.
Can free space ever be negative?
Collaborator
Author
There was a problem hiding this comment.
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
approved these changes
Dec 30, 2022
Collaborator
alice-i-cecile
left a comment
There was a problem hiding this comment.
Code quality LGTM, and I trust you + the tests to steer us right here.
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
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?