From 79a5e97c13cff6d4b21816f117d3768f938540ec Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Mon, 18 Feb 2019 02:25:54 +0000 Subject: [PATCH] style: Implement scroll-margin parser and serializer. The reason why we use RelaxedAtomBool is that ScrollSnapUtils::GetSnapPointForDestination() is called both from the main and the compositor threads, and the function will have a branch depending on the pref value. Differential Revision: https://phabricator.services.mozilla.com/D20101 --- components/style/properties/gecko.mako.rs | 7 ++++- .../style/properties/longhands/margin.mako.rs | 15 ++++++++++ .../properties/shorthands/margin.mako.rs | 29 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index cb64a3d1ed0..0260be793f5 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1661,14 +1661,19 @@ fn static_assert() { } +<% skip_scroll_margin_longhands = " ".join(["scroll-margin-%s" % x.ident for x in SIDES]) %> <% skip_margin_longhands = " ".join(["margin-%s" % x.ident for x in SIDES]) %> <%self:impl_trait style_struct_name="Margin" - skip_longhands="${skip_margin_longhands}"> + skip_longhands="${skip_margin_longhands} + ${skip_scroll_margin_longhands}"> % for side in SIDES: <% impl_split_style_coord("margin_%s" % side.ident, "mMargin", side.index) %> + <% impl_split_style_coord("scroll_margin_%s" % side.ident, + "mScrollMargin", + side.index) %> % endfor diff --git a/components/style/properties/longhands/margin.mako.rs b/components/style/properties/longhands/margin.mako.rs index e5eac633c96..d2a3be11d1d 100644 --- a/components/style/properties/longhands/margin.mako.rs +++ b/components/style/properties/longhands/margin.mako.rs @@ -27,3 +27,18 @@ servo_restyle_damage="reflow" )} % endfor + +% for side in ALL_SIDES: + ${helpers.predefined_type( + "scroll-margin-%s" % side[0], + "Length", + "computed::Length::zero()", + products="gecko", + gecko_pref="layout.css.scroll-snap-v1.enabled", + logical=side[1], + logical_group="scroll-margin", + spec="https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-margin-%s" % side[0], + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE", + animation_value_type="ComputedValue", + )} +% endfor diff --git a/components/style/properties/shorthands/margin.mako.rs b/components/style/properties/shorthands/margin.mako.rs index 8ccd33ebf3b..fd3124a6ae1 100644 --- a/components/style/properties/shorthands/margin.mako.rs +++ b/components/style/properties/shorthands/margin.mako.rs @@ -28,3 +28,32 @@ ${helpers.two_properties_shorthand( "specified::LengthPercentageOrAuto::parse", spec="https://drafts.csswg.org/css-logical/#propdef-margin-inline" )} + +${helpers.four_sides_shorthand( + "scroll-margin", + "scroll-margin-%s", + "specified::Length::parse", + spec="https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-margin", + products="gecko", + gecko_pref="layout.css.scroll-snap-v1.enabled", +)} + +${helpers.two_properties_shorthand( + "scroll-margin-block", + "scroll-margin-block-start", + "scroll-margin-block-end", + "specified::Length::parse", + spec="https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-margin-block", + products="gecko", + gecko_pref="layout.css.scroll-snap-v1.enabled", +)} + +${helpers.two_properties_shorthand( + "scroll-margin-inline", + "scroll-margin-inline-start", + "scroll-margin-inline-end", + "specified::Length::parse", + spec="https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-margin-inline", + products="gecko", + gecko_pref="layout.css.scroll-snap-v1.enabled", +)}