From 7c47b574fc64c892014ac34a607f05f216552a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 17 Sep 2018 14:12:27 +0000 Subject: [PATCH] Bug 1491622 - Deindent the non-css-wide-keyword-related code from cascade_property. r=xidorn There's no good reason we construct a DeclaredValue as an intermediate step. Differential Revision: https://phabricator.services.mozilla.com/D5977 --HG-- extra : moz-landing-system : lando --- .../style/properties/helpers.mako.rs | 160 +++++++++--------- 1 file changed, 77 insertions(+), 83 deletions(-) diff --git a/servo/components/style/properties/helpers.mako.rs b/servo/components/style/properties/helpers.mako.rs index bf262f581d62..c1f4fc9d4502 100644 --- a/servo/components/style/properties/helpers.mako.rs +++ b/servo/components/style/properties/helpers.mako.rs @@ -312,20 +312,6 @@ declaration: &PropertyDeclaration, context: &mut computed::Context, ) { - let value = match *declaration { - PropertyDeclaration::${property.camel_case}(ref value) => { - DeclaredValue::Value(value) - }, - PropertyDeclaration::CSSWideKeyword(ref declaration) => { - debug_assert_eq!(declaration.id, LonghandId::${property.camel_case}); - DeclaredValue::CSSWideKeyword(declaration.keyword) - }, - PropertyDeclaration::WithVariables(..) => { - panic!("variables should already have been substituted") - } - _ => panic!("entered the wrong cascade_property() implementation"), - }; - context.for_non_inherited_property = % if property.style_struct.inherited: None; @@ -333,78 +319,86 @@ Some(LonghandId::${property.camel_case}); % endif - match value { - DeclaredValue::Value(specified_value) => { - % if property.ident in SYSTEM_FONT_LONGHANDS and product == "gecko": - if let Some(sf) = specified_value.get_system() { - longhands::system_font::resolve_system_font(sf, context); + let specified_value = match *declaration { + PropertyDeclaration::${property.camel_case}(ref value) => value, + PropertyDeclaration::CSSWideKeyword(ref declaration) => { + debug_assert_eq!(declaration.id, LonghandId::${property.camel_case}); + match declaration.keyword { + % if not data.current_style_struct.inherited: + CSSWideKeyword::Unset | + % endif + CSSWideKeyword::Initial => { + % if property.ident == "font_size": + computed::FontSize::cascade_initial_font_size(context); + % else: + context.builder.reset_${property.ident}(); + % endif + }, + % if data.current_style_struct.inherited: + CSSWideKeyword::Unset | + % endif + CSSWideKeyword::Inherit => { + % if not property.style_struct.inherited: + context.rule_cache_conditions.borrow_mut().set_uncacheable(); + % endif + % if property.ident == "font_size": + computed::FontSize::cascade_inherit_font_size(context); + % else: + context.builder.inherit_${property.ident}(); + % endif } - % endif - % if not property.style_struct.inherited and property.logical: - context.rule_cache_conditions.borrow_mut() - .set_writing_mode_dependency(context.builder.writing_mode); - % endif - % if property.is_vector: - // In the case of a vector property we want to pass - // down an iterator so that this can be computed - // without allocation - // - // However, computing requires a context, but the - // style struct being mutated is on the context. We - // temporarily remove it, mutate it, and then put it - // back. Vector longhands cannot touch their own - // style struct whilst computing, else this will - // panic. - let mut s = - context.builder.take_${data.current_style_struct.name_lower}(); - { - let iter = specified_value.compute_iter(context); - s.set_${property.ident}(iter); - } - context.builder.put_${data.current_style_struct.name_lower}(s); - % else: - % if property.boxed: - let computed = (**specified_value).to_computed_value(context); - % else: - let computed = specified_value.to_computed_value(context); - % endif - % if property.ident == "font_size": - specified::FontSize::cascade_specified_font_size( - context, - &specified_value, - computed, - ); - % else: - context.builder.set_${property.ident}(computed) - % endif - % endif - } - DeclaredValue::CSSWideKeyword(keyword) => match keyword { - % if not data.current_style_struct.inherited: - CSSWideKeyword::Unset | - % endif - CSSWideKeyword::Initial => { - % if property.ident == "font_size": - computed::FontSize::cascade_initial_font_size(context); - % else: - context.builder.reset_${property.ident}(); - % endif - }, - % if data.current_style_struct.inherited: - CSSWideKeyword::Unset | - % endif - CSSWideKeyword::Inherit => { - % if not property.style_struct.inherited: - context.rule_cache_conditions.borrow_mut().set_uncacheable(); - % endif - % if property.ident == "font_size": - computed::FontSize::cascade_inherit_font_size(context); - % else: - context.builder.inherit_${property.ident}(); - % endif } + return; } - } + PropertyDeclaration::WithVariables(..) => { + panic!("variables should already have been substituted") + } + _ => panic!("entered the wrong cascade_property() implementation"), + }; + + % if property.ident in SYSTEM_FONT_LONGHANDS and product == "gecko": + if let Some(sf) = specified_value.get_system() { + longhands::system_font::resolve_system_font(sf, context); + } + % endif + + % if not property.style_struct.inherited and property.logical: + context.rule_cache_conditions.borrow_mut() + .set_writing_mode_dependency(context.builder.writing_mode); + % endif + + % if property.is_vector: + // In the case of a vector property we want to pass down an + // iterator so that this can be computed without allocation. + // + // However, computing requires a context, but the style struct + // being mutated is on the context. We temporarily remove it, + // mutate it, and then put it back. Vector longhands cannot + // touch their own style struct whilst computing, else this will + // panic. + let mut s = + context.builder.take_${data.current_style_struct.name_lower}(); + { + let iter = specified_value.compute_iter(context); + s.set_${property.ident}(iter); + } + context.builder.put_${data.current_style_struct.name_lower}(s); + % else: + % if property.boxed: + let computed = (**specified_value).to_computed_value(context); + % else: + let computed = specified_value.to_computed_value(context); + % endif + % if property.ident == "font_size": + specified::FontSize::cascade_specified_font_size( + context, + &specified_value, + computed, + ); + % else: + context.builder.set_${property.ident}(computed) + % endif + % endif } pub fn parse_declared<'i, 't>(