Skip to content

Commit 0dc0bf7

Browse files
committed
fix: empty inline nodes should not prevent margin collapse
1 parent e6d0b10 commit 0dc0bf7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

float-pigment-forest/tests/custom/css_margin.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ fn margin_collapse_1() {
8181
)
8282
}
8383

84+
#[test]
85+
fn margin_collapse_empty_inline_nodes() {
86+
assert_xml!(
87+
r#"
88+
<div style="height: 800px;">
89+
<div style="height: 100px; margin-bottom: 50px;"></div>
90+
<div style="display: inline; height: 0;"></div>
91+
<div style="margin-top: 40px;" expect_top="150"></div>
92+
</div>
93+
"#
94+
)
95+
}
96+
8497
#[test]
8598
fn margin_collapse_negative() {
8699
assert_xml!(

float-pigment-layout/src/algo/flow.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ pub(crate) fn is_empty_block<L: LengthNum>(
6969
padding_border_main_axis: L,
7070
min_main_size: L,
7171
node_inner_main_size: L,
72+
main_size: OptionNum<L>,
7273
) -> bool {
7374
if !padding_border_main_axis.is_zero()
7475
|| !min_main_size.is_zero()
7576
|| !node_inner_main_size.is_zero()
77+
|| (main_size.is_some() && !main_size.val().unwrap().is_zero())
7678
{
7779
return false;
7880
}
@@ -800,6 +802,7 @@ impl<T: LayoutTreeNode> Flow<T> for LayoutUnit<T> {
800802
padding_border.main_axis_sum(axis_info.dir),
801803
min_max_limit.min_main_size(axis_info.dir),
802804
total_main_size,
805+
request.size.main_size(axis_info.dir),
803806
) {
804807
collapsed_margin.collapsed_through = true;
805808
}

0 commit comments

Comments
 (0)