mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Move background-repeat and mask-repeat outside of mako.
This commit is contained in:
parent
326f914018
commit
fd1e2c1f3f
8 changed files with 168 additions and 126 deletions
|
@ -15,7 +15,10 @@ use values::specified::length::LengthOrPercentageOrAuto;
|
|||
pub type BackgroundSize = GenericBackgroundSize<LengthOrPercentageOrAuto>;
|
||||
|
||||
impl Parse for BackgroundSize {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(width) = input.try(|i| LengthOrPercentageOrAuto::parse_non_negative(context, i)) {
|
||||
let height = input
|
||||
.try(|i| LengthOrPercentageOrAuto::parse_non_negative(context, i))
|
||||
|
@ -41,3 +44,59 @@ impl BackgroundSize {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One of the keywords for `background-repeat`.
|
||||
define_css_keyword_enum! { RepeatKeyword:
|
||||
"repeat" => Repeat,
|
||||
"space" => Space,
|
||||
"round" => Round,
|
||||
"no-repeat" => NoRepeat
|
||||
}
|
||||
|
||||
/// The specified value for the `background-repeat` property.
|
||||
///
|
||||
/// https://drafts.csswg.org/css-backgrounds/#the-background-repeat
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
||||
pub enum BackgroundRepeat {
|
||||
/// `repeat-x`
|
||||
RepeatX,
|
||||
/// `repeat-y`
|
||||
RepeatY,
|
||||
/// `[repeat | space | round | no-repeat]{1,2}`
|
||||
Keywords(RepeatKeyword, Option<RepeatKeyword>),
|
||||
}
|
||||
|
||||
impl BackgroundRepeat {
|
||||
/// Returns the `repeat` value.
|
||||
#[inline]
|
||||
pub fn repeat() -> Self {
|
||||
BackgroundRepeat::Keywords(RepeatKeyword::Repeat, None)
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for BackgroundRepeat {
|
||||
fn parse<'i, 't>(
|
||||
_context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let ident = input.expect_ident_cloned()?;
|
||||
|
||||
match_ignore_ascii_case! { &ident,
|
||||
"repeat-x" => return Ok(BackgroundRepeat::RepeatX),
|
||||
"repeat-y" => return Ok(BackgroundRepeat::RepeatY),
|
||||
_ => {},
|
||||
}
|
||||
|
||||
let horizontal = match RepeatKeyword::from_ident(&ident) {
|
||||
Ok(h) => h,
|
||||
Err(()) => {
|
||||
return Err(input.new_custom_error(
|
||||
SelectorParseErrorKind::UnexpectedIdent(ident.clone())
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
let vertical = input.try(RepeatKeyword::parse).ok();
|
||||
Ok(BackgroundRepeat::Keywords(horizontal, vertical))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue