@@ -30,6 +30,7 @@ use crate::values::computed::TimingFunction;
3030use crate :: values:: generics:: easing:: { BeforeFlag , StepPosition } ;
3131use crate :: values:: specified:: TransitionBehavior ;
3232use crate :: Atom ;
33+ use debug_unreachable:: debug_unreachable;
3334use parking_lot:: RwLock ;
3435use rustc_hash:: FxHashMap ;
3536use servo_arc:: Arc ;
@@ -801,10 +802,11 @@ impl Animation {
801802 return ;
802803 }
803804
804- // Progress clamped to the current iteration ( 0.0 to 1.0) .
805+ // Progress clamped to the current iteration [ 0.0, 1.0] .
805806 let total_progress = progress. min ( self . current_iteration_end_progress ( ) ) . max ( 0.0 ) ;
806807
807- if total_progress >= 1.0 {
808+ // At 1.0 there is nothing left to interpolate. Return end keyframe.
809+ if total_progress == 1.0 {
808810 let keyframe = match self . current_direction {
809811 AnimationDirection :: Normal => self . computed_steps . last ( ) . unwrap ( ) ,
810812 AnimationDirection :: Reverse => self . computed_steps . first ( ) . unwrap ( ) ,
@@ -855,7 +857,14 @@ impl Animation {
855857
856858 let prev_keyframe = & self . computed_steps [ prev_keyframe_index] ;
857859 let Some ( next_keyframe_index) = next_keyframe_index else {
858- debug_assert ! ( false , "next_keyframe_index should always be Some" ) ;
860+ unsafe {
861+ debug_unreachable ! (
862+ "next_keyframe_index should always be Some: \
863+ total_progress is in [0, 1) at this point. \
864+ Normal direction: keyframe with start_percentage 1.0 always satisfies. \
865+ Reverse direction: keyframe with start_percentage 0.0 always satisfies."
866+ ) ;
867+ }
859868 return ;
860869 } ;
861870
0 commit comments