mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Make border-spacing serialization consistent, and move it to precomputed_type.
This commit is contained in:
parent
f9c06d7932
commit
2ac1327e4b
21 changed files with 200 additions and 219 deletions
|
@ -7,14 +7,16 @@
|
|||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use style_traits::ParseError;
|
||||
use values::computed::{Context, NonNegativeLength, ToComputedValue};
|
||||
use values::generics::size::Size;
|
||||
use values::computed::{self, Context, ToComputedValue};
|
||||
use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
|
||||
use values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth;
|
||||
use values::generics::border::BorderImageSlice as GenericBorderImageSlice;
|
||||
use values::generics::border::BorderRadius as GenericBorderRadius;
|
||||
use values::generics::border::BorderSpacing as GenericBorderSpacing;
|
||||
use values::generics::rect::Rect;
|
||||
use values::generics::size::Size;
|
||||
use values::specified::{AllowQuirks, Number, NumberOrPercentage};
|
||||
use values::specified::length::{Length, LengthOrPercentage};
|
||||
use values::specified::length::{Length, LengthOrPercentage, NonNegativeLength};
|
||||
|
||||
/// A specified value for a single side of the `border-width` property.
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
|
@ -44,7 +46,10 @@ pub type BorderImageSlice = GenericBorderImageSlice<NumberOrPercentage>;
|
|||
pub type BorderRadius = GenericBorderRadius<LengthOrPercentage>;
|
||||
|
||||
/// A specified value for the `border-*-radius` longhand properties.
|
||||
pub type BorderCornerRadius = Size<LengthOrPercentage>;
|
||||
pub type BorderCornerRadius = GenericBorderCornerRadius<LengthOrPercentage>;
|
||||
|
||||
/// A specified value for the `border-spacing` longhand properties.
|
||||
pub type BorderSpacing = GenericBorderSpacing<NonNegativeLength>;
|
||||
|
||||
impl BorderSideWidth {
|
||||
/// Parses, with quirks.
|
||||
|
@ -72,7 +77,7 @@ impl Parse for BorderSideWidth {
|
|||
}
|
||||
|
||||
impl ToComputedValue for BorderSideWidth {
|
||||
type ComputedValue = NonNegativeLength;
|
||||
type ComputedValue = computed::NonNegativeLength;
|
||||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||
|
@ -149,11 +154,22 @@ impl Parse for BorderRadius {
|
|||
}
|
||||
|
||||
impl Parse for BorderCornerRadius {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
let first = LengthOrPercentage::parse_non_negative(context, input)?;
|
||||
let second = input
|
||||
.try(|i| LengthOrPercentage::parse_non_negative(context, i))
|
||||
.unwrap_or_else(|_| first.clone());
|
||||
Ok(Self::new(first, second))
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Size::parse_with(context, input, LengthOrPercentage::parse_non_negative)
|
||||
.map(GenericBorderCornerRadius)
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for BorderSpacing {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Size::parse_with(context, input, |context, input| {
|
||||
Length::parse_non_negative_quirky(context, input, AllowQuirks::Yes).map(From::from)
|
||||
}).map(GenericBorderSpacing)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ pub use self::angle::Angle;
|
|||
pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
|
||||
pub use self::background::BackgroundSize;
|
||||
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
||||
pub use self::border::{BorderImageSideWidth, BorderRadius, BorderSideWidth};
|
||||
pub use self::border::{BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing};
|
||||
pub use self::box_::VerticalAlign;
|
||||
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
||||
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue