mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Use the same computed time representation between Servo and Gecko
Same as above. Differential Revision: https://phabricator.services.mozilla.com/D167126
This commit is contained in:
parent
b96f8f748c
commit
fe8cdbe328
3 changed files with 14 additions and 13 deletions
|
@ -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<LonghandId, Arc<AnimationValue>>,
|
||||
|
@ -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,
|
||||
|
|
|
@ -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<I>(&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;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ use style_traits::{CssWriter, ToCss};
|
|||
/// A computed `<time>` value.
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd, ToResolvedValue)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[repr(C)]
|
||||
pub struct Time {
|
||||
seconds: CSSFloat,
|
||||
}
|
||||
|
@ -18,7 +19,7 @@ pub struct Time {
|
|||
impl Time {
|
||||
/// Creates a time value from a seconds amount.
|
||||
pub fn from_seconds(seconds: CSSFloat) -> Self {
|
||||
Time { seconds: seconds }
|
||||
Time { seconds }
|
||||
}
|
||||
|
||||
/// Returns `0s`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue