diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2023-06-18 13:54:10 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-08-16 17:46:41 +0200 |
commit | f30837baf19b28637cc1571f4b8c6bbd12c1c50c (patch) | |
tree | 344e9ea9e9dd56e14894111fc560d72c6ed14887 /components/derive_common | |
parent | 19a43aa7da62d8871c4061bd923612c875e71d6e (diff) | |
download | servo-f30837baf19b28637cc1571f4b8c6bbd12c1c50c.tar.gz servo-f30837baf19b28637cc1571f4b8c6bbd12c1c50c.zip |
style: Allow to derive Parse/ToCss/SpecifiedValueInfo on bitflags
We keep getting this pattern of properties that have a set of joint and
disjoint flags, and copy-pasting or writing the same parsing and
serialization code in slightly different ways.
container-type is one such type, and I think we should have a single way
of dealing with this, thus implement deriving for various traits for
bitflags, with an attribute that says which flags are single vs mixed.
See docs and properties I ported. The remaining ones I left TODOs with,
they are a bit trickier but can be ported with some care.
Differential Revision: https://phabricator.services.mozilla.com/D142418
Diffstat (limited to 'components/derive_common')
-rw-r--r-- | components/derive_common/cg.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/components/derive_common/cg.rs b/components/derive_common/cg.rs index 93b624483c7..022a589eb58 100644 --- a/components/derive_common/cg.rs +++ b/components/derive_common/cg.rs @@ -373,6 +373,11 @@ pub fn to_css_identifier(mut camel_case: &str) -> String { result } +/// Transforms foo-bar to FOO_BAR. +pub fn to_scream_case(css_case: &str) -> String { + css_case.to_uppercase().replace('-', "_") +} + /// Given "FooBar", returns "Foo" and sets `camel_case` to "Bar". fn split_camel_segment<'input>(camel_case: &mut &'input str) -> Option<&'input str> { let index = match camel_case.chars().next() { |