1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 04:07:35 +00:00

LibWeb: Allow calc() in CSS position values

This commit is contained in:
Sam Atkins 2023-11-10 14:46:28 +00:00 committed by Alexander Kalenik
parent 1b0cc67a28
commit 19da17f07e
3 changed files with 15 additions and 4 deletions

View file

@ -2359,11 +2359,17 @@ RefPtr<PositionStyleValue> Parser::parse_position_value(TokenStream<ComponentVal
auto parse_length_percentage = [&](ComponentValue const& token) -> Optional<LengthPercentage> {
if (token.is(Token::Type::EndOfFile))
return {};
// FIXME: calc()!
auto dimension = parse_dimension(token);
if (!dimension.has_value() || !dimension->is_length_percentage())
if (auto dimension = parse_dimension(token); dimension.has_value()) {
if (dimension->is_length_percentage())
return dimension->length_percentage();
return {};
return dimension->length_percentage();
}
if (auto calc = parse_calculated_value(token); calc && calc->resolves_to_length_percentage())
return LengthPercentage { calc.release_nonnull() };
return {};
};
auto is_horizontal = [](PositionEdge edge, bool accept_center) -> bool {