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

LibWeb: Allow LengthPercentage to hold a calculated value

Most of the time, we cannot resolve a `calc()` expression until we go to
use it. Since any `<length-percentage>` can legally be a `calc
()`, let's store it in `LengthPercentage` rather than make every single
user care about this distinction.
This commit is contained in:
Sam Atkins 2022-01-27 14:38:59 +00:00 committed by Andreas Kling
parent f0fb84dfcb
commit ce0de4b2b4
11 changed files with 145 additions and 107 deletions

View file

@ -70,10 +70,8 @@ LengthPercentage StyleProperties::length_percentage_or_fallback(CSS::PropertyID
return fallback;
auto& value = maybe_value.value();
if (value->is_calculated()) {
// FIXME: Handle percentages here
return Length::make_calculated(value->as_calculated());
}
if (value->is_calculated())
return LengthPercentage { value->as_calculated() };
if (value->is_percentage())
return value->as_percentage().percentage();