Re: Fwd: [css-grid] question on clamping grid items to fixed track size

-------- Forwarded Message --------
Date: Thu, 15 Feb 2018 02:55:15 +0100
From: Mats Palmgren
To: fantasai
CC: Tab Atkins Jr.

On 2/15/18 12:07 AM, fantasai wrote:
 > The min-content size is the width of “foobar”, not the AMS.
 > The AMS is the used min-width. These are two different concepts,
 > and the shrinkwrap size (required by justify-self: start) uses
 > the min-content size, not the min-width in the formula.

Ah, that's where my misunderstanding is then.
I blame the rather vague term "minimum size" used in §6.6 which
I interpreted as a more general concept.
I think I've said this before: it's vague undefined terms and phrases
like this that leads to implementation bugs and incompatibilities in UAs.
I'd strongly encourage the CSS editors to always use terms that have
a normatively defined meaning.  In this case, the title of §6.6 should
be something like "How to calculate the used value for min-width/height
when its computed value is 'auto'".  (I'd recommend removing the term
"Automatic Minimum Size" entirely.)

 > I think you're right, per spec, about the container size,
 > but wrong about the grid item size.

I agree.  But it also changes the column size doesn't it?
If AMS is simply determining the used value of min-width, then
the example is equivalent to:
<style type="text/css">
.grid {
   display: inline-grid;
   grid-template-columns: minmax(auto, 0px);
}
</style>
<div class="grid">
   <div style="justify-self: start; min-width:0">foobar</div>
</div>

Both the min/max-content *contribution* of that item is "foobar",
so the column size will in fact fill the container when the container
is sized under min/max-content constraint.

The interesting case though is when sizing the container under
"no constraint", i.e. in layout:
https://drafts.csswg.org/css-grid/#algo-single-span-items
"Otherwise, set its base size to the maximum of its items’ min-size contributions. The min-size contribution of an item is the 
outer size that would result from assuming the item’s min-width or min-height value (whichever matches the relevant axis) as 
its specified size if its specified size (width or height, whichever matches the relevant axis) is auto, or else the item’s 
min-content contribution."

It's not clear to me if "min-width or min-height value" there is talking
about computed or used values.  So it could be interpreted either as:
"min-width:auto; width:auto", or (with AMS = 0) "min-width:0; width:0".
The "outer size" in the former case would be "foobar", and zero in
the latter case.  The former probably makes more sense, since otherwise
you'd still end up with a zero column size and the item overflowing
its column (but not the container since it was sized to fit) which
would be weird.

OK, so I'll implement these changes and let you know what falls out...


 >> So, the final results in layout for this case should be:
 >> container size = 20px
 >> columnn size = 0
 >> grid item size = 0 (min(20px, max(0px, 0px))
 >
 > column size and grid item size would be 20px then, I think.

Yup.


 > p.s. Would you mind if I forwarded this discussion to www-archive?
 > It might be useful to refer back to at some point in the future.

You're welcome to make any part of this thread public.


/Mats

Received on Monday, 26 March 2018 19:54:37 UTC