Bug 1330824 - Do not set mAnimationNameCount less than 1. r?heycam
animation-name property is 'allow_empty=True', we have to handle 0-length
array case.
MozReview-Commit-ID: LwU3RfhfVfH
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -155,17 +155,17 @@ support-files = file_bug1089417_iframe.h
[test_bug1203766.html]
[test_bug1232829.html]
[test_bug1292447.html]
[test_cascade.html]
[test_ch_ex_no_infloops.html]
[test_change_hint_optimizations.html]
[test_clip-path_polygon.html]
[test_compute_data_with_start_struct.html]
-skip-if = toolkit == 'android' || stylo # bug 1330824 for stylo
+skip-if = toolkit == 'android'
[test_computed_style.html]
[test_computed_style_min_size_auto.html]
[test_computed_style_no_pseudo.html]
[test_computed_style_prefs.html]
[test_condition_text.html]
[test_condition_text_assignment.html]
[test_contain_formatting_context.html]
[test_counter_descriptor_storage.html]
@@ -297,21 +297,20 @@ support-files = ../../reftests/fonts/mar
[test_units_frequency.html]
[test_units_length.html]
[test_units_time.html]
[test_unprefixing_service.html]
support-files = unprefixing_service_iframe.html unprefixing_service_utils.js
[test_unprefixing_service_prefs.html]
support-files = unprefixing_service_iframe.html unprefixing_service_utils.js
[test_value_cloning.html]
-skip-if = toolkit == 'android' || stylo # bug 775227 for android, bug 1330824 for stylo
+skip-if = toolkit == 'android' # bug 775227 for android
[test_value_computation.html]
-skip-if = toolkit == 'android' || stylo # bug 1330824 for stylo
+skip-if = toolkit == 'android'
[test_value_storage.html]
-skip-if = stylo # bug 1330824
[test_variable_serialization_computed.html]
[test_variable_serialization_specified.html]
[test_variables.html]
support-files = support/external-variable-url.css
[test_video_object_fit.html]
[test_viewport_units.html]
[test_visited_image_loading.html]
skip-if = (toolkit == 'android' || stylo) # TIMED_OUT for android, timeout bug 1328511 for stylo
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -1033,17 +1033,19 @@ fn static_assert() {
pub fn animation_${ident}_count(&self) -> usize {
self.gecko.mAnimation${gecko_ffi_name}Count as usize
}
</%def>
<%def name="impl_animation_time_value(ident, gecko_ffi_name)">
#[allow(non_snake_case)]
pub fn set_animation_${ident}(&mut self, v: longhands::animation_${ident}::computed_value::T) {
+ assert!(v.0.len() > 0);
unsafe { self.gecko.mAnimations.ensure_len(v.0.len()) };
+
self.gecko.mAnimation${gecko_ffi_name}Count = v.0.len() as u32;
for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) {
gecko.m${gecko_ffi_name} = servo.seconds() * 1000.;
}
}
#[allow(non_snake_case)]
pub fn animation_${ident}_at(&self, index: usize)
-> longhands::animation_${ident}::computed_value::SingleComputedValue {
@@ -1055,17 +1057,19 @@ fn static_assert() {
</%def>
<%def name="impl_animation_keyword(ident, gecko_ffi_name, keyword, cast_type='u8')">
#[allow(non_snake_case)]
pub fn set_animation_${ident}(&mut self, v: longhands::animation_${ident}::computed_value::T) {
use properties::longhands::animation_${ident}::single_value::computed_value::T as Keyword;
use gecko_bindings::structs;
+ assert!(v.0.len() > 0);
unsafe { self.gecko.mAnimations.ensure_len(v.0.len()) };
+
self.gecko.mAnimation${gecko_ffi_name}Count = v.0.len() as u32;
for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) {
let result = match servo {
% for value in keyword.gecko_values():
Keyword::${to_rust_ident(value)} =>
structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast(cast_type)},
% endfor
@@ -1360,19 +1364,24 @@ fn static_assert() {
pub fn copy_transform_from(&mut self, other: &Self) {
unsafe { self.gecko.mSpecifiedTransform.set(&other.gecko.mSpecifiedTransform); }
}
pub fn set_animation_name(&mut self, v: longhands::animation_name::computed_value::T) {
use nsstring::nsCString;
unsafe { self.gecko.mAnimations.ensure_len(v.0.len()) };
- self.gecko.mAnimationNameCount = v.0.len() as u32;
- for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) {
- gecko.mName.assign_utf8(&nsCString::from(servo.0.to_string()));
+
+ if v.0.len() > 0 {
+ self.gecko.mAnimationNameCount = v.0.len() as u32;
+ for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) {
+ gecko.mName.assign_utf8(&nsCString::from(servo.0.to_string()));
+ }
+ } else {
+ unsafe { self.gecko.mAnimations[0].mName.truncate(); }
}
}
pub fn animation_name_at(&self, index: usize)
-> 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[..])))
@@ -1395,17 +1404,19 @@ fn static_assert() {
data.longhands_by_name["animation-fill-mode"].keyword)}
${impl_animation_keyword('play_state', 'PlayState',
data.longhands_by_name["animation-play-state"].keyword)}
pub fn set_animation_iteration_count(&mut self, v: longhands::animation_iteration_count::computed_value::T) {
use std::f32;
use properties::longhands::animation_iteration_count::single_value::SpecifiedValue as AnimationIterationCount;
+ assert!(v.0.len() > 0);
unsafe { self.gecko.mAnimations.ensure_len(v.0.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 {
AnimationIterationCount::Number(n) => gecko.mIterationCount = n,
AnimationIterationCount::Infinite => gecko.mIterationCount = f32::INFINITY,
}
}
}
@@ -1419,16 +1430,17 @@ fn static_assert() {
} else {
AnimationIterationCount::Number(self.gecko.mAnimations[index].mIterationCount)
}
}
${impl_animation_count('iteration_count', 'IterationCount')}
${impl_copy_animation_value('iteration_count', 'IterationCount')}
pub fn set_animation_timing_function(&mut self, v: longhands::animation_timing_function::computed_value::T) {
+ assert!(v.0.len() > 0);
unsafe { self.gecko.mAnimations.ensure_len(v.0.len()) };
self.gecko.mAnimationTimingFunctionCount = v.0.len() as u32;
for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) {
gecko.mTimingFunction = servo.into();
}
}
${impl_animation_count('timing_function', 'TimingFunction')}