mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Move is_discrete from TransitionProperty to AnimatableLonghand
This commit is contained in:
parent
a2307adf46
commit
5ce7b1cc55
3 changed files with 21 additions and 21 deletions
|
@ -1130,14 +1130,14 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
-> bool {
|
||||
use properties::animated_properties::AnimatedProperty;
|
||||
|
||||
// We don't allow transitions on properties that are not interpolable.
|
||||
if property.is_discrete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// |property| should be an animatable longhand
|
||||
let animatable_longhand = AnimatableLonghand::from_transition_property(property).unwrap();
|
||||
|
||||
// We don't allow transitions on properties that are not interpolable.
|
||||
if animatable_longhand.is_discrete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if existing_transitions.contains_key(property) {
|
||||
// If there is an existing transition, update only if the end value differs.
|
||||
// If the end value has not changed, we should leave the currently running
|
||||
|
|
|
@ -63,6 +63,18 @@ pub enum AnimatableLonghand {
|
|||
}
|
||||
|
||||
impl AnimatableLonghand {
|
||||
/// Returns true if this AnimatableLonghand is one of the discretely animatable properties.
|
||||
pub fn is_discrete(&self) -> bool {
|
||||
match *self {
|
||||
% for prop in data.longhands:
|
||||
% if prop.animation_value_type == "discrete":
|
||||
AnimatableLonghand::${prop.camel_case} => true,
|
||||
% endif
|
||||
% endfor
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts from an nsCSSPropertyID. Returns None if nsCSSPropertyID is not an animatable
|
||||
/// longhand in Servo.
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -224,19 +236,6 @@ impl TransitionProperty {
|
|||
}).map_err(|()| SelectorParseError::UnexpectedIdent(ident.into()).into())
|
||||
}
|
||||
|
||||
/// Returns true if this TransitionProperty is one of the discrete animatable properties and
|
||||
/// this TransitionProperty should be a longhand property.
|
||||
pub fn is_discrete(&self) -> bool {
|
||||
match *self {
|
||||
% for prop in data.longhands:
|
||||
% if prop.animation_value_type == "discrete":
|
||||
TransitionProperty::${prop.camel_case} => true,
|
||||
% endif
|
||||
% endfor
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
/// Return animatable longhands of this shorthand TransitionProperty, except for "all".
|
||||
pub fn longhands(&self) -> &'static [TransitionProperty] {
|
||||
% for prop in data.shorthands_except_all():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue