@@ -40,7 +40,7 @@ pub fn compute_grid_layout(tree: &mut impl LayoutGridContainer, node: NodeId, in
40
40
41
41
let get_child_styles_iter =
42
42
|node| tree. child_ids ( node) . map ( |child_node : NodeId | tree. get_grid_child_style ( child_node) ) ;
43
- let style = tree. get_grid_container_style ( node) . clone ( ) ;
43
+ let style = tree. get_grid_container_style ( node) ;
44
44
let child_styles_iter = get_child_styles_iter ( node) ;
45
45
46
46
let preferred_size = if inputs. sizing_mode == SizingMode :: InherentSize {
@@ -130,6 +130,13 @@ pub fn compute_grid_layout(tree: &mut impl LayoutGridContainer, node: NodeId, in
130
130
content_box_inset. right += scrollbar_gutter. x ;
131
131
content_box_inset. bottom += scrollbar_gutter. y ;
132
132
133
+ let align_content = style. align_content ( ) . unwrap_or ( AlignContent :: Stretch ) ;
134
+ let align_items = style. align_items ( ) ;
135
+ let justify_content = style. justify_content ( ) . unwrap_or ( AlignContent :: Stretch ) ;
136
+ let justify_items = style. justify_items ( ) ;
137
+
138
+ drop ( style) ;
139
+
133
140
let constrained_available_space = known_dimensions
134
141
. or ( size)
135
142
. map ( |size| size. map ( AvailableSpace :: Definite ) )
@@ -176,7 +183,7 @@ pub fn compute_grid_layout(tree: &mut impl LayoutGridContainer, node: NodeId, in
176
183
AbstractAxis :: Inline ,
177
184
min_size. get ( AbstractAxis :: Inline ) ,
178
185
max_size. get ( AbstractAxis :: Inline ) ,
179
- style . grid_align_content ( AbstractAxis :: Block ) ,
186
+ align_content ,
180
187
available_grid_space,
181
188
inner_node_size,
182
189
& mut columns,
@@ -196,7 +203,7 @@ pub fn compute_grid_layout(tree: &mut impl LayoutGridContainer, node: NodeId, in
196
203
AbstractAxis :: Block ,
197
204
min_size. get ( AbstractAxis :: Block ) ,
198
205
max_size. get ( AbstractAxis :: Block ) ,
199
- style . grid_align_content ( AbstractAxis :: Inline ) ,
206
+ justify_content ,
200
207
available_grid_space,
201
208
inner_node_size,
202
209
& mut rows,
@@ -309,7 +316,7 @@ pub fn compute_grid_layout(tree: &mut impl LayoutGridContainer, node: NodeId, in
309
316
AbstractAxis :: Inline ,
310
317
min_size. get ( AbstractAxis :: Inline ) ,
311
318
max_size. get ( AbstractAxis :: Inline ) ,
312
- style . grid_align_content ( AbstractAxis :: Block ) ,
319
+ align_content ,
313
320
available_grid_space,
314
321
inner_node_size,
315
322
& mut columns,
@@ -371,7 +378,7 @@ pub fn compute_grid_layout(tree: &mut impl LayoutGridContainer, node: NodeId, in
371
378
AbstractAxis :: Block ,
372
379
min_size. get ( AbstractAxis :: Block ) ,
373
380
max_size. get ( AbstractAxis :: Block ) ,
374
- style . grid_align_content ( AbstractAxis :: Inline ) ,
381
+ justify_content ,
375
382
available_grid_space,
376
383
inner_node_size,
377
384
& mut rows,
@@ -391,15 +398,15 @@ pub fn compute_grid_layout(tree: &mut impl LayoutGridContainer, node: NodeId, in
391
398
Line { start : padding. left , end : padding. right } ,
392
399
Line { start : border. left , end : border. right } ,
393
400
& mut columns,
394
- style . justify_content ( ) . unwrap_or ( AlignContent :: Stretch ) ,
401
+ justify_content,
395
402
) ;
396
403
// Align rows
397
404
align_tracks (
398
405
container_content_box. get ( AbstractAxis :: Block ) ,
399
406
Line { start : padding. top , end : padding. bottom } ,
400
407
Line { start : border. top , end : border. bottom } ,
401
408
& mut rows,
402
- style . align_content ( ) . unwrap_or ( AlignContent :: Stretch ) ,
409
+ align_content,
403
410
) ;
404
411
405
412
// 9. Size, Align, and Position Grid Items
@@ -410,8 +417,7 @@ pub fn compute_grid_layout(tree: &mut impl LayoutGridContainer, node: NodeId, in
410
417
// Sort items back into original order to allow them to be matched up with styles
411
418
items. sort_by_key ( |item| item. source_order ) ;
412
419
413
- let container_alignment_styles = InBothAbsAxis { horizontal : style. justify_items ( ) , vertical : style. align_items ( ) } ;
414
- drop ( style) ;
420
+ let container_alignment_styles = InBothAbsAxis { horizontal : justify_items, vertical : align_items } ;
415
421
416
422
// Position in-flow children (stored in items vector)
417
423
for ( index, item) in items. iter_mut ( ) . enumerate ( ) {
0 commit comments