Skip to content

Commit 1d1f9ce

Browse files
committed
Be more accurate
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
1 parent a965f64 commit 1d1f9ce

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

style/servo/animation.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use crate::values::computed::TimingFunction;
3030
use crate::values::generics::easing::{BeforeFlag, StepPosition};
3131
use crate::values::specified::TransitionBehavior;
3232
use crate::Atom;
33+
use debug_unreachable::debug_unreachable;
3334
use parking_lot::RwLock;
3435
use rustc_hash::FxHashMap;
3536
use 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

Comments
 (0)