1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

LibWeb: Swap min-content and max-content intrinsic sizes if needed

I'm a little confused about intrinsic heights *really* work, and I'm
struggling to extract that information from the spec. In the meantime,
let's ensure that min-content is always smaller than (or equal to)
max-content so that other math works as expected.
This commit is contained in:
Andreas Kling 2022-03-12 18:29:36 +01:00
parent 4a14c4dae8
commit 2f3d7a7c36

View file

@ -846,6 +846,18 @@ FormattingState::IntrinsicSizes FormattingContext::calculate_intrinsic_sizes(Lay
cached_box_sizes.min_content_size.set_height(BlockFormattingContext::compute_theoretical_height(throwaway_state, box));
}
if (cached_box_sizes.min_content_size.width() > cached_box_sizes.max_content_size.width()) {
float tmp = cached_box_sizes.min_content_size.width();
cached_box_sizes.min_content_size.set_width(cached_box_sizes.max_content_size.width());
cached_box_sizes.max_content_size.set_width(tmp);
}
if (cached_box_sizes.min_content_size.height() > cached_box_sizes.max_content_size.height()) {
float tmp = cached_box_sizes.min_content_size.height();
cached_box_sizes.min_content_size.set_height(cached_box_sizes.max_content_size.height());
cached_box_sizes.max_content_size.set_height(tmp);
}
return cached_box_sizes;
}