Skip to content

[css-values][css-images] Unit algebra with <flex> in stripes() leads to a contradiction #9667

@Loirooriol

Description

@Loirooriol

https://drafts.csswg.org/css-images-4/#stripes

A <flex> is evaluated as a fraction of the total width relative to the total sum of <flex> entries in the function, after subtracting the thickness of any non-<flex> entries (flooring the subtraction result at zero). If the sum of <flex> values is less than 1fr, the result of the subtraction is multiplied by the sum’s value before being distributed.

Suppose a total width of 100px, what should happen with stripes(#000 50px, #111 calc(1fr / 1fr * 50px), #222 1fr)?

  • 1st stripe is a <length> of 50px
  • 2nd stripe is a <length> of calc(1fr / 1fr * 50px) 😓
  • 3rd stripe is a <flex> of 1fr

Then,

  • If we assume that 1fr is not zero, the 2nd stripe is 50px thick, and so we distribute 100px - 50px - 50px into 1fr, so the third stripe is 0px thick. So the final thicknesses are 50px, 50px, 0px, but this is a contradiction because we assumed that 1fr wasn't zero.
  • If we assume that 1fr is zero, the 2nd stripe gets a NaN * px which is censored into 0px at the top-level calculation. So we distribute 100px - 50px - 0px into 1fr, so the 3rd stripe is 50px thick. So the final thicknesses are 50px, 0px, 50px, but this is a contradiction because we assumed that 1fr was zero.

Thus it's a contradiction either way. How to solve it?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions