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

LibWeb: Flexbox: Resolve relative size of flex-items more correctly

This is still very much not the right thing to do, but at least
relatively sized flex-items get the right size.
This commit is contained in:
Tobias Christiansen 2021-09-14 22:34:13 +02:00 committed by Andreas Kling
parent 8e3fe80c06
commit 15b61ce143

View file

@ -90,6 +90,14 @@ void FlexFormattingContext::run(Box& box, LayoutMode)
? box.width()
: box.height();
};
auto specified_main_size_of_child_box = [&is_row, &specified_main_size](Box& box, Box& child_box) {
auto main_size_of_parent = specified_main_size(box);
if (is_row) {
return child_box.computed_values().width().resolved_or_zero(child_box, main_size_of_parent).to_px(child_box);
} else {
return child_box.computed_values().height().resolved_or_zero(child_box, main_size_of_parent).to_px(child_box);
}
};
auto specified_cross_size = [&is_row](Box& box) {
return is_row
? box.height()
@ -313,7 +321,7 @@ void FlexFormattingContext::run(Box& box, LayoutMode)
// FIXME: This is probably too naive.
// FIXME: Care about FlexBasis::Auto
if (has_definite_main_size(child_box)) {
flex_item.flex_base_size = specified_main_size(child_box);
flex_item.flex_base_size = specified_main_size_of_child_box(box, child_box);
} else {
layout_for_maximum_main_size(child_box);
flex_item.flex_base_size = calculated_main_size(child_box);