LibWeb: Move FFC layout algorithm step 11 to a separate function

This commit is contained in:
Andreas Kling 2021-10-13 22:19:17 +02:00
parent 8f027b4792
commit 176f1ad214
2 changed files with 18 additions and 10 deletions

View file

@ -118,16 +118,7 @@ void FlexFormattingContext::run(Box& flex_container, LayoutMode)
// FIXME: This
// 11. Determine the used cross size of each flex item.
// FIXME: Get the alignment via "align-self" of the item (which accesses "align-items" of the parent if unset)
for (auto& flex_line : flex_lines) {
for (auto& flex_item : flex_line.items) {
if (is_cross_auto(flex_item->box) && flex_container.computed_values().align_items() == CSS::AlignItems::Stretch) {
flex_item->cross_size = flex_line.cross_size;
} else {
flex_item->cross_size = flex_item->hypothetical_cross_size;
}
}
}
determine_used_cross_size_of_each_flex_item(flex_container, flex_lines);
// 12. Distribute any remaining free space.
for (auto& flex_line : flex_lines) {
@ -938,4 +929,19 @@ void FlexFormattingContext::calculate_cross_size_of_each_flex_line(const Box& fl
}
}
// https://www.w3.org/TR/css-flexbox-1/#algo-stretch
void FlexFormattingContext::determine_used_cross_size_of_each_flex_item(Box const& flex_container, Vector<FlexLine>& flex_lines)
{
// FIXME: Get the alignment via "align-self" of the item (which accesses "align-items" of the parent if unset)
for (auto& flex_line : flex_lines) {
for (auto& flex_item : flex_line.items) {
if (is_cross_auto(flex_item->box) && flex_container.computed_values().align_items() == CSS::AlignItems::Stretch) {
flex_item->cross_size = flex_line.cross_size;
} else {
flex_item->cross_size = flex_item->hypothetical_cross_size;
}
}
}
}
}

View file

@ -70,6 +70,8 @@ private:
void calculate_cross_size_of_each_flex_line(Box const& flex_container, Vector<FlexLine>&, float cross_min_size, float cross_max_size);
void determine_used_cross_size_of_each_flex_item(Box const& flex_container, Vector<FlexLine>&);
bool is_row_layout() const { return m_flex_direction == CSS::FlexDirection::Row || m_flex_direction == CSS::FlexDirection::RowReverse; }
CSS::FlexDirection m_flex_direction {};