diff --git a/Libraries/LibWeb/CSS/NumericType.cpp b/Libraries/LibWeb/CSS/NumericType.cpp index 0e2f0ef585b..46c40638f6d 100644 --- a/Libraries/LibWeb/CSS/NumericType.cpp +++ b/Libraries/LibWeb/CSS/NumericType.cpp @@ -55,40 +55,38 @@ Optional NumericType::create_from_unit(StringView unit) return NumericType { BaseType::Percent, 1 }; } - // unit is a unit - if (string_to_length_unit(unit).has_value()) { - // Return «[ "length" → 1 ]» - return NumericType { BaseType::Length, 1 }; - } + if (auto dimension = dimension_for_unit(unit); dimension.has_value()) { + switch (*dimension) { + // unit is a unit + case DimensionType::Length: + // Return «[ "length" → 1 ]» + return NumericType { BaseType::Length, 1 }; - // unit is an unit - if (string_to_angle_unit(unit).has_value()) { - // Return «[ "angle" → 1 ]» - return NumericType { BaseType::Angle, 1 }; - } + // unit is an unit + case DimensionType::Angle: + // Return «[ "angle" → 1 ]» + return NumericType { BaseType::Angle, 1 }; - // unit is a