1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:27:35 +00:00

LibWeb: Don't re-resolve "auto" flex item sizes after definitizing them

This is rather subtle and points to our architecture around definite
sizes not being exactly right, but...

At some points during flexbox layout, the spec tells us that the sizes
of certain flex items are considered definite from this point on.
We implement this by marking each item's associated UsedValues as
"has-definite-width/height".

However, this breaks code that tries to resolve computed "auto" sizes
by taking the corresponding size from the containing block. The end
result was that the 1st sizing pass in flexbox would find the right size
for an "auto" sized item, but the 2nd pass would override the correct
size with the containing block's content size in that axis instead.

To work around the issue, FFC now remembers when it "definitizes" an
item, and future attempts to resolve an "auto" computed size for that
value will bypass the computed-auto-is-resolved-against-containing-block
step of the algorithm. It's not perfect, and we'll need to think more
about how to really represent these intermediate states relating to
box sizes being definite..
This commit is contained in:
Andreas Kling 2022-09-14 11:43:57 +02:00
parent b8aa6a4453
commit f25203f245
4 changed files with 45 additions and 23 deletions

View file

@ -62,6 +62,8 @@ private:
DirectionAgnosticMargins padding {};
bool is_min_violation { false };
bool is_max_violation { false };
bool has_assigned_definite_main_size { false };
bool has_assigned_definite_cross_size { false };
float add_main_margin_box_sizes(float content_size) const
{
@ -85,8 +87,8 @@ private:
bool has_definite_cross_size(Box const&) const;
float specified_main_size(Box const&) const;
float specified_cross_size(Box const&) const;
float resolved_definite_main_size(Box const&) const;
float resolved_definite_cross_size(Box const&) const;
float resolved_definite_main_size(FlexItem const&) const;
float resolved_definite_cross_size(FlexItem const&) const;
bool has_main_min_size(Box const&) const;
bool has_cross_min_size(Box const&) const;
float specified_main_max_size(Box const&) const;