Skip to content

Commit

Permalink
style: Have Parse derive respect #[css(skip)] on variant as well and …
Browse files Browse the repository at this point in the history
…derive Parse for KeywordSize.

Bug: 1434130
Reviewed-by: emilio
MozReview-Commit-ID: evSvk1RQGe
  • Loading branch information
upsuper authored and emilio committed Apr 29, 2018
1 parent 185e4ce commit 43bb636
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
5 changes: 3 additions & 2 deletions components/style/values/generics/font.rs
Expand Up @@ -186,8 +186,9 @@ impl<Length> SpecifiedValueInfo for KeywordInfo<Length> {
}

/// CSS font keywords
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToCss)]
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf,
Parse, PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero,
ToCss)]
#[allow(missing_docs)]
pub enum KeywordSize {
#[css(keyword = "xx-small")]
Expand Down
15 changes: 0 additions & 15 deletions components/style/values/specified/font.rs
Expand Up @@ -715,21 +715,6 @@ impl KeywordInfo {
}
}

impl KeywordSize {
/// Parses a keyword size.
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
try_match_ident_ignore_ascii_case! { input,
"xx-small" => Ok(KeywordSize::XXSmall),
"x-small" => Ok(KeywordSize::XSmall),
"small" => Ok(KeywordSize::Small),
"medium" => Ok(KeywordSize::Medium),
"large" => Ok(KeywordSize::Large),
"x-large" => Ok(KeywordSize::XLarge),
"xx-large" => Ok(KeywordSize::XXLarge),
}
}
}

/// This is the ratio applied for font-size: larger
/// and smaller by both Firefox and Chrome
const LARGER_FONT_SIZE_RATIO: f32 = 1.2;
Expand Down
4 changes: 4 additions & 0 deletions components/style_derive/parse.rs
Expand Up @@ -20,6 +20,10 @@ pub fn derive(input: DeriveInput) -> Tokens {
);

let variant_attrs = cg::parse_variant_attrs_from_ast::<CssVariantAttrs>(&variant.ast());
if variant_attrs.skip {
return match_body;
}

let identifier = cg::to_css_identifier(
&variant_attrs.keyword.unwrap_or(variant.ast().ident.as_ref().into()),
);
Expand Down

0 comments on commit 43bb636

Please sign in to comment.