1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

LibWeb: Enforce min/max height constraints on abspos replaced boxes

Fixes #18658
This commit is contained in:
Andreas Kling 2023-05-06 20:51:56 +02:00
parent 36ff6187f6
commit fc3c3aef22
3 changed files with 24 additions and 4 deletions

View file

@ -0,0 +1,4 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x16 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x0 children: not-inline
ImageBox <img#zero-dimensions-but-min-percentages> at (8,8) content-size 800x600 positioned children: not-inline

View file

@ -0,0 +1,9 @@
<!DOCTYPE html><html><head><style>
#zero-dimensions-but-min-percentages {
width: 0;
height: 0;
min-width: 100%;
min-height: 100%;
position: absolute;
}
</style><body><img id="zero-dimensions-but-min-percentages">

View file

@ -497,8 +497,7 @@ CSSPixels FormattingContext::compute_height_for_replaced_element(LayoutState con
// 10.6.2 Inline replaced elements, block-level replaced elements in normal flow,
// 'inline-block' replaced elements in normal flow and floating replaced elements
auto width_of_containing_block_as_length = CSS::Length::make_px(available_space.width.to_px());
auto height_of_containing_block_as_length = CSS::Length::make_px(available_space.height.to_px());
auto height_of_containing_block = state.get(*box.containing_block()).content_height();
auto computed_width = should_treat_width_as_auto(box, available_space) ? CSS::Size::make_auto() : box.computed_values().width();
auto computed_height = should_treat_height_as_auto(box, available_space) ? CSS::Size::make_auto() : box.computed_values().height();
@ -510,6 +509,14 @@ CSSPixels FormattingContext::compute_height_for_replaced_element(LayoutState con
used_height = solve_replaced_size_constraint(state, w, h, box).height();
}
auto const& computed_min_height = box.computed_values().min_height();
auto const& computed_max_height = box.computed_values().max_height();
if (!computed_max_height.is_none())
used_height = min(used_height, computed_max_height.to_px(box, height_of_containing_block));
if (!computed_min_height.is_auto())
used_height = max(used_height, computed_min_height.to_px(box, height_of_containing_block));
return used_height;
}
@ -1310,9 +1317,9 @@ CSS::Length FormattingContext::calculate_inner_width(Layout::Box const& box, Ava
return width.resolved(box, width_of_containing_block_as_length_for_resolve);
}
CSS::Length FormattingContext::calculate_inner_height(Layout::Box const& box, AvailableSize const& available_height, CSS::Size const& height) const
CSS::Length FormattingContext::calculate_inner_height(Layout::Box const& box, AvailableSize const&, CSS::Size const& height) const
{
auto height_of_containing_block = available_height.to_px();
auto height_of_containing_block = m_state.get(*box.containing_block()).content_height();
auto height_of_containing_block_as_length_for_resolve = CSS::Length::make_px(height_of_containing_block);
if (height.is_auto()) {
return height.resolved(box, height_of_containing_block_as_length_for_resolve);