diff --git a/src/compute/block.rs b/src/compute/block.rs
index 2d97bc03c..f1b601efe 100644
--- a/src/compute/block.rs
+++ b/src/compute/block.rs
@@ -446,6 +446,7 @@ fn perform_final_layout_on_in_flow_children(
location,
padding: item.padding,
border: item.border,
+ margin: resolved_margin,
},
);
@@ -674,6 +675,7 @@ fn perform_absolute_layout_on_absolute_children(
location,
padding,
border,
+ margin: resolved_margin,
},
);
diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs
index f87c0bc5e..3392759c9 100644
--- a/src/compute/flexbox.rs
+++ b/src/compute/flexbox.rs
@@ -1835,6 +1835,7 @@ fn calculate_flex_item(
location,
padding: item.padding,
border: item.border,
+ margin: item.margin,
},
);
@@ -2168,6 +2169,7 @@ fn perform_absolute_layout_on_absolute_children(
location,
padding,
border,
+ margin: resolved_margin,
},
);
diff --git a/src/compute/grid/alignment.rs b/src/compute/grid/alignment.rs
index ad2bbf48b..8fe72fa04 100644
--- a/src/compute/grid/alignment.rs
+++ b/src/compute/grid/alignment.rs
@@ -190,7 +190,7 @@ pub(super) fn align_and_position_item(
// Resolve final size
let Size { width, height } = Size { width, height }.unwrap_or(layout_output.size).maybe_clamp(min_size, max_size);
- let x = align_item_within_area(
+ let (x, x_margin) = align_item_within_area(
Line { start: grid_area.left, end: grid_area.right },
justify_self.unwrap_or(alignment_styles.horizontal),
width,
@@ -199,7 +199,7 @@ pub(super) fn align_and_position_item(
margin.horizontal_components(),
0.0,
);
- let y = align_item_within_area(
+ let (y, y_margin) = align_item_within_area(
Line { start: grid_area.top, end: grid_area.bottom },
align_self.unwrap_or(alignment_styles.vertical),
height,
@@ -214,6 +214,8 @@ pub(super) fn align_and_position_item(
height: if overflow.x == Overflow::Scroll { scrollbar_width } else { 0.0 },
};
+ let resolved_margin = Rect { left: x_margin.start, right: x_margin.end, top: y_margin.start, bottom: y_margin.end };
+
tree.set_unrounded_layout(
node,
&Layout {
@@ -225,6 +227,7 @@ pub(super) fn align_and_position_item(
scrollbar_size,
padding,
border,
+ margin: resolved_margin,
},
);
@@ -246,7 +249,7 @@ pub(super) fn align_item_within_area(
inset: Line