@@ -405,85 +405,60 @@ Declaring Masonry Track Templates: the 'grid-template-*' properties</h3>
405405<h4 id=masonry-intrinsic-repeat>
406406Intrinsic Tracks and repeat()</h4>
407407
408- ISSUE(10915): Should we allow auto-repeated content-based tracks?
409- Is this a reasonable definition for them?
410- Should they work also in Grid Layout somehow?
411-
412- In Grid Layout,
413- all [=grid items=] are placed in the grid
414- <em> before</em> the grid tracks are sized.
415- This implies that ''repeat()/auto-fill'' /''repeat()/auto-fit'' repetition
416- can't include intrinsically sized tracks such as ''grid-template-rows/auto''
417- (either in the ''repeat()'' function <em> or</em> alongside it
418- in the fixed portion of the track list),
419- as that would require the layout algorithm
420- to have already determined which items would go in those tracks,
421- to determine how large the tracks are,
422- to determine how many repetitions fit in the available space.
423-
424- In Masonry Layout,
425- as [=masonry item=] placement and layout are intertwined and somewhat simplified,
426- this restriction is no longer strictly required.
427- It requires a slightly heuristic definition of sizing,
428- but auto repetition <em> can</em> include intrinsically-sized tracks
429- in a [=masonry container=] .
430-
431- <div algorithm="determine intrinsic repetitions">
432- To determine the number of repetitions
433- that a ''repeat()'' function resolves to,
434- resolve the repeated track sizing functions to definite sizes
435- by initializing the track sizes (per [[css-grid-2#algo-init]] )
436- and resolving intrinsic track sizes (per [[css-grid-2#algo-content]] )
437- in accordance with [[#track-sizing]]
438- with the following assumptions:
439-
440- * Expand ''repeat()/auto-fill'' /''repeat()/auto-fit'' repeat functions once.
441- * Ignore explicit item placement.
442- (That is, assume all items have an [=automatic position=] .)
443- * Do not [=collapsed grid track|collapse=] any tracks.
444- * If a [=masonry item=] has a span larger than 1,
445- then for each of its intrinsic size contributions,
446- first subtract the combined size of the gaps it would span,
447- and divide by its span.
448- Then treat it as an item that has a span of 1
449- and these modified intrinsic size contributions.
450-
451- All tracks are then treated as having the size
452- calculated by this simplified layout
453- (including those in ''repeat()'' arguments,
454- taking from their corresponding single repetition)
455- for the purpose of determining how many repetitions
456- the ''repeat()'' functions resolve to.
408+ Level 3 extends the ''repeat()'' notation to allow repetitions where
409+ neither the [=min track sizing function=] nor the [=max tack sizing function=] is [=definite=] ;
410+ in other words, the syntax for <<auto-repeat>> is relaxed to the following:
411+
412+ <pre class=prod>
413+ <dfn><<auto-repeat>></dfn> = repeat( [ auto-fill | auto-fit ] , [ <<line-names>> ? <<track-size>> ]+ <<line-names>> ? )
414+ </pre>
415+
416+ In order to resolve the number of repetitions,
417+ a hypothetical size is calculated for such tracks
418+ by initializing the track sizes (per [[css-grid-2#algo-init]] )
419+ and resolving intrinsic track sizes (per [[css-grid-2#algo-content]] )
420+ in accordance with [[#track-sizing]]
421+ with the following assumptions:
422+
423+ * Ignore explicit item placement.
424+ (That is, assume all items have an [=automatic position=] .)
425+ * Do not [=collapsed grid track|collapse=] any tracks.
426+ * Expand the repeated track listing to capture all possible automatic placements of each item,
427+ i.e. repeat the track listing <code> 2 + (<var ignore> largest span</var> - 2)/(<var ignore> number of tracks in repeat()</var> )</code> times,
428+ rounded <em> down</em> to a whole number.
429+
430+ The hypothetical size of each track in the ''repeat()'' listing
431+ is given by the largest track corresponding to that entry (by index) in the listing.
432+
433+ <div class=example>
434+ For example,
435+ given a template of ''repeat(auto-fill, 50px auto auto)''
436+ and a largest spanner of 2,
437+ you need to repeat the track listing twice,
438+ giving ''50px auto auto 50px auto auto'' .
439+ After doing the hypothetical layout,
440+ the 2nd and 5th tracks are maxed together to provide a hypothetical size for the first <css> auto</css>
441+ and the 3rd and 6th tracks are maxed together to provide a hypothetical size for the second <css> auto</css> .
442+ Those concrete sizes are then used to determine how many repetitions will fill the container.
457443 </div>
458444
459- <details class=note>
460- <summary> Motivation</summary>
461-
462- This simplified layout heuristic is defined to be "good enough",
463- while remaining fast and consistent.
464-
465- Ignoring placement is required just to make the concept coherent;
466- before you know how many repetitions you need,
467- you can't tell what track an item with a definite placement
468- will end up in.
469-
470- By chopping spanning items into span-1 items,
471- this avoids the possible need to expand a repeat() multiple times,
472- and the incoherent possibility of getting different sizes
473- for the same keyword across the repetitions.
474-
475- It also makes the layout as a whole significantly cheaper,
476- as you only need to consider each unique track size;
477- you don't even <em> really</em> need to do any repeat() expansion.
478- That is, in ''auto repeat(auto-fill, min-content auto)'' ,
479- both of the ''grid-template-rows/auto'' keywords
480- will resolve to the same size under this heuristic layout;
481- you can just figure out what
482- a ''grid-template-columns/auto''
483- and ''grid-template-columns/min-content'' track sizes
484- would each result in,
485- and use those sizes.
486- </details>
445+ ISSUE(10915): Should this work also in Grid Layout somehow, or fall back to a single repetition? If so, how?
446+
447+ Note: This simplified layout heuristic is defined to be "good enough",
448+ while remaining fast and consistent.
449+ Ignoring placement is required just to make the concept coherent;
450+ before you know how many repetitions you need,
451+ you can't tell what track an item
452+ (even one with a definite placement)
453+ will end up in.
454+
455+ ISSUE: Technically, if your explicit placement does not enter or cross over the repetition,
456+ we can know its placement prior to resolving the reptition.
457+ Do we want to adjust the algorithm above to account for this?
458+ That is, given ''auto repeat(auto-fill, ...) auto'' ,
459+ if you explicitly place an item against line 1 or -1,
460+ we could let it only affect that track
461+ (rather than pretending it'll go in every track).
487462
488463<h3 id="subgrids">
489464Subgrids</h3>
@@ -1540,6 +1515,9 @@ Additions Since Level 2</h3>
15401515
15411516 <ul>
15421517 <li> Added [=masonry layout=] .
1518+ <li> Expanded ''repeat(auto-fill)'' and ''repeat(auto-fit)'' to accept indefinite track sizing functions.
1519+ (<a href="https://github.com/w3c/csswg-drafts/issues/9321">Issue 9321</a> ,
1520+ <a href="https://github.com/w3c/csswg-drafts/issues/12899">Issue 12899</a> )
15431521 <li> Added the 'item-flow' property and its longhands,
15441522 as generic controls for item ordering and placement.
15451523 See [[#flow-control]] .
@@ -1556,6 +1534,9 @@ Recent Changes</h3>
15561534 (<a href="https://github.com/w3c/csswg-drafts/issues/12022">Issue 12022</a> )
15571535 * Dropped the unnecessary <css> auto-areas</css> value from ''repeat()'' .
15581536 (<a href="https://github.com/w3c/csswg-drafts/issues/10854">Issue 10854</a> )
1537+ * Adjusted heuristic for ''repeat(auto-fill)'' and ''repeat(auto-fit)'' with indefinite track sizing functions.
1538+ (<a href="https://github.com/w3c/csswg-drafts/issues/12899">Issue 12899</a> )
1539+
15591540
15601541 See also <a href="https://www.w3.org/TR/2025/WD-css-grid-3-20250917/#recent-changes">earlier changes</a> .
15611542
0 commit comments