1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:57:44 +00:00

LibWeb: Adjust flex item main size through aspect ratio if needed

If there are min or max size constraints in the cross axis for a flex
item that has a desired aspect ratio, we may need to adjust the main
size *after* applying the cross size constraints.

All the steps to achieving this aren't mentioned in the spec, but it
seems that all other browsers behave this way, so we should too.
This commit is contained in:
Andreas Kling 2023-05-10 10:09:29 +02:00
parent f248f566b8
commit 0c26717ba3
4 changed files with 66 additions and 9 deletions

View file

@ -34,6 +34,9 @@ private:
[[nodiscard]] bool should_treat_main_size_as_auto(Box const&) const;
[[nodiscard]] bool should_treat_cross_size_as_auto(Box const&) const;
[[nodiscard]] CSSPixels adjust_main_size_through_aspect_ratio_for_cross_size_min_max_constraints(Box const&, CSSPixels main_size, CSS::Size const& min_cross_size, CSS::Size const& max_cross_size) const;
[[nodiscard]] CSSPixels calculate_main_size_from_cross_size_and_aspect_ratio(CSSPixels cross_size, float aspect_ratio) const;
void dump_items() const;
struct DirectionAgnosticMargins {