mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-26 20:26:53 +00:00
LibWeb: Avoid an infinite recursion in replaced element sizing
In the case where we had a preferred aspect ratio and a natural height but no natural width, we'd get into ping-ponging infinite recursion by trying to find the width to resolve the height to resolve the width to resolve the height...
This commit is contained in:
parent
d0149d8fc0
commit
d3ee49b092
Notes:
github-actions[bot]
2024-11-23 15:41:30 +00:00
Author: https://github.com/awesomekling
Commit: d3ee49b092
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2523
5 changed files with 700 additions and 1 deletions
|
@ -645,7 +645,10 @@ CSSPixels FormattingContext::compute_height_for_replaced_element(Box const& box,
|
|||
// use the algorithm under 'Minimum and maximum widths'
|
||||
// https://www.w3.org/TR/CSS22/visudet.html#min-max-widths
|
||||
// to find the used width and height.
|
||||
if (computed_width.is_auto() && computed_height.is_auto() && box.has_preferred_aspect_ratio()) {
|
||||
if ((computed_width.is_auto() && computed_height.is_auto() && box.has_preferred_aspect_ratio())
|
||||
// NOTE: This is a special case where calling tentative_width_for_replaced_element() would call us right back,
|
||||
// and we'd end up in an infinite loop. So we need to handle this case separately.
|
||||
&& !(!box.has_natural_width() && box.has_natural_height())) {
|
||||
CSSPixels w = tentative_width_for_replaced_element(box, computed_width, available_space);
|
||||
CSSPixels h = used_height;
|
||||
used_height = solve_replaced_size_constraint(w, h, box, available_space).height();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue