W3C home > Mailing lists > Public > public-css-archive@w3.org > February 2019

Re: [csswg-drafts] [css-grid] minmax(auto, min-content) under a max-content constraint (#3565)

From: Mats Palmgren via GitHub <sysbot+gh@w3.org>
Date: Tue, 05 Feb 2019 15:27:28 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-460679850-1549380446-sysbot+gh@w3.org>
> The track does have an auto min track sizing function and the grid container is being sized under a max-content constraint. So the track’s base size should be set to 100px.

I think this is the basic misunderstanding. The min-/max-content constraint is only used while determining the grid containers intrinsic size, not while flowing the box after that size has been determined. (i.e. the "Otherwise" part of "For auto minimums")

I stepped through this in Gecko in a debugger and jotted down some notes in case it's helpful:
```plaintext
grid container min-content size:
  1. initialize => base=0 limit=unconstrained
  2. intrinsic track sizing
       auto min-sizing,
         min-width:auto => item min size = 50px
         base=50px limit=50px
  => 50px

grid container max-content size:
  1. initialize => base=0 limit=unconstrained
  2. intrinsic track sizing
       auto min-sizing,
         item max-content contribution = 100px
         base=100px limit=unconstrained
       min-content max-sizing,
         item min-content contribution = 50px
         base=100px limit=50px
         base > limit =>
           base=100px limit=100px
  => 100px

Assuming the grid has a CB that is at least 100px, then its
intrinsic content-box width is 100px.  Now, flow the container
with that CB width:

grid container reflow:
  1. initialize => base=0 limit=unconstrained
  2. intrinsic track sizing
       auto min-sizing,
         min-width:auto => item min size = 50px
         base=50px limit=unconstrained
       min-content max-sizing,
         min-width:auto => item min size = 50px
         base=50px limit=50px
     => base=50px limit=50px
  3. distribute free space (100px)
       no growable tracks
  4. stretch flex tracks
       no flex tracks
  => base=50px limit=50px
=> grid area width is 50px

```
(I'll be happy to elaborate in more detail if needed.)

AFAICT, Gecko implements exactly what the spec says and thus its rendering is correct.

We could cap the item's max-content contribution also for `min-content` to get the rendering in Chrome, if that's desirable.  Or we could make them "growable" to get the rendering in the "Expected" image in the OP.  I don't feel strongly that anything needs to be changed in the spec though. If the result in Firefox isn't what the author wants they should just use `min-content` track sizing (to get the result in Chrome) or `auto` track sizing (to get the result in "Expected"). Whatever you decide, please make sure it makes sense also when span > 1 and when there's a mix of fixed and `min-content` max-sizing tracks.

-- 
GitHub Notification of comment by MatsPalmgren
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3565#issuecomment-460679850 using your GitHub account
Received on Tuesday, 5 February 2019 15:27:59 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:43 UTC