Bug 1330824 - Do not copy animation property over mAnimationXXCount. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 14 Jan 2017 08:26:27 +0900
changeset 460846 afc6a99fab5e0f84179a661efc3f59acdf05ffb1
parent 460845 76c18191cab316a055e8b0d49ba7b6fd4c8541a9
child 542159 35d67e1a3067970cc8a22c6e503617926d95287c
push id41514
push userhiikezoe@mozilla-japan.org
push dateFri, 13 Jan 2017 23:27:08 +0000
reviewersheycam
bugs1330824
milestone53.0a1
Bug 1330824 - Do not copy animation property over mAnimationXXCount. r?heycam MozReview-Commit-ID: GeSWnPQltHf
layout/style/test/mochitest.ini
servo/components/style/properties/gecko.mako.rs
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -267,17 +267,16 @@ skip-if = toolkit == 'android' #bug 7752
 [test_text_decoration_shorthands.html]
 [test_transitions_and_reframes.html]
 [test_transitions_and_restyles.html]
 [test_transitions_and_zoom.html]
 skip-if = stylo # timeout bug 1328499
 [test_transitions_cancel_near_end.html]
 skip-if = stylo # timeout bug 1328499
 [test_transitions_computed_values.html]
-skip-if = stylo # bug 1330825
 [test_transitions_computed_value_combinations.html]
 [test_transitions_events.html]
 skip-if = stylo # timeout bug 1328499
 [test_transitions.html]
 skip-if = (android_version == '18' && debug) # bug 1159532
 [test_transitions_bug537151.html]
 skip-if = stylo # timeout bug 1328499
 [test_transitions_dynamic_changes.html]
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -1016,18 +1016,23 @@ fn static_assert() {
     }
 
 </%self:impl_trait>
 
 <%def name="impl_copy_animation_value(ident, gecko_ffi_name)">
     #[allow(non_snake_case)]
     pub fn copy_animation_${ident}_from(&mut self, other: &Self) {
         unsafe { self.gecko.mAnimations.ensure_len(other.gecko.mAnimations.len()) };
-        self.gecko.mAnimation${gecko_ffi_name}Count = other.gecko.mAnimation${gecko_ffi_name}Count;
-        for (index, animation) in self.gecko.mAnimations.iter_mut().enumerate() {
+
+        let count = other.gecko.mAnimation${gecko_ffi_name}Count;
+        self.gecko.mAnimation${gecko_ffi_name}Count = count;
+
+        // The length of mAnimations is often greater than mAnimationXXCount,
+        // don't copy values over the count.
+        for (index, animation) in self.gecko.mAnimations.iter_mut().enumerate().take(count as usize) {
             animation.m${gecko_ffi_name} = other.gecko.mAnimations[index].m${gecko_ffi_name};
         }
     }
 </%def>
 
 <%def name="impl_animation_count(ident, gecko_ffi_name)">
     #[allow(non_snake_case)]
     pub fn animation_${ident}_count(&self) -> usize {
@@ -1383,18 +1388,23 @@ fn static_assert() {
         -> longhands::animation_name::computed_value::SingleComputedValue {
         use Atom;
         use properties::longhands::animation_name::single_value::SpecifiedValue as AnimationName;
         // XXX: Is there any effective ways?
         AnimationName(Atom::from(String::from_utf16_lossy(&self.gecko.mAnimations[index].mName[..])))
     }
     pub fn copy_animation_name_from(&mut self, other: &Self) {
         unsafe { self.gecko.mAnimations.ensure_len(other.gecko.mAnimations.len()) };
-        self.gecko.mAnimationNameCount = other.gecko.mAnimationNameCount;
-        for (index, animation) in self.gecko.mAnimations.iter_mut().enumerate() {
+
+        let count = other.gecko.mAnimationNameCount;
+        self.gecko.mAnimationNameCount = count;
+
+        // The length of mAnimations is often greater than mAnimationXXCount,
+        // don't copy values over the count.
+        for (index, animation) in self.gecko.mAnimations.iter_mut().enumerate().take(count as usize) {
             animation.mName.assign(&other.gecko.mAnimations[index].mName);
         }
     }
     ${impl_animation_count('name', 'Name')}
 
     ${impl_animation_time_value('delay', 'Delay')}
     ${impl_animation_time_value('duration', 'Duration')}