mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #17613 - birtles:zero-length-lists, r=hiro
Handle zero length lists when interpolating These are the Servo side changes for [Gecko bug 1377053](https://bugzilla.mozilla.org/show_bug.cgi?id=1377053). These patches have been reviewed by @hiikezoe. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17613) <!-- Reviewable:end -->
This commit is contained in:
commit
dd11ee1257
2 changed files with 9 additions and 1 deletions
|
@ -828,6 +828,10 @@ macro_rules! repeated_vec_impl {
|
|||
$(impl<T: RepeatableListAnimatable> Animatable for $ty {
|
||||
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64)
|
||||
-> Result<Self, ()> {
|
||||
// If the length of either list is zero, the least common multiple is undefined.
|
||||
if cmp::min(self.len(), other.len()) < 1 {
|
||||
return Err(());
|
||||
}
|
||||
use num_integer::lcm;
|
||||
let len = lcm(self.len(), other.len());
|
||||
self.iter().cycle().zip(other.iter().cycle()).take(len).map(|(me, you)| {
|
||||
|
@ -842,6 +846,10 @@ macro_rules! repeated_vec_impl {
|
|||
|
||||
#[inline]
|
||||
fn compute_squared_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||
// If the length of either list is zero, the least common multiple is undefined.
|
||||
if cmp::min(self.len(), other.len()) < 1 {
|
||||
return Err(());
|
||||
}
|
||||
use num_integer::lcm;
|
||||
let len = lcm(self.len(), other.len());
|
||||
self.iter().cycle().zip(other.iter().cycle()).take(len).map(|(me, you)| {
|
||||
|
|
|
@ -545,7 +545,7 @@ pub extern "C" fn Servo_AnimationCompose(raw_value_map: RawServoAnimationValueMa
|
|||
};
|
||||
if let Ok(value) = from_value.interpolate(to_value, position) {
|
||||
value_map.insert(property, value);
|
||||
} else if progress < 0.5 {
|
||||
} else if position < 0.5 {
|
||||
value_map.insert(property, from_value.clone());
|
||||
} else {
|
||||
value_map.insert(property, to_value.clone());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue