Re: [css-sizing][css-flexbox] intrinsic min/max-width/height values and percentage children

On Wed, Sep 24, 2014 at 3:14 PM, fantasai <fantasai.lists@inkedblade.net> wrote:
> On 07/01/2014 12:33 PM, Tab Atkins Jr. wrote:
>> However, Sizing now adds min-content/max-content/etc keywords to
>> min/max-width/height, which are indefinite, intrinsic sizes, and
>> Flexbox's "min-width/height: auto" value implicitly relies on
>> min-content sizing as well. This means that a percentage-sized child
>> could be trying to resolve against an intrinsic size even when
>> 'width/height' itself is definite.
>>
>> What should happen in such a situation?
>>
>> A. Have the percentage child size as for 'auto', as for intrinsic
>> 'width/height' values on the parent? (This means that, by default,
>> percentage heights will never work on children of flex items, since
>> flex items have a default min-size calculation involving the
>> min-content height.)
>> B. Ignore the potential effects of the min/max size when resolve the
>> percentage? (This means the child may underflow/overflow the flex
>> item.)
>> C. Do a two-pass layout? (We already do this in some cases, like
>> percentage cross-sizes resolved against an indefinite flex container.
>> But note that stacked 2-pass layouts are O(n^2).)
>> D. Something else?
>
> The CSSWG resolved on B at the Sophia F2F.
> I've updated the Flexbox spec accordingly; Sizing is still pending edits.

So, this doesn't work.  Here's the text we put into the spec:

> If a percentage is going to be resolved against a <a>flex item’s</a> <a>main size</a>,
> and the <a>flex item</a> has a <a>definite</a> <a>flex basis</a>,
> and the <a>flex container</a> has a <a>definite</a> <a>main size</a>,
> the <a>flex item’s</a> <a>main size</a> must be treated as <a>definite</a>
> for the purpose of resolving the percentage,
> and the percentage must resolve against the <strong>flexed</strong> <a>main size</a> of the <a>flex item</a>
> (that is, after the layout algorithm below has been completed for the <a>flex item’s</a> <a>flex container</a>,
> and the <a>flex item</a> has acquired its final size).

If you have min-width:auto, then you need to calculate the min-content
size of the flex item.  This doesn't care about the width or
flex-basis, it cares about the min-size contributions of the flex
item's children.  We thus can't treat a percentage on a child as
resolving against a definite width here, because we're in the process
of computing that width; but if the width isn't definite, then the
percentage becomes auto *here*, and then a resolved definite value
*later*, which is confusing and weird and two-pass, and we'd like to
avoid two-pass layout in the default case.  (In other words, this
becomes just a variant of the option C two-pass layout.)

So I think we're screwed and need to go with option A.

~TJ

Received on Monday, 2 March 2015 20:55:00 UTC