diff options
-rw-r--r-- | components/style/properties/data.py | 3 | ||||
-rw-r--r-- | components/style/properties/gecko.mako.rs | 10 |
2 files changed, 6 insertions, 7 deletions
diff --git a/components/style/properties/data.py b/components/style/properties/data.py index 7c63356ca22..400b054ba74 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -58,6 +58,9 @@ class Keyword(object): def needs_cast(self): return self.gecko_enum_prefix is None + def maybe_cast(self, type_str): + return "as " + type_str if self.needs_cast() else "" + class Longhand(object): def __init__(self, style_struct, name, animatable=None, derived_from=None, keyword=None, diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 3037f78cd98..4ebe4a5a12a 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -220,11 +220,7 @@ def set_gecko_property(ffi_name, expr): // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts let result = match v { % for value in keyword.values_for('gecko'): - % if keyword.needs_cast(): - Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)} as u8, - % else: - Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)}, - % endif + Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast("u8")}, % endfor }; ${set_gecko_property(gecko_ffi_name, "result")} @@ -236,11 +232,11 @@ def set_gecko_property(ffi_name, expr): pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { use properties::longhands::${ident}::computed_value::T as Keyword; // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts - match ${get_gecko_property(gecko_ffi_name)} as u32 { + match ${get_gecko_property(gecko_ffi_name)} ${keyword.maybe_cast("u32")} { % for value in keyword.values_for('gecko'): structs::${keyword.gecko_constant(value)} => Keyword::${to_rust_ident(value)}, % endfor - x => panic!("Found unexpected value in style struct for ${ident} property: {}", x), + x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x), } } </%def> |