mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Move represents_keyword to the css attributes.
Bug: 1457635 Reviewed-by: xidorn MozReview-Commit-ID: 21yuU4h34AQ
This commit is contained in:
parent
a375baf84b
commit
c508d8576d
8 changed files with 24 additions and 69 deletions
|
@ -140,13 +140,13 @@ fn derive_struct_fields<'a>(
|
|||
values.push(value.to_string());
|
||||
}
|
||||
}
|
||||
if info_attrs.represents_keyword {
|
||||
let css_attrs = cg::parse_field_attrs::<CssFieldAttrs>(field);
|
||||
if css_attrs.represents_keyword {
|
||||
let ident = field.ident.as_ref()
|
||||
.expect("only named field should use represents_keyword");
|
||||
values.push(cg::to_css_identifier(ident.as_ref()));
|
||||
return None;
|
||||
}
|
||||
let css_attrs = cg::parse_field_attrs::<CssFieldAttrs>(field);
|
||||
if let Some(if_empty) = css_attrs.if_empty {
|
||||
values.push(if_empty);
|
||||
}
|
||||
|
@ -176,6 +176,5 @@ struct ValueInfoVariantAttrs {
|
|||
#[darling(attributes(value_info), default)]
|
||||
#[derive(Default, FromField)]
|
||||
struct ValueInfoFieldAttrs {
|
||||
represents_keyword: bool,
|
||||
other_values: Option<String>,
|
||||
}
|
||||
|
|
|
@ -189,6 +189,15 @@ fn derive_single_field_expr(
|
|||
writer.item(&item)?;
|
||||
}
|
||||
}
|
||||
} else if attrs.represents_keyword {
|
||||
let ident =
|
||||
field.ast().ident.as_ref().expect("Unnamed field with represents_keyword?");
|
||||
let ident = cg::to_css_identifier(ident.as_ref());
|
||||
quote! {
|
||||
if *#field {
|
||||
writer.raw_item(#ident)?;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if attrs.field_bound {
|
||||
let ty = &field.ast().ty;
|
||||
|
@ -236,5 +245,6 @@ pub struct CssFieldAttrs {
|
|||
pub field_bound: bool,
|
||||
pub iterable: bool,
|
||||
pub skip: bool,
|
||||
pub represents_keyword: bool,
|
||||
pub skip_if: Option<Path>,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue