Handle floats in BlockContainer::inline_content_sizes

Typically, block-level contents are stacked vertically, so this was just
taking the maximum size among all contents. However, floats can be
stacked horizontally, so we need to sum their sizes.
This commit is contained in:
Oriol Brufau 2023-06-14 23:26:34 +02:00
parent 47fb54fc54
commit 4ec6dd1783
4 changed files with 112 additions and 28 deletions

View file

@ -33,13 +33,20 @@ impl ContentSizes {
}
}
pub fn max(self, other: Self) -> Self {
pub fn max(&self, other: Self) -> Self {
Self {
min_content: self.min_content.max(other.min_content),
max_content: self.max_content.max(other.max_content),
}
}
pub fn add(&self, other: &Self) -> Self {
Self {
min_content: self.min_content.max(other.min_content),
max_content: self.max_content + other.max_content,
}
}
/// Relevant to outer intrinsic inline sizes, for percentages from padding and margin.
pub fn adjust_for_pbm_percentages(&mut self, percentages: Percentage) {
// " Note that this may yield an infinite result, but undefined results