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

LibWeb: Convert flex-basis to LengthPercentage

The flexbox logic confuses me so regressions are possible, though our
test page looks the same as before so it should be fine.

Renamed FlexBasis::Length -> LengthPercentage too, for clarity.
This commit is contained in:
Sam Atkins 2022-01-19 11:52:01 +00:00 committed by Andreas Kling
parent 784ba2ec42
commit cb0cce5cdc
5 changed files with 29 additions and 15 deletions

View file

@ -17,9 +17,12 @@
namespace Web::Layout {
static float get_pixel_size(Box const& box, CSS::Length const& length)
static float get_pixel_size(Box const& box, CSS::LengthPercentage const& length_percentage)
{
return length.resolved(CSS::Length::make_px(0), box, box.containing_block()->width()).to_px(box);
auto inner_main_size = CSS::Length::make_px(box.containing_block()->width());
return length_percentage.resolved(inner_main_size)
.resolved(CSS::Length::make_px(0), box, box.containing_block()->width())
.to_px(box);
}
FlexFormattingContext::FlexFormattingContext(Box& flex_container, FormattingContext* parent)
@ -461,7 +464,7 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
// A. If the item has a definite used flex basis, thats the flex base size.
if (used_flex_basis.is_definite()) {
auto specified_base_size = get_pixel_size(child_box, used_flex_basis.length);
auto specified_base_size = get_pixel_size(child_box, used_flex_basis.length_percentage.value());
if (specified_base_size == 0)
return calculated_main_size(flex_item.box);
return specified_base_size;