From 8099e0c0b98ed848ce252d1d845b7a37e992a411 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 20 Apr 2016 10:44:33 -0700 Subject: [PATCH] Manually implement overflow-y. --- ports/geckolib/properties.mako.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/ports/geckolib/properties.mako.rs b/ports/geckolib/properties.mako.rs index 3faa645cbcf..07a55497e29 100644 --- a/ports/geckolib/properties.mako.rs +++ b/ports/geckolib/properties.mako.rs @@ -311,7 +311,7 @@ ${caller.body()} } -<%self:impl_trait style_struct_name="Box" skip_longhands="display"> +<%self:impl_trait style_struct_name="Box" skip_longhands="display overflow-y"> // We manually-implement the |display| property until we get general // infrastructure for preffing certain values. @@ -319,6 +319,34 @@ ${caller.body()} "table-header-group table-footer-group table-row table-column-group " + "table-column table-cell table-caption list-item flex none") %> <%call expr="impl_keyword('display', 'mDisplay', display_keyword, True)"> + + // overflow-y is implemented as a newtype of overflow-x, so we need special handling. + // We could generalize this if we run into other newtype keywords. + <% overflow_x = data.longhands_by_name["overflow-x"] %> + fn set_overflow_y(&mut self, v: longhands::overflow_y::computed_value::T) { + use gecko_style_structs as gss; + use style::properties::longhands::overflow_x::computed_value::T as BaseType; + // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts + self.gecko.mOverflowY = match v.0 { + % for value in overflow_x.keyword.values_for('gecko'): + BaseType::${to_rust_ident(value)} => gss::${overflow_x.keyword.gecko_constant(value)} as u8, + % endfor + }; + } + <%call expr="impl_simple_copy('overflow_y', 'mOverflowY')"> + fn clone_overflow_y(&self) -> longhands::overflow_y::computed_value::T { + use gecko_style_structs as gss; + use style::properties::longhands::overflow_x::computed_value::T as BaseType; + use style::properties::longhands::overflow_y::computed_value::T as NewType; + // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts + match self.gecko.mOverflowY as u32 { + % for value in overflow_x.keyword.values_for('gecko'): + gss::${overflow_x.keyword.gecko_constant(value)} => NewType(BaseType::${to_rust_ident(value)}), + % endfor + x => panic!("Found unexpected value in style struct for overflow_y property: {}", x), + } + } + % for style_struct in data.style_structs: