[csswg-drafts] [css-flexbox-1] Clamp "hypothetical main size" to be non-negative? (#12222)

tabatkins has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-flexbox-1] Clamp "hypothetical main size" to be non-negative? ==
As @bfgeek points out in <https://github.com/w3c/csswg-drafts/issues/3070#issuecomment-2899320836>, the Flexbox spec uses the "outer size" of flex items to calculate line-breaking, but negative margins can cause this size to become negative, and nothing prevents that.

This means flex-line length is not monotonically non-decreasing; a line can be full (zero free space), then take an item with a negative outer size, and now it's no longer full and can accept more positive-sized items.

This was just an oversight on our part; negative-size boxes are very easy to forget to handle. I don't believe there's any use-cases for allowing this. Unless there's evidence of compat impact, can we add a clamping step to the line-breaking algorithm that forces a minimum size of zero?

(Note: this also happens in inline contexts, and it's pretty likely people *are* depending on that, accidentally or not. I'm not proposing to change that. Flexbox is *analogous* to an inline formatting context in many ways, but different and generally simpler in many others.)

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12222 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 21 May 2025 22:44:47 UTC