diff options
author | Tobias Christiansen <tobyase@serenityos.org> | 2021-09-18 13:45:31 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-18 15:50:47 +0200 |
commit | d10488575739d10bb82db892b9aba6157ed76ea2 (patch) | |
tree | 89d51bc12bbddd6172092cd0b495df7a4c23fe05 /Userland/Libraries/LibWeb/Layout | |
parent | ddb7402649057696719512880c86eb7b84d8c054 (diff) | |
download | serenity-d10488575739d10bb82db892b9aba6157ed76ea2.zip |
LibWeb: Flexbox: Assume Block when finding max main size of flex-column
This is a hack, but it seems to do quite okay.
What we should do is to find the largest size the Box could want in its
main axis. To do that we have to layout the Box according to the needed
LayoutMode. For flex-rows we do as requested and try to make the Box as
wide as we want.
However, for flex-columns we simply assume the Box is a Block and we
calculate their height according to this.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index 50a66d7a99..b4fda3ef5f 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -61,10 +61,12 @@ void FlexFormattingContext::run(Box& box, LayoutMode) return length.resolved(CSS::Length::make_px(0), box, box.containing_block()->width()).to_px(box); }; auto layout_for_maximum_main_size = [&](Box& box) { - if (is_row) + if (is_row) { layout_inside(box, LayoutMode::OnlyRequiredLineBreaks); - else - layout_inside(box, LayoutMode::AllPossibleLineBreaks); + return box.width(); + } else { + return BlockFormattingContext::compute_theoretical_height(box); + } }; auto containing_block_effective_main_size = [&is_row, &main_size_is_infinite](Box& box) { if (is_row) { @@ -330,11 +332,9 @@ void FlexFormattingContext::run(Box& box, LayoutMode) if (has_definite_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); + flex_item.flex_base_size = layout_for_maximum_main_size(child_box); } } - auto clamp_min = has_main_min_size(child_box) ? specified_main_min_size(child_box) : 0; |