Re: [css3-flexbox] Bad result in flex algorithm when combining stretch, and elements with an aspect ratio

On Mon, Oct 29, 2012 at 7:53 AM, Kang-Hao (Kenny) Lu
<kanghaol@oupeng.com> wrote:
> (12/10/28 23:51), Tab Atkins Jr. wrote:
>> Any objections?  Otherwise, I'll edit the flexbox layout algorithm
>> with the following two changes:
>>
>> 1. Add a bullet point to step 3 (hypothetical main size determination)
>> to handle aspect-ratio items with "stretch" alignment (so they get the
>> correct hypothetical main size).
>
> I am not getting this part. Are you saying that the *correct*
> hypothetical main size of <image> in the above example is 50px? Why?
> That doesn't feel right to me....

Well, either you honor "stretch" and preserve the aspect ratio (making
it 50x100), honor "stretch" and don't preserve the aspect ratio
(making it 100x100), or don't honor stretch at all (making it
100x200).

Of all of these, it seems that the first is the best option.  We
should always honor the aspect ratio if possible, and we should always
honor stretch if possible.  As long as nothing is happening in the
main axis, we can always honor both.

>> 2. Modify step 9 (handling "stretch" alignment) to have an explicit
>> statement about handling aspect-ratio items, to clarify that it
>> changes the cross-size *while ignoring the aspect ratio*, so the main
>> size doesn't change.
>
> This is easier to understand. 'align-self: stretch' has contradicted CSS
> 2.1 already. For example, a 'height: auto; align-self: stretch;' flex
> item would already fail the CSS 2.1 requirement for a non-replaced
> element with 'height: auto' saying that the height is the sum of heights
> of blocks or lineboxes inside. Therefore, "honoring aspect ratio", being
> a requirement for a replaced element with 'height: auto;' , would
> similarly fail to be be satisfied.

Yes, stretch applies slightly different rules to auto-sizing.  I see
no reason to think that should mean that you lose *all* the old
properties of auto-sizing.  Honoring the aspect ratio is an important
and useful thing to do if possible.

~TJ

Received on Monday, 29 October 2012 07:03:19 UTC