Skip to content

Commit e3406b4

Browse files
authored
Implement transition-behavior (#84)
Also removes some code that isn't present upstream. Signed-off-by: Oriol Brufau <[email protected]>
1 parent 8f9898c commit e3406b4

File tree

5 files changed

+9
-52
lines changed

5 files changed

+9
-52
lines changed

style/animation.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use crate::stylesheets::layer_rule::LayerOrder;
2727
use crate::values::animated::{Animate, Procedure};
2828
use crate::values::computed::{Time, TimingFunction};
2929
use crate::values::generics::easing::BeforeFlag;
30+
use crate::values::specified::TransitionBehavior;
3031
use crate::Atom;
3132
use fxhash::FxHashMap;
3233
use parking_lot::RwLock;
@@ -1029,11 +1030,16 @@ impl ElementAnimationSet {
10291030
old_style: &ComputedValues,
10301031
new_style: &Arc<ComputedValues>,
10311032
) {
1032-
if !property_declaration_id.is_transitionable() {
1033+
let style = new_style.get_ui();
1034+
1035+
#[cfg(feature = "servo")]
1036+
if !property_declaration_id.is_animatable() ||
1037+
(style.transition_behavior_mod(index) != TransitionBehavior::AllowDiscrete &&
1038+
property_declaration_id.is_discrete_animatable())
1039+
{
10331040
return;
10341041
}
10351042

1036-
let style = new_style.get_ui();
10371043
let timing_function = style.transition_timing_function_mod(index);
10381044
let duration = style.transition_duration_mod(index);
10391045
let delay = style.transition_delay_mod(index).seconds() as f64;

style/properties/data.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,6 @@ def __init__(
429429
assert animation_type in ["none", "normal", "discrete"]
430430
self.animation_type = animation_type
431431
self.animatable = animation_type != "none"
432-
self.transitionable = (
433-
animation_type != "none" and animation_type != "discrete"
434-
)
435432

436433
# See compute_damage for the various values this can take
437434
self.servo_restyle_damage = servo_restyle_damage
@@ -675,16 +672,7 @@ def get_animatable(self):
675672
return True
676673
return False
677674

678-
def get_transitionable(self):
679-
transitionable = False
680-
for sub in self.sub_properties:
681-
if sub.transitionable:
682-
transitionable = True
683-
break
684-
return transitionable
685-
686675
animatable = property(get_animatable)
687-
transitionable = property(get_transitionable)
688676

689677
@staticmethod
690678
def type():
@@ -701,7 +689,6 @@ def __init__(self, name, original, gecko_pref):
701689
self.animatable = original.animatable
702690
self.servo_pref = original.servo_pref
703691
self.gecko_pref = gecko_pref
704-
self.transitionable = original.transitionable
705692
self.rule_types_allowed = original.rule_types_allowed
706693
self.flags = original.flags
707694

style/properties/longhands/ui.mako.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ ${helpers.predefined_type(
201201
need_index=True,
202202
animation_type="none",
203203
gecko_pref="layout.css.transition-behavior.enabled",
204-
servo_pref="layout.unimplemented",
204+
servo_pref="layout.css.transition-behavior.enabled",
205205
spec="https://drafts.csswg.org/css-transitions-2/#transition-behavior-property",
206206
affects="",
207207
)}

style/properties/mod.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,6 @@ impl PropertyId {
367367
}
368368
}
369369

370-
/// Returns true if this property is one of the transitionable properties.
371-
pub fn is_transitionable(&self) -> bool {
372-
match self {
373-
Self::NonCustom(id) => id.is_transitionable(),
374-
Self::Custom(..) => true,
375-
}
376-
}
377-
378370
/// Returns a given property from the given name, _regardless of whether it is enabled or
379371
/// not_, or Err(()) for unknown properties.
380372
///
@@ -1117,15 +1109,6 @@ impl<'a> PropertyDeclarationId<'a> {
11171109
}
11181110
}
11191111

1120-
/// Returns whether this property is transitionable.
1121-
#[inline]
1122-
pub fn is_transitionable(self) -> bool {
1123-
match self {
1124-
PropertyDeclarationId::Longhand(id) => id.is_transitionable(),
1125-
PropertyDeclarationId::Custom(..) => false,
1126-
}
1127-
}
1128-
11291112
/// Converts from a to an adequate nsCSSPropertyID, returning
11301113
/// eCSSPropertyExtra_variable for custom properties.
11311114
#[cfg(feature = "gecko")]

style/properties/properties.mako.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,6 @@ impl NonCustomPropertyId {
485485
MAP[self.0 as usize]
486486
}
487487

488-
/// Returns whether this property is transitionable.
489-
#[inline]
490-
pub fn is_transitionable(self) -> bool {
491-
${static_non_custom_property_id_set("TRANSITIONABLE", lambda p: p.transitionable)}
492-
TRANSITIONABLE.contains(self)
493-
}
494-
495488
/// Returns whether this property is animatable.
496489
#[inline]
497490
pub fn is_animatable(self) -> bool {
@@ -831,12 +824,6 @@ impl LonghandIdSet {
831824
&DISCRETE_ANIMATABLE
832825
}
833826

834-
#[inline]
835-
fn transitionable() -> &'static Self {
836-
${static_longhand_id_set("TRANSITIONABLE", lambda p: p.transitionable)}
837-
&TRANSITIONABLE
838-
}
839-
840827
#[inline]
841828
pub(super) fn logical() -> &'static Self {
842829
${static_longhand_id_set("LOGICAL", lambda p: p.logical)}
@@ -1014,12 +1001,6 @@ impl LonghandId {
10141001
(PARSE_PROPERTY[self as usize])(context, input)
10151002
}
10161003

1017-
/// Returns whether this property is transitionable.
1018-
#[inline]
1019-
pub fn is_transitionable(self) -> bool {
1020-
LonghandIdSet::transitionable().contains(self)
1021-
}
1022-
10231004
/// Return the relevant data to map a particular logical property into physical.
10241005
fn logical_mapping_data(self) -> Option<<&'static LogicalMappingData> {
10251006
const LOGICAL_MAPPING_DATA: [Option<LogicalMappingData>; ${len(data.longhands)}] = [

0 commit comments

Comments
 (0)