Add test_fixtures/_scratch dir to gitignore (#739)
1//! This module is a partial implementation of the CSS Grid Level 1 specification
2//! <https://www.w3.org/TR/css-grid-1>
3use core::borrow::Borrow;
4
5use crate::geometry::{AbsoluteAxis, AbstractAxis, InBothAbsAxis};
6use crate::geometry::{Line, Point, Rect, Size};
7use crate::style::{AlignItems, AlignSelf, AvailableSpace, Overflow, Position};
8use crate::tree::{Layout, LayoutInput, LayoutOutput, LayoutPartialTreeExt, NodeId, RunMode, SizingMode};
9use crate::util::debug::debug_log;
10use crate::util::sys::{f32_max, GridTrackVec, Vec};
11use crate::util::MaybeMath;
12use crate::util::{MaybeResolve, ResolveOrZero};
13use crate::{
14 style_helpers::*, AlignContent, BoxGenerationMode, BoxSizing, CoreStyle, GridContainerStyle, GridItemStyle,
15 JustifyContent, LayoutGridContainer,
16};
17use alignment::{align_and_position_item, align_tracks};
18use explicit_grid::{compute_explicit_grid_size_in_axis, initialize_grid_tracks};
19use implicit_grid::compute_grid_size_estimate;
20use placement::place_grid_items;
21use track_sizing::{
22 determine_if_item_crosses_flexible_or_intrinsic_tracks, resolve_item_track_indexes, track_sizing_algorithm,
23};
24use types::{CellOccupancyMatrix, GridTrack};
25
26pub(crate) use types::{GridCoordinate, GridLine, OriginZeroLine};
27
28mod alignment;
29mod explicit_grid;
30mod implicit_grid;
31mod placement;
32mod track_sizing;
33mod types;
34mod util;
35
36/// Grid layout algorithm
37/// This consists of a few phases:
38/// - Resolving the explicit grid
39/// - Placing items (which also resolves the implicit grid)
40/// - Track (row/column) sizing
41/// - Alignment & Final item placement
42pub fn compute_grid_layout(tree: &mut impl LayoutGridContainer, node: NodeId, inputs: LayoutInput) -> LayoutOutput {
43 let LayoutInput { known_dimensions, parent_size, available_space, run_mode, .. } = inputs;
44
45 let style = tree.get_grid_container_style(node);
46
47 // 1. Compute "available grid space"
48 // https://www.w3.org/TR/css-grid-1/#available-grid-space
49 let aspect_ratio = style.aspect_ratio();
50 let padding = style.padding().resolve_or_zero(parent_size.width);
51 let border = style.border().resolve_or_zero(parent_size.width);
52 let padding_border = padding + border;
53 let padding_border_size = padding_border.sum_axes();
54 let box_sizing_adjustment =
55 if style.box_sizing() == BoxSizing::ContentBox { padding_border_size } else { Size::ZERO };
56
57 let min_size = style
58 .min_size()
59 .maybe_resolve(parent_size)
60 .maybe_apply_aspect_ratio(aspect_ratio)
61 .maybe_add(box_sizing_adjustment);
62 let max_size = style
63 .max_size()
64 .maybe_resolve(parent_size)
65 .maybe_apply_aspect_ratio(aspect_ratio)
66 .maybe_add(box_sizing_adjustment);
67 let preferred_size = if inputs.sizing_mode == SizingMode::InherentSize {
68 style
69 .size()
70 .maybe_resolve(parent_size)
71 .maybe_apply_aspect_ratio(style.aspect_ratio())
72 .maybe_add(box_sizing_adjustment)
73 } else {
74 Size::NONE
75 };
76
77 // Scrollbar gutters are reserved when the `overflow` property is set to `Overflow::Scroll`.
78 // However, the axis are switched (transposed) because a node that scrolls vertically needs
79 // *horizontal* space to be reserved for a scrollbar
80 let scrollbar_gutter = style.overflow().transpose().map(|overflow| match overflow {
81 Overflow::Scroll => style.scrollbar_width(),
82 _ => 0.0,
83 });
84 // TODO: make side configurable based on the `direction` property
85 let mut content_box_inset = padding_border;
86 content_box_inset.right += scrollbar_gutter.x;
87 content_box_inset.bottom += scrollbar_gutter.y;
88
89 let align_content = style.align_content().unwrap_or(AlignContent::Stretch);
90 let justify_content = style.justify_content().unwrap_or(JustifyContent::Stretch);
91 let align_items = style.align_items();
92 let justify_items = style.justify_items();
93
94 // Note: we avoid accessing the grid rows/columns methods more than once as this can
95 // cause an expensive-ish computation
96 let grid_template_columms = style.grid_template_columns();
97 let grid_template_rows = style.grid_template_rows();
98 let grid_auto_columms = style.grid_auto_columns();
99 let grid_auto_rows = style.grid_auto_rows();
100
101 let constrained_available_space = known_dimensions
102 .or(preferred_size)
103 .map(|size| size.map(AvailableSpace::Definite))
104 .unwrap_or(available_space)
105 .maybe_clamp(min_size, max_size)
106 .maybe_max(padding_border_size);
107
108 let available_grid_space = Size {
109 width: constrained_available_space
110 .width
111 .map_definite_value(|space| space - content_box_inset.horizontal_axis_sum()),
112 height: constrained_available_space
113 .height
114 .map_definite_value(|space| space - content_box_inset.vertical_axis_sum()),
115 };
116
117 let outer_node_size =
118 known_dimensions.or(preferred_size).maybe_clamp(min_size, max_size).maybe_max(padding_border_size);
119 let mut inner_node_size = Size {
120 width: outer_node_size.width.map(|space| space - content_box_inset.horizontal_axis_sum()),
121 height: outer_node_size.height.map(|space| space - content_box_inset.vertical_axis_sum()),
122 };
123
124 debug_log!("parent_size", dbg:parent_size);
125 debug_log!("outer_node_size", dbg:outer_node_size);
126 debug_log!("inner_node_size", dbg:inner_node_size);
127
128 if let (RunMode::ComputeSize, Some(width), Some(height)) = (run_mode, outer_node_size.width, outer_node_size.height)
129 {
130 return LayoutOutput::from_outer_size(Size { width, height });
131 }
132
133 let get_child_styles_iter =
134 |node| tree.child_ids(node).map(|child_node: NodeId| tree.get_grid_child_style(child_node));
135 let child_styles_iter = get_child_styles_iter(node);
136
137 // 2. Resolve the explicit grid
138
139 // This is very similar to the inner_node_size except if the inner_node_size is not definite but the node
140 // has a min- or max- size style then that will be used in it's place.
141 let auto_fit_container_size = outer_node_size
142 .or(max_size)
143 .or(min_size)
144 .maybe_clamp(min_size, max_size)
145 .maybe_max(padding_border_size)
146 .maybe_sub(content_box_inset.sum_axes());
147
148 // Exactly compute the number of rows and columns in the explicit grid.
149 let explicit_col_count = compute_explicit_grid_size_in_axis(
150 &style,
151 grid_template_columms.borrow(),
152 auto_fit_container_size,
153 AbsoluteAxis::Horizontal,
154 );
155 let explicit_row_count = compute_explicit_grid_size_in_axis(
156 &style,
157 grid_template_rows.borrow(),
158 auto_fit_container_size,
159 AbsoluteAxis::Vertical,
160 );
161
162 // 3. Implicit Grid: Estimate Track Counts
163 // Estimate the number of rows and columns in the implicit grid (= the entire grid)
164 // This is necessary as part of placement. Doing it early here is a perf optimisation to reduce allocations.
165 let (est_col_counts, est_row_counts) =
166 compute_grid_size_estimate(explicit_col_count, explicit_row_count, child_styles_iter);
167
168 // 4. Grid Item Placement
169 // Match items (children) to a definite grid position (row start/end and column start/end position)
170 let mut items = Vec::with_capacity(tree.child_count(node));
171 let mut cell_occupancy_matrix = CellOccupancyMatrix::with_track_counts(est_col_counts, est_row_counts);
172 let in_flow_children_iter = || {
173 tree.child_ids(node)
174 .enumerate()
175 .map(|(index, child_node)| (index, child_node, tree.get_grid_child_style(child_node)))
176 .filter(|(_, _, style)| {
177 style.box_generation_mode() != BoxGenerationMode::None && style.position() != Position::Absolute
178 })
179 };
180 place_grid_items(
181 &mut cell_occupancy_matrix,
182 &mut items,
183 in_flow_children_iter,
184 style.grid_auto_flow(),
185 align_items.unwrap_or(AlignItems::Stretch),
186 justify_items.unwrap_or(AlignItems::Stretch),
187 );
188
189 // Extract track counts from previous step (auto-placement can expand the number of tracks)
190 let final_col_counts = *cell_occupancy_matrix.track_counts(AbsoluteAxis::Horizontal);
191 let final_row_counts = *cell_occupancy_matrix.track_counts(AbsoluteAxis::Vertical);
192
193 // 5. Initialize Tracks
194 // Initialize (explicit and implicit) grid tracks (and gutters)
195 // This resolves the min and max track sizing functions for all tracks and gutters
196 let mut columns = GridTrackVec::new();
197 let mut rows = GridTrackVec::new();
198 initialize_grid_tracks(
199 &mut columns,
200 final_col_counts,
201 grid_template_columms.borrow(),
202 grid_auto_columms.borrow(),
203 style.gap().width,
204 |column_index| cell_occupancy_matrix.column_is_occupied(column_index),
205 );
206 initialize_grid_tracks(
207 &mut rows,
208 final_row_counts,
209 grid_template_rows.borrow(),
210 grid_auto_rows.borrow(),
211 style.gap().height,
212 |row_index| cell_occupancy_matrix.row_is_occupied(row_index),
213 );
214
215 drop(grid_template_rows);
216 drop(grid_template_columms);
217 drop(grid_auto_rows);
218 drop(grid_auto_columms);
219 drop(style);
220
221 // 6. Track Sizing
222
223 // Convert grid placements in origin-zero coordinates to indexes into the GridTrack (rows and columns) vectors
224 // This computation is relatively trivial, but it requires the final number of negative (implicit) tracks in
225 // each axis, and doing it up-front here means we don't have to keep repeating that calculation
226 resolve_item_track_indexes(&mut items, final_col_counts, final_row_counts);
227
228 // For each item, and in each axis, determine whether the item crosses any flexible (fr) tracks
229 // Record this as a boolean (per-axis) on each item for later use in the track-sizing algorithm
230 determine_if_item_crosses_flexible_or_intrinsic_tracks(&mut items, &columns, &rows);
231
232 // Determine if the grid has any baseline aligned items
233 let has_baseline_aligned_item = items.iter().any(|item| item.align_self == AlignSelf::Baseline);
234
235 // Run track sizing algorithm for Inline axis
236 track_sizing_algorithm(
237 tree,
238 AbstractAxis::Inline,
239 min_size.get(AbstractAxis::Inline),
240 max_size.get(AbstractAxis::Inline),
241 align_content,
242 available_grid_space,
243 inner_node_size,
244 &mut columns,
245 &mut rows,
246 &mut items,
247 |track: &GridTrack, parent_size: Option<f32>| track.max_track_sizing_function.definite_value(parent_size),
248 has_baseline_aligned_item,
249 );
250 let initial_column_sum = columns.iter().map(|track| track.base_size).sum::<f32>();
251 inner_node_size.width = inner_node_size.width.or_else(|| initial_column_sum.into());
252
253 items.iter_mut().for_each(|item| item.available_space_cache = None);
254
255 // Run track sizing algorithm for Block axis
256 track_sizing_algorithm(
257 tree,
258 AbstractAxis::Block,
259 min_size.get(AbstractAxis::Block),
260 max_size.get(AbstractAxis::Block),
261 justify_content,
262 available_grid_space,
263 inner_node_size,
264 &mut rows,
265 &mut columns,
266 &mut items,
267 |track: &GridTrack, _| Some(track.base_size),
268 false, // TODO: Support baseline alignment in the vertical axis
269 );
270 let initial_row_sum = rows.iter().map(|track| track.base_size).sum::<f32>();
271 inner_node_size.height = inner_node_size.height.or_else(|| initial_row_sum.into());
272
273 debug_log!("initial_column_sum", dbg:initial_column_sum);
274 debug_log!(dbg: columns.iter().map(|track| track.base_size).collect::<Vec<_>>());
275 debug_log!("initial_row_sum", dbg:initial_row_sum);
276 debug_log!(dbg: rows.iter().map(|track| track.base_size).collect::<Vec<_>>());
277
278 // 6. Compute container size
279 let resolved_style_size = known_dimensions.or(preferred_size);
280 let container_border_box = Size {
281 width: resolved_style_size
282 .get(AbstractAxis::Inline)
283 .unwrap_or_else(|| initial_column_sum + content_box_inset.horizontal_axis_sum())
284 .maybe_clamp(min_size.width, max_size.width)
285 .max(padding_border_size.width),
286 height: resolved_style_size
287 .get(AbstractAxis::Block)
288 .unwrap_or_else(|| initial_row_sum + content_box_inset.vertical_axis_sum())
289 .maybe_clamp(min_size.height, max_size.height)
290 .max(padding_border_size.height),
291 };
292 let container_content_box = Size {
293 width: f32_max(0.0, container_border_box.width - content_box_inset.horizontal_axis_sum()),
294 height: f32_max(0.0, container_border_box.height - content_box_inset.vertical_axis_sum()),
295 };
296
297 // If only the container's size has been requested
298 if run_mode == RunMode::ComputeSize {
299 return LayoutOutput::from_outer_size(container_border_box);
300 }
301
302 // 7. Resolve percentage track base sizes
303 // In the case of an indefinitely sized container these resolve to zero during the "Initialise Tracks" step
304 // and therefore need to be re-resolved here based on the content-sized content box of the container
305 if !available_grid_space.width.is_definite() {
306 for column in &mut columns {
307 let min: Option<f32> =
308 column.min_track_sizing_function.resolved_percentage_size(container_content_box.width);
309 let max: Option<f32> =
310 column.max_track_sizing_function.resolved_percentage_size(container_content_box.width);
311 column.base_size = column.base_size.maybe_clamp(min, max);
312 }
313 }
314 if !available_grid_space.height.is_definite() {
315 for row in &mut rows {
316 let min: Option<f32> = row.min_track_sizing_function.resolved_percentage_size(container_content_box.height);
317 let max: Option<f32> = row.max_track_sizing_function.resolved_percentage_size(container_content_box.height);
318 row.base_size = row.base_size.maybe_clamp(min, max);
319 }
320 }
321
322 // Column sizing must be re-run (once) if:
323 // - The grid container's width was initially indefinite and there are any columns with percentage track sizing functions
324 // - Any grid item crossing an intrinsically sized track's min content contribution width has changed
325 // TODO: Only rerun sizing for tracks that actually require it rather than for all tracks if any need it.
326 let mut rerun_column_sizing;
327
328 let has_percentage_column = columns.iter().any(|track| track.uses_percentage());
329 let parent_width_indefinite = !available_space.width.is_definite();
330 rerun_column_sizing = parent_width_indefinite && has_percentage_column;
331
332 if !rerun_column_sizing {
333 let min_content_contribution_changed =
334 items.iter_mut().filter(|item| item.crosses_intrinsic_column).any(|item| {
335 let available_space = item.available_space(
336 AbstractAxis::Inline,
337 &rows,
338 inner_node_size.height,
339 |track: &GridTrack, _| Some(track.base_size),
340 );
341 let new_min_content_contribution =
342 item.min_content_contribution(AbstractAxis::Inline, tree, available_space, inner_node_size);
343
344 let has_changed = Some(new_min_content_contribution) != item.min_content_contribution_cache.width;
345
346 item.available_space_cache = Some(available_space);
347 item.min_content_contribution_cache.width = Some(new_min_content_contribution);
348 item.max_content_contribution_cache.width = None;
349 item.minimum_contribution_cache.width = None;
350
351 has_changed
352 });
353 rerun_column_sizing = min_content_contribution_changed;
354 } else {
355 // Clear intrisic width caches
356 items.iter_mut().for_each(|item| {
357 item.available_space_cache = None;
358 item.min_content_contribution_cache.width = None;
359 item.max_content_contribution_cache.width = None;
360 item.minimum_contribution_cache.width = None;
361 });
362 }
363
364 if rerun_column_sizing {
365 // Re-run track sizing algorithm for Inline axis
366 track_sizing_algorithm(
367 tree,
368 AbstractAxis::Inline,
369 min_size.get(AbstractAxis::Inline),
370 max_size.get(AbstractAxis::Inline),
371 align_content,
372 available_grid_space,
373 inner_node_size,
374 &mut columns,
375 &mut rows,
376 &mut items,
377 |track: &GridTrack, _| Some(track.base_size),
378 has_baseline_aligned_item,
379 );
380
381 // Row sizing must be re-run (once) if:
382 // - The grid container's height was initially indefinite and there are any rows with percentage track sizing functions
383 // - Any grid item crossing an intrinsically sized track's min content contribution height has changed
384 // TODO: Only rerun sizing for tracks that actually require it rather than for all tracks if any need it.
385 let mut rerun_row_sizing;
386
387 let has_percentage_row = rows.iter().any(|track| track.uses_percentage());
388 let parent_height_indefinite = !available_space.height.is_definite();
389 rerun_row_sizing = parent_height_indefinite && has_percentage_row;
390
391 if !rerun_row_sizing {
392 let min_content_contribution_changed =
393 items.iter_mut().filter(|item| item.crosses_intrinsic_column).any(|item| {
394 let available_space = item.available_space(
395 AbstractAxis::Block,
396 &columns,
397 inner_node_size.width,
398 |track: &GridTrack, _| Some(track.base_size),
399 );
400 let new_min_content_contribution =
401 item.min_content_contribution(AbstractAxis::Block, tree, available_space, inner_node_size);
402
403 let has_changed = Some(new_min_content_contribution) != item.min_content_contribution_cache.height;
404
405 item.available_space_cache = Some(available_space);
406 item.min_content_contribution_cache.height = Some(new_min_content_contribution);
407 item.max_content_contribution_cache.height = None;
408 item.minimum_contribution_cache.height = None;
409
410 has_changed
411 });
412 rerun_row_sizing = min_content_contribution_changed;
413 } else {
414 items.iter_mut().for_each(|item| {
415 // Clear intrisic height caches
416 item.available_space_cache = None;
417 item.min_content_contribution_cache.height = None;
418 item.max_content_contribution_cache.height = None;
419 item.minimum_contribution_cache.height = None;
420 });
421 }
422
423 if rerun_row_sizing {
424 // Re-run track sizing algorithm for Block axis
425 track_sizing_algorithm(
426 tree,
427 AbstractAxis::Block,
428 min_size.get(AbstractAxis::Block),
429 max_size.get(AbstractAxis::Block),
430 justify_content,
431 available_grid_space,
432 inner_node_size,
433 &mut rows,
434 &mut columns,
435 &mut items,
436 |track: &GridTrack, _| Some(track.base_size),
437 false, // TODO: Support baseline alignment in the vertical axis
438 );
439 }
440 }
441
442 // 8. Track Alignment
443
444 // Align columns
445 align_tracks(
446 container_content_box.get(AbstractAxis::Inline),
447 Line { start: padding.left, end: padding.right },
448 Line { start: border.left, end: border.right },
449 &mut columns,
450 justify_content,
451 );
452 // Align rows
453 align_tracks(
454 container_content_box.get(AbstractAxis::Block),
455 Line { start: padding.top, end: padding.bottom },
456 Line { start: border.top, end: border.bottom },
457 &mut rows,
458 align_content,
459 );
460
461 // 9. Size, Align, and Position Grid Items
462
463 #[cfg_attr(not(feature = "content_size"), allow(unused_mut))]
464 let mut item_content_size_contribution = Size::ZERO;
465
466 // Sort items back into original order to allow them to be matched up with styles
467 items.sort_by_key(|item| item.source_order);
468
469 let container_alignment_styles = InBothAbsAxis { horizontal: justify_items, vertical: align_items };
470
471 // Position in-flow children (stored in items vector)
472 for (index, item) in items.iter_mut().enumerate() {
473 let grid_area = Rect {
474 top: rows[item.row_indexes.start as usize + 1].offset,
475 bottom: rows[item.row_indexes.end as usize].offset,
476 left: columns[item.column_indexes.start as usize + 1].offset,
477 right: columns[item.column_indexes.end as usize].offset,
478 };
479 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
480 let (content_size_contribution, y_position, height) = align_and_position_item(
481 tree,
482 item.node,
483 index as u32,
484 grid_area,
485 container_alignment_styles,
486 item.baseline_shim,
487 );
488 item.y_position = y_position;
489 item.height = height;
490
491 #[cfg(feature = "content_size")]
492 {
493 item_content_size_contribution = item_content_size_contribution.f32_max(content_size_contribution);
494 }
495 }
496
497 // Position hidden and absolutely positioned children
498 let mut order = items.len() as u32;
499 (0..tree.child_count(node)).for_each(|index| {
500 let child = tree.get_child_id(node, index);
501 let child_style = tree.get_grid_child_style(child);
502
503 // Position hidden child
504 if child_style.box_generation_mode() == BoxGenerationMode::None {
505 drop(child_style);
506 tree.set_unrounded_layout(child, &Layout::with_order(order));
507 tree.perform_child_layout(
508 child,
509 Size::NONE,
510 Size::NONE,
511 Size::MAX_CONTENT,
512 SizingMode::InherentSize,
513 Line::FALSE,
514 );
515 order += 1;
516 return;
517 }
518
519 // Position absolutely positioned child
520 if child_style.position() == Position::Absolute {
521 // Convert grid-col-{start/end} into Option's of indexes into the columns vector
522 // The Option is None if the style property is Auto and an unresolvable Span
523 let maybe_col_indexes = child_style
524 .grid_column()
525 .into_origin_zero(final_col_counts.explicit)
526 .resolve_absolutely_positioned_grid_tracks()
527 .map(|maybe_grid_line| {
528 maybe_grid_line.map(|line: OriginZeroLine| line.into_track_vec_index(final_col_counts))
529 });
530 // Convert grid-row-{start/end} into Option's of indexes into the row vector
531 // The Option is None if the style property is Auto and an unresolvable Span
532 let maybe_row_indexes = child_style
533 .grid_row()
534 .into_origin_zero(final_row_counts.explicit)
535 .resolve_absolutely_positioned_grid_tracks()
536 .map(|maybe_grid_line| {
537 maybe_grid_line.map(|line: OriginZeroLine| line.into_track_vec_index(final_row_counts))
538 });
539
540 let grid_area = Rect {
541 top: maybe_row_indexes.start.map(|index| rows[index].offset).unwrap_or(border.top),
542 bottom: maybe_row_indexes
543 .end
544 .map(|index| rows[index].offset)
545 .unwrap_or(container_border_box.height - border.bottom - scrollbar_gutter.y),
546 left: maybe_col_indexes.start.map(|index| columns[index].offset).unwrap_or(border.left),
547 right: maybe_col_indexes
548 .end
549 .map(|index| columns[index].offset)
550 .unwrap_or(container_border_box.width - border.right - scrollbar_gutter.x),
551 };
552 drop(child_style);
553
554 // TODO: Baseline alignment support for absolutely positioned items (should check if is actuallty specified)
555 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
556 let (content_size_contribution, _, _) =
557 align_and_position_item(tree, child, order, grid_area, container_alignment_styles, 0.0);
558 #[cfg(feature = "content_size")]
559 {
560 item_content_size_contribution = item_content_size_contribution.f32_max(content_size_contribution);
561 }
562
563 order += 1;
564 }
565 });
566
567 // If there are not items then return just the container size (no baseline)
568 if items.is_empty() {
569 return LayoutOutput::from_outer_size(container_border_box);
570 }
571
572 // Determine the grid container baseline(s) (currently we only compute the first baseline)
573 let grid_container_baseline: f32 = {
574 // Sort items by row start position so that we can iterate items in groups which are in the same row
575 items.sort_by_key(|item| item.row_indexes.start);
576
577 // Get the row index of the first row containing items
578 let first_row = items[0].row_indexes.start;
579
580 // Create a slice of all of the items start in this row (taking advantage of the fact that we have just sorted the array)
581 let first_row_items = &items[0..].split(|item| item.row_indexes.start != first_row).next().unwrap();
582
583 // Check if any items in *this row* are baseline aligned
584 let row_has_baseline_item = first_row_items.iter().any(|item| item.align_self == AlignSelf::Baseline);
585
586 let item = if row_has_baseline_item {
587 first_row_items.iter().find(|item| item.align_self == AlignSelf::Baseline).unwrap()
588 } else {
589 &first_row_items[0]
590 };
591
592 item.y_position + item.baseline.unwrap_or(item.height)
593 };
594
595 LayoutOutput::from_sizes_and_baselines(
596 container_border_box,
597 item_content_size_contribution,
598 Point { x: None, y: Some(grid_container_baseline) },
599 )
600}