diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index d27b6a2da39..42d0d40f19f 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -3099,6 +3099,8 @@ fn static_assert() { scroll-snap-points-x scroll-snap-points-y scroll-snap-type-x scroll-snap-type-y scroll-snap-coordinate perspective-origin -moz-binding will-change + overscroll-behavior-x overscroll-behavior-y + perspective-origin -moz-binding will-change shape-outside contain touch-action""" %> <%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}"> @@ -3486,6 +3488,11 @@ fn static_assert() { ${impl_keyword('scroll_snap_type_y', 'mScrollSnapTypeY', scroll_snap_type_keyword)} ${impl_keyword('scroll_snap_type_x', 'mScrollSnapTypeX', scroll_snap_type_keyword)} + <% overscroll_behavior_keyword = Keyword("overscroll-behavior", "Auto Contain None", + gecko_enum_prefix="StyleOverscrollBehavior") %> + ${impl_keyword('overscroll_behavior_x', 'mOverscrollBehaviorX', overscroll_behavior_keyword)} + ${impl_keyword('overscroll_behavior_y', 'mOverscrollBehaviorY', overscroll_behavior_keyword)} + pub fn set_perspective_origin(&mut self, v: longhands::perspective_origin::computed_value::T) { self.gecko.mPerspectiveOrigin[0].set(v.horizontal); self.gecko.mPerspectiveOrigin[1].set(v.vertical); diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 13d79b0a2d0..c48f7b2cffb 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -601,6 +601,19 @@ ${helpers.single_keyword("scroll-behavior", )} % endfor +% for axis in ["x", "y"]: + ${helpers.predefined_type( + "overscroll-behavior-" + axis, + "OverscrollBehavior", + "computed::OverscrollBehavior::Auto", + products="gecko", + needs_context=False, + gecko_pref="layout.css.overscroll-behavior.enabled", + spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties", + animation_value_type="discrete" + )} +% endfor + // Compositing and Blending Level 1 // http://www.w3.org/TR/compositing-1/ ${helpers.single_keyword("isolation", diff --git a/components/style/properties/shorthand/box.mako.rs b/components/style/properties/shorthand/box.mako.rs index 26371090716..67b14878c12 100644 --- a/components/style/properties/shorthand/box.mako.rs +++ b/components/style/properties/shorthand/box.mako.rs @@ -346,7 +346,7 @@ macro_rules! try_parse_one { } impl<'a> ToCss for LonghandsToSerialize<'a> { - // Serializes into the single keyword value if both scroll-snap-type and scroll-snap-type-y are same. + // Serializes into the single keyword value if both scroll-snap-type-x and scroll-snap-type-y are same. // Otherwise into an empty string. This is done to match Gecko's behaviour. fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { if self.scroll_snap_type_x == self.scroll_snap_type_y { @@ -358,6 +358,36 @@ macro_rules! try_parse_one { } +<%helpers:shorthand name="overscroll-behavior" products="gecko" + gecko_pref="layout.css.overscroll-behavior.enabled" + sub_properties="overscroll-behavior-x overscroll-behavior-y" + spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties"> + pub fn parse_value<'i, 't>( + _: &ParserContext, + input: &mut Parser<'i, 't> + ) -> Result> { + use values::specified::OverscrollBehavior; + let behavior_x = OverscrollBehavior::parse(input)?; + let behavior_y = input.try(OverscrollBehavior::parse).unwrap_or(behavior_x); + Ok(expanded! { + overscroll_behavior_x: behavior_x, + overscroll_behavior_y: behavior_y, + }) + } + + impl<'a> ToCss for LonghandsToSerialize<'a> { + // Serializes into the single keyword value if both overscroll-behavior-x and overscroll-behavior-y are same. + // Otherwise into two values separated by a space. + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + self.overscroll_behavior_x.to_css(dest)?; + if self.overscroll_behavior_y != self.overscroll_behavior_x { + dest.write_str(" ")?; + self.overscroll_behavior_y.to_css(dest)?; + } + Ok(()) + } + } + <%helpers:shorthand name="-moz-transform" products="gecko" sub_properties="transform" diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs index 9448f8b738c..fe83543e108 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, ScrollSnapType}; +pub use values::specified::box_::{AnimationName, OverscrollBehavior, 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 5d1dbe2587d..342633ed8a6 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -40,7 +40,7 @@ pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVa pub use self::font::{FontLanguageOverride, FontVariantSettings, FontVariantEastAsian}; pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings}; pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XTextZoom, XLang}; -pub use self::box_::{AnimationIterationCount, AnimationName, ScrollSnapType, VerticalAlign}; +pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior, 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 9f4f9b31032..ca7c6d9a0a6 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -117,3 +117,10 @@ define_css_keyword_enum! { ScrollSnapType: "proximity" => Proximity, } add_impls_for_keyword_enum!(ScrollSnapType); + +define_css_keyword_enum! { OverscrollBehavior: + "auto" => Auto, + "contain" => Contain, + "none" => None, +} +add_impls_for_keyword_enum!(OverscrollBehavior); diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index ef7ada23e99..72e9343641e 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -34,7 +34,7 @@ pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVa pub use self::font::{FontLanguageOverride, FontVariantSettings, FontVariantEastAsian}; pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings}; pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XTextZoom, XLang}; -pub use self::box_::{AnimationIterationCount, AnimationName, ScrollSnapType, VerticalAlign}; +pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior, ScrollSnapType, VerticalAlign}; pub use self::color::{Color, ColorPropertyValue, RGBAColor}; pub use self::effects::{BoxShadow, Filter, SimpleShadow}; pub use self::flex::FlexBasis;