-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix crash with certain right-aligned text #10271
Fix crash with certain right-aligned text #10271
Conversation
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.
If nothing else, this seems like a safe way to avoid the panic.
I think it may actually be clearer to just do the clamp logic manually, but I won't block on that.
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.
Taffy (following how CSS deals with min-width
> max-width
) does val.min(max).max(min)
instead of val.clamp(min, max)
, which avoids the panic introduced by the stdlib clamp by giving min priority over max. Perhaps we could also do that here?
See: DioxusLabs/taffy#261
Hmm... Actually the spec (https://www.w3.org/TR/css-sizing-3/#column-sizing) defines a
So I think that would be : x.max(self.info.min.x).min(self.info.max.x) in the function above |
Okay, thanks for pointing out that spec. I'll try that out and test with the problematic right aligned text constrained in various ways and see if I can find a difference between us/browsers there just to be sure. |
This still ultimately seems like a text layout / measurement bug to me. But we should probably do something along the lines of this PR anyway so that we at least don't panic when text layout is returning something nonsensical. From alexheretic/glyph-brush#167:
Seems to me that collapsible whitespace ought not to count towards the min-content size. Whereas I would expect a single very long alphanumeric word to extend that size. Not sure if we can implement that. |
I swapped to nicoburns' suggestion of In my testing I just became less confident that I knew what was going on. It is hard for me to say which bits of the css spec actually apply here. (the "auto box sizes fit-content" section seems to suggest doing the exact opposite thing). I haven't yet figured out what a proper comparison with a browser would even be. But this should do nothing except in the cases where we would crash previously, so I guess that's an improvement. |
The CSS spec may be assuming that |
# Objective Fixes bevyengine#9395 Alternative to bevyengine#9415 (See discussion here) ## Solution Do clamping like [`fit-content`](https://www.w3.org/TR/css-sizing-3/#column-sizing). ## Notes I am not sure if this is a valid approach. It doesn't seem to cause any obvious issues with our existing examples.
# Objective Fixes bevyengine#9395 Alternative to bevyengine#9415 (See discussion here) ## Solution Do clamping like [`fit-content`](https://www.w3.org/TR/css-sizing-3/#column-sizing). ## Notes I am not sure if this is a valid approach. It doesn't seem to cause any obvious issues with our existing examples.
Objective
Fixes #9395
Alternative to #9415 (See discussion here)
Solution
Do clamping like
fit-content
.Notes
I am not sure if this is a valid approach. It doesn't seem to cause any obvious issues with our existing examples.