W3C home > Mailing lists > Public > www-style@w3.org > September 2011

Re: hypothetical size of vertical flexbox WAS: [css3-flexbox] Nailing down the layout algorithm

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 9 Sep 2011 12:46:38 -0700
Message-ID: <CAAWBYDD4sUXr4Q1ULAtHGkJg72YC=UC1=RJegCx+jvPzfH3XMw@mail.gmail.com>
To: Ojan Vafai <ojan@chromium.org>
Cc: "L. David Baron" <dbaron@dbaron.org>, Alex Mogilevsky <alexmog@microsoft.com>, Arron Eicholz <Arron.Eicholz@microsoft.com>, Tony Chang <tc@google.com>, www-style list <www-style@w3.org>
On Fri, Sep 9, 2011 at 12:12 PM, Ojan Vafai <ojan@chromium.org> wrote:
> On Fri, Aug 26, 2011 at 6:23 PM, Tab Atkins Jr. <jackalmage@gmail.com>
> wrote:
>> In the current WD of Flexbox, there's a (somewhat
>> incomplete/incorrect) exact layout algorithm for flexbox.  I attempted
>> to eliminate the need for this, and just describe the layout algorithm
>> property-by-property, but it turns out that things are too
>> interconnected to make that a sane approach.
>>
>> So, I need to rewrite the layout algorithm to address the spec changes
>> and fix the previous mistakes and holes.  Here's my first draft of an
>> outline of the algorithm:
>>
>> 1. Reorder flexbox items according to ‘flex-order’.
>>
>> 2. Find the "hypothetical size" of every flexbox item
>>   by treating them like a normal element of their display
>>   type and the flexbox like a display:block element, and
>>   both the flexbox and the item establish BFCs. Resolve
>>   flexible widths/heights by treating them like their
>>   preferred size. Resolve ‘auto’ widths/heights by
>>   shrinkwrapping them.
>>
>> 3. Based on the hypothetical sizes of the items, find the
>>   real main size of the flexbox and the hypothetical
>>   cross size.
>
> Given the following:
> <div style="display: flexbox; flex-flow: vertical-ttb;">...</div>
> The flexbox does not have a specified height. Is the "real main size" here
> the shrinkwrapped height before linebreaking?

Yes.


> And the "hypothetical cross
> size" is actually it's width based off it's parent element?

It's the largest width of any of the flexbox items.  Recall that auto
widths are shrinkwrapped, and then the flexbox itself shrinkwraps its
contents in both directions.


> Basically, I think this algorithm treats vertical/horizontal flexing as
> perfectly symmetrical, but it's not in the cases of determining the
> width/height of the flexbox itself, right?

The flexbox algorithm *itself* is intended to be symmetrical, but some
of its inputs aren't symmetrical, since the flexbox is probably
embedded in, and contains, things that use block layout or similar.

Remember, if any of this is crazy, push back on it; don't just take me
on my word here!

~TJ
Received on Friday, 9 September 2011 19:47:33 GMT

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