Skip to content

Commit

Permalink
[css-multicol] style: Implement percentages for 'column-gap'.
Browse files Browse the repository at this point in the history
Bug: 1398537
Reviewed-by: emilio,dholbert
  • Loading branch information
Mats Palmgren authored and emilio committed Apr 1, 2018
1 parent 9677d5c commit 3532f64
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions components/layout/multicol.rs
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/gecko.mako.rs
Expand Up @@ -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,
Expand Down
23 changes: 15 additions & 8 deletions components/style/properties/longhand/column.mako.rs
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions components/style/values/computed/length.rs
Expand Up @@ -897,6 +897,9 @@ pub type NonNegativeLengthOrAuto = Either<NonNegativeLength, Auto>;
/// Either a computed NonNegativeLength or the `normal` keyword.
pub type NonNegativeLengthOrNormal = Either<NonNegativeLength, Normal>;

/// Either a computed NonNegativeLengthOrPercentage or the `normal` keyword.
pub type NonNegativeLengthOrPercentageOrNormal = Either<NonNegativeLengthOrPercentage, Normal>;

/// A type for possible values for min- and max- flavors of width, height,
/// block-size, and inline-size.
#[allow(missing_docs)]
Expand Down
9 changes: 6 additions & 3 deletions components/style/values/specified/length.rs
Expand Up @@ -679,9 +679,6 @@ impl NonNegativeLength {
}
}

/// Either a NonNegativeLength or the `normal` keyword.
pub type NonNegativeLengthOrNormal = Either<NonNegativeLength, Normal>;

/// Either a NonNegativeLength or the `auto` keyword.
pub type NonNegativeLengthOrAuto = Either<NonNegativeLength, Auto>;

Expand Down Expand Up @@ -1020,6 +1017,12 @@ impl Parse for LengthOrPercentageOrNone {
/// A wrapper of LengthOrPercentage, whose value must be >= 0.
pub type NonNegativeLengthOrPercentage = NonNegative<LengthOrPercentage>;

/// Either a computed NonNegativeLength or the `normal` keyword.
pub type NonNegativeLengthOrNormal = Either<NonNegativeLength, Normal>;

/// Either a NonNegativeLengthOrPercentage or the `normal` keyword.
pub type NonNegativeLengthOrPercentageOrNormal = Either<NonNegativeLengthOrPercentage, Normal>;

impl From<NoCalcLength> for NonNegativeLengthOrPercentage {
#[inline]
fn from(len: NoCalcLength) -> Self {
Expand Down

0 comments on commit 3532f64

Please sign in to comment.