Re: [css3-flexbox] Algorithm never clamps inflexible children, when all children are inflexible

On Tue, Jun 5, 2012 at 5:35 PM, Daniel Holbert <dholbert@mozilla.com> wrote:
> Right now, I don't think the spec's algorithm ever clamps inflexible
> items to their min-max range, when all the children are inflexible.
>
> As an example: suppose we have a flex container with 2 items, both of
> which have w/ "flex: 0 0 10px" and "min-width: 50px".  Let's say the
> flexbox has an explicit "width: 200px", for simplicity -- so there's
> plenty of available space.
>
> Clearly, we want our flex items to both end up with a main size (width)
> of 50px.  But right now, that doesn't explicitly happen, AFAICT.
>
> We'll hit the following steps in the algorithm:
>  # 9.2. Line Length Determination
>  #  2. Determine the hypothetical main size of each item:
>  #     If the item has a definite flex basis, that's
>  #     the hypothetical size.
>
> --> hypothetical main size = 10px
>
>  # [...]
>  #  6. Resolve the flexible lengths of all the flex items
>  #     to find their used main size
>
> --> OK, that takes us here:
>
>  # 9.7. Resolving Flexible Lengths
>  #  2. Check that you can distribute any space. If all the
>  #     flex items on the line are either frozen or have a
>  #     flexibility of zero, exit the algorithm.
>  #  [...]
>  #
> --> All our flex items have a flexibility of 0.
>
> So now we've exited the algorithm -- but it never actually set the used
> main size of our items!!  The only main size we've actually set is the
> "hypothetical main size", which is still at 10px (unclamped).
>
> ~Daniel
>
> (NOTE: The algorithm does have us do some _temporary_ clamping in a few
> places -- "Collect flex items into flex lines" and "Determine the used
> flexibility" -- but that clamping is just for the purposes of those
> steps, and its effects don't stick.  Section 9.2 also says to _not_
> clamp flexible lengths at that point, but it doesn't definitively say
> that we _should_ clamp inflexible lengths.)

I think we've fixed this now.  As part of an unrelated edit, we've
separated out the concept of "flex base size" (unclamped) and
"hypothetical main size" (clamped).  We've now added an additional
step to the flex distribution algo that explicitly sets the used size
of all elements that are inflexible (given whether we're in a grow or
shrink situation).

Are the chances all right?

~TJ

Received on Friday, 29 June 2012 00:19:37 UTC