From 328f142f38d8522ad9b0b3d360e000091221ecb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 25 Oct 2017 20:12:37 +0200 Subject: [PATCH] style: Cleanup a bit the scroll-snap-type properties. Still not perfect, but at least a bit more consistent. --- components/style/properties/gecko.mako.rs | 6 ++--- .../style/properties/longhand/box.mako.rs | 25 ++++++++----------- components/style/values/computed/box.rs | 2 +- components/style/values/computed/mod.rs | 2 +- components/style/values/specified/box.rs | 7 ++++++ components/style/values/specified/mod.rs | 2 +- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index d43267ba0fc..cb0866df0c4 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -2698,7 +2698,7 @@ fn static_assert() { 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 + scroll-snap-type-x scroll-snap-type-y scroll-snap-coordinate perspective-origin transform-origin -moz-binding will-change shape-outside contain touch-action""" %> <%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}"> @@ -3301,9 +3301,9 @@ fn static_assert() { ${impl_animation_timing_function()} - <% scroll_snap_type_keyword = Keyword("scroll-snap-type", "none mandatory proximity") %> - + <% scroll_snap_type_keyword = Keyword("scroll-snap-type", "None Mandatory Proximity") %> ${impl_keyword('scroll_snap_type_y', 'mScrollSnapTypeY', scroll_snap_type_keyword)} + ${impl_keyword('scroll_snap_type_x', 'mScrollSnapTypeX', scroll_snap_type_keyword)} pub fn set_perspective_origin(&mut self, v: longhands::perspective_origin::computed_value::T) { self.gecko.mPerspectiveOrigin[0].set(v.horizontal); diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 721a428e064..2b487206f7a 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -1451,20 +1451,17 @@ ${helpers.single_keyword("scroll-behavior", spec="https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior", animation_value_type="discrete")} -${helpers.single_keyword("scroll-snap-type-x", - "none mandatory proximity", - products="gecko", - gecko_constant_prefix="NS_STYLE_SCROLL_SNAP_TYPE", - spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-type-x)", - animation_value_type="discrete")} - -<%helpers:longhand products="gecko" name="scroll-snap-type-y" animation_value_type="discrete" - spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-type-x)"> - pub use super::scroll_snap_type_x::SpecifiedValue; - pub use super::scroll_snap_type_x::computed_value; - pub use super::scroll_snap_type_x::get_initial_value; - pub use super::scroll_snap_type_x::parse; - +% for axis in ["x", "y"]: + ${helpers.predefined_type( + "scroll-snap-type-" + axis, + "ScrollSnapType", + "computed::ScrollSnapType::None", + products="gecko", + needs_context=False, + spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-type-x)", + animation_value_type="discrete" + )} +% endfor // Compositing and Blending Level 1 // http://www.w3.org/TR/compositing-1/ diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs index 85534f1813e..9448f8b738c 100644 --- a/components/style/values/computed/box.rs +++ b/components/style/values/computed/box.rs @@ -9,7 +9,7 @@ use values::computed::length::LengthOrPercentage; use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount; use values::generics::box_::VerticalAlign as GenericVerticalAlign; -pub use values::specified::box_::AnimationName; +pub use values::specified::box_::{AnimationName, ScrollSnapType}; /// A computed value for the `vertical-align` property. pub type VerticalAlign = GenericVerticalAlign; diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index b457973587f..5ca51b54f10 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -36,7 +36,7 @@ pub use self::angle::Angle; pub use self::background::{BackgroundSize, BackgroundRepeat}; pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageSideWidth}; pub use self::border::{BorderRadius, BorderCornerRadius, BorderSpacing}; -pub use self::box_::{AnimationIterationCount, AnimationName, VerticalAlign}; +pub use self::box_::{AnimationIterationCount, AnimationName, ScrollSnapType, VerticalAlign}; pub use self::color::{Color, ColorPropertyValue, RGBAColor}; pub use self::effects::{BoxShadow, Filter, SimpleShadow}; pub use self::flex::FlexBasis; diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index 4abf55f3878..9f4f9b31032 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -110,3 +110,10 @@ impl Parse for AnimationName { Ok(AnimationName(None)) } } + +define_css_keyword_enum! { ScrollSnapType: + "none" => None, + "mandatory" => Mandatory, + "proximity" => Proximity, +} +add_impls_for_keyword_enum!(ScrollSnapType); diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 300cb46afc8..3e68e8df4c0 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -30,7 +30,7 @@ pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, Justify pub use self::background::{BackgroundRepeat, BackgroundSize}; pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth}; pub use self::border::{BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing}; -pub use self::box_::{AnimationIterationCount, AnimationName, VerticalAlign}; +pub use self::box_::{AnimationIterationCount, AnimationName, ScrollSnapType, VerticalAlign}; pub use self::color::{Color, ColorPropertyValue, RGBAColor}; pub use self::effects::{BoxShadow, Filter, SimpleShadow}; pub use self::flex::FlexBasis;