LibWeb: Use computed value of font-size in keyframes

Remaining test failures in font-size-interpolation-00* are either:
 - Rounding of font-size to CSSPixels when setting the expected value
 - Not clamping negative values from the point of view of
   getComputedStyle (used values are still clamped)
This commit is contained in:
Callum Law 2025-08-31 17:10:31 +12:00 committed by Sam Atkins
commit cfbe0244d4
Notes: github-actions[bot] 2025-09-19 09:08:46 +00:00
3 changed files with 38 additions and 14 deletions

View file

@ -2101,8 +2101,7 @@ WillChange ComputedProperties::will_change() const
CSSPixels ComputedProperties::font_size() const
{
// FIXME: Respect animated font-size here once we store it in computed form
return property(PropertyID::FontSize, WithAnimationsApplied::No).as_length().length().absolute_length_to_px();
return property(PropertyID::FontSize).as_length().length().absolute_length_to_px();
}
}

View file

@ -1043,6 +1043,28 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
});
}
DOM::AbstractElement abstract_element { element, pseudo_element };
auto const& inheritance_parent = abstract_element.element_to_inherit_style_from();
auto inheritance_parent_has_computed_properties = inheritance_parent.has_value() && inheritance_parent->computed_properties();
auto parent_length_resolution_context = inheritance_parent_has_computed_properties ? Length::ResolutionContext::for_element(inheritance_parent.value()) : Length::ResolutionContext::for_window(*m_document->window());
if (auto const& font_size_specified_value = specified_values.get(PropertyID::FontSize); font_size_specified_value.has_value()) {
// FIXME: We need to respect the math-depth of this computed keyframe if it is present
auto computed_math_depth = computed_properties.math_depth();
auto inherited_font_size = inheritance_parent_has_computed_properties ? inheritance_parent->computed_properties()->font_size() : InitialValues::font_size();
auto inherited_math_depth = inheritance_parent_has_computed_properties ? inheritance_parent->computed_properties()->math_depth() : InitialValues::math_depth();
auto const& font_size_in_computed_form = compute_font_size(
*font_size_specified_value.value(),
computed_math_depth,
inherited_font_size,
inherited_math_depth,
parent_length_resolution_context);
result.set(PropertyID::FontSize, font_size_in_computed_form);
}
PropertyValueComputationContext property_value_computation_context {
.length_resolution_context = {
.viewport_rect = viewport_rect(),
@ -1064,6 +1086,9 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
if (!style_value)
continue;
if (first_is_one_of(property_id, PropertyID::FontSize))
continue;
auto const& computed_value = compute_value_of_property(property_id, *style_value, get_property_specified_value, property_value_computation_context);
result.set(property_id, computed_value->absolutized(viewport_rect(), font_metrics, m_root_element_font_metrics));
}

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 140 tests
126 Pass
14 Fail
136 Pass
4 Fail
Pass CSS Transitions: property <font-size> from neutral to [20px] at (-2) should be [0px]
Pass CSS Transitions: property <font-size> from neutral to [20px] at (-0.3) should be [7px]
Pass CSS Transitions: property <font-size> from neutral to [20px] at (0) should be [10px]
@ -46,20 +46,20 @@ Pass CSS Transitions with transition: all: property <font-size> from [initial] t
Fail CSS Transitions with transition: all: property <font-size> from [initial] to [20px] at (0.6) should be [18.4px]
Pass CSS Transitions with transition: all: property <font-size> from [initial] to [20px] at (1) should be [20px]
Pass CSS Transitions with transition: all: property <font-size> from [initial] to [20px] at (1.5) should be [22px]
Fail CSS Animations: property <font-size> from [initial] to [20px] at (-2) should be [8px]
Fail CSS Animations: property <font-size> from [initial] to [20px] at (-0.3) should be [14.8px]
Fail CSS Animations: property <font-size> from [initial] to [20px] at (0) should be [16px]
Fail CSS Animations: property <font-size> from [initial] to [20px] at (0.3) should be [17.2px]
Pass CSS Animations: property <font-size> from [initial] to [20px] at (-2) should be [8px]
Pass CSS Animations: property <font-size> from [initial] to [20px] at (-0.3) should be [14.8px]
Pass CSS Animations: property <font-size> from [initial] to [20px] at (0) should be [16px]
Pass CSS Animations: property <font-size> from [initial] to [20px] at (0.3) should be [17.2px]
Fail CSS Animations: property <font-size> from [initial] to [20px] at (0.6) should be [18.4px]
Pass CSS Animations: property <font-size> from [initial] to [20px] at (1) should be [20px]
Fail CSS Animations: property <font-size> from [initial] to [20px] at (1.5) should be [22px]
Fail Web Animations: property <font-size> from [initial] to [20px] at (-2) should be [8px]
Fail Web Animations: property <font-size> from [initial] to [20px] at (-0.3) should be [14.8px]
Fail Web Animations: property <font-size> from [initial] to [20px] at (0) should be [16px]
Fail Web Animations: property <font-size> from [initial] to [20px] at (0.3) should be [17.2px]
Pass CSS Animations: property <font-size> from [initial] to [20px] at (1.5) should be [22px]
Pass Web Animations: property <font-size> from [initial] to [20px] at (-2) should be [8px]
Pass Web Animations: property <font-size> from [initial] to [20px] at (-0.3) should be [14.8px]
Pass Web Animations: property <font-size> from [initial] to [20px] at (0) should be [16px]
Pass Web Animations: property <font-size> from [initial] to [20px] at (0.3) should be [17.2px]
Fail Web Animations: property <font-size> from [initial] to [20px] at (0.6) should be [18.4px]
Pass Web Animations: property <font-size> from [initial] to [20px] at (1) should be [20px]
Fail Web Animations: property <font-size> from [initial] to [20px] at (1.5) should be [22px]
Pass Web Animations: property <font-size> from [initial] to [20px] at (1.5) should be [22px]
Pass CSS Transitions: property <font-size> from [inherit] to [20px] at (-2) should be [50px]
Pass CSS Transitions: property <font-size> from [inherit] to [20px] at (-0.3) should be [33px]
Pass CSS Transitions: property <font-size> from [inherit] to [20px] at (0) should be [30px]