From a095565a8ce8ef7233ad3ecfd884e7e3d809e75d Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 6 Feb 2017 17:45:09 -0800 Subject: [PATCH] stylo: Implement scroll-snap-destination MozReview-Commit-ID: 6mr4ktfeEGT --- components/style/properties/gecko.mako.rs | 9 ++++++++- components/style/properties/longhand/box.mako.rs | 6 ++++++ components/style/values/computed/mod.rs | 1 + components/style/values/computed/position.rs | 10 ++++++++++ components/style/values/specified/mod.rs | 1 + 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 065599b4f73..34377f37c73 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1169,7 +1169,7 @@ fn static_assert() { animation-iteration-count animation-timing-function -moz-binding page-break-before page-break-after scroll-snap-points-x scroll-snap-points-y transform - scroll-snap-type-y perspective-origin transform-origin""" %> + scroll-snap-type-y scroll-snap-destination 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 @@ -1340,6 +1340,13 @@ fn static_assert() { ${impl_coord_copy('scroll_snap_points_y', 'mScrollSnapPointsY')} + pub fn set_scroll_snap_destination(&mut self, v: longhands::scroll_snap_destination::computed_value::T) { + self.gecko.mScrollSnapDestination.mXPosition = v.horizontal.into(); + self.gecko.mScrollSnapDestination.mYPosition = v.vertical.into(); + } + + ${impl_simple_copy('scroll_snap_destination', 'mScrollSnapDestination')} + <%def name="transform_function_arm(name, keyword, items)"> <% pattern = None diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 95d23dbf0e4..81108d47b66 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -1049,6 +1049,12 @@ ${helpers.single_keyword("animation-fill-mode", +${helpers.predefined_type("scroll-snap-destination", + "Position", + "computed::Position::zero()", + products="gecko", + spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)", + animatable=False)} <%helpers:longhand name="transform" products="gecko servo" extra_prefixes="webkit" animatable="True" diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index a653d18918c..034f8f6953a 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -20,6 +20,7 @@ pub use super::specified::{Angle, BorderStyle, GridLine, Time, UrlOrNone}; pub use super::specified::url::UrlExtraData; pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto}; pub use self::length::{LengthOrPercentageOrAutoOrContent, LengthOrPercentageOrNone, LengthOrNone}; +pub use self::position::Position; pub mod basic_shape; pub mod image; diff --git a/components/style/values/computed/position.rs b/components/style/values/computed/position.rs index a9b51953810..d2cc4b1e48f 100644 --- a/components/style/values/computed/position.rs +++ b/components/style/values/computed/position.rs @@ -19,6 +19,16 @@ pub struct Position { pub vertical: LengthOrPercentage, } +impl Position { + /// Construct a position at (0, 0) + pub fn zero() -> Self { + Position { + horizontal: LengthOrPercentage::zero(), + vertical: LengthOrPercentage::zero(), + } + } +} + impl ToCss for Position { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { try!(self.horizontal.to_css(dest)); diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index dac10f661f7..c7dc71d1bec 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -27,6 +27,7 @@ pub use self::image::{SizeKeyword, VerticalDirection}; pub use self::length::{FontRelativeLength, ViewportPercentageLength, CharacterWidth, Length, CalcLengthOrPercentage}; pub use self::length::{Percentage, LengthOrNone, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto}; pub use self::length::{LengthOrPercentageOrNone, LengthOrPercentageOrAutoOrContent, NoCalcLength, CalcUnit}; +pub use self::position::{HorizontalPosition, Position, VerticalPosition}; pub mod basic_shape; pub mod grid;