W3C home > Mailing lists > Public > www-style@w3.org > April 2012

Re: [css3-flexbox] Updates to Resolving Flexible Sizes

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 25 Apr 2012 12:21:23 -0700
Message-ID: <CAAWBYDB+bjMRQ74mB7mP-VJVHJ4o1OCAx0S2AFwoeo+bVNYU7g@mail.gmail.com>
To: Alex Mogilevsky <alexmog@microsoft.com>
Cc: fantasai <fantasai.lists@inkedblade.net>, "www-style@w3.org" <www-style@w3.org>
On Wed, Apr 25, 2012 at 7:35 AM, Alex Mogilevsky <alexmog@microsoft.com> wrote:
> From: fantasai [mailto:fantasai.lists@inkedblade.net]
> ±    3. The zero clause only exits if the free space is also zero.
> ±       Previously you could exit with undistributed free space.
>
> How could that happen? At step 3 of the algorithm, we've distributed all available space, total item size must be equal to total available space.
>
> Then at step 4 we've fixed min/max and added up deltas from that. If the total change from fixing min/max is zero, it means total size has not changed, which means it is still equal to available space...
>
> What am I not getting here?
>
> I suppose that can happen when there are no flexible items, but the algorithm should just check that in step 1 and exit (which it doesn't).

Hm, I had an example, but when I run through it again, it looks like I
had a math error that led me to believe there was a problem.

Thinking through it again, I think you're right - it's not possible to
have a total zero adjustment and yet still have undistributed space,
since you're guaranteed that


> ±    4. Loop begins with determining the sign of the flexibility again.
> ±       This is necessary if freezing violations flips the sign of the
> ±       free space.
>
> I think it is a good change, but then the sizes being added up shouldn't get clamped with min/max. With clamping it will always get the same sign, but I don't think it is what you want.
>
> We came up with the first step for flexibility sign because we were not sure that alternating flexibility will always converge. It was easier to see that it will converge if the sign never changes. But I don't think that fear was justified.
>
> You seem to be OK with alternating sign too, then the sign should be calculated based on current iteration.
>
> A way to prove that the algorithm converges, without guessing flex direction up-front:
> * Each additional iteration is invoked only after one or more items lose flexibility
> * When there is no flexible items left, the algorithm will exit
> (for this proof to be true, 'zero' clause has to either always exit or only proceed if it managed to freeze something)
>
> In step 3, the condition "If the sign of the free space matches the sign of the flexibility," also seems unnecessary. It matches the approach of defining flex sign once per algorithm, but then if flex sign can change within the algorithm, it should be ok that it has effect...

Hmm, I'll need to think about this.

~TJ
Received on Wednesday, 25 April 2012 19:22:12 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:52 GMT