diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-08-15 03:28:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-15 03:28:21 -0500 |
commit | 87c872a7f729effe115036034084d2af39d0447b (patch) | |
tree | e90186c434b39c12c484459f4de28dda05505157 | |
parent | 74558990b258cb55f230ebe8ec3fc557fd286f94 (diff) | |
parent | 08ebc524cfff916a5f917e3a1756ac6e6c6b82be (diff) | |
download | servo-87c872a7f729effe115036034084d2af39d0447b.tar.gz servo-87c872a7f729effe115036034084d2af39d0447b.zip |
Auto merge of #18081 - hiikezoe:interpolation-with-auto, r=birtles,boris,mantaroh
Fix interpolation between auto and other values
<!-- Please describe your changes on the following line: -->
https://bugzilla.mozilla.org/show_bug.cgi?id=1387939
---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
<!-- 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/18081)
<!-- Reviewable:end -->
-rw-r--r-- | components/style/gecko/wrapper.rs | 6 | ||||
-rw-r--r-- | components/style/properties/gecko.mako.rs | 6 | ||||
-rw-r--r-- | components/style/properties/helpers/animated_properties.mako.rs | 7 | ||||
-rw-r--r-- | components/style/values/animated/mod.rs | 2 |
4 files changed, 11 insertions, 10 deletions
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<TransitionProperty, Arc<AnimationValue>>) -> 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] diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 92cc18ab3af..45ffb371d8a 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -5434,10 +5434,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) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index ac1e5dc3660..64d29252ddc 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<Self, ()> { - 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) } } @@ -2410,10 +2410,7 @@ impl<T, U> Animatable for Either<T, U> (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(()), } } } 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() } } |