LibWeb: Avoid crash from zero-duration transitions

This commit is contained in:
Gingeh 2025-01-08 14:37:03 +11:00 committed by Sam Atkins
parent 8e56109515
commit 2cac0dc20c
Notes: github-actions[bot] 2025-01-08 11:24:13 +00:00
2 changed files with 8 additions and 3 deletions

View file

@ -140,6 +140,11 @@ void CSSTransition::visit_edges(Cell::Visitor& visitor)
double CSSTransition::timing_function_output_at_time(double t) const
{
auto progress = (t - transition_start_time()) / (transition_end_time() - transition_start_time());
// AD-HOC: If the transition has an empty duration then we get NaN here,
// setting progress to 1 because an instant transition may be considered "finished".
if (transition_start_time() < transition_end_time())
progress = 1;
// FIXME: Is this before_flag value correct?
bool before_flag = t < transition_start_time();
return m_keyframe_effect->timing_function().evaluate_at(progress, before_flag);

View file

@ -2,11 +2,11 @@ Harness status: OK
Found 10 tests
5 Pass
5 Fail
6 Pass
4 Fail
Pass After setting a transition's effect to null, it still reports the original transition property
Pass After setting a transition's effect to null, it becomes finished
Fail After setting a transition's effect to null, style is updated
Pass After setting a transition's effect to null, style is updated
Fail After setting a transition's effect to null, a new transition can be started
Fail After setting a transition's effect to null, it should be possible to interrupt that transition
Pass After setting a new keyframe effect with a shorter duration, the transition becomes finished