mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Bug 1374233 - Part 6: Add PositiveInteger and PositiveIntegerOrAuto for column-count.
column-count should be a positive integer or auto. MozReview-Commit-ID: 9LFvrYo8De5
This commit is contained in:
parent
190cd5b952
commit
9d69cb2866
7 changed files with 49 additions and 9 deletions
|
@ -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!(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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")}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -511,6 +511,19 @@ impl IntegerOrAuto {
|
|||
}
|
||||
}
|
||||
|
||||
/// A wrapper of Integer, but only accept a value >= 1.
|
||||
pub type PositiveInteger = GreaterThanOrEqualToOne<CSSInteger>;
|
||||
|
||||
impl From<CSSInteger> for PositiveInteger {
|
||||
#[inline]
|
||||
fn from(int: CSSInteger) -> PositiveInteger {
|
||||
GreaterThanOrEqualToOne::<CSSInteger>(int)
|
||||
}
|
||||
}
|
||||
|
||||
/// PositiveInteger | auto
|
||||
pub type PositiveIntegerOrAuto = Either<PositiveInteger, Auto>;
|
||||
|
||||
/// <length> | <percentage> | <number>
|
||||
pub type LengthOrPercentageOrNumber = Either<Number, LengthOrPercentage>;
|
||||
|
||||
|
|
|
@ -717,6 +717,19 @@ impl IntegerOrAuto {
|
|||
}
|
||||
}
|
||||
|
||||
/// A wrapper of Integer, with value >= 1.
|
||||
pub type PositiveInteger = GreaterThanOrEqualToOne<Integer>;
|
||||
|
||||
impl Parse for PositiveInteger {
|
||||
#[inline]
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
Integer::parse_positive(context, input).map(GreaterThanOrEqualToOne::<Integer>)
|
||||
}
|
||||
}
|
||||
|
||||
/// PositiveInteger | auto
|
||||
pub type PositiveIntegerOrAuto = Either<PositiveInteger, Auto>;
|
||||
|
||||
#[allow(missing_docs)]
|
||||
pub type UrlOrNone = Either<SpecifiedUrl, None_>;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue