Auto merge of #19924 - emilio:bim, r=emilio

style: Move border-image-repeat outside of mako.

This is a rebased / nitpick-addressed / bug-fixed version of #19021, and with a commit from #19668 renaming the two `RepeatKeyword`s to different names.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19924)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-02-01 08:24:12 -06:00 committed by GitHub
commit d222c9501b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 139 additions and 99 deletions

View file

@ -48,7 +48,7 @@ impl BackgroundSize {
/// One of the keywords for `background-repeat`.
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
#[allow(missing_docs)]
pub enum RepeatKeyword {
pub enum BackgroundRepeatKeyword {
Repeat,
Space,
Round,
@ -65,14 +65,14 @@ pub enum BackgroundRepeat {
/// `repeat-y`
RepeatY,
/// `[repeat | space | round | no-repeat]{1,2}`
Keywords(RepeatKeyword, Option<RepeatKeyword>),
Keywords(BackgroundRepeatKeyword, Option<BackgroundRepeatKeyword>),
}
impl BackgroundRepeat {
/// Returns the `repeat` value.
#[inline]
pub fn repeat() -> Self {
BackgroundRepeat::Keywords(RepeatKeyword::Repeat, None)
BackgroundRepeat::Keywords(BackgroundRepeatKeyword::Repeat, None)
}
}
@ -89,7 +89,7 @@ impl Parse for BackgroundRepeat {
_ => {},
}
let horizontal = match RepeatKeyword::from_ident(&ident) {
let horizontal = match BackgroundRepeatKeyword::from_ident(&ident) {
Ok(h) => h,
Err(()) => {
return Err(input.new_custom_error(
@ -98,7 +98,7 @@ impl Parse for BackgroundRepeat {
}
};
let vertical = input.try(RepeatKeyword::parse).ok();
let vertical = input.try(BackgroundRepeatKeyword::parse).ok();
Ok(BackgroundRepeat::Keywords(horizontal, vertical))
}
}

View file

@ -171,3 +171,39 @@ impl Parse for BorderSpacing {
}).map(GenericBorderSpacing)
}
}
/// A single border-image-repeat keyword.
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)]
pub enum BorderImageRepeatKeyword {
Stretch,
Repeat,
Round,
Space,
}
/// The specified value for the `border-image-repeat` property.
///
/// https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
pub struct BorderImageRepeat(pub BorderImageRepeatKeyword, pub Option<BorderImageRepeatKeyword>);
impl BorderImageRepeat {
/// Returns the `stretch` value.
#[inline]
pub fn stretch() -> Self {
BorderImageRepeat(BorderImageRepeatKeyword::Stretch, None)
}
}
impl Parse for BorderImageRepeat {
fn parse<'i, 't>(
_context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
let horizontal = BorderImageRepeatKeyword::parse(input)?;
let vertical = input.try(BorderImageRepeatKeyword::parse).ok();
Ok(BorderImageRepeat(horizontal, vertical))
}
}

View file

@ -32,7 +32,7 @@ pub use self::align::{AlignContent, JustifyContent, AlignItems, ContentDistribut
pub use self::align::{AlignSelf, JustifySelf};
pub use self::background::{BackgroundRepeat, BackgroundSize};
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
pub use self::border::{BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing};
pub use self::border::{BorderImageRepeat, BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing};
pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVariantAlternates};
pub use self::font::{FontFamily, FontLanguageOverride, FontVariationSettings, FontVariantEastAsian};
pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings};