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

Re: [css3-flexbox] flex-basis initial value should be 0px

From: Tony Chang <tony@chromium.org>
Date: Thu, 24 May 2012 15:29:18 -0700
Message-ID: <CAL-=4P2MfY-A-SevkVo8-Jw930ftXQxntvzPFF_+dm0k6qDFRg@mail.gmail.com>
To: Sylvain Galineau <sylvaing@microsoft.com>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Ojan Vafai <ojan@chromium.org>, fantasai <fantasai.lists@inkedblade.net>, "www-style@w3.org" <www-style@w3.org>
On Wed, May 23, 2012 at 3:42 PM, Sylvain Galineau <sylvaing@microsoft.com>wrote:

> [Tab Atkins Jr.:]
> >
> > On Wed, May 23, 2012 at 1:52 PM, Sylvain Galineau <
> sylvaing@microsoft.com>
> > wrote:
> > > Second layout passes are never fun but are we talking about an impact
> > > that will be noticeable to your average author building a nav bar? How
> > > are they going to notice it i.e. what's the baseline? Would they be
> able
> > to tell the flexbox version is visibly slower than the built-with-divs-
> > and-duct-tape version?
> >
> > Ojan and Tony are mostly concerned about the speed effect on Flexbox used
> > for page layout, where the contents of the flex item might be "the entire
> > body of the page".  The effects on a nav bar are obviously small enough
> to
> > probably be completely ignorable.
> >
> Fair. It will always hurt at some level. Though I'd still like to get a
> concrete
> idea of what kind of impact we're talking about. Has this been measured
> already
> or are we guessing?
>

I started to measure this, then realized that computing the min-content
size doesn't require a full layout.  So having an implied minimum size for
a flex item isn't a problem.  I'm sorry for the confusion and ensuing
discussion caused by my mistake.  I got thrown off by this:

On Wed, May 23, 2012 at 11:23 AM, Tab Atkins Jr. <jackalmage@gmail.com>
 wrote:

> >> Ojan, Tony, when you say that 'flex-basis:0' is cheaper than 'auto',
> >> are you keeping in mind that, by default, flexbox items will have a
> >> min-width/height value of 'min-content'?  I don't know if we
> >> fast-track that for width, but it seems to require at least *some*
> >> layout-level computation.  For column flexboxes, the min-height seems
> >> to require a full layout anyway.
>

Why does computing the min-height for a column flexbox require a full
layout?  In the case of column flexboxes, I don't think we have to do any
extra work because we can't end up smaller than the min-content (the height
is already the min).

That said, flex-basis: auto is about twice as slow as flex-basis: 0 (or any
other fixed value).  This is because before you can do the flex algorithm,
you need to compute the the basis (layout the child), then after you've run
the flex algorithm, you have to do a second layout at the computed width.

I would prefer that the initial value of flex-basis be 0.  As Tab mentioned
up thread, this won't cause overflow anymore than flex-basis: auto.

tony
Received on Thursday, 24 May 2012 22:29:47 GMT

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