From f6b8fb177c30a355b9ef64e3a30bc3bef71157ef Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Tue, 15 Aug 2017 13:03:17 +0900 Subject: [PATCH 1/5] Check interpolatable to tell whether transition is created or not. --- components/style/gecko/wrapper.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index bb079321bf5..80ab02ae518 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1396,6 +1396,8 @@ impl<'le> TElement for GeckoElement<'le> { existing_transitions: &HashMap>) -> bool { + use properties::animated_properties::Animatable; + // |property| should be an animatable longhand let animatable_longhand = AnimatableLonghand::from_transition_property(property).unwrap(); @@ -1414,7 +1416,9 @@ impl<'le> TElement for GeckoElement<'le> { let to = AnimationValue::from_computed_values(&animatable_longhand, after_change_style); - combined_duration > 0.0f32 && from != to + combined_duration > 0.0f32 && + from != to && + from.interpolate(&to, 0.5).is_ok() } #[inline] From 19d498f01e9d7c6711ce86379e4c1b454d13562e Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Tue, 15 Aug 2017 13:03:32 +0900 Subject: [PATCH 2/5] Make assertion for colum-count more accurate. column-count should be greater than or equal to 1. Also it should be less than or equal to nsStyleColumn_kMaxColumnCount since we limit it in set_column_count(). --- components/style/properties/gecko.mako.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index e7f9db30b9e..666f94e8850 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -5444,10 +5444,10 @@ clip-path ${impl_simple_copy('column_count', 'mColumnCount')} pub fn clone_column_count(&self) -> longhands::column_count::computed_value::T { - use gecko_bindings::structs::NS_STYLE_COLUMN_COUNT_AUTO; + use gecko_bindings::structs::{NS_STYLE_COLUMN_COUNT_AUTO, nsStyleColumn_kMaxColumnCount}; if self.gecko.mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO { - debug_assert!((self.gecko.mColumnCount as i32) >= 0 && - (self.gecko.mColumnCount as i32) < i32::max_value()); + debug_assert!(self.gecko.mColumnCount >= 1 && + self.gecko.mColumnCount <= nsStyleColumn_kMaxColumnCount); Either::First((self.gecko.mColumnCount as i32).into()) } else { Either::Second(Auto) From fa3b62746db5c7c504b623d25e3f113f68077fcc Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Tue, 15 Aug 2017 13:03:53 +0900 Subject: [PATCH 3/5] ComputedPositiveInteger is an integer greater than or equal to 1. --- components/style/values/animated/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/style/values/animated/mod.rs b/components/style/values/animated/mod.rs index 8f505211ab6..6883f98ac09 100644 --- a/components/style/values/animated/mod.rs +++ b/components/style/values/animated/mod.rs @@ -172,7 +172,7 @@ impl ToAnimatedValue for ComputedPositiveInteger { #[inline] fn from_animated_value(animated: Self::AnimatedValue) -> Self { - max(animated.0, 0).into() + max(animated.0, 1).into() } } From bff67d82722abc77a229b283385f44e3a0e04e19 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Tue, 15 Aug 2017 13:04:06 +0900 Subject: [PATCH 4/5] Don't fallback to discrete animation within add_weighted() for Either<>. For CSS Transitions we want this case to return Err() so we know that the two values are not interpolable. For CSS Animations/Web Animations we implement discrete animation as the fallback behavior when Err() is returned. --- .../style/properties/helpers/animated_properties.mako.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 87325fa70cd..2863b04294c 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -2410,10 +2410,7 @@ impl Animatable for Either (Either::Second(ref this), Either::Second(ref other)) => { this.add_weighted(&other, self_portion, other_portion).map(Either::Second) }, - _ => { - let result = if self_portion > other_portion {*self} else {*other}; - Ok(result) - } + _ => Err(()), } } } From 08ebc524cfff916a5f917e3a1756ac6e6c6b82be Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Tue, 15 Aug 2017 13:04:21 +0900 Subject: [PATCH 5/5] Round halfway values toward positive infinity for integer type of animation. From the spec[1]; `with values halfway between a pair of integers rounded towards positive infinity.` [1] https://drafts.csswg.org/css-transitions/#animtype-integer --- components/style/properties/helpers/animated_properties.mako.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 2863b04294c..3e12db37389 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -863,7 +863,7 @@ impl Animatable for f64 { impl Animatable for i32 { #[inline] fn add_weighted(&self, other: &i32, self_portion: f64, other_portion: f64) -> Result { - Ok((*self as f64 * self_portion + *other as f64 * other_portion).round() as i32) + Ok((*self as f64 * self_portion + *other as f64 * other_portion + 0.5).floor() as i32) } }