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: https://github.com/LadybirdBrowser/ladybird/commit/ae906ca497 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/258
3 changed files with 24 additions and 2 deletions
|
@ -0,0 +1,12 @@
|
|||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x800 [BFC] children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 784x784 children: inline
|
||||
frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 784x784] baseline: 784
|
||||
SVGSVGBox <svg> at (8,8) content-size 784x784 [SVG] children: not-inline
|
||||
SVGGeometryBox <rect> at (8,8) content-size 392x392 children: not-inline
|
||||
|
||||
ViewportPaintable (Viewport<#document>) [0,0 800x600] overflow: [0,0 800x800]
|
||||
PaintableWithLines (BlockContainer<HTML>) [0,0 800x800]
|
||||
PaintableWithLines (BlockContainer<BODY>) [8,8 784x784]
|
||||
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 784x784]
|
||||
SVGPathPaintable (SVGGeometryBox<rect>) [8,8 392x392]
|
|
@ -0,0 +1,3 @@
|
|||
<!DOCTYPE html><style>
|
||||
svg { width: max-content; }
|
||||
</style><body><svg viewBox="0 0 24 24"><rect x=0 y=0 width=12 height=12></svg>
|
|
@ -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
Reference in a new issue