mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-25 19:56:30 +00:00
LibWeb: Account for natural aspect ratio in calculate_min_content_height
By the time we calculate the min-content height, the width is already known, so we can use it to calculate the height based on the natural aspect ratio.
This commit is contained in:
parent
44d2e22b93
commit
8d9920af16
Notes:
github-actions[bot]
2025-07-08 20:36:08 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 8d9920af16
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5358
Reviewed-by: https://github.com/awesomekling ✅
4 changed files with 29 additions and 5 deletions
|
@ -1513,8 +1513,11 @@ CSSPixels FormattingContext::calculate_min_content_height(Layout::Box const& box
|
||||||
if (box.is_block_container() || box.display().is_table_inside())
|
if (box.is_block_container() || box.display().is_table_inside())
|
||||||
return calculate_max_content_height(box, width);
|
return calculate_max_content_height(box, width);
|
||||||
|
|
||||||
if (box.has_natural_height())
|
if (box.has_natural_height()) {
|
||||||
|
if (box.has_natural_aspect_ratio())
|
||||||
|
return width / *box.natural_aspect_ratio();
|
||||||
return *box.natural_height();
|
return *box.natural_height();
|
||||||
|
}
|
||||||
|
|
||||||
auto& cache = box.cached_intrinsic_sizes().min_content_height.ensure(width);
|
auto& cache = box.cached_intrinsic_sizes().min_content_height.ensure(width);
|
||||||
if (cache.has_value())
|
if (cache.has_value())
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
|
BlockContainer <html> at (0,0) content-size 800x66 [BFC] children: not-inline
|
||||||
|
Box <body> at (8,8) content-size 50x50 [GFC] children: not-inline
|
||||||
|
ImageBox <img> at (8,8) content-size 50x50 children: not-inline
|
||||||
|
|
||||||
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<HTML>) [0,0 800x66]
|
||||||
|
PaintableBox (Box<BODY>) [8,8 50x50]
|
||||||
|
ImagePaintable (ImageBox<IMG>) [8,8 50x50]
|
|
@ -0,0 +1,12 @@
|
||||||
|
<!doctype html><style>
|
||||||
|
body {
|
||||||
|
display: grid;
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
grid-area: 1 / 1;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style><body><img src="../../../Assets/120.png">
|
|
@ -2,15 +2,15 @@ Harness status: OK
|
||||||
|
|
||||||
Found 10 tests
|
Found 10 tests
|
||||||
|
|
||||||
7 Pass
|
9 Pass
|
||||||
3 Fail
|
1 Fail
|
||||||
Pass .flexbox 1
|
Pass .flexbox 1
|
||||||
Pass .flexbox 2
|
Pass .flexbox 2
|
||||||
Pass .flexbox 3
|
Pass .flexbox 3
|
||||||
Pass .flexbox 4
|
Pass .flexbox 4
|
||||||
Fail .flexbox 5
|
Fail .flexbox 5
|
||||||
Pass .flexbox 6
|
Pass .flexbox 6
|
||||||
Fail .flexbox 7
|
Pass .flexbox 7
|
||||||
Pass .flexbox 8
|
Pass .flexbox 8
|
||||||
Pass .flexbox 9
|
Pass .flexbox 9
|
||||||
Fail .flexbox 10
|
Pass .flexbox 10
|
Loading…
Add table
Add a link
Reference in a new issue