mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
LibWeb: Use parse_length_percentage() for border-radius parsing
This commit is contained in:
parent
30a11dc133
commit
8200fdeddc
1 changed files with 13 additions and 13 deletions
|
@ -3457,20 +3457,20 @@ RefPtr<StyleValue> Parser::parse_border_radius_value(TokenStream<ComponentValue>
|
||||||
{
|
{
|
||||||
if (tokens.remaining_token_count() == 2) {
|
if (tokens.remaining_token_count() == 2) {
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
auto horizontal = parse_dimension(tokens.next_token());
|
auto horizontal = parse_length_percentage(tokens);
|
||||||
auto vertical = parse_dimension(tokens.next_token());
|
auto vertical = parse_length_percentage(tokens);
|
||||||
if (horizontal.has_value() && horizontal->is_length_percentage() && vertical.has_value() && vertical->is_length_percentage()) {
|
if (horizontal.has_value() && vertical.has_value()) {
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
return BorderRadiusStyleValue::create(horizontal->length_percentage(), vertical->length_percentage());
|
return BorderRadiusStyleValue::create(horizontal.release_value(), vertical.release_value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokens.remaining_token_count() == 1) {
|
if (tokens.remaining_token_count() == 1) {
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
auto radius = parse_dimension(tokens.next_token());
|
auto radius = parse_length_percentage(tokens);
|
||||||
if (radius.has_value() && radius->is_length_percentage()) {
|
if (radius.has_value()) {
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
return BorderRadiusStyleValue::create(radius->length_percentage(), radius->length_percentage());
|
return BorderRadiusStyleValue::create(radius.value(), radius.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3524,22 +3524,22 @@ RefPtr<StyleValue> Parser::parse_border_radius_shorthand_value(TokenStream<Compo
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
|
|
||||||
while (tokens.has_next_token()) {
|
while (tokens.has_next_token()) {
|
||||||
auto& token = tokens.next_token();
|
if (tokens.peek_token().is_delim('/')) {
|
||||||
if (token.is_delim('/')) {
|
|
||||||
if (reading_vertical || horizontal_radii.is_empty())
|
if (reading_vertical || horizontal_radii.is_empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
reading_vertical = true;
|
reading_vertical = true;
|
||||||
|
(void)tokens.next_token(); // `/`
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto maybe_dimension = parse_dimension(token);
|
auto maybe_dimension = parse_length_percentage(tokens);
|
||||||
if (!maybe_dimension.has_value() || !maybe_dimension->is_length_percentage())
|
if (!maybe_dimension.has_value())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (reading_vertical) {
|
if (reading_vertical) {
|
||||||
vertical_radii.append(maybe_dimension->length_percentage());
|
vertical_radii.append(maybe_dimension.release_value());
|
||||||
} else {
|
} else {
|
||||||
horizontal_radii.append(maybe_dimension->length_percentage());
|
horizontal_radii.append(maybe_dimension.release_value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue