From c9b0ea314f739420a25d0d59e3cce9079a840225 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Mon, 13 Mar 2017 12:42:01 +0900 Subject: [PATCH 1/3] Don't set transition properties to mAnimations array. --- components/style/properties/gecko.mako.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 2f7cc0945af..5866fce056b 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1323,7 +1323,7 @@ fn static_assert() { pub fn ${type}_${ident}_at(&self, index: usize) -> longhands::${type}_${ident}::computed_value::SingleComputedValue { use values::specified::Time; - Time(self.gecko.mAnimations[index].m${gecko_ffi_name} / 1000.) + Time(self.gecko.m${type.capitalize()}s[index].m${gecko_ffi_name} / 1000.) } ${impl_animation_or_transition_count(type, ident, gecko_ffi_name)} ${impl_copy_animation_or_transition_value(type, ident, gecko_ffi_name)} From 448b74ba1881d9d6b5f7ba4ccbfec13a3b5d207f Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Mon, 13 Mar 2017 12:42:17 +0900 Subject: [PATCH 2/3] Cascade animation-name property earlier than other animation properties. As per the CSS Animations spec, in the case when multiple values for an animation property are set, if the value length is less than the length of animation-name property, then shortage values are filled up. Because of this we need to know the length of animation-name proper before we set other animation properties, so we need to cascade animation-name property earlier than other animation properties. We do the same thing for transition-property. --- components/style/properties/properties.mako.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 3e7398ab15f..b8153417a78 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1957,6 +1957,8 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D, PropertyDeclaration::Direction(_) % if product == 'gecko': | PropertyDeclaration::TextOrientation(_) + | PropertyDeclaration::AnimationName(_) + | PropertyDeclaration::TransitionProperty(_) % endif ); if From 1c607dcc2ac9e79ea9ec85cfc7d02465bf504b1f Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Mon, 13 Mar 2017 12:42:37 +0900 Subject: [PATCH 3/3] Fill shortage values for animation/transition properties. --- components/style/properties/gecko.mako.rs | 36 +++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 5866fce056b..aa059acb258 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1312,11 +1312,12 @@ fn static_assert() { #[allow(non_snake_case)] pub fn set_${type}_${ident}(&mut self, v: longhands::${type}_${ident}::computed_value::T) { debug_assert!(!v.0.is_empty()); - unsafe { self.gecko.m${type.capitalize()}s.ensure_len(v.0.len()) }; + let input_len = v.0.len(); + unsafe { self.gecko.m${type.capitalize()}s.ensure_len(input_len) }; - self.gecko.m${type.capitalize()}${gecko_ffi_name}Count = v.0.len() as u32; - for (servo, gecko) in v.0.into_iter().zip(self.gecko.m${type.capitalize()}s.iter_mut()) { - gecko.m${gecko_ffi_name} = servo.seconds() * 1000.; + self.gecko.m${type.capitalize()}${gecko_ffi_name}Count = input_len as u32; + for (i, gecko) in self.gecko.m${type.capitalize()}s.iter_mut().enumerate() { + gecko.m${gecko_ffi_name} = v.0[i % input_len].seconds() * 1000.; } } #[allow(non_snake_case)] @@ -1332,11 +1333,12 @@ fn static_assert() { <%def name="impl_animation_or_transition_timing_function(type)"> pub fn set_${type}_timing_function(&mut self, v: longhands::${type}_timing_function::computed_value::T) { debug_assert!(!v.0.is_empty()); - unsafe { self.gecko.m${type.capitalize()}s.ensure_len(v.0.len()) }; + let input_len = v.0.len(); + unsafe { self.gecko.m${type.capitalize()}s.ensure_len(input_len) }; - self.gecko.m${type.capitalize()}TimingFunctionCount = v.0.len() as u32; - for (servo, gecko) in v.0.into_iter().zip(self.gecko.m${type.capitalize()}s.iter_mut()) { - gecko.mTimingFunction = servo.into(); + self.gecko.m${type.capitalize()}TimingFunctionCount = input_len as u32; + for (i, gecko) in self.gecko.m${type.capitalize()}s.iter_mut().enumerate() { + gecko.mTimingFunction = v.0[i % input_len].into(); } } ${impl_animation_or_transition_count(type, 'timing_function', 'TimingFunction')} @@ -1382,12 +1384,13 @@ fn static_assert() { use gecko_bindings::structs; debug_assert!(!v.0.is_empty()); - unsafe { self.gecko.mAnimations.ensure_len(v.0.len()) }; + let input_len = v.0.len(); + unsafe { self.gecko.mAnimations.ensure_len(input_len) }; - self.gecko.mAnimation${gecko_ffi_name}Count = v.0.len() as u32; + self.gecko.mAnimation${gecko_ffi_name}Count = input_len as u32; - for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) { - let result = match servo { + for (i, gecko) in self.gecko.mAnimations.iter_mut().enumerate() { + let result = match v.0[i % input_len] { % for value in keyword.gecko_values(): Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast(cast_type)}, @@ -1848,11 +1851,12 @@ fn static_assert() { use properties::longhands::animation_iteration_count::single_value::SpecifiedValue as AnimationIterationCount; debug_assert!(!v.0.is_empty()); - unsafe { self.gecko.mAnimations.ensure_len(v.0.len()) }; + let input_len = v.0.len(); + unsafe { self.gecko.mAnimations.ensure_len(input_len) }; - self.gecko.mAnimationIterationCountCount = v.0.len() as u32; - for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) { - match servo { + self.gecko.mAnimationIterationCountCount = input_len as u32; + for (i, gecko) in self.gecko.mAnimations.iter_mut().enumerate() { + match v.0[i % input_len] { AnimationIterationCount::Number(n) => gecko.mIterationCount = n, AnimationIterationCount::Infinite => gecko.mIterationCount = f32::INFINITY, }