Skip to content

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

@tabatkins

Description

@tabatkins

As @bfgeek points out in #3070 (comment), 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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions