mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
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
This commit is contained in:
parent
19a43aa7da
commit
f30837baf1
8 changed files with 222 additions and 312 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue