1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

LibWeb: Add parsing for NumericStyleValue

This StyleValue can hold an arbitrary float value.
This commit is contained in:
Tobias Christiansen 2021-06-03 21:59:41 +02:00 committed by Ali Mohammad Pur
parent ae3e6510d6
commit af4d80af4d
2 changed files with 27 additions and 1 deletions

View file

@ -240,8 +240,12 @@ RefPtr<CSS::StyleValue> parse_css_value(const CSS::ParsingContext& context, cons
}
auto length = parse_length(context, string, is_bad_length);
if (is_bad_length)
if (is_bad_length) {
auto float_number = try_parse_float(string);
if (float_number.has_value())
return CSS::NumericStyleValue::create(float_number.value());
return nullptr;
}
if (!length.is_undefined())
return CSS::LengthStyleValue::create(length);