mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:57:44 +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
|
@ -88,22 +88,14 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
|||
width = image.width();
|
||||
height = image.height();
|
||||
} else if (x_is_auto) {
|
||||
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height()))
|
||||
.resolved(layout_node)
|
||||
.to_px(layout_node);
|
||||
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height())).to_px(layout_node);
|
||||
width = roundf(image.width() * ((float)height / (float)image.height()));
|
||||
} else if (y_is_auto) {
|
||||
width = layer.size_x.resolved(layout_node, CSS::Length::make_px(background_positioning_area.width()))
|
||||
.resolved(layout_node)
|
||||
.to_px(layout_node);
|
||||
width = layer.size_x.resolved(layout_node, CSS::Length::make_px(background_positioning_area.width())).to_px(layout_node);
|
||||
height = roundf(image.height() * ((float)width / (float)image.width()));
|
||||
} else {
|
||||
width = layer.size_x.resolved(layout_node, CSS::Length::make_px(background_positioning_area.width()))
|
||||
.resolved(layout_node)
|
||||
.to_px(layout_node);
|
||||
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height()))
|
||||
.resolved(layout_node)
|
||||
.to_px(layout_node);
|
||||
width = layer.size_x.resolved(layout_node, CSS::Length::make_px(background_positioning_area.width())).to_px(layout_node);
|
||||
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height())).to_px(layout_node);
|
||||
}
|
||||
|
||||
image_rect.set_size(width, height);
|
||||
|
@ -143,18 +135,14 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
|||
int space_y = background_positioning_area.height() - image_rect.height();
|
||||
|
||||
// Position
|
||||
int offset_x = layer.position_offset_x.resolved(layout_node, CSS::Length::make_px(space_x))
|
||||
.resolved(layout_node)
|
||||
.to_px(layout_node);
|
||||
int offset_x = layer.position_offset_x.resolved(layout_node, CSS::Length::make_px(space_x)).to_px(layout_node);
|
||||
if (layer.position_edge_x == CSS::PositionEdge::Right) {
|
||||
image_rect.set_right_without_resize(background_positioning_area.right() - offset_x);
|
||||
} else {
|
||||
image_rect.set_left(background_positioning_area.left() + offset_x);
|
||||
}
|
||||
|
||||
int offset_y = layer.position_offset_y.resolved(layout_node, CSS::Length::make_px(space_y))
|
||||
.resolved(layout_node)
|
||||
.to_px(layout_node);
|
||||
int offset_y = layer.position_offset_y.resolved(layout_node, CSS::Length::make_px(space_y)).to_px(layout_node);
|
||||
if (layer.position_edge_y == CSS::PositionEdge::Bottom) {
|
||||
image_rect.set_bottom_without_resize(background_positioning_area.bottom() - offset_y);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue