W3C home > Mailing lists > Public > www-style@w3.org > February 2015

Re: [css-flexbox] Behaviour of percentage heights in column direction

From: Daniel Holbert <dholbert@mozilla.com>
Date: Mon, 9 Feb 2015 15:45:13 -0800
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: www-style list <www-style@w3.org>
message-id: <54D94689.9020802@mozilla.com>
On 02/09/2015 01:43 PM, Daniel Holbert wrote:
> On 07/01/2014 09:53 AM, Tab Atkins Jr. wrote:
>> fantasai and I discussed this this morning.  Based on that discussion,
>> and the telcon discussion we had last week, we agree with the
>> conclusions of this thread.  Namely, percentage heights on children of
>> flex items should be resolveable if the item's 'flex-basis' is
>> definite; they resolve against the *flexed height* of the flex item
>> (not its flex-basis directly).

So, I think this rule is *supposed to* mean that we can avoid having to
layout any flex item more than once, during a flex-container reflow.

In particular [assuming our flex container is vertical], I think the
idea is supposed to be:
 - If the flex item has a definite flex-basis, everything's easy -- we
run the flex algorithm & reflow the flex item once, with the final size
from the flex algorithm (resolving percentages against the item's final
height).

 - Otherwise, the flex item has an *indefinite* flex-basis -- so we
reflow it once, up-front (with an indefinite height), to establish a
flex-basis that we can use for the flex algorithm. Then at the end of
the flex algorithm, we can simply update the item's height, but we don't
have to bother adjusting its percent-height children, because they
already know it has an indefinite height & they've been treated as being
auto-height.

But, we can't quite do this optimization, because the "easy" case isn't
actually so easy after all -- we likely have to layout the flex item
up-front *regardless* of its flex-basis, to establish its
"min-height:auto" value, before we can run the flexbox algorithm. So
really, we need two reflows for the "easy" case.

SUGGESTION

I think the most sensible way to tweak to the spec (both to make it
consistent on "definite"-ness, as noted in my response[1] to Peter, and
to actually create an opportunity for this optimization) would be to
change section 9.8 to take the main-axis min-size & max-size properties
into account.

Specifically, it currently says:
   # If... the flex item has a definite flex basis,
   # the main size must be treated as definite
...but I think it should say something like:
   # If... the flex item has a definite flex basis,
   # and its main-axis min-size & max-size properties
   # are also definite, the main size must be treated as
   # definite.
Spec link: http://dev.w3.org/csswg/css-flexbox-1/#definite

Thoughts?

~Daniel
[1] https://lists.w3.org/Archives/Public/www-style/2015Feb/0209.html
Received on Monday, 9 February 2015 23:45:44 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:52:01 UTC