Skip to content

Commit

Permalink
Block auto margins are zeroed by two auto insets not two auto margins
Browse files Browse the repository at this point in the history
The rule is:

"If all three of 'left', 'width', and 'right' are 'auto': First set any
'auto' values for 'margin-left' and 'margin-right' to 0."

Taffy was previously erroneously checking 'margin-left' and
'margin-right' instead of 'left' and 'right'
  • Loading branch information
nicoburns committed May 30, 2024
1 parent 3526f73 commit aa79d7c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/compute/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ fn perform_final_layout_on_in_flow_children(
let free_x_space = f32_max(0.0, container_inner_width - final_size.width - item_non_auto_x_margin_sum);
let x_axis_auto_margin_size = {
let auto_margin_count = item_margin.left.is_none() as u8 + item_margin.right.is_none() as u8;
if auto_margin_count == 2 && item.size.width.is_none() {
if item.inset.left.is_auto() && item.inset.right.is_auto() && item.size.width.is_none() {
0.0
} else if auto_margin_count > 0 {
free_x_space / auto_margin_count as f32
Expand Down

0 comments on commit aa79d7c

Please sign in to comment.