Bug 1343751 - Pass transition-property into gecko's struct. r?emilio
MozReview-Commit-ID: COwxp4wtQNy
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -615,19 +615,16 @@ impl Debug for ${style_struct.gecko_stru
force_stub += ["font-variant"]
# These have unusual representations in gecko.
force_stub += ["list-style-type"]
# These are part of shorthands so we must include them in stylo builds,
# but we haven't implemented the stylo glue for the longhand
# so we generate a stub
force_stub += ["flex-basis", # position
-
- # transition
- "transition-property",
]
# Types used with predefined_type()-defined properties that we can auto-generate.
predefined_types = {
"length::LengthOrAuto": impl_style_coord,
"length::LengthOrNormal": impl_style_coord,
"Length": impl_absolute_length,
"Position": impl_position,
@@ -1358,16 +1355,20 @@ fn static_assert() {
self.gecko.m${type.capitalize()}s[index].mTimingFunction.into()
}
</%def>
<%def name="impl_transition_time_value(ident, gecko_ffi_name)">
${impl_animation_or_transition_time_value('transition', ident, gecko_ffi_name)}
</%def>
+<%def name="impl_transition_count(ident, gecko_ffi_name)">
+ ${impl_animation_or_transition_count('transition', ident, gecko_ffi_name)}
+</%def>
+
<%def name="impl_copy_animation_value(ident, gecko_ffi_name)">
${impl_copy_animation_or_transition_value('animation', ident, gecko_ffi_name)}
</%def>
<%def name="impl_transition_timing_function()">
${impl_animation_or_transition_timing_function('transition')}
</%def>
@@ -1419,17 +1420,17 @@ fn static_assert() {
${impl_copy_animation_value(ident, gecko_ffi_name)}
</%def>
<% skip_box_longhands= """display overflow-y vertical-align
animation-name animation-delay animation-duration
animation-direction animation-fill-mode animation-play-state
animation-iteration-count animation-timing-function
transition-duration transition-delay
- transition-timing-function
+ transition-timing-function transition-property
page-break-before page-break-after
scroll-snap-points-x scroll-snap-points-y transform
scroll-snap-type-y scroll-snap-coordinate
perspective-origin transform-origin""" %>
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
// We manually-implement the |display| property until we get general
// infrastructure for preffing certain values.
@@ -1767,16 +1768,48 @@ fn static_assert() {
}
computed_value::T(Some(result))
}
${impl_transition_time_value('delay', 'Delay')}
${impl_transition_time_value('duration', 'Duration')}
${impl_transition_timing_function()}
+ pub fn set_transition_property(&mut self, v: longhands::transition_property::computed_value::T) {
+ use gecko_bindings::structs::nsCSSPropertyID_eCSSPropertyExtra_no_properties;
+
+ unsafe { self.gecko.mTransitions.ensure_len(v.0.len()) };
+ if !v.0.is_empty() {
+ self.gecko.mTransitionPropertyCount = v.0.len() as u32;
+ for (servo, gecko) in v.0.into_iter().zip(self.gecko.mTransitions.iter_mut()) {
+ gecko.mProperty = servo.into();
+ }
+ } else {
+ // In gecko |none| is represented by eCSSPropertyExtra_no_properties.
+ self.gecko.mTransitionPropertyCount = 1;
+ self.gecko.mTransitions[0].mProperty = nsCSSPropertyID_eCSSPropertyExtra_no_properties;
+ }
+ }
+ pub fn transition_property_at(&self, index: usize)
+ -> longhands::transition_property::computed_value::SingleComputedValue {
+ self.gecko.mTransitions[index].mProperty.into()
+ }
+
+ pub fn copy_transition_property_from(&mut self, other: &Self) {
+ unsafe { self.gecko.mTransitions.ensure_len(other.gecko.mTransitions.len()) };
+
+ let count = other.gecko.mTransitionPropertyCount;
+ self.gecko.mTransitionPropertyCount = count;
+
+ for (index, transition) in self.gecko.mTransitions.iter_mut().enumerate().take(count as usize) {
+ transition.mProperty = other.gecko.mTransitions[index].mProperty;
+ }
+ }
+ ${impl_transition_count('property', 'Property')}
+
pub fn set_animation_name(&mut self, v: longhands::animation_name::computed_value::T) {
use nsstring::nsCString;
unsafe { self.gecko.mAnimations.ensure_len(v.0.len()) };
if v.0.len() > 0 {
self.gecko.mAnimationNameCount = v.0.len() as u32;
for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) {
gecko.mName.assign_utf8(&nsCString::from(servo.0.to_string()));
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -121,16 +121,34 @@ impl From<TransitionProperty> for nsCSSP
=> ${helpers.to_nscsspropertyid(prop.ident)},
% endif
% endfor
TransitionProperty::All => nsCSSPropertyID::eCSSPropertyExtra_all_properties,
}
}
}
+/// Convert nsCSSPropertyID to TransitionProperty
+#[cfg(feature = "gecko")]
+#[allow(non_upper_case_globals)]
+impl From<nsCSSPropertyID> for TransitionProperty {
+ fn from(property: nsCSSPropertyID) -> TransitionProperty {
+ match property {
+ % for prop in data.longhands:
+ % if prop.animatable:
+ ${helpers.to_nscsspropertyid(prop.ident)}
+ => TransitionProperty::${prop.camel_case},
+ % endif
+ % endfor
+ nsCSSPropertyID::eCSSPropertyExtra_all_properties => TransitionProperty::All,
+ _ => panic!(),
+ }
+ }
+}
+
/// Convert to PropertyDeclarationId.
#[cfg(feature = "gecko")]
#[allow(non_upper_case_globals)]
impl<'a> From<TransitionProperty> for PropertyDeclarationId<'a> {
fn from(transition_property: TransitionProperty) -> PropertyDeclarationId<'a> {
match transition_property {
% for prop in data.longhands:
% if prop.animatable: