diff options
author | Andreas Kling <kling@serenityos.org> | 2022-10-15 09:26:30 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-10-15 14:01:54 +0200 |
commit | 869b322a8fdf56382162af08f85d60dadc647d1f (patch) | |
tree | 1f6b515decd297446df59ebe1b57d4b4bc59ac8f /Userland/Libraries/LibWeb/Layout/LayoutState.h | |
parent | 6bb738c1b3f0ad222bda6391e88872bc8298c32c (diff) | |
download | serenity-869b322a8fdf56382162af08f85d60dadc647d1f.zip |
LibWeb: Assign hypothetical flex item main sizes as temporary main size
This colors a bit outside the lines of the specification, but the spec
doesn't offer a proper explanation for how descendants of a flex item
are supposed to have access to the flex item's main size for purposes
of percentage resolution.
The approach I came up with here was to take the hypothetical main size
of each flex item, and assign it as a temporary main size. This allows
percentage resolution in descendants to work against the pre-flexing
main size of items. This seems to match how other engines behave,
although it feels somewhat dirty. If/when we learn more about this,
we can come up with something nicer.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/LayoutState.h')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/LayoutState.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/LayoutState.h b/Userland/Libraries/LibWeb/Layout/LayoutState.h index 9e79c0ce34..a85eae6e5e 100644 --- a/Userland/Libraries/LibWeb/Layout/LayoutState.h +++ b/Userland/Libraries/LibWeb/Layout/LayoutState.h @@ -53,6 +53,11 @@ struct LayoutState { void set_content_width(float); void set_content_height(float); + // NOTE: These are used by FlexFormattingContext to assign a temporary main size to items + // early on, so that descendants have something to resolve percentages against. + void set_temporary_content_width(float); + void set_temporary_content_height(float); + bool has_definite_width() const { return m_has_definite_width && width_constraint == SizeConstraint::None; } bool has_definite_height() const { return m_has_definite_height && height_constraint == SizeConstraint::None; } |