diff --git a/Tests/LibWeb/Layout/expected/replaced-within-max-content.txt b/Tests/LibWeb/Layout/expected/replaced-within-max-content.txt new file mode 100644 index 00000000000..18829a016a0 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/replaced-within-max-content.txt @@ -0,0 +1,21 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x166 [BFC] children: not-inline + BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline + TextNode <#text> + BlockContainer at (8,8) content-size 784x150 children: not-inline + BlockContainer at (8,8) content-size 150x150 children: inline + line 0 width: 150, height: 150, bottom: 150, baseline: 150 + frag 0 from ImageBox start: 0, length: 0, rect: [8,8 150x150] + ImageBox at (8,8) content-size 150x150 children: not-inline + (SVG-as-image isolated context) + Viewport <#document> at (0,0) content-size 150x150 children: inline + SVGSVGBox at (0,0) content-size 150x150 [SVG] children: not-inline + SVGGeometryBox at (0,0) content-size 150x150 children: not-inline + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x166] + PaintableWithLines (BlockContainer(anonymous)) [0,0 800x0] + PaintableWithLines (BlockContainer) [8,8 784x150] + PaintableWithLines (BlockContainer
.container) [8,8 150x150] + ImagePaintable (ImageBox.replaced) [8,8 150x150] diff --git a/Tests/LibWeb/Layout/input/replaced-within-max-content.html b/Tests/LibWeb/Layout/input/replaced-within-max-content.html new file mode 100644 index 00000000000..80536c32dde --- /dev/null +++ b/Tests/LibWeb/Layout/input/replaced-within-max-content.html @@ -0,0 +1,15 @@ + + + + + +
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index 6fcb9a1474a..168c0bf4b49 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -274,7 +274,7 @@ CSSPixelSize FormattingContext::solve_replaced_size_constraint(CSSPixels input_w auto specified_max_height = should_treat_max_height_as_none(box, available_space.height) ? input_height : box.computed_values().max_height().to_px(box, height_of_containing_block); auto max_height = max(min_height, specified_max_height); - auto aspect_ratio = input_width / input_height; + CSSPixelFraction aspect_ratio = *box.preferred_aspect_ratio(); // These are from the "Constraint Violation" table in spec, but reordered so that each condition is // interpreted as mutually exclusive to any other.