style: Switch to the new scroll-snap-type syntax for the old scroll snap implementation and drop the scroll-snap-type-{x,y} longhands.

Now scroll-snap-type is a longhand property.

Differential Revision: https://phabricator.services.mozilla.com/D21622
This commit is contained in:
Hiroyuki Ikezoe 2019-04-11 06:19:31 +00:00 committed by Emilio Cobos Álvarez
parent 2f457ed144
commit 21481e315e
7 changed files with 109 additions and 47 deletions

View file

@ -341,7 +341,9 @@ class Longhand(object):
"SVGOpacity",
"SVGPaintOrder",
"ScrollSnapAlign",
"ScrollSnapAxis",
"ScrollSnapStrictness",
"ScrollSnapType",
"TextAlign",
"TextDecorationLine",
"TextEmphasisPosition",

View file

@ -427,18 +427,15 @@ ${helpers.predefined_type(
animation_value_type="discrete",
)}
% for axis in ["x", "y"]:
${helpers.predefined_type(
"scroll-snap-type-" + axis,
"ScrollSnapStrictness",
"computed::ScrollSnapStrictness::None",
products="gecko",
needs_context=False,
gecko_pref="layout.css.scroll-snap.enabled",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-type-x)",
animation_value_type="discrete",
)}
% endfor
${helpers.predefined_type(
"scroll-snap-type",
"ScrollSnapType",
"computed::ScrollSnapType::none()",
products="gecko",
gecko_pref="layout.css.scroll-snap.enabled",
spec="https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-type",
animation_value_type="discrete",
)}
% for axis in ["x", "y"]:
${helpers.predefined_type(

View file

@ -303,36 +303,6 @@ macro_rules! try_parse_one {
}
</%helpers:shorthand>
<%helpers:shorthand name="scroll-snap-type" products="gecko"
gecko_pref="layout.css.scroll-snap.enabled"
sub_properties="scroll-snap-type-x scroll-snap-type-y"
spec="https://drafts.csswg.org/css-scroll-snap/#propdef-scroll-snap-type">
use crate::properties::longhands::scroll_snap_type_x;
pub fn parse_value<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> {
let result = scroll_snap_type_x::parse(context, input)?;
Ok(expanded! {
scroll_snap_type_x: result,
scroll_snap_type_y: result,
})
}
impl<'a> ToCss for LonghandsToSerialize<'a> {
// 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<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
if self.scroll_snap_type_x == self.scroll_snap_type_y {
self.scroll_snap_type_x.to_css(dest)
} else {
Ok(())
}
}
}
</%helpers:shorthand>
${helpers.two_properties_shorthand(
"overscroll-behavior",
"overscroll-behavior-x",