Re: [csswg-drafts] [css-grid] Intrinsic size of grid containers

FYI, this is now fixed in the latest [Firefox Nightly](https://nightly.mozilla.org/).
The algorithm we use in ["For auto minimums"](https://drafts.csswg.org/css-grid/#algo-single-span-items) is:

```
if 'width' doesn't behave as auto {
  return the item's min-content contribution
}
if 'min-width' is 'auto' {
  if 'overflow' is 'visible' {
    if sizing under a max-content constraint {
      return the item's max-content contribution, clamped*
    }
    return the item's min-content contribution, clamped*
  }
  set the used value of 'min-width' to zero, fall-through
}
set the used value of 'width' to the used value of 'min-width'
return the item's margin-box size

```
clamped: means shrink the margin box size to fit a fixed track max-sizing function (if there is one), without making the content-box size negative (as usual per [Grid ยง6.6](https://drafts.csswg.org/css-grid/#min-size-auto))

With this definition of ["behave as auto"](https://drafts.csswg.org/css-sizing-3/#behave-auto).

(ditto for `'min-height'/'height'`)

So, the trick is to always clamp the size in "For auto minimums" (when AMS and clamping applies).  This gives the grid container the desired intrinsic size. Then, in layout (no sizing constraint), we'll return a clamped min-content contribution there, but since the grid container now has a definite size (the intrinsic size), we'll grow the track in the ["Maximize Tracks"](https://drafts.csswg.org/css-grid/#algo-grow-tracks) step up to the desired size.

As far as I can tell, this gives the same layout as in Chrome for all the tests I looked at.
I found only one difference, but I tend to think that's simply a somewhat unrelated [bug in Chrome](https://bugs.chromium.org/p/chromium/issues/detail?id=818401).

-- 
GitHub Notification of comment by MatsPalmgren
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2303#issuecomment-370118422 using your GitHub account

Received on Saturday, 3 March 2018 04:52:41 UTC