diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index 888fe8b9d06..8a1b3bee6ee 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -107,11 +107,11 @@ impl Flow for MulticolFlow { column_count = max(1, (content_inline_size + column_gap).0 / (column_width.0 + column_gap).0); if let Either::First(specified_column_count) = column_style.column_count { - column_count = min(column_count, specified_column_count as i32); + column_count = min(column_count, specified_column_count.0 as i32); } } else { column_count = match column_style.column_count { - Either::First(n) => n, + Either::First(n) => n.0, _ => unreachable!(), } } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 23ccf753c4c..45fa2401863 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -5423,8 +5423,8 @@ clip-path use gecko_bindings::structs::{NS_STYLE_COLUMN_COUNT_AUTO, nsStyleColumn_kMaxColumnCount}; self.gecko.mColumnCount = match v { - Either::First(number) => unsafe { - cmp::min(number as u32, nsStyleColumn_kMaxColumnCount) + Either::First(integer) => unsafe { + cmp::min(integer.0 as u32, nsStyleColumn_kMaxColumnCount) }, Either::Second(Auto) => NS_STYLE_COLUMN_COUNT_AUTO }; @@ -5437,7 +5437,7 @@ clip-path if self.gecko.mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO { debug_assert!((self.gecko.mColumnCount as i32) >= 0 && (self.gecko.mColumnCount as i32) < i32::max_value()); - Either::First(self.gecko.mColumnCount as i32) + Either::First((self.gecko.mColumnCount as i32).into()) } else { Either::Second(Auto) } diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 9eaa03d4f36..9dcd1ff8417 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -44,7 +44,7 @@ use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone use values::computed::{BorderCornerRadius, ClipRect}; use values::computed::{CalcLengthOrPercentage, Color, Context, ComputedValueAsSpecified}; use values::computed::{LengthOrPercentage, MaxLength, MozLength, Percentage, ToComputedValue}; -use values::computed::{NonNegativeAu, NonNegativeNumber}; +use values::computed::{NonNegativeAu, NonNegativeNumber, PositiveIntegerOrAuto}; use values::computed::length::{NonNegativeLengthOrAuto, NonNegativeLengthOrNormal}; use values::generics::{GreaterThanOrEqualToOne, NonNegative}; use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius; diff --git a/components/style/properties/longhand/column.mako.rs b/components/style/properties/longhand/column.mako.rs index 5929b42addc..dda11ea696c 100644 --- a/components/style/properties/longhand/column.mako.rs +++ b/components/style/properties/longhand/column.mako.rs @@ -17,12 +17,11 @@ ${helpers.predefined_type("column-width", ${helpers.predefined_type("column-count", - "IntegerOrAuto", + "PositiveIntegerOrAuto", "Either::Second(Auto)", - parse_method="parse_positive", initial_specified_value="Either::Second(Auto)", experimental="True", - animation_value_type="ComputedValue", + animation_value_type="PositiveIntegerOrAuto", extra_prefixes="moz", spec="https://drafts.csswg.org/css-multicol/#propdef-column-count")} diff --git a/components/style/values/animated/mod.rs b/components/style/values/animated/mod.rs index cbc2f63b311..2a7ab83a67b 100644 --- a/components/style/values/animated/mod.rs +++ b/components/style/values/animated/mod.rs @@ -14,6 +14,7 @@ use values::computed::Angle as ComputedAngle; use values::computed::GreaterThanOrEqualToOneNumber as ComputedGreaterThanOrEqualToOneNumber; use values::computed::NonNegativeAu; use values::computed::NonNegativeNumber as ComputedNonNegativeNumber; +use values::computed::PositiveInteger as ComputedPositiveInteger; use values::specified::url::SpecifiedUrl; pub mod effects; @@ -134,6 +135,20 @@ impl ToAnimatedValue for NonNegativeAu { } } +impl ToAnimatedValue for ComputedPositiveInteger { + type AnimatedValue = Self; + + #[inline] + fn to_animated_value(self) -> Self { + self + } + + #[inline] + fn from_animated_value(animated: Self::AnimatedValue) -> Self { + max(animated.0, 0).into() + } +} + /// Returns a value similar to `self` that represents zero. pub trait ToAnimatedZero: Sized { /// Returns a value that, when added with an underlying value, will produce the underlying diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index a00461f6998..9871a8e11d2 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -511,6 +511,19 @@ impl IntegerOrAuto { } } +/// A wrapper of Integer, but only accept a value >= 1. +pub type PositiveInteger = GreaterThanOrEqualToOne; + +impl From for PositiveInteger { + #[inline] + fn from(int: CSSInteger) -> PositiveInteger { + GreaterThanOrEqualToOne::(int) + } +} + +/// PositiveInteger | auto +pub type PositiveIntegerOrAuto = Either; + /// | | pub type LengthOrPercentageOrNumber = Either; diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 11183126df1..db43432d256 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -717,6 +717,19 @@ impl IntegerOrAuto { } } +/// A wrapper of Integer, with value >= 1. +pub type PositiveInteger = GreaterThanOrEqualToOne; + +impl Parse for PositiveInteger { + #[inline] + fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { + Integer::parse_positive(context, input).map(GreaterThanOrEqualToOne::) + } +} + +/// PositiveInteger | auto +pub type PositiveIntegerOrAuto = Either; + #[allow(missing_docs)] pub type UrlOrNone = Either;