1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +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

@ -3009,18 +3009,18 @@ RefPtr<StyleValue> Parser::parse_border_value(Vector<StyleComponentValueRule> co
RefPtr<StyleValue> Parser::parse_border_radius_value(Vector<StyleComponentValueRule> const& component_values)
{
if (component_values.size() == 2) {
auto horizontal = parse_length(component_values[0]);
auto vertical = parse_length(component_values[1]);
if (horizontal.has_value() && vertical.has_value())
return BorderRadiusStyleValue::create(horizontal.value(), vertical.value());
auto horizontal = parse_dimension(component_values[0]);
auto vertical = parse_dimension(component_values[1]);
if (horizontal.has_value() && horizontal->is_length_percentage() && vertical.has_value() && vertical->is_length_percentage())
return BorderRadiusStyleValue::create(horizontal->length_percentage(), vertical->length_percentage());
return nullptr;
}
if (component_values.size() == 1) {
auto radius = parse_length(component_values[0]);
if (radius.has_value())
return BorderRadiusStyleValue::create(radius.value(), radius.value());
auto radius = parse_dimension(component_values[0]);
if (radius.has_value() && radius->is_length_percentage())
return BorderRadiusStyleValue::create(radius->length_percentage(), radius->length_percentage());
return nullptr;
}