W3C home > Mailing lists > Public > www-style@w3.org > May 2014

Re: [css-flexbox] Simplification to "Distribute free space proportional to the flex factors" step

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 19 May 2014 23:06:32 +0900
Message-ID: <CAAWBYDBnY8V6OGE09Kizk2wD6ue0MQF4hsFE69uc_D2DTTTxXA@mail.gmail.com>
To: Daniel Holbert <dholbert@mozilla.com>
Cc: www-style <www-style@w3.org>
On Fri, May 16, 2014 at 9:53 AM, Daniel Holbert <dholbert@mozilla.com> wrote:
> Hi Tab & Fantasai,
>
> In the CR version of the resolving-flexible-lengths algorithm[1], step 4
> part c is currently:
>
>  # c. Distribute free space proportional to the flex factors.
>  #      If using the flex grow factor and the
>  #      remaining free space is positive
>  #        [...]
>  #      If using the flex shrink factor the
>  #      remaining free space is negative
>  #         [...]
>
> I have two tweaks to this (but the second obsoletes the first).
>
> The first tweak is a minor typofix:
>   s/shrink factor/shrink factor and/
>
> The second tweak is: I think we can drop the "and the free space is
> [positive|negative]" qualifiers completely. We really only need to check
> whether the free space is nonzero. (And if it is nonzero, its sign
> *must* be what we want it to be.)
>
> We *used* to need to check that the sign matched the type of flexing
> that we're doing -- and if it didn't match, we'd skip straight to the
> "fix min/max violations" step and clamp whichever items were too
> extreme. However, nowadays, we'll have fixed those violations
> ahead-of-time, in the "Size inflexible items" (a.k.a. "early freeze")
> step that was added to the spec in the past few weeks.
>
> With that early-freeze step, I don't think it's possible for us to hit
> step 4c with an incorrectly-signed-free-space value anymore. If we're
> growing, any flex items with absurdly-large flex base sizes (greater
> than their max-size) will already have been clamped. (and similar for
> min-size, if we're shrinking)
>
> I'd suggest replacing step 4 part c with text like this, using an early
> 0-check:
>
>  # c. Distribute free space proportional to the flex factors.
>  #      If the remaining free space is 0, skip this step. Otherwise
>  #      If using the flex grow factor
>  #        [...]
>  #      If using the flex shrink factor
>  #        [...]
>
> (If I'm missing something, though, I'd love to see a counterexample
> where we actually do need to check whether the sign is positive or
> negative.)
>
> Thanks,
> ~Daniel
>
> [1]
> http://dev.w3.org/csswg/css-flexbox/#resolve-flexible-lengths-flex-factors

Yup, pretty sure you're right that the early-freeze step prevents us
from getting caught by a wrong-sign free space.  I've made the
adjustments you suggets.

~TJ
Received on Monday, 19 May 2014 14:07:20 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:51:27 UTC