mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 20:16:02 +00:00
LibWeb: Treat width: {min,max,fit}-content as auto if ratio unresolvable
This appears to match other engines.
This commit is contained in:
parent
db1faef786
commit
ae906ca497
Notes:
sideshowbarker
2024-07-16 20:21:48 +09:00
Author: https://github.com/awesomekling
Commit: ae906ca497
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/258
3 changed files with 24 additions and 2 deletions
|
@ -1767,14 +1767,21 @@ CSSPixels FormattingContext::calculate_stretch_fit_height(Box const& box, Availa
|
|||
|
||||
bool FormattingContext::should_treat_width_as_auto(Box const& box, AvailableSpace const& available_space)
|
||||
{
|
||||
if (box.computed_values().width().is_auto())
|
||||
auto const& computed_width = box.computed_values().width();
|
||||
if (computed_width.is_auto())
|
||||
return true;
|
||||
if (box.computed_values().width().contains_percentage()) {
|
||||
if (computed_width.contains_percentage()) {
|
||||
if (available_space.width.is_max_content())
|
||||
return true;
|
||||
if (available_space.width.is_indefinite())
|
||||
return true;
|
||||
}
|
||||
// AD-HOC: If the box has a preferred aspect ratio and no natural height,
|
||||
// we treat the width as auto, since it can't be resolved through the ratio.
|
||||
if (computed_width.is_min_content() || computed_width.is_max_content() || computed_width.is_fit_content()) {
|
||||
if (box.has_preferred_aspect_ratio() && !box.has_natural_height())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue