mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
LibWeb: Use CSSPixelFraction
to represent aspect ratios
This allows us to retain perfect precision for aspect ratios derived from either the intrinsic sizes of replaced elements, or the `aspect-ratio` CSS property.
This commit is contained in:
parent
4fb209d25f
commit
34c5043cbe
22 changed files with 57 additions and 55 deletions
|
@ -87,12 +87,12 @@ Painting::PaintableBox const* Box::paintable_box() const
|
|||
return static_cast<Painting::PaintableBox const*>(Node::paintable());
|
||||
}
|
||||
|
||||
Optional<float> Box::preferred_aspect_ratio() const
|
||||
Optional<CSSPixelFraction> Box::preferred_aspect_ratio() const
|
||||
{
|
||||
auto computed_aspect_ratio = computed_values().aspect_ratio();
|
||||
if (computed_aspect_ratio.use_natural_aspect_ratio_if_available && natural_aspect_ratio().has_value())
|
||||
return natural_aspect_ratio();
|
||||
return computed_aspect_ratio.preferred_ratio.map([](CSS::Ratio const& ratio) { return static_cast<float>(ratio.value()); });
|
||||
return computed_aspect_ratio.preferred_ratio.map([](CSS::Ratio const& ratio) { return CSSPixelFraction(CSSPixels(ratio.numerator()), CSSPixels(ratio.denominator())); });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue