diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index bf06761d6f0..e09fb9e9af0 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -858,7 +858,7 @@ impl<'le> GeckoElement<'le> { fn needs_transitions_update_per_property( &self, longhand_id: LonghandId, - combined_duration: f32, + combined_duration_seconds: f32, before_change_style: &ComputedValues, after_change_style: &ComputedValues, existing_transitions: &FxHashMap>, @@ -884,7 +884,7 @@ impl<'le> GeckoElement<'le> { debug_assert_eq!(to.is_some(), from.is_some()); - combined_duration > 0.0f32 && + combined_duration_seconds > 0.0f32 && from != to && from.unwrap() .animate( @@ -1533,7 +1533,7 @@ impl<'le> TElement for GeckoElement<'le> { transitions_to_keep.insert(physical_longhand); if self.needs_transitions_update_per_property( physical_longhand, - after_change_ui_style.transition_combined_duration_at(transition_property.index), + after_change_ui_style.transition_combined_duration_at(transition_property.index).seconds(), before_change_style, after_change_style, &existing_transitions, diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index c799ebdb03f..bb134a64ac9 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -39,8 +39,7 @@ use servo_arc::{Arc, RawOffsetArc, UniqueArc}; use std::mem::{forget, MaybeUninit}; use std::{cmp, ops, ptr}; use crate::values::{self, CustomIdent, KeyframesName}; -use crate::values::computed::{Percentage, TransitionProperty}; -use crate::values::computed::BorderStyle; +use crate::values::computed::{BorderStyle, Percentage, Time, TransitionProperty}; use crate::values::computed::font::FontSize; use crate::values::generics::column::ColumnCount; @@ -1038,14 +1037,13 @@ fn static_assert() { self.gecko.m${type.capitalize()}${gecko_ffi_name}Count = input_len as u32; for (gecko, servo) in self.gecko.m${type.capitalize()}s.iter_mut().take(input_len as usize).zip(v) { - gecko.m${gecko_ffi_name} = servo.seconds() * 1000.; + gecko.m${gecko_ffi_name} = servo; } } #[allow(non_snake_case)] pub fn ${type}_${ident}_at(&self, index: usize) -> longhands::${type}_${ident}::computed_value::SingleComputedValue { - use crate::values::computed::Time; - Time::from_seconds(self.gecko.m${type.capitalize()}s[index].m${gecko_ffi_name} / 1000.) + self.gecko.m${type.capitalize()}s[index].m${gecko_ffi_name} } ${impl_animation_or_transition_count(type, ident, gecko_ffi_name)} ${impl_copy_animation_or_transition_value(type, ident, gecko_ffi_name)} @@ -1772,10 +1770,12 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask- ${impl_transition_time_value('duration', 'Duration')} ${impl_animation_or_transition_timing_function('transition')} - pub fn transition_combined_duration_at(&self, index: usize) -> f32 { + pub fn transition_combined_duration_at(&self, index: usize) -> Time { // https://drafts.csswg.org/css-transitions/#transition-combined-duration - self.gecko.mTransitions[index % self.gecko.mTransitionDurationCount as usize].mDuration.max(0.0) - + self.gecko.mTransitions[index % self.gecko.mTransitionDelayCount as usize].mDelay + Time::from_seconds( + self.transition_duration_at(index).seconds().max(0.0) + + self.transition_delay_at(index).seconds() + ) } pub fn set_transition_property(&mut self, v: I) @@ -1818,7 +1818,7 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask- use crate::gecko_bindings::structs::nsCSSPropertyID::eCSSPropertyExtra_all_properties; if self.gecko.mTransitionPropertyCount == 1 && self.gecko.mTransitions[0].mProperty == eCSSPropertyExtra_all_properties && - self.transition_combined_duration_at(0) <= 0.0f32 { + self.transition_combined_duration_at(0).seconds() <= 0.0f32 { return false; } diff --git a/components/style/values/computed/time.rs b/components/style/values/computed/time.rs index 5681f6fab5e..1f0a6df018b 100644 --- a/components/style/values/computed/time.rs +++ b/components/style/values/computed/time.rs @@ -11,6 +11,7 @@ use style_traits::{CssWriter, ToCss}; /// A computed `