# [css-grid] On base size and growth limits restrictions

From: Sergio Villar Senin <svillar@igalia.com>
Date: Mon, 05 Jan 2015 12:22:17 +0100
Message-ID: <54AA73E9.1050804@igalia.com>

```Happy New Year!

the grid layout specs mention[1] that

"(The base size might end up being larger than the growth limit, but the
algorithm attempts to avoid this situation.)"

the thing is that IMO we should change it so that the the track sizes
fulfill, at any moment, the following restriction.

base size <= growth limit

Otherwise the algorithm won't produce the expected results. I'll
demonstrate it with a simple example:

<div style="display: grid; grid-template-columns: minmax(40px,
min-content) minmax(50px, max-content);">
<div style="grid-column: 1 / -1;" id="item1"></div>
<div style="grid-column: 1;" id="item2"></div>
<div style="grid-column: 2;" id="item3"></div>
</div>

Let's use the following sizes (min-content,max-content) in pixels for
the items:
- item1: (40, 90)
- item2: (10, 10)
- item3: (10, 10)

If we run the track sizing algorithm, the first step after initializing
the track sizes is to process non-spanning grid items. After that the
track sizes would be something like:

(40, 10) (50, 10)

Afterwards we need to process the spanning grid item (item1). We move
directly to the processing of intrinsic maximums (as there are not
intrinsic minimums). This is where the problem arises.  Strictly
following the algorithm we need to fulfill item1's min-content which is
40. If we sum the tracks' growth limits we get 10+10=20 so we need to
distribute 40-20=20 equally. The result would be something like

(40, 30) (50,30)

something that is wrong because we shouldn't have to distribute anything
as the base sizes are more than enough (40+50>40). This might seem
harmless, but let's run the final step, the max-content maximums. We
have to distribute 90-30-30=30 only to the second track, so the sizes
would be:

(40, 30) (50, 60)

This means that the final sizes for the tracks (provided there were
enough available space) after growing them to their maximums would be
[40, 60] meaning that the grid would be larger (100px) than required (90px).

This won't happen if we, as I propose, enforce that the growth limits
must be always >= base sizes.

Thoughts? Am I missing anything?

BR

[1] http://dev.w3.org/csswg/css-grid/#algo-track-sizing
```
Received on Monday, 5 January 2015 11:22:45 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:50 UTC