Bug 1359669 - Set multiple properties in a keyframe correctly. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 02 May 2017 11:32:42 +0900
changeset 571098 1f9cd516eac84da2a4b6cd3fb78197000f1caee4
parent 571080 4168f0fec8342bd1dbaa7631eb9575716131cb36
child 571099 10ad293528aa27ed3676d176d39b27252f9b1018
push id56682
push userhikezoe@mozilla.com
push dateTue, 02 May 2017 03:15:47 +0000
reviewersbirtles
bugs1359669
milestone55.0a1
Bug 1359669 - Set multiple properties in a keyframe correctly. r?birtles MozReview-Commit-ID: 9EMRCbPdZoX
servo/ports/geckolib/glue.rs
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -2011,16 +2011,17 @@ pub extern "C" fn Servo_GetComputedKeyfr
     for (index, keyframe) in keyframes.iter().enumerate() {
         let ref mut animation_values = computed_keyframes[index];
 
         let mut seen = LonghandIdSet::new();
 
         // mServoDeclarationBlock is null in the case where we have an invalid css property.
         let iter = keyframe.mPropertyValues.iter()
                                            .filter(|&property| !property.mServoDeclarationBlock.mRawPtr.is_null());
+        let mut property_index = 0;
         for property in iter {
             let declarations = unsafe { &*property.mServoDeclarationBlock.mRawPtr.clone() };
             let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
             let guard = declarations.read_with(&guard);
 
             let anim_iter = guard.declarations()
                             .iter()
                             .filter_map(|&(ref decl, imp)| {
@@ -2037,27 +2038,28 @@ pub extern "C" fn Servo_GetComputedKeyfr
                                     } else {
                                         Some((property.unwrap(), animation.unwrap()))
                                     }
                                 } else {
                                     None
                                 }
                             });
 
-            for (i, anim) in anim_iter.enumerate() {
+            for anim in anim_iter {
                 if !seen.has_transition_property_bit(&anim.0) {
                     // This is safe since we immediately write to the uninitialized values.
-                    unsafe { animation_values.set_len((i + 1) as u32) };
+                    unsafe { animation_values.set_len((property_index + 1) as u32) };
                     seen.set_transition_property_bit(&anim.0);
-                    animation_values[i].mProperty = (&anim.0).into();
+                    animation_values[property_index].mProperty = (&anim.0).into();
                     // We only make sure we have enough space for this variable,
                     // but didn't construct a default value for StyleAnimationValue,
                     // so we should zero it to avoid getting undefined behaviors.
-                    animation_values[i].mValue.mGecko = unsafe { mem::zeroed() };
-                    animation_values[i].mValue.mServo.set_arc_leaky(Arc::new(anim.1));
+                    animation_values[property_index].mValue.mGecko = unsafe { mem::zeroed() };
+                    animation_values[property_index].mValue.mServo.set_arc_leaky(Arc::new(anim.1));
+                    property_index += 1;
                 }
             }
         }
     }
 }
 
 
 #[no_mangle]