Skip to content

Commit

Permalink
Implement transition-behavior
Browse files Browse the repository at this point in the history
Also removes some code that isn't present upstream.

Signed-off-by: Oriol Brufau <[email protected]>
  • Loading branch information
Loirooriol committed Oct 24, 2024
1 parent 8f9898c commit 253e5d7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 52 deletions.
10 changes: 8 additions & 2 deletions style/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::stylesheets::layer_rule::LayerOrder;
use crate::values::animated::{Animate, Procedure};
use crate::values::computed::{Time, TimingFunction};
use crate::values::generics::easing::BeforeFlag;
use crate::values::specified::TransitionBehavior;
use crate::Atom;
use fxhash::FxHashMap;
use parking_lot::RwLock;
Expand Down Expand Up @@ -1029,11 +1030,16 @@ impl ElementAnimationSet {
old_style: &ComputedValues,
new_style: &Arc<ComputedValues>,
) {
if !property_declaration_id.is_transitionable() {
let style = new_style.get_ui();

#[cfg(feature = "servo")]
if !property_declaration_id.is_animatable() ||
(style.transition_behavior_mod(index) != TransitionBehavior::AllowDiscrete &&
property_declaration_id.is_discrete_animatable())
{
return;
}

let style = new_style.get_ui();
let timing_function = style.transition_timing_function_mod(index);
let duration = style.transition_duration_mod(index);
let delay = style.transition_delay_mod(index).seconds() as f64;
Expand Down
13 changes: 0 additions & 13 deletions style/properties/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,6 @@ def __init__(
assert animation_type in ["none", "normal", "discrete"]
self.animation_type = animation_type
self.animatable = animation_type != "none"
self.transitionable = (
animation_type != "none" and animation_type != "discrete"
)

# See compute_damage for the various values this can take
self.servo_restyle_damage = servo_restyle_damage
Expand Down Expand Up @@ -675,16 +672,7 @@ def get_animatable(self):
return True
return False

def get_transitionable(self):
transitionable = False
for sub in self.sub_properties:
if sub.transitionable:
transitionable = True
break
return transitionable

animatable = property(get_animatable)
transitionable = property(get_transitionable)

@staticmethod
def type():
Expand All @@ -701,7 +689,6 @@ def __init__(self, name, original, gecko_pref):
self.animatable = original.animatable
self.servo_pref = original.servo_pref
self.gecko_pref = gecko_pref
self.transitionable = original.transitionable
self.rule_types_allowed = original.rule_types_allowed
self.flags = original.flags

Expand Down
2 changes: 1 addition & 1 deletion style/properties/longhands/ui.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ ${helpers.predefined_type(
need_index=True,
animation_type="none",
gecko_pref="layout.css.transition-behavior.enabled",
servo_pref="layout.unimplemented",
servo_pref="layout.css.transition-behavior.enabled",
spec="https://drafts.csswg.org/css-transitions-2/#transition-behavior-property",
affects="",
)}
Expand Down
17 changes: 0 additions & 17 deletions style/properties/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,6 @@ impl PropertyId {
}
}

/// Returns true if this property is one of the transitionable properties.
pub fn is_transitionable(&self) -> bool {
match self {
Self::NonCustom(id) => id.is_transitionable(),
Self::Custom(..) => true,
}
}

/// Returns a given property from the given name, _regardless of whether it is enabled or
/// not_, or Err(()) for unknown properties.
///
Expand Down Expand Up @@ -1117,15 +1109,6 @@ impl<'a> PropertyDeclarationId<'a> {
}
}

/// Returns whether this property is transitionable.
#[inline]
pub fn is_transitionable(self) -> bool {
match self {
PropertyDeclarationId::Longhand(id) => id.is_transitionable(),
PropertyDeclarationId::Custom(..) => false,
}
}

/// Converts from a to an adequate nsCSSPropertyID, returning
/// eCSSPropertyExtra_variable for custom properties.
#[cfg(feature = "gecko")]
Expand Down
19 changes: 0 additions & 19 deletions style/properties/properties.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,6 @@ impl NonCustomPropertyId {
MAP[self.0 as usize]
}

/// Returns whether this property is transitionable.
#[inline]
pub fn is_transitionable(self) -> bool {
${static_non_custom_property_id_set("TRANSITIONABLE", lambda p: p.transitionable)}
TRANSITIONABLE.contains(self)
}

/// Returns whether this property is animatable.
#[inline]
pub fn is_animatable(self) -> bool {
Expand Down Expand Up @@ -831,12 +824,6 @@ impl LonghandIdSet {
&DISCRETE_ANIMATABLE
}

#[inline]
fn transitionable() -> &'static Self {
${static_longhand_id_set("TRANSITIONABLE", lambda p: p.transitionable)}
&TRANSITIONABLE
}

#[inline]
pub(super) fn logical() -> &'static Self {
${static_longhand_id_set("LOGICAL", lambda p: p.logical)}
Expand Down Expand Up @@ -1014,12 +1001,6 @@ impl LonghandId {
(PARSE_PROPERTY[self as usize])(context, input)
}

/// Returns whether this property is transitionable.
#[inline]
pub fn is_transitionable(self) -> bool {
LonghandIdSet::transitionable().contains(self)
}

/// Return the relevant data to map a particular logical property into physical.
fn logical_mapping_data(self) -> Option<<&'static LogicalMappingData> {
const LOGICAL_MAPPING_DATA: [Option<LogicalMappingData>; ${len(data.longhands)}] = [
Expand Down

0 comments on commit 253e5d7

Please sign in to comment.