Auto merge of #20123 - servo:rm-all, r=emilio

Remove TransitionProperty::All

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20123)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-02-26 10:41:31 -05:00 committed by GitHub
commit 2c2f8be1cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 68 deletions

View file

@ -309,22 +309,6 @@ impl PropertyAnimation {
} }
result 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
}
} }
} }

View file

@ -1525,11 +1525,6 @@ impl<'le> TElement for GeckoElement<'le> {
}; };
match transition_property { match transition_property {
TransitionProperty::All => {
if TransitionProperty::any(property_check_helper) {
return true;
}
},
TransitionProperty::Unsupported(..) => {}, TransitionProperty::Unsupported(..) => {},
TransitionProperty::Shorthand(ref shorthand) => { TransitionProperty::Shorthand(ref shorthand) => {
if shorthand.longhands().iter().any(property_check_helper) { if shorthand.longhands().iter().any(property_check_helper) {

View file

@ -82,11 +82,6 @@ pub fn nscsspropertyid_is_animatable(property: nsCSSPropertyID) -> bool {
// beforehand. // beforehand.
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq)] #[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
pub enum TransitionProperty { 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. /// A shorthand.
Shorthand(ShorthandId), Shorthand(ShorthandId),
/// A longhand transitionable property. /// A longhand transitionable property.
@ -102,7 +97,6 @@ impl ToCss for TransitionProperty {
W: Write, W: Write,
{ {
match *self { match *self {
TransitionProperty::All => dest.write_str("all"),
TransitionProperty::Shorthand(ref id) => dest.write_str(id.name()), TransitionProperty::Shorthand(ref id) => dest.write_str(id.name()),
TransitionProperty::Longhand(ref id) => dest.write_str(id.name()), TransitionProperty::Longhand(ref id) => dest.write_str(id.name()),
TransitionProperty::Unsupported(ref id) => id.to_css(dest), TransitionProperty::Unsupported(ref id) => id.to_css(dest),
@ -113,6 +107,12 @@ impl ToCss for TransitionProperty {
trivial_to_computed_value!(TransitionProperty); trivial_to_computed_value!(TransitionProperty);
impl TransitionProperty { impl TransitionProperty {
/// Returns `all`.
#[inline]
pub fn all() -> Self {
TransitionProperty::Shorthand(ShorthandId::All)
}
/// Iterates over each longhand property. /// Iterates over each longhand property.
pub fn each<F: FnMut(&LonghandId) -> ()>(mut cb: F) { pub fn each<F: FnMut(&LonghandId) -> ()>(mut cb: F) {
% for prop in data.longhands: % for prop in data.longhands:
@ -122,20 +122,6 @@ impl TransitionProperty {
% endfor % 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<F: FnMut(&LonghandId) -> 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. /// Parse a transition-property value.
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> { pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
// FIXME(https://github.com/rust-lang/rust/issues/33156): remove this // FIXME(https://github.com/rust-lang/rust/issues/33156): remove this
@ -144,14 +130,12 @@ impl TransitionProperty {
// //
// FIXME: This should handle aliases too. // FIXME: This should handle aliases too.
pub enum StaticId { pub enum StaticId {
All,
Longhand(LonghandId), Longhand(LonghandId),
Shorthand(ShorthandId), Shorthand(ShorthandId),
} }
ascii_case_insensitive_phf_map! { ascii_case_insensitive_phf_map! {
static_id -> StaticId = { static_id -> StaticId = {
"all" => StaticId::All, % for prop in data.shorthands:
% for prop in data.shorthands_except_all():
"${prop.name}" => StaticId::Shorthand(ShorthandId::${prop.camel_case}), "${prop.name}" => StaticId::Shorthand(ShorthandId::${prop.camel_case}),
% endfor % endfor
% for prop in data.longhands: % for prop in data.longhands:
@ -164,7 +148,6 @@ impl TransitionProperty {
let ident = input.expect_ident()?; let ident = input.expect_ident()?;
Ok(match static_id(&ident) { Ok(match static_id(&ident) {
Some(&StaticId::All) => TransitionProperty::All,
Some(&StaticId::Longhand(id)) => TransitionProperty::Longhand(id), Some(&StaticId::Longhand(id)) => TransitionProperty::Longhand(id),
Some(&StaticId::Shorthand(id)) => TransitionProperty::Shorthand(id), Some(&StaticId::Shorthand(id)) => TransitionProperty::Shorthand(id),
None => { None => {
@ -179,7 +162,9 @@ impl TransitionProperty {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub fn to_nscsspropertyid(&self) -> Result<nsCSSPropertyID, ()> { pub fn to_nscsspropertyid(&self) -> Result<nsCSSPropertyID, ()> {
Ok(match *self { 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::Shorthand(ref id) => id.to_nscsspropertyid(),
TransitionProperty::Longhand(ref id) => id.to_nscsspropertyid(), TransitionProperty::Longhand(ref id) => id.to_nscsspropertyid(),
TransitionProperty::Unsupported(..) => return Err(()), TransitionProperty::Unsupported(..) => return Err(()),
@ -203,7 +188,9 @@ impl From<nsCSSPropertyID> for TransitionProperty {
TransitionProperty::Shorthand(ShorthandId::${prop.camel_case}) TransitionProperty::Shorthand(ShorthandId::${prop.camel_case})
} }
% endfor % endfor
nsCSSPropertyID::eCSSPropertyExtra_all_properties => TransitionProperty::All, nsCSSPropertyID::eCSSPropertyExtra_all_properties => {
TransitionProperty::Shorthand(ShorthandId::All)
}
_ => { _ => {
panic!("non-convertible nsCSSPropertyID") panic!("non-convertible nsCSSPropertyID")
} }

View file

@ -246,8 +246,8 @@ ${helpers.predefined_type("transition-timing-function",
${helpers.predefined_type( ${helpers.predefined_type(
"transition-property", "transition-property",
"TransitionProperty", "TransitionProperty",
"computed::TransitionProperty::All", "computed::TransitionProperty::all()",
initial_specified_value="specified::TransitionProperty::All", initial_specified_value="specified::TransitionProperty::all()",
vector=True, vector=True,
allow_empty="NotInitial", allow_empty="NotInitial",
need_index=True, need_index=True,

View file

@ -550,12 +550,6 @@ impl From<CSSInteger> for PositiveInteger {
} }
} }
/// <length> | <percentage> | <number>
pub type LengthOrPercentageOrNumber = Either<Number, LengthOrPercentage>;
/// NonNegativeLengthOrPercentage | NonNegativeNumber
pub type NonNegativeLengthOrPercentageOrNumber = Either<NonNegativeNumber, NonNegativeLengthOrPercentage>;
#[allow(missing_docs)] #[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[cfg_attr(feature = "servo", derive(MallocSizeOf))]
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, PartialEq)] #[derive(Clone, ComputeSquaredDistance, Copy, Debug, PartialEq)]

View file

@ -550,12 +550,6 @@ pub type GridLine = GenericGridLine<Integer>;
/// `<grid-template-rows> | <grid-template-columns>` /// `<grid-template-rows> | <grid-template-columns>`
pub type GridTemplateComponent = GenericGridTemplateComponent<LengthOrPercentage, Integer>; pub type GridTemplateComponent = GenericGridTemplateComponent<LengthOrPercentage, Integer>;
/// <length> | <percentage> | <number>
pub type LengthOrPercentageOrNumber = Either<Number, LengthOrPercentage>;
/// NonNegativeLengthOrPercentage | NonNegativeNumber
pub type NonNegativeLengthOrPercentageOrNumber = Either<NonNegativeNumber, NonNegativeLengthOrPercentage>;
#[derive(Clone, Debug, MallocSizeOf, PartialEq)] #[derive(Clone, Debug, MallocSizeOf, PartialEq)]
/// rect(<top>, <left>, <bottom>, <right>) used by clip and image-region /// rect(<top>, <left>, <bottom>, <right>) used by clip and image-region
pub struct ClipRect { pub struct ClipRect {

View file

@ -7,8 +7,6 @@ use parsing::parse;
use style::context::QuirksMode; use style::context::QuirksMode;
use style::parser::{Parse, ParserContext}; use style::parser::{Parse, ParserContext};
use style::stylesheets::{CssRuleType, Origin}; 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::values::specified::length::{AbsoluteLength, Length, NoCalcLength};
use style_traits::{ParsingMode, ToCss}; use style_traits::{ParsingMode, ToCss};
@ -49,8 +47,3 @@ fn test_parsing_modes() {
assert!(result.is_ok()); assert!(result.is_ok());
assert_eq!(result.unwrap(), Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(1.)))); 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.))));
}