mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Pass null servo's computed values into ComputedKeyframeValues
With this patch series, test_cssanimation_missing_keyframes.html can pass now.
This commit is contained in:
parent
eb63511304
commit
4834162e4a
1 changed files with 39 additions and 15 deletions
|
@ -2863,32 +2863,56 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
|
||||||
|
|
||||||
let mut seen = LonghandIdSet::new();
|
let mut seen = LonghandIdSet::new();
|
||||||
|
|
||||||
// mServoDeclarationBlock is null in the case where we have an invalid css property.
|
let iter = keyframe.mPropertyValues.iter();
|
||||||
let iter = keyframe.mPropertyValues.iter()
|
|
||||||
.filter(|&property| !property.mServoDeclarationBlock.mRawPtr.is_null());
|
|
||||||
let mut property_index = 0;
|
let mut property_index = 0;
|
||||||
for property in iter {
|
for property in iter {
|
||||||
if simulate_compute_values_failure(property) {
|
if simulate_compute_values_failure(property) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut maybe_append_animation_value = |property: AnimatableLonghand,
|
||||||
|
value: Option<AnimationValue>| {
|
||||||
|
if seen.has_animatable_longhand_bit(&property) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
seen.set_animatable_longhand_bit(&property);
|
||||||
|
|
||||||
|
// This is safe since we immediately write to the uninitialized values.
|
||||||
|
unsafe { animation_values.set_len((property_index + 1) as u32) };
|
||||||
|
animation_values[property_index].mProperty = (&property).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[property_index].mValue.mGecko = unsafe { mem::zeroed() };
|
||||||
|
match value {
|
||||||
|
Some(v) => {
|
||||||
|
animation_values[property_index].mValue.mServo.set_arc_leaky(Arc::new(v));
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
animation_values[property_index].mValue.mServo.mRawPtr = ptr::null_mut();
|
||||||
|
},
|
||||||
|
}
|
||||||
|
property_index += 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if property.mServoDeclarationBlock.mRawPtr.is_null() {
|
||||||
|
let animatable_longhand =
|
||||||
|
AnimatableLonghand::from_nscsspropertyid(property.mProperty);
|
||||||
|
// |keyframes.mPropertyValues| should only contain animatable
|
||||||
|
// properties, but we check the result from_nscsspropertyid
|
||||||
|
// just in case.
|
||||||
|
if let Some(property) = animatable_longhand {
|
||||||
|
maybe_append_animation_value(property, None);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let declarations = unsafe { &*property.mServoDeclarationBlock.mRawPtr.clone() };
|
let declarations = unsafe { &*property.mServoDeclarationBlock.mRawPtr.clone() };
|
||||||
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||||
let guard = declarations.read_with(&guard);
|
let guard = declarations.read_with(&guard);
|
||||||
|
|
||||||
for anim in guard.to_animation_value_iter(&mut context, &default_values) {
|
for anim in guard.to_animation_value_iter(&mut context, &default_values) {
|
||||||
if !seen.has_animatable_longhand_bit(&anim.0) {
|
maybe_append_animation_value(anim.0, Some(anim.1));
|
||||||
// This is safe since we immediately write to the uninitialized values.
|
|
||||||
unsafe { animation_values.set_len((property_index + 1) as u32) };
|
|
||||||
seen.set_animatable_longhand_bit(&anim.0);
|
|
||||||
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[property_index].mValue.mGecko = unsafe { mem::zeroed() };
|
|
||||||
animation_values[property_index].mValue.mServo.set_arc_leaky(Arc::new(anim.1));
|
|
||||||
property_index += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue