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

LibWeb: Remove redundant Length::resolved() calls

Now that calc() is also resolved in to_px(), code in the form
`foo.resolved(bar).to_px(bar)` can be simplified to `foo.to_px(bar)`.
This commit is contained in:
Sam Atkins 2022-02-18 16:27:28 +00:00 committed by Andreas Kling
parent 6df3f9920d
commit b715943035
9 changed files with 60 additions and 72 deletions

View file

@ -22,7 +22,7 @@ static float get_pixel_size(Box const& box, Optional<CSS::LengthPercentage> cons
if (!length_percentage.has_value())
return 0;
auto inner_main_size = CSS::Length::make_px(box.containing_block()->content_width());
return length_percentage->resolved(box, inner_main_size).resolved(box).to_px(box);
return length_percentage->resolved(box, inner_main_size).to_px(box);
}
static bool is_undefined_or_auto(Optional<CSS::LengthPercentage> const& length_percentage)
@ -120,15 +120,15 @@ void FlexFormattingContext::populate_specified_margins(FlexItem& item, CSS::Flex
auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block);
// FIXME: This should also take reverse-ness into account
if (flex_direction == CSS::FlexDirection::Row || flex_direction == CSS::FlexDirection::RowReverse) {
item.margins.main_before = item.box.computed_values().margin().left.resolved(item.box, width_of_containing_block_as_length).resolved(item.box).to_px(item.box);
item.margins.main_after = item.box.computed_values().margin().right.resolved(item.box, width_of_containing_block_as_length).resolved(item.box).to_px(item.box);
item.margins.cross_before = item.box.computed_values().margin().top.resolved(item.box, width_of_containing_block_as_length).resolved(item.box).to_px(item.box);
item.margins.cross_after = item.box.computed_values().margin().bottom.resolved(item.box, width_of_containing_block_as_length).resolved(item.box).to_px(item.box);
item.margins.main_before = item.box.computed_values().margin().left.resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
item.margins.main_after = item.box.computed_values().margin().right.resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
item.margins.cross_before = item.box.computed_values().margin().top.resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
item.margins.cross_after = item.box.computed_values().margin().bottom.resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
} else {
item.margins.main_before = item.box.computed_values().margin().top.resolved(item.box, width_of_containing_block_as_length).resolved(item.box).to_px(item.box);
item.margins.main_after = item.box.computed_values().margin().bottom.resolved(item.box, width_of_containing_block_as_length).resolved(item.box).to_px(item.box);
item.margins.cross_before = item.box.computed_values().margin().left.resolved(item.box, width_of_containing_block_as_length).resolved(item.box).to_px(item.box);
item.margins.cross_after = item.box.computed_values().margin().right.resolved(item.box, width_of_containing_block_as_length).resolved(item.box).to_px(item.box);
item.margins.main_before = item.box.computed_values().margin().top.resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
item.margins.main_after = item.box.computed_values().margin().bottom.resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
item.margins.cross_before = item.box.computed_values().margin().left.resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
item.margins.cross_after = item.box.computed_values().margin().right.resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
}
};
@ -148,7 +148,7 @@ void FlexFormattingContext::generate_anonymous_flex_items()
auto& maybe_width = flex_container().computed_values().width();
if (maybe_width.has_value()) {
auto width = maybe_width->resolved(flex_container(), CSS::Length::make_px(container_width)).resolved(flex_container()).to_px(flex_container());
auto width = maybe_width->resolved(flex_container(), CSS::Length::make_px(container_width)).to_px(flex_container());
flex_container().set_content_width(width);
} else {
flex_container().set_content_width(0);
@ -161,7 +161,7 @@ void FlexFormattingContext::generate_anonymous_flex_items()
auto container_height = flex_container().containing_block()->content_height();
auto& maybe_height = flex_container().computed_values().height();
if (maybe_height.has_value()) {
auto height = maybe_height->resolved(flex_container(), CSS::Length::make_px(container_height)).resolved(flex_container()).to_px(flex_container());
auto height = maybe_height->resolved(flex_container(), CSS::Length::make_px(container_height)).to_px(flex_container());
flex_container().set_content_height(height);
} else {
flex_container().set_content_height(0);
@ -256,7 +256,7 @@ float FlexFormattingContext::specified_main_size_of_child_box(Box const& child_b
auto& value = is_row_layout() ? child_box.computed_values().width() : child_box.computed_values().height();
if (!value.has_value())
return 0;
return value->resolved(child_box, CSS::Length::make_px(main_size_of_parent)).resolved(child_box).to_px(child_box);
return value->resolved(child_box, CSS::Length::make_px(main_size_of_parent)).to_px(child_box);
}
float FlexFormattingContext::specified_main_min_size(Box const& box) const