From 90a323afe91ec0c9268442dc96fbf7a3eff5e44e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 26 Feb 2018 10:41:31 -0500 Subject: [PATCH] servo: Merge #20123 - Remove TransitionProperty::All (from servo:rm-all); r=emilio Source-Repo: https://github.com/servo/servo Source-Revision: 2c2f8be1ccfbb38d46c351f78f0334226b3ec5f7 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 18fc10c94722332e3a5c7211376ea422980460ed --- servo/components/style/animation.rs | 16 -------- servo/components/style/gecko/wrapper.rs | 5 --- .../helpers/animated_properties.mako.rs | 39 +++++++------------ .../style/properties/longhand/box.mako.rs | 4 +- servo/components/style/values/computed/mod.rs | 6 --- .../components/style/values/specified/mod.rs | 6 --- servo/tests/unit/style/parsing/length.rs | 7 ---- 7 files changed, 15 insertions(+), 68 deletions(-) diff --git a/servo/components/style/animation.rs b/servo/components/style/animation.rs index c934d075245c..ee960586be72 100644 --- a/servo/components/style/animation.rs +++ b/servo/components/style/animation.rs @@ -309,22 +309,6 @@ impl PropertyAnimation { } result } - TransitionProperty::All => { - TransitionProperty::each(|longhand_id| { - let animation = PropertyAnimation::from_longhand( - longhand_id, - timing_function, - duration, - old_style, - new_style, - ); - - if let Some(animation) = animation { - result.push(animation); - } - }); - result - } } } diff --git a/servo/components/style/gecko/wrapper.rs b/servo/components/style/gecko/wrapper.rs index 0c5e283cee74..659e55a4c209 100644 --- a/servo/components/style/gecko/wrapper.rs +++ b/servo/components/style/gecko/wrapper.rs @@ -1525,11 +1525,6 @@ impl<'le> TElement for GeckoElement<'le> { }; match transition_property { - TransitionProperty::All => { - if TransitionProperty::any(property_check_helper) { - return true; - } - }, TransitionProperty::Unsupported(..) => {}, TransitionProperty::Shorthand(ref shorthand) => { if shorthand.longhands().iter().any(property_check_helper) { diff --git a/servo/components/style/properties/helpers/animated_properties.mako.rs b/servo/components/style/properties/helpers/animated_properties.mako.rs index f0eb0113c956..3258cc35aeb7 100644 --- a/servo/components/style/properties/helpers/animated_properties.mako.rs +++ b/servo/components/style/properties/helpers/animated_properties.mako.rs @@ -82,11 +82,6 @@ pub fn nscsspropertyid_is_animatable(property: nsCSSPropertyID) -> bool { // beforehand. #[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq)] pub enum TransitionProperty { - /// All, any transitionable property changing should generate a transition. - /// - /// FIXME(emilio): Can we remove this and just use - /// Shorthand(ShorthandId::All)? - All, /// A shorthand. Shorthand(ShorthandId), /// A longhand transitionable property. @@ -102,7 +97,6 @@ impl ToCss for TransitionProperty { W: Write, { match *self { - TransitionProperty::All => dest.write_str("all"), TransitionProperty::Shorthand(ref id) => dest.write_str(id.name()), TransitionProperty::Longhand(ref id) => dest.write_str(id.name()), TransitionProperty::Unsupported(ref id) => id.to_css(dest), @@ -113,6 +107,12 @@ impl ToCss for TransitionProperty { trivial_to_computed_value!(TransitionProperty); impl TransitionProperty { + /// Returns `all`. + #[inline] + pub fn all() -> Self { + TransitionProperty::Shorthand(ShorthandId::All) + } + /// Iterates over each longhand property. pub fn each ()>(mut cb: F) { % for prop in data.longhands: @@ -122,20 +122,6 @@ impl TransitionProperty { % endfor } - /// Iterates over every longhand property that is not - /// TransitionProperty::All, stopping and returning true when the provided - /// callback returns true for the first time. - pub fn any bool>(mut cb: F) -> bool { - % for prop in data.longhands: - % if prop.transitionable: - if cb(&LonghandId::${prop.camel_case}) { - return true; - } - % endif - % endfor - false - } - /// Parse a transition-property value. pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { // FIXME(https://github.com/rust-lang/rust/issues/33156): remove this @@ -144,14 +130,12 @@ impl TransitionProperty { // // FIXME: This should handle aliases too. pub enum StaticId { - All, Longhand(LonghandId), Shorthand(ShorthandId), } ascii_case_insensitive_phf_map! { static_id -> StaticId = { - "all" => StaticId::All, - % for prop in data.shorthands_except_all(): + % for prop in data.shorthands: "${prop.name}" => StaticId::Shorthand(ShorthandId::${prop.camel_case}), % endfor % for prop in data.longhands: @@ -164,7 +148,6 @@ impl TransitionProperty { let ident = input.expect_ident()?; Ok(match static_id(&ident) { - Some(&StaticId::All) => TransitionProperty::All, Some(&StaticId::Longhand(id)) => TransitionProperty::Longhand(id), Some(&StaticId::Shorthand(id)) => TransitionProperty::Shorthand(id), None => { @@ -179,7 +162,9 @@ impl TransitionProperty { #[cfg(feature = "gecko")] pub fn to_nscsspropertyid(&self) -> Result { Ok(match *self { - TransitionProperty::All => nsCSSPropertyID::eCSSPropertyExtra_all_properties, + TransitionProperty::Shorthand(ShorthandId::All) => { + nsCSSPropertyID::eCSSPropertyExtra_all_properties + } TransitionProperty::Shorthand(ref id) => id.to_nscsspropertyid(), TransitionProperty::Longhand(ref id) => id.to_nscsspropertyid(), TransitionProperty::Unsupported(..) => return Err(()), @@ -203,7 +188,9 @@ impl From for TransitionProperty { TransitionProperty::Shorthand(ShorthandId::${prop.camel_case}) } % endfor - nsCSSPropertyID::eCSSPropertyExtra_all_properties => TransitionProperty::All, + nsCSSPropertyID::eCSSPropertyExtra_all_properties => { + TransitionProperty::Shorthand(ShorthandId::All) + } _ => { panic!("non-convertible nsCSSPropertyID") } diff --git a/servo/components/style/properties/longhand/box.mako.rs b/servo/components/style/properties/longhand/box.mako.rs index 6bc9bf8e6219..3cc55b54b61c 100644 --- a/servo/components/style/properties/longhand/box.mako.rs +++ b/servo/components/style/properties/longhand/box.mako.rs @@ -246,8 +246,8 @@ ${helpers.predefined_type("transition-timing-function", ${helpers.predefined_type( "transition-property", "TransitionProperty", - "computed::TransitionProperty::All", - initial_specified_value="specified::TransitionProperty::All", + "computed::TransitionProperty::all()", + initial_specified_value="specified::TransitionProperty::all()", vector=True, allow_empty="NotInitial", need_index=True, diff --git a/servo/components/style/values/computed/mod.rs b/servo/components/style/values/computed/mod.rs index 36d70e7ea3e7..ebbb7af6b5cd 100644 --- a/servo/components/style/values/computed/mod.rs +++ b/servo/components/style/values/computed/mod.rs @@ -550,12 +550,6 @@ impl From for PositiveInteger { } } -/// | | -pub type LengthOrPercentageOrNumber = Either; - -/// NonNegativeLengthOrPercentage | NonNegativeNumber -pub type NonNegativeLengthOrPercentageOrNumber = Either; - #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[derive(Clone, ComputeSquaredDistance, Copy, Debug, PartialEq)] diff --git a/servo/components/style/values/specified/mod.rs b/servo/components/style/values/specified/mod.rs index b0c0c1cffba7..5ea811a5c95d 100644 --- a/servo/components/style/values/specified/mod.rs +++ b/servo/components/style/values/specified/mod.rs @@ -550,12 +550,6 @@ pub type GridLine = GenericGridLine; /// ` | ` pub type GridTemplateComponent = GenericGridTemplateComponent; -/// | | -pub type LengthOrPercentageOrNumber = Either; - -/// NonNegativeLengthOrPercentage | NonNegativeNumber -pub type NonNegativeLengthOrPercentageOrNumber = Either; - #[derive(Clone, Debug, MallocSizeOf, PartialEq)] /// rect(, , , ) used by clip and image-region pub struct ClipRect { diff --git a/servo/tests/unit/style/parsing/length.rs b/servo/tests/unit/style/parsing/length.rs index 7b691311ebdb..0d506926ad8c 100644 --- a/servo/tests/unit/style/parsing/length.rs +++ b/servo/tests/unit/style/parsing/length.rs @@ -7,8 +7,6 @@ use parsing::parse; use style::context::QuirksMode; use style::parser::{Parse, ParserContext}; use style::stylesheets::{CssRuleType, Origin}; -use style::values::Either; -use style::values::specified::{LengthOrPercentageOrNumber, Number}; use style::values::specified::length::{AbsoluteLength, Length, NoCalcLength}; use style_traits::{ParsingMode, ToCss}; @@ -49,8 +47,3 @@ fn test_parsing_modes() { assert!(result.is_ok()); assert_eq!(result.unwrap(), Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(1.)))); } - -#[test] -fn test_zero_percentage_length_or_number() { - assert_eq!(parse(LengthOrPercentageOrNumber::parse, "0"), Ok(Either::First(Number::new(0.)))); -}