LibWeb: Lazy evaluate optional to avoid crash

This commit is contained in:
stelar7 2023-05-27 22:56:07 +02:00 committed by Andreas Kling
parent 5cdeb994b2
commit e23d31ae83
Notes: sideshowbarker 2024-07-16 23:55:09 +09:00

View File

@ -7492,8 +7492,10 @@ ErrorOr<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readonl
break;
case CalculatedStyleValue::ResolvedType::Integer:
case CalculatedStyleValue::ResolvedType::Number:
if (property_accepts_numeric)
return PropertyAndValue { property_accepting_integer.value_or(property_accepting_number.value()), calculated };
if (property_accepts_numeric) {
auto property_or_resolved = property_accepting_integer.value_or_lazy_evaluated([property_accepting_number]() { return property_accepting_number.value(); });
return PropertyAndValue { property_or_resolved, calculated };
}
break;
case CalculatedStyleValue::ResolvedType::Length:
if (auto property = any_property_accepts_type(property_ids, ValueType::Length); property.has_value())