diff --git a/components/style/gecko/values.rs b/components/style/gecko/values.rs index f256def2ac3..f05ede6b489 100644 --- a/components/style/gecko/values.rs +++ b/components/style/gecko/values.rs @@ -22,6 +22,7 @@ use values::computed::{MaxLength, MozLength}; use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius; use values::generics::CounterStyleOrNone; use values::generics::basic_shape::ShapeRadius; +use values::generics::gecko::ScrollSnapPoint; use values::generics::grid::{TrackBreadth, TrackKeyword}; use values::specified::Percentage; @@ -368,6 +369,30 @@ impl GeckoStyleCoordConvertible for MaxLength { } } +impl GeckoStyleCoordConvertible for ScrollSnapPoint { + fn to_gecko_style_coord(&self, coord: &mut T) { + match self.repeated() { + None => coord.set_value(CoordDataValue::None), + Some(l) => l.to_gecko_style_coord(coord), + }; + } + + fn from_gecko_style_coord(coord: &T) -> Option { + use gecko_bindings::structs::root::nsStyleUnit; + use values::generics::gecko::ScrollSnapPoint; + + Some( + match coord.unit() { + nsStyleUnit::eStyleUnit_None => ScrollSnapPoint::None, + nsStyleUnit::eStyleUnit_Coord | nsStyleUnit::eStyleUnit_Percent => + ScrollSnapPoint::Repeat(LengthOrPercentage::from_gecko_style_coord(coord) + .expect("coord could not convert to LengthOrPercentage")), + x => panic!("Unexpected unit {:?}", x) + } + ) + } +} + /// Convert a given RGBA value to `nscolor`. pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 { ((rgba.alpha as u32) << 24) | diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 32705300f7b..384ba40cda0 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1250,6 +1250,30 @@ fn static_assert() { self.gecko.mGridAuto${kind.title()}Max.copy_from(&other.gecko.mGridAuto${kind.title()}Max); } + pub fn clone_grid_auto_${kind}(&self) -> longhands::grid_auto_${kind}::computed_value::T { + use gecko_bindings::structs::root::nsStyleUnit::eStyleUnit_None; + use values::computed::length::LengthOrPercentage; + use values::generics::grid::{TrackSize, TrackBreadth}; + + let ref min_gecko = self.gecko.mGridAuto${kind.title()}Min; + let ref max_gecko = self.gecko.mGridAuto${kind.title()}Max; + if min_gecko.unit() == eStyleUnit_None { + debug_assert!(max_gecko.unit() != eStyleUnit_None); + return TrackSize::FitContent(LengthOrPercentage::from_gecko_style_coord(max_gecko) + .expect("mGridAuto${kind.title()}Max contains style coord")); + } + + let min = TrackBreadth::from_gecko_style_coord(min_gecko) + .expect("mGridAuto${kind.title()}Min contains style coord"); + let max = TrackBreadth::from_gecko_style_coord(max_gecko) + .expect("mGridAuto${kind.title()}Max contains style coord"); + if min == max { + TrackSize::Breadth(max) + } else { + TrackSize::MinMax(min, max) + } + } + pub fn set_grid_template_${kind}(&mut self, v: longhands::grid_template_${kind}::computed_value::T) { <% self_grid = "self.gecko.mGridTemplate%s" % kind.title() %> use gecko::values::GeckoStyleCoordConvertible; @@ -2223,16 +2247,8 @@ fn static_assert() { } % endfor - % for axis in ["x", "y"]: - pub fn set_scroll_snap_points_${axis}(&mut self, v: longhands::scroll_snap_points_${axis}::computed_value::T) { - match v.repeated() { - None => self.gecko.mScrollSnapPoints${axis.upper()}.set_value(CoordDataValue::None), - Some(l) => l.to_gecko_style_coord(&mut self.gecko.mScrollSnapPoints${axis.upper()}), - }; - } - - ${impl_coord_copy('scroll_snap_points_' + axis, 'mScrollSnapPoints' + axis.upper())} - % endfor + ${impl_style_coord("scroll_snap_points_x", "mScrollSnapPointsX", True)} + ${impl_style_coord("scroll_snap_points_y", "mScrollSnapPointsY", True)} pub fn set_scroll_snap_coordinate(&mut self, v: I) where I: IntoIterator, diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 82cd921709a..27aa4d0b8b4 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -656,7 +656,7 @@ ${helpers.predefined_type("animation-delay", "scroll-snap-points-" + axis, "ScrollSnapPoint", "computed::ScrollSnapPoint::none()", - animation_value_type="none", + animation_value_type="discrete", products="gecko", disable_when_testing=True, spec="Nonstandard (https://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/#scroll-snap-points)", diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 1cf56b645ce..1ab47d007ab 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -271,7 +271,7 @@ ${helpers.predefined_type("object-position", ${helpers.predefined_type("grid-auto-%ss" % kind, "TrackSize", "Default::default()", - animation_value_type="none", + animation_value_type="discrete", spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-%ss" % kind, products="gecko", boxed=True)}