mirror of
https://github.com/servo/servo.git
synced 2025-06-21 23:59:00 +01:00
Use CustomIdent for transition-property
This commit is contained in:
parent
cdcc8157c6
commit
51a4481388
3 changed files with 31 additions and 32 deletions
|
@ -63,8 +63,8 @@ use std::mem::{forget, transmute, zeroed};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use stylearc::Arc;
|
use stylearc::Arc;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
use values::{Auto, CustomIdent, Either, KeyframesName};
|
||||||
use values::computed::{Shadow, ToComputedValue};
|
use values::computed::{Shadow, ToComputedValue};
|
||||||
use values::{Either, Auto, KeyframesName};
|
|
||||||
use computed_values::border_style;
|
use computed_values::border_style;
|
||||||
|
|
||||||
pub mod style_structs {
|
pub mod style_structs {
|
||||||
|
@ -2430,8 +2430,8 @@ fn static_assert() {
|
||||||
self.gecko.mTransitionPropertyCount = v.len() as u32;
|
self.gecko.mTransitionPropertyCount = v.len() as u32;
|
||||||
for (servo, gecko) in v.zip(self.gecko.mTransitions.iter_mut()) {
|
for (servo, gecko) in v.zip(self.gecko.mTransitions.iter_mut()) {
|
||||||
match servo {
|
match servo {
|
||||||
TransitionProperty::Unsupported(ref atom) => unsafe {
|
TransitionProperty::Unsupported(ref ident) => unsafe {
|
||||||
Gecko_StyleTransition_SetUnsupportedProperty(gecko, atom.as_ptr())
|
Gecko_StyleTransition_SetUnsupportedProperty(gecko, ident.0.as_ptr())
|
||||||
},
|
},
|
||||||
_ => gecko.mProperty = (&servo).into(),
|
_ => gecko.mProperty = (&servo).into(),
|
||||||
}
|
}
|
||||||
|
@ -2466,11 +2466,11 @@ fn static_assert() {
|
||||||
if property == eCSSProperty_UNKNOWN || property == eCSSPropertyExtra_variable {
|
if property == eCSSProperty_UNKNOWN || property == eCSSPropertyExtra_variable {
|
||||||
let atom = self.gecko.mTransitions[index].mUnknownProperty.raw::<nsIAtom>();
|
let atom = self.gecko.mTransitions[index].mUnknownProperty.raw::<nsIAtom>();
|
||||||
debug_assert!(!atom.is_null());
|
debug_assert!(!atom.is_null());
|
||||||
TransitionProperty::Unsupported(atom.into())
|
TransitionProperty::Unsupported(CustomIdent(atom.into()))
|
||||||
} else if property == eCSSPropertyExtra_no_properties {
|
} else if property == eCSSPropertyExtra_no_properties {
|
||||||
// Actually, we don't expect TransitionProperty::Unsupported also represents "none",
|
// Actually, we don't expect TransitionProperty::Unsupported also represents "none",
|
||||||
// but if the caller wants to convert it, it is fine. Please use it carefully.
|
// but if the caller wants to convert it, it is fine. Please use it carefully.
|
||||||
TransitionProperty::Unsupported(atom!("none"))
|
TransitionProperty::Unsupported(CustomIdent(atom!("none")))
|
||||||
} else {
|
} else {
|
||||||
property.into()
|
property.into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<% from data import SYSTEM_FONT_LONGHANDS %>
|
<% from data import SYSTEM_FONT_LONGHANDS %>
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use cssparser::{Parser, RGBA, serialize_identifier};
|
use cssparser::{Parser, RGBA};
|
||||||
use euclid::{Point2D, Size2D};
|
use euclid::{Point2D, Size2D};
|
||||||
#[cfg(feature = "gecko")] use gecko_bindings::bindings::RawServoAnimationValueMap;
|
#[cfg(feature = "gecko")] use gecko_bindings::bindings::RawServoAnimationValueMap;
|
||||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::RawGeckoGfxMatrix4x4;
|
#[cfg(feature = "gecko")] use gecko_bindings::structs::RawGeckoGfxMatrix4x4;
|
||||||
|
@ -28,15 +28,13 @@ use properties::longhands::vertical_align::computed_value::T as VerticalAlign;
|
||||||
use properties::longhands::visibility::computed_value::T as Visibility;
|
use properties::longhands::visibility::computed_value::T as Visibility;
|
||||||
#[cfg(feature = "gecko")] use properties::{PropertyDeclarationId, LonghandId};
|
#[cfg(feature = "gecko")] use properties::{PropertyDeclarationId, LonghandId};
|
||||||
use selectors::parser::SelectorParseError;
|
use selectors::parser::SelectorParseError;
|
||||||
#[cfg(feature = "servo")] use servo_atoms::Atom;
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
#[cfg(feature = "gecko")] use std::collections::HashMap;
|
#[cfg(feature = "gecko")] use std::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style_traits::{ToCss, ParseError};
|
use style_traits::{ToCss, ParseError};
|
||||||
use super::ComputedValues;
|
use super::ComputedValues;
|
||||||
use values::CSSFloat;
|
use values::{Auto, CSSFloat, CustomIdent, Either};
|
||||||
use values::{Auto, Either};
|
|
||||||
use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
||||||
use values::computed::{BorderCornerRadius, ClipRect};
|
use values::computed::{BorderCornerRadius, ClipRect};
|
||||||
use values::computed::{CalcLengthOrPercentage, Color, Context, ComputedValueAsSpecified};
|
use values::computed::{CalcLengthOrPercentage, Color, Context, ComputedValueAsSpecified};
|
||||||
|
@ -193,7 +191,7 @@ pub enum TransitionProperty {
|
||||||
% endfor
|
% endfor
|
||||||
/// Unrecognized property which could be any non-transitionable, custom property, or
|
/// Unrecognized property which could be any non-transitionable, custom property, or
|
||||||
/// unknown property.
|
/// unknown property.
|
||||||
Unsupported(Atom)
|
Unsupported(CustomIdent)
|
||||||
}
|
}
|
||||||
|
|
||||||
no_viewport_percentage!(TransitionProperty);
|
no_viewport_percentage!(TransitionProperty);
|
||||||
|
@ -226,21 +224,22 @@ impl TransitionProperty {
|
||||||
/// 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>> {
|
||||||
let ident = try!(input.expect_ident());
|
let ident = try!(input.expect_ident());
|
||||||
(match_ignore_ascii_case! { &ident,
|
let supported = match_ignore_ascii_case! { &ident,
|
||||||
"all" => Ok(TransitionProperty::All),
|
"all" => Ok(Some(TransitionProperty::All)),
|
||||||
% for prop in data.longhands + data.shorthands_except_all():
|
% for prop in data.longhands + data.shorthands_except_all():
|
||||||
% if prop.transitionable:
|
% if prop.transitionable:
|
||||||
"${prop.name}" => Ok(TransitionProperty::${prop.camel_case}),
|
"${prop.name}" => Ok(Some(TransitionProperty::${prop.camel_case})),
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
"none" => Err(()),
|
"none" => Err(()),
|
||||||
_ => {
|
_ => Ok(None),
|
||||||
match CSSWideKeyword::from_ident(&ident) {
|
};
|
||||||
Some(_) => Err(()),
|
|
||||||
None => Ok(TransitionProperty::Unsupported((&*ident).into()))
|
match supported {
|
||||||
}
|
Ok(Some(property)) => Ok(property),
|
||||||
}
|
Ok(None) => CustomIdent::from_ident(ident, &[]).map(TransitionProperty::Unsupported),
|
||||||
}).map_err(|()| SelectorParseError::UnexpectedIdent(ident.into()).into())
|
Err(()) => Err(SelectorParseError::UnexpectedIdent(ident).into()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return transitionable longhands of this shorthand TransitionProperty, except for "all".
|
/// Return transitionable longhands of this shorthand TransitionProperty, except for "all".
|
||||||
|
@ -290,11 +289,7 @@ impl ToCss for TransitionProperty {
|
||||||
TransitionProperty::${prop.camel_case} => dest.write_str("${prop.name}"),
|
TransitionProperty::${prop.camel_case} => dest.write_str("${prop.name}"),
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
#[cfg(feature = "gecko")]
|
TransitionProperty::Unsupported(ref ident) => ident.to_css(dest),
|
||||||
TransitionProperty::Unsupported(ref atom) => serialize_identifier(&atom.to_string(),
|
|
||||||
dest),
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
TransitionProperty::Unsupported(ref atom) => serialize_identifier(atom, dest),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,7 +324,7 @@ impl From<nsCSSPropertyID> for TransitionProperty {
|
||||||
=> TransitionProperty::${prop.camel_case},
|
=> TransitionProperty::${prop.camel_case},
|
||||||
% else:
|
% else:
|
||||||
${helpers.to_nscsspropertyid(prop.ident)}
|
${helpers.to_nscsspropertyid(prop.ident)}
|
||||||
=> TransitionProperty::Unsupported(Atom::from("${prop.ident}")),
|
=> TransitionProperty::Unsupported(CustomIdent(Atom::from("${prop.ident}"))),
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
nsCSSPropertyID::eCSSPropertyExtra_all_properties => TransitionProperty::All,
|
nsCSSPropertyID::eCSSPropertyExtra_all_properties => TransitionProperty::All,
|
||||||
|
|
|
@ -7,6 +7,7 @@ use servo_atoms::Atom;
|
||||||
use style::properties::animated_properties::TransitionProperty;
|
use style::properties::animated_properties::TransitionProperty;
|
||||||
use style::properties::longhands::transition_property;
|
use style::properties::longhands::transition_property;
|
||||||
use style::properties::shorthands::transition;
|
use style::properties::shorthands::transition;
|
||||||
|
use style::values::CustomIdent;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -19,12 +20,15 @@ fn test_longhand_properties() {
|
||||||
assert_roundtrip_with_context!(transition_property::parse, "-other-unsupported-property");
|
assert_roundtrip_with_context!(transition_property::parse, "-other-unsupported-property");
|
||||||
assert_roundtrip_with_context!(transition_property::parse, "--var");
|
assert_roundtrip_with_context!(transition_property::parse, "--var");
|
||||||
|
|
||||||
assert_eq!(parse_longhand!(transition_property, "margin-left, transition-delay, width, --var"),
|
assert_eq!(
|
||||||
transition_property::SpecifiedValue(
|
parse_longhand!(transition_property, "margin-left, transition-delay, width, --var"),
|
||||||
vec![TransitionProperty::MarginLeft,
|
transition_property::SpecifiedValue(vec![
|
||||||
TransitionProperty::Unsupported(Atom::from("transition-delay")),
|
TransitionProperty::MarginLeft,
|
||||||
TransitionProperty::Width,
|
TransitionProperty::Unsupported(CustomIdent(Atom::from("transition-delay"))),
|
||||||
TransitionProperty::Unsupported(Atom::from("--var"))]));
|
TransitionProperty::Width,
|
||||||
|
TransitionProperty::Unsupported(CustomIdent(Atom::from("--var"))),
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
assert!(parse(transition_property::parse, ".width").is_err());
|
assert!(parse(transition_property::parse, ".width").is_err());
|
||||||
assert!(parse(transition_property::parse, "1width").is_err());
|
assert!(parse(transition_property::parse, "1width").is_err());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue