Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions float-pigment-forest/tests/custom/css_margin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ fn margin_collapse_1() {
)
}

#[test]
fn margin_collapse_empty_inline_nodes() {
assert_xml!(
r#"
<div style="height: 800px;">
<div style="height: 100px; margin-bottom: 50px;"></div>
<div style="display: inline; height: 0;"></div>
<div style="margin-top: 40px;" expect_top="150"></div>
</div>
"#
)
}

#[test]
fn margin_collapse_negative() {
assert_xml!(
Expand Down
14 changes: 8 additions & 6 deletions float-pigment-layout/src/algo/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,17 +674,19 @@ impl<T: LayoutTreeNode> Flow<T> for LayoutUnit<T> {
request.kind == ComputeRequestKind::Position,
);

if let Some((prev_collapsed_margin, prev_collapsed_through)) =
prev_sibling_collapsed_margin
{
if !prev_collapsed_through {
total_main_size += prev_collapsed_margin.solve();
if block_size.main_size(axis_info.dir) > T::Length::zero() {
if let Some((prev_collapsed_margin, prev_collapsed_through)) =
prev_sibling_collapsed_margin
{
if !prev_collapsed_through {
total_main_size += prev_collapsed_margin.solve();
}
}
prev_sibling_collapsed_margin.replace((CollapsedMargin::zero(), false));
}
let main_offset = padding_border
.main_axis_start(axis_info.dir, axis_info.main_dir_rev)
+ total_main_size;
prev_sibling_collapsed_margin.replace((CollapsedMargin::zero(), false));

total_main_size += block_size.main_size(axis_info.dir);
max_cross_size = max_cross_size.max(block_size.cross_size(axis_info.dir));
Expand Down
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "1.81.0"
components = [ "rustfmt", "clippy" ]
profile = "minimal"
Loading