mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibWeb: Fix calculating the intrinsic height of a box
For computing height in FormattingContext::calculate_intrinsic_sizes we were calling into BlockFormattingContext::compute_theoretical_height which will check if the CSS height property was defined and calculate the height based on that instead of calculating the intrinsic height This patch adds a new function calculate_intrinsic_height, which will call into compute_auto_height_for_block_level_element for a block element, or into compute_height_for_replaced_element for a replaced element.
This commit is contained in:
parent
b526a10d76
commit
74d8e201eb
2 changed files with 12 additions and 2 deletions
|
@ -817,7 +817,7 @@ FormattingState::IntrinsicSizes FormattingContext::calculate_intrinsic_sizes(Lay
|
|||
|
||||
independent_formatting_context->run(box, LayoutMode::MaxContent);
|
||||
cached_box_sizes.max_content_size.set_width(independent_formatting_context->greatest_child_width(box));
|
||||
cached_box_sizes.max_content_size.set_height(BlockFormattingContext::compute_theoretical_height(throwaway_state, box));
|
||||
cached_box_sizes.max_content_size.set_height(compute_intrinsic_height(throwaway_state, box));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -829,7 +829,7 @@ FormattingState::IntrinsicSizes FormattingContext::calculate_intrinsic_sizes(Lay
|
|||
VERIFY(independent_formatting_context);
|
||||
independent_formatting_context->run(box, LayoutMode::MinContent);
|
||||
cached_box_sizes.min_content_size.set_width(independent_formatting_context->greatest_child_width(box));
|
||||
cached_box_sizes.min_content_size.set_height(BlockFormattingContext::compute_theoretical_height(throwaway_state, box));
|
||||
cached_box_sizes.min_content_size.set_height(compute_intrinsic_height(throwaway_state, box));
|
||||
}
|
||||
|
||||
if (cached_box_sizes.min_content_size.width() > cached_box_sizes.max_content_size.width()) {
|
||||
|
@ -888,4 +888,13 @@ float FormattingContext::calculate_fit_content_height(Layout::Box const& box, Op
|
|||
auto [min_content_size, max_content_size] = calculate_min_and_max_content_height(box);
|
||||
return calculate_fit_content_size(min_content_size, max_content_size, available_space);
|
||||
}
|
||||
|
||||
float FormattingContext::compute_intrinsic_height(FormattingState const& state, Box const& box)
|
||||
{
|
||||
if (is<ReplacedBox>(box)) {
|
||||
return compute_height_for_replaced_element(state, verify_cast<ReplacedBox>(box));
|
||||
}
|
||||
|
||||
return compute_auto_height_for_block_level_element(state, box);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue