From 611a2f099192540ae5957858c1f7ed464c69f150 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 20 Apr 2016 13:45:14 -0700 Subject: [PATCH] Handle BORDER_STYLE_MASK. Gecko uses the higher bits of certain border-style-like properties to store other things. This duplicates the logic in Gecko's {Get,Set}BorderStyle and similar. --- ports/geckolib/properties.mako.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ports/geckolib/properties.mako.rs b/ports/geckolib/properties.mako.rs index 07a55497e29..486e62f5450 100644 --- a/ports/geckolib/properties.mako.rs +++ b/ports/geckolib/properties.mako.rs @@ -118,16 +118,35 @@ pub struct ${style_struct.gecko_struct_name}; } +<%! +def is_border_style_masked(ffi_name): + return ffi_name.split("[")[0] in ["mBorderStyle", "mOutlineStyle", "mTextDecorationStyle"] + +def get_gecko_property(ffi_name): + if is_border_style_masked(ffi_name): + return "(self.gecko.%s & (gecko_style_structs::BORDER_STYLE_MASK as u8))" % ffi_name + else: + return "self.gecko.%s" % ffi_name + +def set_gecko_property(ffi_name, expr): + if is_border_style_masked(ffi_name): + return "self.gecko.%s &= !(gecko_style_structs::BORDER_STYLE_MASK as u8);" % ffi_name + \ + "self.gecko.%s |= %s as u8;" % (ffi_name, expr) + else: + return "self.gecko.%s = %s;" % (ffi_name, expr) +%> + <%def name="impl_keyword_setter(ident, gecko_ffi_name, keyword)"> fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { use gecko_style_structs as gss; use style::properties::longhands::${ident}::computed_value::T as Keyword; // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts - self.gecko.${gecko_ffi_name} = match v { + let result = match v { % for value in keyword.values_for('gecko'): Keyword::${to_rust_ident(value)} => gss::${keyword.gecko_constant(value)} as u8, % endfor }; + ${set_gecko_property(gecko_ffi_name, "result")} } @@ -136,7 +155,7 @@ pub struct ${style_struct.gecko_struct_name}; use gecko_style_structs as gss; use style::properties::longhands::${ident}::computed_value::T as Keyword; // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts - match self.gecko.${gecko_ffi_name} as u32 { + match ${get_gecko_property(gecko_ffi_name)} as u32 { % for value in keyword.values_for('gecko'): gss::${keyword.gecko_constant(value)} => Keyword::${to_rust_ident(value)}, % endfor