mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:27: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
|
@ -32,7 +32,7 @@ public:
|
|||
// https://www.w3.org/TR/css-images-3/#natural-dimensions
|
||||
Optional<CSSPixels> natural_width() const { return m_natural_width; }
|
||||
Optional<CSSPixels> natural_height() const { return m_natural_height; }
|
||||
Optional<float> natural_aspect_ratio() const { return m_natural_aspect_ratio; }
|
||||
Optional<CSSPixelFraction> natural_aspect_ratio() const { return m_natural_aspect_ratio; }
|
||||
|
||||
bool has_natural_width() const { return natural_width().has_value(); }
|
||||
bool has_natural_height() const { return natural_height().has_value(); }
|
||||
|
@ -40,10 +40,10 @@ public:
|
|||
|
||||
void set_natural_width(Optional<CSSPixels> width) { m_natural_width = width; }
|
||||
void set_natural_height(Optional<CSSPixels> height) { m_natural_height = height; }
|
||||
void set_natural_aspect_ratio(Optional<float> ratio) { m_natural_aspect_ratio = ratio; }
|
||||
void set_natural_aspect_ratio(Optional<CSSPixelFraction> ratio) { m_natural_aspect_ratio = ratio; }
|
||||
|
||||
// https://www.w3.org/TR/css-sizing-4/#preferred-aspect-ratio
|
||||
Optional<float> preferred_aspect_ratio() const;
|
||||
Optional<CSSPixelFraction> preferred_aspect_ratio() const;
|
||||
bool has_preferred_aspect_ratio() const { return preferred_aspect_ratio().has_value(); }
|
||||
|
||||
virtual ~Box() override;
|
||||
|
@ -65,7 +65,7 @@ private:
|
|||
|
||||
Optional<CSSPixels> m_natural_width;
|
||||
Optional<CSSPixels> m_natural_height;
|
||||
Optional<float> m_natural_aspect_ratio;
|
||||
Optional<CSSPixelFraction> m_natural_aspect_ratio;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue