LibWeb: Clamp dimension percentage values to the specified percentage

Previously we would clamp the percentage value to the allowed range for
canonical dimension values rather than the percentage value.

Also fixes an issue where we would clamp pure percentages (i.e.
percentages that don't have a hint) against the allowed values for the
first dimension we checked (i.e. angle)
This commit is contained in:
Callum Law 2025-09-02 20:32:55 +12:00 committed by Sam Atkins
commit 073d10c6d1
Notes: github-actions[bot] 2025-09-19 09:08:11 +00:00

View file

@ -2955,19 +2955,19 @@ Optional<CalculatedStyleValue::ResolvedValue> CalculatedStyleValue::resolve_valu
if (value->type()->matches_number(m_context.percentages_resolve_as))
accepted_range = m_context.resolve_numbers_as_integers ? m_context.accepted_type_ranges.get(ValueType::Integer) : m_context.accepted_type_ranges.get(ValueType::Number);
else if (value->type()->matches_angle_percentage(m_context.percentages_resolve_as))
else if (value->type()->matches_angle(m_context.percentages_resolve_as))
accepted_range = m_context.accepted_type_ranges.get(ValueType::Angle);
else if (value->type()->matches_flex(m_context.percentages_resolve_as))
accepted_range = m_context.accepted_type_ranges.get(ValueType::Flex);
else if (value->type()->matches_frequency_percentage(m_context.percentages_resolve_as))
else if (value->type()->matches_frequency(m_context.percentages_resolve_as))
accepted_range = m_context.accepted_type_ranges.get(ValueType::Frequency);
else if (value->type()->matches_length_percentage(m_context.percentages_resolve_as))
else if (value->type()->matches_length(m_context.percentages_resolve_as))
accepted_range = m_context.accepted_type_ranges.get(ValueType::Length);
else if (value->type()->matches_percentage())
accepted_range = m_context.accepted_type_ranges.get(ValueType::Percentage);
else if (value->type()->matches_resolution(m_context.percentages_resolve_as))
accepted_range = m_context.accepted_type_ranges.get(ValueType::Resolution);
else if (value->type()->matches_time_percentage(m_context.percentages_resolve_as))
else if (value->type()->matches_time(m_context.percentages_resolve_as))
accepted_range = m_context.accepted_type_ranges.get(ValueType::Time);
if (!accepted_range.has_value()) {