1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:37:34 +00:00

LibWeb: Remove fallback value from Length::resolved()

Nobody makes undefined Lengths now, (although actually removing
Undefined will come in a later commit) so we can remove this parameter,
and `resolved_or_auto()`/`resolved_or_zero()`.
This commit is contained in:
Sam Atkins 2022-02-18 16:17:27 +00:00 committed by Andreas Kling
parent 5b2482a939
commit 67066c5140
11 changed files with 106 additions and 120 deletions

View file

@ -89,20 +89,20 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
height = image.height();
} else if (x_is_auto) {
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height()))
.resolved_or_zero(layout_node)
.resolved(layout_node)
.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_or_zero(layout_node)
.resolved(layout_node)
.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_or_zero(layout_node)
.resolved(layout_node)
.to_px(layout_node);
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height()))
.resolved_or_zero(layout_node)
.resolved(layout_node)
.to_px(layout_node);
}
@ -144,7 +144,7 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
// Position
int offset_x = layer.position_offset_x.resolved(layout_node, CSS::Length::make_px(space_x))
.resolved_or_zero(layout_node)
.resolved(layout_node)
.to_px(layout_node);
if (layer.position_edge_x == CSS::PositionEdge::Right) {
image_rect.set_right_without_resize(background_positioning_area.right() - offset_x);
@ -153,7 +153,7 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
}
int offset_y = layer.position_offset_y.resolved(layout_node, CSS::Length::make_px(space_y))
.resolved_or_zero(layout_node)
.resolved(layout_node)
.to_px(layout_node);
if (layer.position_edge_y == CSS::PositionEdge::Bottom) {
image_rect.set_bottom_without_resize(background_positioning_area.bottom() - offset_y);

View file

@ -17,10 +17,10 @@ BorderRadiusData normalized_border_radius_data(Layout::Node const& node, Gfx::Fl
// Spec just says "Refer to corresponding dimension of the border box."
// For now, all relative values are relative to the width.
auto width_length = CSS::Length::make_px(rect.width());
auto bottom_left_radius_px = bottom_left_radius.resolved(node, width_length).resolved_or_zero(node).to_px(node);
auto bottom_right_radius_px = bottom_right_radius.resolved(node, width_length).resolved_or_zero(node).to_px(node);
auto top_left_radius_px = top_left_radius.resolved(node, width_length).resolved_or_zero(node).to_px(node);
auto top_right_radius_px = top_right_radius.resolved(node, width_length).resolved_or_zero(node).to_px(node);
auto bottom_left_radius_px = bottom_left_radius.resolved(node, width_length).resolved(node).to_px(node);
auto bottom_right_radius_px = bottom_right_radius.resolved(node, width_length).resolved(node).to_px(node);
auto top_left_radius_px = top_left_radius.resolved(node, width_length).resolved(node).to_px(node);
auto top_right_radius_px = top_right_radius.resolved(node, width_length).resolved(node).to_px(node);
// Scale overlapping curves according to https://www.w3.org/TR/css-backgrounds-3/#corner-overlap
auto f = 1.0f;