LibWeb: Use calculate_inner_width to compute min and max widths

Use calculate_inner_width that consider box-sizing in compute_width
to resolve min_width and max_width.
This commit is contained in:
Aliaksandr Kalenik 2022-11-23 22:18:04 +03:00 committed by Andreas Kling
parent 428db6e766
commit 7c00619e47
Notes: sideshowbarker 2024-07-17 04:11:20 +09:00

View File

@ -194,7 +194,7 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const&
// 2. The tentative used width is greater than 'max-width', the rules above are applied again,
// but this time using the computed value of 'max-width' as the computed value for 'width'.
if (!computed_values.max_width().is_none()) {
auto max_width = computed_values.max_width().resolved(box, width_of_containing_block_as_length_for_resolve).resolved(box);
auto max_width = calculate_inner_width(box, available_space.width, computed_values.max_width());
if (used_width.to_px(box) > max_width.to_px(box)) {
used_width = try_compute_width(max_width);
}
@ -203,7 +203,7 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const&
// 3. If the resulting width is smaller than 'min-width', the rules above are applied again,
// but this time using the value of 'min-width' as the computed value for 'width'.
if (!computed_values.min_width().is_auto()) {
auto min_width = computed_values.min_width().resolved(box, width_of_containing_block_as_length_for_resolve).resolved(box);
auto min_width = calculate_inner_width(box, available_space.width, computed_values.min_width());
if (used_width.to_px(box) < min_width.to_px(box)) {
used_width = try_compute_width(min_width);
}