mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibWeb: Fallback to auto when aspect ratio is degenerate as per spec
When aspect-ratio is degenerate (e.g. 0/1 or 1/0) we should fallback to the same behaviour as `aspect-ratio: auto` according to spec This commit explicitly handles this case and fixes five WPT test in css/css-sizing/aspect-ratio (zero-or-infinity-[006-010])
This commit is contained in:
parent
20376adbc3
commit
c6f77f4818
Notes:
github-actions[bot]
2024-10-27 10:12:32 +00:00
Author: https://github.com/kkckkc 🔰
Commit: c6f77f4818
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1945
3 changed files with 22 additions and 1 deletions
|
@ -0,0 +1,10 @@
|
|||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x216 [BFC] children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 784x200 children: inline
|
||||
frag 0 from ImageBox start: 0, length: 0, rect: [8,8 200x200] baseline: 200
|
||||
ImageBox <img> at (8,8) content-size 200x200 children: not-inline
|
||||
|
||||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||
PaintableWithLines (BlockContainer<HTML>) [0,0 800x216]
|
||||
PaintableWithLines (BlockContainer<BODY>) [8,8 784x200]
|
||||
ImagePaintable (ImageBox<IMG>) [8,8 200x200]
|
|
@ -0,0 +1,6 @@
|
|||
<!doctype html><style>
|
||||
img {
|
||||
width: 200px;
|
||||
aspect-ratio: 0/1;
|
||||
}
|
||||
</style><img src="120.png"/>
|
|
@ -880,7 +880,12 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
} else if (aspect_ratio->is_keyword() && aspect_ratio->as_keyword().keyword() == CSS::Keyword::Auto) {
|
||||
computed_values.set_aspect_ratio({ true, {} });
|
||||
} else if (aspect_ratio->is_ratio()) {
|
||||
computed_values.set_aspect_ratio({ false, aspect_ratio->as_ratio().ratio() });
|
||||
// https://drafts.csswg.org/css-sizing-4/#aspect-ratio
|
||||
// If the <ratio> is degenerate, the property instead behaves as auto.
|
||||
if (aspect_ratio->as_ratio().ratio().is_degenerate())
|
||||
computed_values.set_aspect_ratio({ true, {} });
|
||||
else
|
||||
computed_values.set_aspect_ratio({ false, aspect_ratio->as_ratio().ratio() });
|
||||
}
|
||||
|
||||
auto math_shift_value = computed_style.property(CSS::PropertyID::MathShift);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue