mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:48:14 +00:00
LibWeb: Allow percentage tokens again when parsing calc()
I unintentionally broke this in my LengthPercentage PR, but it was not convenient to fix until now.
This commit is contained in:
parent
ce0de4b2b4
commit
b54cd17c1e
3 changed files with 15 additions and 5 deletions
|
@ -4210,10 +4210,16 @@ Optional<CalculatedStyleValue::CalcValue> Parser::parse_calc_value(TokenStream<S
|
|||
return CalculatedStyleValue::CalcValue { static_cast<float>(current_token.token().number_value()) };
|
||||
|
||||
if (current_token.is(Token::Type::Dimension) || current_token.is(Token::Type::Percentage)) {
|
||||
auto maybe_length = parse_length(current_token);
|
||||
if (maybe_length.has_value() && !maybe_length.value().is_undefined())
|
||||
return CalculatedStyleValue::CalcValue { maybe_length.value() };
|
||||
return {};
|
||||
auto maybe_dimension = parse_dimension(current_token);
|
||||
if (!maybe_dimension.has_value())
|
||||
return {};
|
||||
auto& dimension = maybe_dimension.value();
|
||||
|
||||
if (dimension.is_length())
|
||||
return CalculatedStyleValue::CalcValue { dimension.length() };
|
||||
if (dimension.is_percentage())
|
||||
return CalculatedStyleValue::CalcValue { dimension.percentage() };
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue