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

LibWeb: Convert border-radii from Length to LengthPercentage :^)

The visit_lengths() code is a bit awkward but we'll clean that up later.
This commit is contained in:
Sam Atkins 2022-01-14 20:49:06 +00:00 committed by Andreas Kling
parent 2a3abf09ff
commit f75e796909
5 changed files with 46 additions and 34 deletions

View file

@ -11,13 +11,16 @@
namespace Web::Painting {
BorderRadiusData normalized_border_radius_data(Layout::Node const& node, Gfx::FloatRect const& rect, CSS::Length top_left_radius, CSS::Length top_right_radius, CSS::Length bottom_right_radius, CSS::Length bottom_left_radius)
BorderRadiusData normalized_border_radius_data(Layout::Node const& node, Gfx::FloatRect const& rect, CSS::LengthPercentage top_left_radius, CSS::LengthPercentage top_right_radius, CSS::LengthPercentage bottom_right_radius, CSS::LengthPercentage bottom_left_radius)
{
// FIXME: some values should be relative to the height() if specified, but which? For now, all relative values are relative to the width.
auto bottom_left_radius_px = bottom_left_radius.resolved_or_zero(node, rect.width()).to_px(node);
auto bottom_right_radius_px = bottom_right_radius.resolved_or_zero(node, rect.width()).to_px(node);
auto top_left_radius_px = top_left_radius.resolved_or_zero(node, rect.width()).to_px(node);
auto top_right_radius_px = top_right_radius.resolved_or_zero(node, rect.width()).to_px(node);
// FIXME: Some values should be relative to the height() if specified, but which?
// 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(width_length).resolved_or_zero(node, rect.width()).to_px(node);
auto bottom_right_radius_px = bottom_right_radius.resolved(width_length).resolved_or_zero(node, rect.width()).to_px(node);
auto top_left_radius_px = top_left_radius.resolved(width_length).resolved_or_zero(node, rect.width()).to_px(node);
auto top_right_radius_px = top_right_radius.resolved(width_length).resolved_or_zero(node, rect.width()).to_px(node);
// Scale overlapping curves according to https://www.w3.org/TR/css-backgrounds-3/#corner-overlap
auto f = 1.0f;