mirror of
https://github.com/servo/servo.git
synced 2025-07-03 05:23:38 +01:00
Make a macro for timing function.
This commit is contained in:
parent
40822f9575
commit
d61a2ff29e
1 changed files with 23 additions and 15 deletions
|
@ -1342,6 +1342,24 @@ fn static_assert() {
|
||||||
${impl_copy_animation_or_transition_value(type, ident, gecko_ffi_name)}
|
${impl_copy_animation_or_transition_value(type, ident, gecko_ffi_name)}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
<%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()) };
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
${impl_animation_or_transition_count(type, 'timing_function', 'TimingFunction')}
|
||||||
|
${impl_copy_animation_or_transition_value(type, 'timing_function', 'TimingFunction')}
|
||||||
|
pub fn ${type}_timing_function_at(&self, index: usize)
|
||||||
|
-> longhands::${type}_timing_function::computed_value::SingleComputedValue {
|
||||||
|
self.gecko.m${type.capitalize()}s[index].mTimingFunction.into()
|
||||||
|
}
|
||||||
|
</%def>
|
||||||
|
|
||||||
<%def name="impl_transition_time_value(ident, gecko_ffi_name)">
|
<%def name="impl_transition_time_value(ident, gecko_ffi_name)">
|
||||||
${impl_animation_or_transition_time_value('transition', ident, gecko_ffi_name)}
|
${impl_animation_or_transition_time_value('transition', ident, gecko_ffi_name)}
|
||||||
</%def>
|
</%def>
|
||||||
|
@ -1358,6 +1376,10 @@ fn static_assert() {
|
||||||
${impl_animation_or_transition_time_value('animation', ident, gecko_ffi_name)}
|
${impl_animation_or_transition_time_value('animation', ident, gecko_ffi_name)}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
<%def name="impl_animation_timing_function()">
|
||||||
|
${impl_animation_or_transition_timing_function('animation')}
|
||||||
|
</%def>
|
||||||
|
|
||||||
<%def name="impl_animation_keyword(ident, gecko_ffi_name, keyword, cast_type='u8')">
|
<%def name="impl_animation_keyword(ident, gecko_ffi_name, keyword, cast_type='u8')">
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn set_animation_${ident}(&mut self, v: longhands::animation_${ident}::computed_value::T) {
|
pub fn set_animation_${ident}(&mut self, v: longhands::animation_${ident}::computed_value::T) {
|
||||||
|
@ -1817,21 +1839,7 @@ fn static_assert() {
|
||||||
${impl_animation_count('iteration_count', 'IterationCount')}
|
${impl_animation_count('iteration_count', 'IterationCount')}
|
||||||
${impl_copy_animation_value('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) {
|
${impl_animation_timing_function()}
|
||||||
debug_assert!(!v.0.is_empty());
|
|
||||||
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')}
|
|
||||||
${impl_copy_animation_value('timing_function', 'TimingFunction')}
|
|
||||||
pub fn animation_timing_function_at(&self, index: usize)
|
|
||||||
-> longhands::animation_timing_function::computed_value::SingleComputedValue {
|
|
||||||
self.gecko.mAnimations[index].mTimingFunction.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
<% scroll_snap_type_keyword = Keyword("scroll-snap-type", "none mandatory proximity") %>
|
<% scroll_snap_type_keyword = Keyword("scroll-snap-type", "none mandatory proximity") %>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue