Bug 1371518 - Introduce AnimatableLonghand type; r?hiro draft
authorBrian Birtles <birtles@gmail.com>
Wed, 14 Jun 2017 14:36:53 +0900
changeset 593853 63b47754692cd1ec8251a1497ed442f6cc5d3d7e
parent 593852 2ec206dda31926dd66ee5930a09dd5cf5140ea5d
child 593854 c14e3c0c642f0a64657e9d668dbce6c1ba245a13
push id63840
push userbbirtles@mozilla.com
push dateWed, 14 Jun 2017 07:29:38 +0000
reviewershiro
bugs1371518
milestone56.0a1
Bug 1371518 - Introduce AnimatableLonghand type; r?hiro This type, which we will use in the next patch in this series, can represent only longhands whose animation type is not "none". By introducing this type, we can later restrict the meaning of TransitionProperty to only cover properties whose animation type is not "none" OR "discrete" (since currently CSS transitions should not animate properties whose animation type is discrete). Doing so will also mean that CSS transitions ignore the 'display' property by default. Furthermore, introducing this type will allow the animation code to clearly document when a property is allowed to be a shorthand or unanimatable property and when it is expected to be an animatable longhand. This, in turn, will allow us to remove a few no-longer-necessary checks and simplify the code. MozReview-Commit-ID: 96aVio9EED
servo/components/style/properties/helpers/animated_properties.mako.rs
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -41,16 +41,30 @@ use values::computed::{Angle, LengthOrPe
 use values::computed::{BorderCornerRadius, ClipRect};
 use values::computed::{CalcLengthOrPercentage, Color, Context, ComputedValueAsSpecified};
 use values::computed::{LengthOrPercentage, MaxLength, MozLength, Shadow, ToComputedValue};
 use values::generics::{SVGPaint, SVGPaintKind};
 use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
 use values::generics::position as generic_position;
 
 
+/// A longhand property whose animation type is not "none".
+///
+/// NOTE: This includes the 'display' property since it is animatable from SMIL even though it is
+/// not animatable from CSS animations or Web Animations. CSS transitions also does not allow
+/// animating 'display', but for CSS transitions we have the separate TransitionProperty type.
+pub enum AnimatableLonghand {
+    % for prop in data.longhands:
+        % if prop.animatable:
+            /// ${prop.name}
+            ${prop.camel_case},
+        % endif
+    % endfor
+}
+
 /// A given transition property, that is either `All`, an animatable longhand property,
 /// a shorthand with at least one animatable longhand component, or an unsupported property.
 // NB: This needs to be here because it needs all the longhands generated
 // beforehand.
 #[derive(Clone, Debug, PartialEq, Eq, Hash)]
 #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub enum TransitionProperty {
     /// All, any animatable property changing should generate a transition.