mirror of
https://github.com/servo/servo.git
synced 2025-08-17 19:35:33 +01:00
Replace PositiveIntegerOrAuto by ColumnCount
It was its only use.
This commit is contained in:
parent
363aae6a43
commit
761689f32d
11 changed files with 94 additions and 28 deletions
11
components/style/values/computed/column.rs
Normal file
11
components/style/values/computed/column.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Computed types for the column properties.
|
||||
|
||||
use values::computed::PositiveInteger;
|
||||
use values::generics::column::ColumnCount as GenericColumnCount;
|
||||
|
||||
/// A computed type for `column-count` values.
|
||||
pub type ColumnCount = GenericColumnCount<PositiveInteger>;
|
|
@ -50,6 +50,7 @@ pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier,
|
|||
pub use self::box_::{AnimationIterationCount, AnimationName, Display, OverscrollBehavior, Contain};
|
||||
pub use self::box_::{OverflowClipBox, ScrollSnapType, TouchAction, VerticalAlign, WillChange};
|
||||
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
||||
pub use self::column::ColumnCount;
|
||||
pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset};
|
||||
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
pub use self::flex::FlexBasis;
|
||||
|
@ -91,6 +92,7 @@ pub mod border;
|
|||
#[path = "box.rs"]
|
||||
pub mod box_;
|
||||
pub mod color;
|
||||
pub mod column;
|
||||
pub mod counters;
|
||||
pub mod effects;
|
||||
pub mod flex;
|
||||
|
@ -548,9 +550,6 @@ impl From<CSSInteger> for PositiveInteger {
|
|||
}
|
||||
}
|
||||
|
||||
/// PositiveInteger | auto
|
||||
pub type PositiveIntegerOrAuto = Either<PositiveInteger, Auto>;
|
||||
|
||||
/// <length> | <percentage> | <number>
|
||||
pub type LengthOrPercentageOrNumber = Either<Number, LengthOrPercentage>;
|
||||
|
||||
|
|
29
components/style/values/generics/column.rs
Normal file
29
components/style/values/generics/column.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Generic types for the column properties.
|
||||
|
||||
/// A generic type for `column-count` values.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum ColumnCount<PositiveInteger> {
|
||||
/// A positive integer.
|
||||
Integer(PositiveInteger),
|
||||
/// The keyword `auto`.
|
||||
Auto,
|
||||
}
|
||||
|
||||
impl<I> ColumnCount<I> {
|
||||
/// Returns `auto`.
|
||||
#[inline]
|
||||
pub fn auto() -> Self {
|
||||
ColumnCount::Auto
|
||||
}
|
||||
|
||||
/// Returns whether this value is `auto`.
|
||||
#[inline]
|
||||
pub fn is_auto(self) -> bool {
|
||||
matches!(self, ColumnCount::Auto)
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ pub mod basic_shape;
|
|||
pub mod border;
|
||||
#[path = "box.rs"]
|
||||
pub mod box_;
|
||||
pub mod column;
|
||||
pub mod counters;
|
||||
pub mod effects;
|
||||
pub mod flex;
|
||||
|
|
26
components/style/values/specified/column.rs
Normal file
26
components/style/values/specified/column.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Specified types for the column properties.
|
||||
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use style_traits::ParseError;
|
||||
use values::generics::column::ColumnCount as GenericColumnCount;
|
||||
use values::specified::PositiveInteger;
|
||||
|
||||
/// A specified type for `column-count` values.
|
||||
pub type ColumnCount = GenericColumnCount<PositiveInteger>;
|
||||
|
||||
impl Parse for ColumnCount {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input.try(|i| i.expect_ident_matching("auto")).is_ok() {
|
||||
return Ok(GenericColumnCount::Auto);
|
||||
}
|
||||
Ok(GenericColumnCount::Integer(PositiveInteger::parse(context, input)?))
|
||||
}
|
||||
}
|
|
@ -34,6 +34,7 @@ pub use self::align::{AlignSelf, JustifySelf};
|
|||
pub use self::background::{BackgroundRepeat, BackgroundSize};
|
||||
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
||||
pub use self::border::{BorderImageRepeat, BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing};
|
||||
pub use self::column::ColumnCount;
|
||||
pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVariantAlternates};
|
||||
pub use self::font::{FontFamily, FontLanguageOverride, FontVariationSettings, FontVariantEastAsian};
|
||||
pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings};
|
||||
|
@ -88,6 +89,7 @@ pub mod border;
|
|||
pub mod box_;
|
||||
pub mod calc;
|
||||
pub mod color;
|
||||
pub mod column;
|
||||
pub mod counters;
|
||||
pub mod effects;
|
||||
pub mod flex;
|
||||
|
@ -529,9 +531,6 @@ impl Parse for PositiveInteger {
|
|||
}
|
||||
}
|
||||
|
||||
/// 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