mirror of
https://github.com/servo/servo.git
synced 2025-08-01 19:50:30 +01:00
Fix intrinsic sizing of block container containing a BFC root after floats (#30012)
A block that establishes an independent formatting context is placed next to previous floats, so we should add their sizes when computing the intrinsic contribution of the parent block container.
This commit is contained in:
parent
cf9ec700de
commit
727d61a99d
1 changed files with 16 additions and 17 deletions
|
@ -260,14 +260,14 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
|||
let size = sizing::outer_inline(&style, writing_mode, || {
|
||||
contents.inline_content_sizes(layout_context, style.writing_mode)
|
||||
});
|
||||
// The element may in fact have clearance, but the logic below ignores it,
|
||||
// so don't bother retrieving it from the style.
|
||||
Some((size, Float::None, Clear::None))
|
||||
// A block in the same BFC can overlap floats, it's not moved next to them,
|
||||
// so we shouldn't add its size to the size of the floats.
|
||||
// Instead, we treat it like an independent block with 'clear: both'.
|
||||
Some((size, Float::None, Clear::Both))
|
||||
},
|
||||
BlockLevelBox::Independent(ref mut independent) => {
|
||||
let size = independent.outer_inline_content_sizes(layout_context, writing_mode);
|
||||
// TODO: do the right thing instead of copying SameFormattingContextBlock.
|
||||
Some((size, Float::None, Clear::None))
|
||||
Some((size, Float::None, independent.style().get_box().clear))
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -308,18 +308,17 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
|||
}
|
||||
|
||||
let accumulate = |mut data: AccumulatedData, (size, float, clear)| {
|
||||
if float == Float::None {
|
||||
// TODO: The first BFC root after a sequence of floats should appear next to them
|
||||
// (if it doesn't have clearance).
|
||||
data.clear_floats(Clear::Both);
|
||||
data.max_size = data.max_size.max(size);
|
||||
} else {
|
||||
data.clear_floats(clear);
|
||||
match float {
|
||||
Float::Left => data.left_floats = data.left_floats.add(&size),
|
||||
Float::Right => data.right_floats = data.right_floats.add(&size),
|
||||
Float::None => unreachable!(),
|
||||
}
|
||||
data.clear_floats(clear);
|
||||
match float {
|
||||
Float::Left => data.left_floats = data.left_floats.add(&size),
|
||||
Float::Right => data.right_floats = data.right_floats.add(&size),
|
||||
Float::None => {
|
||||
data.max_size = data
|
||||
.max_size
|
||||
.max(data.left_floats.add(&data.right_floats).add(&size));
|
||||
data.left_floats = ContentSizes::zero();
|
||||
data.right_floats = ContentSizes::zero();
|
||||
},
|
||||
}
|
||||
data
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue