summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-07-17 19:40:02 +0200
committerAndreas Kling <kling@serenityos.org>2022-07-21 01:46:26 +0200
commit237fbe4d54b083a79b5fcf05b9b464acefa44e6f (patch)
treeeb2a1027fae29c97baa50e590c6da9c7d4608cc8 /Userland/Libraries/LibWeb/Layout
parentb7003194d2cce2b75eb0860af9445a0b176b8abf (diff)
downloadserenity-237fbe4d54b083a79b5fcf05b9b464acefa44e6f.zip
LibWeb: Remember the used flex basis for each flex item
This will be consulted later on in the flex layout algorithm.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout')
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp12
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h1
2 files changed, 7 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index 9b8d7a13f8..432152e99c 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -568,11 +568,11 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
auto& child_box = flex_item.box;
flex_item.flex_base_size = [&] {
- auto used_flex_basis = used_flex_basis_for_item(flex_item);
+ flex_item.used_flex_basis = used_flex_basis_for_item(flex_item);
// A. If the item has a definite used flex basis, that’s the flex base size.
- if (used_flex_basis.is_definite()) {
- return get_pixel_size(m_state, child_box, used_flex_basis.length_percentage.value());
+ if (flex_item.used_flex_basis.is_definite()) {
+ return get_pixel_size(m_state, child_box, flex_item.used_flex_basis.length_percentage.value());
}
// B. If the flex item has ...
@@ -580,7 +580,7 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
// - a used flex basis of content, and
// - a definite cross size,
if (flex_item.box.has_intrinsic_aspect_ratio()
- && used_flex_basis.type == CSS::FlexBasis::Content
+ && flex_item.used_flex_basis.type == CSS::FlexBasis::Content
&& has_definite_cross_size(flex_item.box)) {
// flex_base_size is calculated from definite cross size and intrinsic aspect ratio
return resolved_definite_cross_size(flex_item.box) * flex_item.box.intrinsic_aspect_ratio().value();
@@ -591,7 +591,7 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
// (e.g. when performing automatic table layout [CSS21]), size the item under that constraint.
// The flex base size is the item’s resulting main size.
auto flex_container_main_size_constraint = is_row_layout() ? m_flex_container_state.width_constraint : m_flex_container_state.height_constraint;
- if (used_flex_basis.type == CSS::FlexBasis::Content && flex_container_main_size_constraint != SizeConstraint::None) {
+ if (flex_item.used_flex_basis.type == CSS::FlexBasis::Content && flex_container_main_size_constraint != SizeConstraint::None) {
if (flex_container_main_size_constraint == SizeConstraint::MinContent)
return calculate_min_content_main_size(flex_item);
return calculate_max_content_main_size(flex_item);
@@ -601,7 +601,7 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
// the available main size is infinite, and the flex item’s inline axis is parallel to the main axis,
// lay the item out using the rules for a box in an orthogonal flow [CSS3-WRITING-MODES].
// The flex base size is the item’s max-content main size.
- if (used_flex_basis.type == CSS::FlexBasis::Content
+ if (flex_item.used_flex_basis.type == CSS::FlexBasis::Content
// FIXME: && main_size is infinite && inline axis is parallel to the main axis
&& false && false) {
TODO();
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h
index 0d23e36ecd..b5c950bbd1 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h
@@ -42,6 +42,7 @@ private:
struct FlexItem {
Box& box;
+ CSS::FlexBasisData used_flex_basis {};
float flex_base_size { 0 };
float hypothetical_main_size { 0 };
float hypothetical_cross_size { 0 };