style: Convert text-emphasis-position #defines to enum classes

Differential Revision: https://phabricator.services.mozilla.com/D155557
This commit is contained in:
Anurag Kalia 2022-09-27 07:38:08 +00:00 committed by Martin Robinson
parent 6cfdd989d5
commit 1a9198a5ef
3 changed files with 36 additions and 145 deletions

View file

@ -328,24 +328,29 @@ fn derive_single_field_expr(
}
#[derive(Default, FromMeta)]
#[darling(default)]
pub struct CssBitflagAttrs {
/// Flags that can only go on their own, comma-separated.
pub single: String,
pub single: Option<String>,
/// Flags that can go mixed with each other, comma-separated.
pub mixed: String,
pub mixed: Option<String>,
/// Extra validation of the resulting mixed flags.
#[darling(default)]
pub validate_mixed: Option<Path>,
/// Whether there are overlapping bits we need to take care of when
/// serializing.
#[darling(default)]
pub overlapping_bits: bool,
}
impl CssBitflagAttrs {
/// Returns a vector of (rust_name, css_name) of a given flag list.
fn names(s: &str) -> Vec<(String, String)> {
s.split(',').map(|css_name| (cg::to_scream_case(css_name), css_name.to_owned())).collect()
fn names(s: &Option<String>) -> Vec<(String, String)> {
let s = match s {
Some(s) => s,
None => return vec![],
};
s.split(',')
.map(|css_name| (cg::to_scream_case(css_name), css_name.to_owned()))
.collect()
}
pub fn single_flags(&self) -> Vec<(String, String)> {