From 3532f64b324c1e1a72a554f10660c108ed7a66b0 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Mon, 2 Apr 2018 00:25:30 +0200 Subject: [PATCH] [css-multicol] style: Implement percentages for 'column-gap'. Bug: 1398537 Reviewed-by: emilio,dholbert --- components/layout/multicol.rs | 1 + components/style/properties/gecko.mako.rs | 2 +- .../style/properties/longhand/column.mako.rs | 23 ++++++++++++------- components/style/values/computed/length.rs | 3 +++ components/style/values/specified/length.rs | 9 +++++--- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index 6eb8ac6ecae..22f8e3e24ab 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -106,6 +106,7 @@ impl Flow for MulticolFlow { { let column_style = self.block_flow.fragment.style.get_column(); + // FIXME(#20498): This should support percentages too. let column_gap = match column_style.column_gap { Either::First(len) => len.into(), Either::Second(_normal) => self.block_flow.fragment.style.get_font().font_size.size(), diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 50280b8e306..ed8e92c53e5 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1445,7 +1445,7 @@ impl Clone for ${style_struct.gecko_struct_name} { "length::LengthOrAuto": impl_style_coord, "length::LengthOrNormal": impl_style_coord, "length::NonNegativeLengthOrAuto": impl_style_coord, - "length::NonNegativeLengthOrNormal": impl_style_coord, + "length::NonNegativeLengthOrPercentageOrNormal": impl_style_coord, "Length": impl_absolute_length, "LengthOrNormal": impl_style_coord, "LengthOrPercentage": impl_style_coord, diff --git a/components/style/properties/longhand/column.mako.rs b/components/style/properties/longhand/column.mako.rs index 87f284f7377..9113479218b 100644 --- a/components/style/properties/longhand/column.mako.rs +++ b/components/style/properties/longhand/column.mako.rs @@ -29,14 +29,21 @@ ${helpers.predefined_type( servo_restyle_damage="rebuild_and_reflow", )} -${helpers.predefined_type("column-gap", - "length::NonNegativeLengthOrNormal", - "Either::Second(Normal)", - extra_prefixes="moz", - servo_pref="layout.columns.enabled", - animation_value_type="NonNegativeLengthOrNormal", - spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap", - servo_restyle_damage = "reflow")} + +<% +# FIXME(#20498): Servo should support percentages in column-gap. +col_gap_type = "NonNegativeLengthOrPercentageOrNormal" if product == "gecko" else "NonNegativeLengthOrNormal" +%> +${helpers.predefined_type( + "column-gap", + "length::%s" % col_gap_type, + "Either::Second(Normal)", + extra_prefixes="moz", + servo_pref="layout.columns.enabled", + animation_value_type=col_gap_type, + spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap", + servo_restyle_damage = "reflow", +)} ${helpers.single_keyword("column-fill", "balance auto", extra_prefixes="moz", products="gecko", animation_value_type="discrete", diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 3b5e4d0c986..9b4116fe576 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -897,6 +897,9 @@ pub type NonNegativeLengthOrAuto = Either; /// Either a computed NonNegativeLength or the `normal` keyword. pub type NonNegativeLengthOrNormal = Either; +/// Either a computed NonNegativeLengthOrPercentage or the `normal` keyword. +pub type NonNegativeLengthOrPercentageOrNormal = Either; + /// A type for possible values for min- and max- flavors of width, height, /// block-size, and inline-size. #[allow(missing_docs)] diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index a9a51b50aca..e89b16fef2d 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -679,9 +679,6 @@ impl NonNegativeLength { } } -/// Either a NonNegativeLength or the `normal` keyword. -pub type NonNegativeLengthOrNormal = Either; - /// Either a NonNegativeLength or the `auto` keyword. pub type NonNegativeLengthOrAuto = Either; @@ -1020,6 +1017,12 @@ impl Parse for LengthOrPercentageOrNone { /// A wrapper of LengthOrPercentage, whose value must be >= 0. pub type NonNegativeLengthOrPercentage = NonNegative; +/// Either a computed NonNegativeLength or the `normal` keyword. +pub type NonNegativeLengthOrNormal = Either; + +/// Either a NonNegativeLengthOrPercentage or the `normal` keyword. +pub type NonNegativeLengthOrPercentageOrNormal = Either; + impl From for NonNegativeLengthOrPercentage { #[inline] fn from(len: NoCalcLength) -> Self {