mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +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:
parent
6df3f9920d
commit
b715943035
9 changed files with 60 additions and 72 deletions
|
@ -157,10 +157,10 @@ static Gfx::FloatSize solve_replaced_size_constraint(float w, float h, const Rep
|
|||
auto width_of_containing_block = CSS::Length::make_px(containing_block.content_width());
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.content_height());
|
||||
|
||||
auto specified_min_width = box.computed_values().min_width().has_value() ? box.computed_values().min_width()->resolved(box, width_of_containing_block).resolved(box).to_px(box) : 0;
|
||||
auto specified_max_width = box.computed_values().max_width().has_value() ? box.computed_values().max_width()->resolved(box, width_of_containing_block).resolved(box).to_px(box) : w;
|
||||
auto specified_min_height = box.computed_values().min_height().has_value() ? box.computed_values().min_height()->resolved(box, height_of_containing_block).resolved(box).to_px(box) : 0;
|
||||
auto specified_max_height = box.computed_values().max_height().has_value() ? box.computed_values().max_height()->resolved(box, height_of_containing_block).resolved(box).to_px(box) : h;
|
||||
auto specified_min_width = box.computed_values().min_width().has_value() ? box.computed_values().min_width()->resolved(box, width_of_containing_block).to_px(box) : 0;
|
||||
auto specified_max_width = box.computed_values().max_width().has_value() ? box.computed_values().max_width()->resolved(box, width_of_containing_block).to_px(box) : w;
|
||||
auto specified_min_height = box.computed_values().min_height().has_value() ? box.computed_values().min_height()->resolved(box, height_of_containing_block).to_px(box) : 0;
|
||||
auto specified_max_height = box.computed_values().max_height().has_value() ? box.computed_values().max_height()->resolved(box, height_of_containing_block).to_px(box) : h;
|
||||
|
||||
auto min_width = min(specified_min_width, specified_max_width);
|
||||
auto max_width = max(specified_min_width, specified_max_width);
|
||||
|
@ -573,12 +573,12 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
|
|||
auto specified_max_height = computed_values.max_height().has_value() ? computed_values.max_height()->resolved(box, height_of_containing_block).resolved(box) : CSS::Length::make_auto();
|
||||
auto specified_min_height = computed_values.min_height().has_value() ? computed_values.min_height()->resolved(box, height_of_containing_block).resolved(box) : CSS::Length::make_auto();
|
||||
|
||||
box.box_model().margin.top = computed_values.margin().top.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
||||
box.box_model().margin.bottom = computed_values.margin().bottom.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
||||
box.box_model().margin.top = computed_values.margin().top.resolved(box, width_of_containing_block).to_px(box);
|
||||
box.box_model().margin.bottom = computed_values.margin().bottom.resolved(box, width_of_containing_block).to_px(box);
|
||||
box.box_model().border.top = computed_values.border_top().width;
|
||||
box.box_model().border.bottom = computed_values.border_bottom().width;
|
||||
box.box_model().padding.top = computed_values.padding().top.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
||||
box.box_model().padding.bottom = computed_values.padding().bottom.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
||||
box.box_model().padding.top = computed_values.padding().top.resolved(box, width_of_containing_block).to_px(box);
|
||||
box.box_model().padding.bottom = computed_values.padding().bottom.resolved(box, width_of_containing_block).to_px(box);
|
||||
|
||||
if (specified_height.is_auto() && !specified_top.is_auto() && specified_bottom.is_auto()) {
|
||||
const auto& margin = box.box_model().margin;
|
||||
|
@ -620,20 +620,20 @@ void FormattingContext::layout_absolutely_positioned_element(Box& box)
|
|||
auto independent_formatting_context = layout_inside(box, LayoutMode::Default);
|
||||
compute_height_for_absolutely_positioned_element(box);
|
||||
|
||||
box_model.margin.left = box.computed_values().margin().left.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
||||
box_model.margin.top = box.computed_values().margin().top.resolved(box, height_of_containing_block).resolved(box).to_px(box);
|
||||
box_model.margin.right = box.computed_values().margin().right.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
||||
box_model.margin.bottom = box.computed_values().margin().bottom.resolved(box, height_of_containing_block).resolved(box).to_px(box);
|
||||
box_model.margin.left = box.computed_values().margin().left.resolved(box, width_of_containing_block).to_px(box);
|
||||
box_model.margin.top = box.computed_values().margin().top.resolved(box, height_of_containing_block).to_px(box);
|
||||
box_model.margin.right = box.computed_values().margin().right.resolved(box, width_of_containing_block).to_px(box);
|
||||
box_model.margin.bottom = box.computed_values().margin().bottom.resolved(box, height_of_containing_block).to_px(box);
|
||||
|
||||
box_model.border.left = box.computed_values().border_left().width;
|
||||
box_model.border.right = box.computed_values().border_right().width;
|
||||
box_model.border.top = box.computed_values().border_top().width;
|
||||
box_model.border.bottom = box.computed_values().border_bottom().width;
|
||||
|
||||
box_model.offset.left = box.computed_values().offset().left.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
||||
box_model.offset.top = box.computed_values().offset().top.resolved(box, height_of_containing_block).resolved(box).to_px(box);
|
||||
box_model.offset.right = box.computed_values().offset().right.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
||||
box_model.offset.bottom = box.computed_values().offset().bottom.resolved(box, height_of_containing_block).resolved(box).to_px(box);
|
||||
box_model.offset.left = box.computed_values().offset().left.resolved(box, width_of_containing_block).to_px(box);
|
||||
box_model.offset.top = box.computed_values().offset().top.resolved(box, height_of_containing_block).to_px(box);
|
||||
box_model.offset.right = box.computed_values().offset().right.resolved(box, width_of_containing_block).to_px(box);
|
||||
box_model.offset.bottom = box.computed_values().offset().bottom.resolved(box, height_of_containing_block).to_px(box);
|
||||
|
||||
auto is_auto = [](auto const& length_percentage) {
|
||||
return length_percentage.is_length() && length_percentage.length().is_auto();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue