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 -->
This commit is contained in:
bors-servo 2017-08-15 03:28:21 -05:00 committed by GitHub
commit 87c872a7f7
4 changed files with 11 additions and 10 deletions

View file

@ -1396,6 +1396,8 @@ impl<'le> TElement for GeckoElement<'le> {
existing_transitions: &HashMap<TransitionProperty, existing_transitions: &HashMap<TransitionProperty,
Arc<AnimationValue>>) Arc<AnimationValue>>)
-> bool { -> bool {
use properties::animated_properties::Animatable;
// |property| should be an animatable longhand // |property| should be an animatable longhand
let animatable_longhand = AnimatableLonghand::from_transition_property(property).unwrap(); 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, let to = AnimationValue::from_computed_values(&animatable_longhand,
after_change_style); after_change_style);
combined_duration > 0.0f32 && from != to combined_duration > 0.0f32 &&
from != to &&
from.interpolate(&to, 0.5).is_ok()
} }
#[inline] #[inline]

View file

@ -5434,10 +5434,10 @@ clip-path
${impl_simple_copy('column_count', 'mColumnCount')} ${impl_simple_copy('column_count', 'mColumnCount')}
pub fn clone_column_count(&self) -> longhands::column_count::computed_value::T { 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 { if self.gecko.mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO {
debug_assert!((self.gecko.mColumnCount as i32) >= 0 && debug_assert!(self.gecko.mColumnCount >= 1 &&
(self.gecko.mColumnCount as i32) < i32::max_value()); self.gecko.mColumnCount <= nsStyleColumn_kMaxColumnCount);
Either::First((self.gecko.mColumnCount as i32).into()) Either::First((self.gecko.mColumnCount as i32).into())
} else { } else {
Either::Second(Auto) Either::Second(Auto)

View file

@ -863,7 +863,7 @@ impl Animatable for f64 {
impl Animatable for i32 { impl Animatable for i32 {
#[inline] #[inline]
fn add_weighted(&self, other: &i32, self_portion: f64, other_portion: f64) -> Result<Self, ()> { 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)) => { (Either::Second(ref this), Either::Second(ref other)) => {
this.add_weighted(&other, self_portion, other_portion).map(Either::Second) this.add_weighted(&other, self_portion, other_portion).map(Either::Second)
}, },
_ => { _ => Err(()),
let result = if self_portion > other_portion {*self} else {*other};
Ok(result)
}
} }
} }
} }

View file

@ -172,7 +172,7 @@ impl ToAnimatedValue for ComputedPositiveInteger {
#[inline] #[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self { fn from_animated_value(animated: Self::AnimatedValue) -> Self {
max(animated.0, 0).into() max(animated.0, 1).into()
} }
} }