From c23dca874fbbf3fd0bb84b822f0c14d234cc9c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 1 Jul 2018 23:06:17 +0000 Subject: [PATCH 1/9] style: Reformat font.mako.rs. To be consistent, use the block indentation the rest of the Rust code uses. Differential Revision: https://phabricator.services.mozilla.com/D1906 Bug: 1472552 Reviewed-by: xidorn --- .../style/properties/longhands/font.mako.rs | 464 ++++++++++-------- 1 file changed, 257 insertions(+), 207 deletions(-) diff --git a/components/style/properties/longhands/font.mako.rs b/components/style/properties/longhands/font.mako.rs index 69f95532c16..e14d16e0cb7 100644 --- a/components/style/properties/longhands/font.mako.rs +++ b/components/style/properties/longhands/font.mako.rs @@ -7,13 +7,15 @@ <% data.new_style_struct("Font", inherited=True) %> -${helpers.predefined_type("font-family", - "FontFamily", - initial_value="computed::FontFamily::serif()", - animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-family", - servo_restyle_damage="rebuild_and_reflow")} +${helpers.predefined_type( + "font-family", + "FontFamily", + initial_value="computed::FontFamily::serif()", + animation_value_type="discrete", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-family", + servo_restyle_damage="rebuild_and_reflow", +)} ${helpers.predefined_type( "font-style", @@ -32,16 +34,18 @@ ${helpers.predefined_type( "all-petite-caps": "ALLPETITE", "titling-caps": "TITLING" } %> -${helpers.single_keyword_system("font-variant-caps", - "normal small-caps", - extra_gecko_values="all-small-caps petite-caps all-petite-caps unicase titling-caps", - gecko_constant_prefix="NS_FONT_VARIANT_CAPS", - gecko_ffi_name="mFont.variantCaps", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps", - custom_consts=font_variant_caps_custom_consts, - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - animation_value_type="discrete", - servo_restyle_damage="rebuild_and_reflow")} +${helpers.single_keyword_system( + "font-variant-caps", + "normal small-caps", + extra_gecko_values="all-small-caps petite-caps all-petite-caps unicase titling-caps", + gecko_constant_prefix="NS_FONT_VARIANT_CAPS", + gecko_ffi_name="mFont.variantCaps", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps", + custom_consts=font_variant_caps_custom_consts, + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + animation_value_type="discrete", + servo_restyle_damage="rebuild_and_reflow", +)} ${helpers.predefined_type( "font-weight", @@ -54,32 +58,38 @@ ${helpers.predefined_type( servo_restyle_damage="rebuild_and_reflow", )} -${helpers.predefined_type("font-size", - "FontSize", - initial_value="computed::FontSize::medium()", - initial_specified_value="specified::FontSize::medium()", - animation_value_type="NonNegativeLength", - allow_quirks=True, - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-size", - servo_restyle_damage="rebuild_and_reflow")} +${helpers.predefined_type( + "font-size", + "FontSize", + initial_value="computed::FontSize::medium()", + initial_specified_value="specified::FontSize::medium()", + animation_value_type="NonNegativeLength", + allow_quirks=True, + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-size", + servo_restyle_damage="rebuild_and_reflow", +)} -${helpers.predefined_type("font-size-adjust", - "FontSizeAdjust", - products="gecko", - initial_value="computed::FontSizeAdjust::none()", - initial_specified_value="specified::FontSizeAdjust::none()", - animation_value_type="ComputedValue", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-size-adjust")} +${helpers.predefined_type( + "font-size-adjust", + "FontSizeAdjust", + products="gecko", + initial_value="computed::FontSizeAdjust::none()", + initial_specified_value="specified::FontSizeAdjust::none()", + animation_value_type="ComputedValue", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-size-adjust", +)} -${helpers.predefined_type("font-synthesis", - "FontSynthesis", - products="gecko", - initial_value="specified::FontSynthesis::get_initial_value()", - animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-synthesis")} +${helpers.predefined_type( + "font-synthesis", + "FontSynthesis", + products="gecko", + initial_value="specified::FontSynthesis::get_initial_value()", + animation_value_type="discrete", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-synthesis", +)} ${helpers.predefined_type( "font-stretch", @@ -92,69 +102,83 @@ ${helpers.predefined_type( servo_restyle_damage="rebuild_and_reflow", )} -${helpers.single_keyword_system("font-kerning", - "auto none normal", - products="gecko", - gecko_ffi_name="mFont.kerning", - gecko_constant_prefix="NS_FONT_KERNING", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-kerning", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - animation_value_type="discrete")} +${helpers.single_keyword_system( + "font-kerning", + "auto none normal", + products="gecko", + gecko_ffi_name="mFont.kerning", + gecko_constant_prefix="NS_FONT_KERNING", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-kerning", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + animation_value_type="discrete", +)} -${helpers.predefined_type("font-variant-alternates", - "FontVariantAlternates", - products="gecko", - initial_value="computed::FontVariantAlternates::get_initial_value()", - initial_specified_value="specified::FontVariantAlternates::get_initial_specified_value()", - animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-alternates")} +${helpers.predefined_type( + "font-variant-alternates", + "FontVariantAlternates", + products="gecko", + initial_value="computed::FontVariantAlternates::get_initial_value()", + initial_specified_value="specified::FontVariantAlternates::get_initial_specified_value()", + animation_value_type="discrete", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-alternates", +)} -${helpers.predefined_type("font-variant-east-asian", - "FontVariantEastAsian", - products="gecko", - initial_value="computed::FontVariantEastAsian::empty()", - initial_specified_value="specified::FontVariantEastAsian::empty()", - animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-east-asian")} +${helpers.predefined_type( + "font-variant-east-asian", + "FontVariantEastAsian", + products="gecko", + initial_value="computed::FontVariantEastAsian::empty()", + initial_specified_value="specified::FontVariantEastAsian::empty()", + animation_value_type="discrete", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-east-asian", +)} -${helpers.predefined_type("font-variant-ligatures", - "FontVariantLigatures", - products="gecko", - initial_value="computed::FontVariantLigatures::empty()", - initial_specified_value="specified::FontVariantLigatures::empty()", - animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-ligatures")} +${helpers.predefined_type( + "font-variant-ligatures", + "FontVariantLigatures", + products="gecko", + initial_value="computed::FontVariantLigatures::empty()", + initial_specified_value="specified::FontVariantLigatures::empty()", + animation_value_type="discrete", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-ligatures", +)} -${helpers.predefined_type("font-variant-numeric", - "FontVariantNumeric", - products="gecko", - initial_value="computed::FontVariantNumeric::empty()", - initial_specified_value="specified::FontVariantNumeric::empty()", - animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-numeric")} +${helpers.predefined_type( + "font-variant-numeric", + "FontVariantNumeric", + products="gecko", + initial_value="computed::FontVariantNumeric::empty()", + initial_specified_value="specified::FontVariantNumeric::empty()", + animation_value_type="discrete", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-numeric", +)} -${helpers.single_keyword_system("font-variant-position", - "normal sub super", - products="gecko", - gecko_ffi_name="mFont.variantPosition", - gecko_constant_prefix="NS_FONT_VARIANT_POSITION", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-position", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - animation_value_type="discrete")} +${helpers.single_keyword_system( + "font-variant-position", + "normal sub super", + products="gecko", + gecko_ffi_name="mFont.variantPosition", + gecko_constant_prefix="NS_FONT_VARIANT_POSITION", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-position", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + animation_value_type="discrete", +)} -${helpers.predefined_type("font-feature-settings", - "FontFeatureSettings", - products="gecko", - initial_value="computed::FontFeatureSettings::normal()", - initial_specified_value="specified::FontFeatureSettings::normal()", - extra_prefixes="moz:layout.css.prefixes.font-features", - animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-feature-settings")} +${helpers.predefined_type( + "font-feature-settings", + "FontFeatureSettings", + products="gecko", + initial_value="computed::FontFeatureSettings::normal()", + initial_specified_value="specified::FontFeatureSettings::normal()", + extra_prefixes="moz:layout.css.prefixes.font-features", + animation_value_type="discrete", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="https://drafts.csswg.org/css-fonts/#propdef-font-feature-settings", +)} <% # This spec link is too long to fit elsewhere @@ -163,100 +187,120 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- """ %> -${helpers.predefined_type("font-variation-settings", - "FontVariationSettings", - products="gecko", - gecko_pref="layout.css.font-variations.enabled", - initial_value="computed::FontVariationSettings::normal()", - initial_specified_value="specified::FontVariationSettings::normal()", - animation_value_type="ComputedValue", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="${variation_spec}")} +${helpers.predefined_type( + "font-variation-settings", + "FontVariationSettings", + products="gecko", + gecko_pref="layout.css.font-variations.enabled", + initial_value="computed::FontVariationSettings::normal()", + initial_specified_value="specified::FontVariationSettings::normal()", + animation_value_type="ComputedValue", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="${variation_spec}", +)} -${helpers.predefined_type("font-language-override", - "FontLanguageOverride", - products="gecko", - initial_value="computed::FontLanguageOverride::zero()", - initial_specified_value="specified::FontLanguageOverride::normal()", - animation_value_type="discrete", - extra_prefixes="moz:layout.css.prefixes.font-features", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts-3/#propdef-font-language-override")} +${helpers.predefined_type( + "font-language-override", + "FontLanguageOverride", + products="gecko", + initial_value="computed::FontLanguageOverride::zero()", + initial_specified_value="specified::FontLanguageOverride::normal()", + animation_value_type="discrete", + extra_prefixes="moz:layout.css.prefixes.font-features", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="https://drafts.csswg.org/css-fonts-3/#propdef-font-language-override", +)} -${helpers.single_keyword_system("font-optical-sizing", - "auto none", - products="gecko", - gecko_pref="layout.css.font-variations.enabled", - gecko_ffi_name="mFont.opticalSizing", - gecko_constant_prefix="NS_FONT_OPTICAL_SIZING", - animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://www.w3.org/TR/css-fonts-4/#font-optical-sizing-def")} +${helpers.single_keyword_system( + "font-optical-sizing", + "auto none", + products="gecko", + gecko_pref="layout.css.font-variations.enabled", + gecko_ffi_name="mFont.opticalSizing", + gecko_constant_prefix="NS_FONT_OPTICAL_SIZING", + animation_value_type="discrete", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + spec="https://www.w3.org/TR/css-fonts-4/#font-optical-sizing-def", +)} -${helpers.predefined_type("-x-lang", - "XLang", - products="gecko", - initial_value="computed::XLang::get_initial_value()", - animation_value_type="none", - enabled_in="", - spec="Internal (not web-exposed)")} +${helpers.predefined_type( + "-x-lang", + "XLang", + products="gecko", + initial_value="computed::XLang::get_initial_value()", + animation_value_type="none", + enabled_in="", + spec="Internal (not web-exposed)", +)} -${helpers.predefined_type("-moz-script-size-multiplier", - "MozScriptSizeMultiplier", - products="gecko", - initial_value="computed::MozScriptSizeMultiplier::get_initial_value()", - animation_value_type="none", - gecko_ffi_name="mScriptSizeMultiplier", - enabled_in="", - spec="Internal (not web-exposed)")} +${helpers.predefined_type( + "-moz-script-size-multiplier", + "MozScriptSizeMultiplier", + products="gecko", + initial_value="computed::MozScriptSizeMultiplier::get_initial_value()", + animation_value_type="none", + gecko_ffi_name="mScriptSizeMultiplier", + enabled_in="", + spec="Internal (not web-exposed)", +)} -${helpers.predefined_type("-moz-script-level", - "MozScriptLevel", - 0, - animation_value_type="none", - products="gecko", - enabled_in="ua", - gecko_ffi_name="mScriptLevel", - spec="Internal (not web-exposed)")} +${helpers.predefined_type( + "-moz-script-level", + "MozScriptLevel", + 0, + animation_value_type="none", + products="gecko", + enabled_in="ua", + gecko_ffi_name="mScriptLevel", + spec="Internal (not web-exposed)", +)} -${helpers.single_keyword("-moz-math-display", - "inline block", - gecko_constant_prefix="NS_MATHML_DISPLAYSTYLE", - gecko_ffi_name="mMathDisplay", - products="gecko", - enabled_in="ua", - spec="Internal (not web-exposed)", - animation_value_type="none")} +${helpers.single_keyword( + "-moz-math-display", + "inline block", + gecko_constant_prefix="NS_MATHML_DISPLAYSTYLE", + gecko_ffi_name="mMathDisplay", + products="gecko", + enabled_in="ua", + spec="Internal (not web-exposed)", + animation_value_type="none", +)} -${helpers.single_keyword("-moz-math-variant", - """none normal bold italic bold-italic script bold-script - fraktur double-struck bold-fraktur sans-serif - bold-sans-serif sans-serif-italic sans-serif-bold-italic - monospace initial tailed looped stretched""", - gecko_constant_prefix="NS_MATHML_MATHVARIANT", - gecko_ffi_name="mMathVariant", - products="gecko", - spec="Internal (not web-exposed)", - animation_value_type="none", - enabled_in="", - needs_conversion=True)} +${helpers.single_keyword( + "-moz-math-variant", + """none normal bold italic bold-italic script bold-script + fraktur double-struck bold-fraktur sans-serif + bold-sans-serif sans-serif-italic sans-serif-bold-italic + monospace initial tailed looped stretched""", + gecko_constant_prefix="NS_MATHML_MATHVARIANT", + gecko_ffi_name="mMathVariant", + products="gecko", + spec="Internal (not web-exposed)", + animation_value_type="none", + enabled_in="", + needs_conversion=True, +)} -${helpers.predefined_type("-moz-script-min-size", - "MozScriptMinSize", - "specified::MozScriptMinSize::get_initial_value()", - animation_value_type="none", - products="gecko", - enabled_in="", - gecko_ffi_name="mScriptMinSize", - spec="Internal (not web-exposed)")} +${helpers.predefined_type( + "-moz-script-min-size", + "MozScriptMinSize", + "specified::MozScriptMinSize::get_initial_value()", + animation_value_type="none", + products="gecko", + enabled_in="", + gecko_ffi_name="mScriptMinSize", + spec="Internal (not web-exposed)", +)} -${helpers.predefined_type("-x-text-zoom", - "XTextZoom", - "computed::XTextZoom(true)", - animation_value_type="none", - products="gecko", - enabled_in="", - spec="Internal (not web-exposed)")} +${helpers.predefined_type( + "-x-text-zoom", + "XTextZoom", + "computed::XTextZoom(true)", + animation_value_type="none", + products="gecko", + enabled_in="", + spec="Internal (not web-exposed)", +)} % if product == "gecko": pub mod system_font { @@ -462,29 +506,35 @@ ${helpers.predefined_type("-x-text-zoom", } % endif -${helpers.single_keyword("-moz-osx-font-smoothing", - "auto grayscale", - gecko_constant_prefix="NS_FONT_SMOOTHING", - gecko_ffi_name="mFont.smoothing", - gecko_pref="layout.css.osx-font-smoothing.enabled", - products="gecko", - spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth)", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - animation_value_type="discrete")} +${helpers.single_keyword( + "-moz-osx-font-smoothing", + "auto grayscale", + gecko_constant_prefix="NS_FONT_SMOOTHING", + gecko_ffi_name="mFont.smoothing", + gecko_pref="layout.css.osx-font-smoothing.enabled", + products="gecko", + spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth)", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + animation_value_type="discrete", +)} -${helpers.predefined_type("-moz-font-smoothing-background-color", - "RGBAColor", - "RGBA::transparent()", - animation_value_type="AnimatedRGBA", - products="gecko", - gecko_ffi_name="mFont.fontSmoothingBackgroundColor", - enabled_in="chrome", - spec="None (Nonstandard internal property)")} +${helpers.predefined_type( + "-moz-font-smoothing-background-color", + "RGBAColor", + "RGBA::transparent()", + animation_value_type="AnimatedRGBA", + products="gecko", + gecko_ffi_name="mFont.fontSmoothingBackgroundColor", + enabled_in="chrome", + spec="None (Nonstandard internal property)", +)} -${helpers.predefined_type("-moz-min-font-size-ratio", - "Percentage", - "computed::Percentage::hundred()", - animation_value_type="none", - products="gecko", - enabled_in="ua", - spec="Nonstandard (Internal-only)")} +${helpers.predefined_type( + "-moz-min-font-size-ratio", + "Percentage", + "computed::Percentage::hundred()", + animation_value_type="none", + products="gecko", + enabled_in="ua", + spec="Nonstandard (Internal-only)", +)} From 50a85a5dd6003b10e57ea65af21ebd0e469f429b Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 3 Jul 2018 23:47:48 +0000 Subject: [PATCH 2/9] style: Cap the number of style threads at six. Differential Revision: https://phabricator.services.mozilla.com/D1928 Bug: 1431285 Reviewed-by: emilio --- components/style/gecko/global_style_data.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/style/gecko/global_style_data.rs b/components/style/gecko/global_style_data.rs index f1cb107dff0..6671de9867d 100644 --- a/components/style/gecko/global_style_data.rs +++ b/components/style/gecko/global_style_data.rs @@ -65,7 +65,12 @@ lazy_static! { .map(|s| s.parse::().expect("invalid STYLO_THREADS value")); let mut num_threads = match stylo_threads { Ok(num) => num, - _ => cmp::max(num_cpus::get() * 3 / 4, 1), + // The default heuristic is num_virtual_cores * .75. This gives us + // three threads on a hyper-threaded dual core, and six threads on + // a hyper-threaded quad core. The performance benefit of additional + // threads seems to level off at around six, so we cap it there on + // many-core machines (see bug 1431285 comment 14). + _ => cmp::min(cmp::max(num_cpus::get() * 3 / 4, 1), 6), }; // If num_threads is one, there's no point in creating a thread pool, so From 769188ddbbbaf5604d8f3cf65668820278cea67d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 6 Jul 2018 05:05:57 +0200 Subject: [PATCH 3/9] style: Remove dead code. Bug: 1473793 Reviewed-by: heycam --- components/style/properties/gecko.mako.rs | 29 ++--------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 53d0baf9aba..c82288e14ae 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -49,8 +49,7 @@ use gecko::values::round_border_to_device_pixels; use logical_geometry::WritingMode; use media_queries::Device; use properties::computed_value_flags::*; -use properties::{longhands, Importance, LonghandId}; -use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId}; +use properties::longhands; use rule_tree::StrongRuleNode; use selector_parser::PseudoElement; use servo_arc::{Arc, RawOffsetArc}; @@ -58,7 +57,7 @@ use std::marker::PhantomData; use std::mem::{forget, uninitialized, transmute, zeroed}; use std::{cmp, ops, ptr}; use values::{self, CustomIdent, Either, KeyframesName, None_}; -use values::computed::{NonNegativeLength, ToComputedValue, Percentage, TransitionProperty}; +use values::computed::{NonNegativeLength, Percentage, TransitionProperty}; use values::computed::font::FontSize; use values::computed::effects::{BoxShadow, Filter, SimpleShadow}; use values::computed::outline::OutlineStyle; @@ -307,30 +306,6 @@ impl ComputedValuesInner { pub fn has_moz_binding(&self) -> bool { !self.get_box().gecko.mBinding.mRawPtr.is_null() } - - pub fn to_declaration_block(&self, property: PropertyDeclarationId) -> PropertyDeclarationBlock { - let value = match property { - % for prop in data.longhands: - % if prop.animatable: - PropertyDeclarationId::Longhand(LonghandId::${prop.camel_case}) => { - PropertyDeclaration::${prop.camel_case}( - % if prop.boxed: - Box::new( - % endif - longhands::${prop.ident}::SpecifiedValue::from_computed_value( - &self.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}()) - % if prop.boxed: - ) - % endif - ) - }, - % endif - % endfor - PropertyDeclarationId::Custom(_name) => unimplemented!(), - _ => unimplemented!() - }; - PropertyDeclarationBlock::with_one(value, Importance::Normal) - } } <%def name="declare_style_struct(style_struct)"> From 263d4258eaaeac3ce0a8949f6cc6a6d7c8c8af65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 6 Jul 2018 05:08:03 +0200 Subject: [PATCH 4/9] style: Add a clone helper that works regardless of whether the property is logical. Bug: 1473793 Reviewed-by: heycam --- .../helpers/animated_properties.mako.rs | 10 +++---- .../style/properties/properties.mako.rs | 28 +++++++++++-------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 7a34cc4ade4..d4a96e1f177 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -207,8 +207,8 @@ impl AnimatedProperty { % for prop in data.longhands: % if prop.animatable: LonghandId::${prop.camel_case} => { - let old_computed = old_style.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}(); - let new_computed = new_style.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}(); + let old_computed = old_style.clone_${prop.ident}(); + let new_computed = new_style.clone_${prop.ident}(); AnimatedProperty::${prop.camel_case}( % if prop.is_animatable_with_computed_value: old_computed, @@ -546,15 +546,13 @@ impl AnimationValue { /// Get an AnimationValue for an AnimatableLonghand from a given computed values. pub fn from_computed_values( property: LonghandId, - computed_values: &ComputedValues + style: &ComputedValues, ) -> Option { Some(match property { % for prop in data.longhands: % if prop.animatable: LonghandId::${prop.camel_case} => { - let computed = computed_values - .get_${prop.style_struct.ident.strip("_")}() - .clone_${prop.ident}(); + let computed = style.clone_${prop.ident}(); AnimationValue::${prop.camel_case}( % if prop.is_animatable_with_computed_value: computed diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 3e51c1a6c71..11b7f8b0807 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -2615,6 +2615,22 @@ impl ComputedValues { self.custom_properties.as_ref() } +% for prop in data.longhands: + /// Gets the computed value of a given property. + #[inline(always)] + #[allow(non_snake_case)] + pub fn clone_${prop.ident}( + &self, + ) -> longhands::${prop.ident}::computed_value::T { + self.get_${prop.style_struct.ident.strip("_")}() + % if prop.logical: + .clone_${prop.ident}(self.writing_mode) + % else: + .clone_${prop.ident}() + % endif + } +% endfor + /// Writes the value of the given longhand as a string in `dest`. /// /// Note that the value will usually be the computed value, except for @@ -2635,20 +2651,10 @@ impl ComputedValues { match property_id { % for prop in data.longhands: LonghandId::${prop.camel_case} => { - let style_struct = - self.get_${prop.style_struct.ident.strip("_")}(); - let value = - style_struct - % if prop.logical: - .clone_${prop.ident}(self.writing_mode); - % else: - .clone_${prop.ident}(); - % endif - + let value = self.clone_${prop.ident}(); % if prop.predefined_type == "Color": let value = self.resolve_color(value); % endif - value.to_css(dest) } % endfor From 6518b0adfaef187b03bd35b84814aeac672577ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 6 Jul 2018 05:13:28 +0200 Subject: [PATCH 5/9] style: Other minor properties.mako.rs cleanups and improvements. Also, add an is_logical method, which we'll use in a bit. Bug: 1473793 Reviewed-by: heycam MozReview-Commit-ID: Hq63wgbiRRu --- .../style/properties/properties.mako.rs | 59 +++++++++---------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 11b7f8b0807..63e7cc87734 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -946,25 +946,17 @@ impl LonghandId { } /// Returns whether this property is animatable. + #[inline] pub fn is_animatable(self) -> bool { - match self { - % for property in data.longhands: - LonghandId::${property.camel_case} => { - ${str(property.animatable).lower()} - } - % endfor - } + ${static_longhand_id_set("ANIMATABLE", lambda p: p.animatable)} + ANIMATABLE.contains(self) } /// Returns whether this property is animatable in a discrete way. + #[inline] pub fn is_discrete_animatable(self) -> bool { - match self { - % for property in data.longhands: - LonghandId::${property.camel_case} => { - ${str(property.animation_value_type == "discrete").lower()} - } - % endfor - } + ${static_longhand_id_set("DISCRETE_ANIMATABLE", lambda p: p.animation_value_type == "discrete")} + DISCRETE_ANIMATABLE.contains(self) } /// Converts from a LonghandId to an adequate nsCSSPropertyID. @@ -985,20 +977,30 @@ impl LonghandId { } } - /// If this is a logical property, return the corresponding physical one in the given writing mode. + /// Return whether this property is logical. + #[inline] + pub fn is_logical(&self) -> bool { + ${static_longhand_id_set("LOGICAL", lambda p: p.logical)} + LOGICAL.contains(*self) + } + + /// If this is a logical property, return the corresponding physical one in + /// the given writing mode. + /// /// Otherwise, return unchanged. + #[inline] pub fn to_physical(&self, wm: WritingMode) -> Self { match *self { % for property in data.longhands: - % if property.logical: - LonghandId::${property.camel_case} => { - <%helpers:logical_setter_helper name="${property.name}"> - <%def name="inner(physical_ident)"> - LonghandId::${to_camel_case(physical_ident)} - - - } - % endif + % if property.logical: + LonghandId::${property.camel_case} => { + <%helpers:logical_setter_helper name="${property.name}"> + <%def name="inner(physical_ident)"> + LonghandId::${to_camel_case(physical_ident)} + + + } + % endif % endfor _ => *self } @@ -1937,14 +1939,15 @@ impl PropertyDeclaration { } /// Returns whether or not the property is set by a system font - #[cfg(feature = "gecko")] pub fn get_system(&self) -> Option { match *self { + % if product == "gecko": % for prop in SYSTEM_FONT_LONGHANDS: PropertyDeclaration::${to_camel_case(prop)}(ref prop) => { prop.get_system() } % endfor + % endif _ => None, } } @@ -1957,12 +1960,6 @@ impl PropertyDeclaration { } } - #[cfg(feature = "servo")] - /// Dummy method to avoid cfg()s - pub fn get_system(&self) -> Option<()> { - None - } - /// Returns whether the declaration may be serialized as part of a shorthand. /// /// This method returns false if this declaration contains variable or has a From a11dcefee7bf0633ea8ddd9f5d656af514119578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 6 Jul 2018 03:41:56 +0200 Subject: [PATCH 6/9] style: Reformat most of inherited_box.mako.rs. image-orientation is being changed as we speak, so I left it there to avoid bitrot. Bug: 1473779 Reviewed-by: heycam --- .../longhands/inherited_box.mako.rs | 90 +++++++++++-------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/components/style/properties/longhands/inherited_box.mako.rs b/components/style/properties/longhands/inherited_box.mako.rs index 23dfe7fef5c..1bbfeabba95 100644 --- a/components/style/properties/longhands/inherited_box.mako.rs +++ b/components/style/properties/longhands/inherited_box.mako.rs @@ -7,57 +7,71 @@ <% data.new_style_struct("InheritedBox", inherited=True, gecko_name="Visibility") %> // TODO: collapse. Well, do tables first. -${helpers.single_keyword("visibility", - "visible hidden", - extra_gecko_values="collapse", - gecko_ffi_name="mVisible", - animation_value_type="ComputedValue", - spec="https://drafts.csswg.org/css-box/#propdef-visibility")} +${helpers.single_keyword( + "visibility", + "visible hidden", + extra_gecko_values="collapse", + gecko_ffi_name="mVisible", + animation_value_type="ComputedValue", + spec="https://drafts.csswg.org/css-box/#propdef-visibility", +)} // CSS Writing Modes Level 3 // https://drafts.csswg.org/css-writing-modes-3 -${helpers.single_keyword("writing-mode", - "horizontal-tb vertical-rl vertical-lr", - extra_gecko_values="sideways-rl sideways-lr", - extra_gecko_aliases="lr=horizontal-tb lr-tb=horizontal-tb \ - rl=horizontal-tb rl-tb=horizontal-tb \ - tb=vertical-rl tb-rl=vertical-rl", - servo_pref="layout.writing-mode.enabled", - animation_value_type="discrete", - spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode", - servo_restyle_damage="rebuild_and_reflow")} +${helpers.single_keyword( + "writing-mode", + "horizontal-tb vertical-rl vertical-lr", + extra_gecko_values="sideways-rl sideways-lr", + extra_gecko_aliases="lr=horizontal-tb lr-tb=horizontal-tb \ + rl=horizontal-tb rl-tb=horizontal-tb \ + tb=vertical-rl tb-rl=vertical-rl", + servo_pref="layout.writing-mode.enabled", + animation_value_type="discrete", + spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode", + servo_restyle_damage="rebuild_and_reflow", +)} -${helpers.single_keyword("direction", "ltr rtl", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-writing-modes/#propdef-direction", - needs_conversion=True, - servo_restyle_damage="rebuild_and_reflow")} +${helpers.single_keyword( + "direction", + "ltr rtl", + animation_value_type="discrete", + spec="https://drafts.csswg.org/css-writing-modes/#propdef-direction", + needs_conversion=True, + servo_restyle_damage="rebuild_and_reflow", +)} -${helpers.single_keyword("text-orientation", - "mixed upright sideways", - extra_gecko_aliases="sideways-right=sideways", - products="gecko", - animation_value_type="discrete", - spec="https://drafts.csswg.org/css-writing-modes/#propdef-text-orientation")} +${helpers.single_keyword( + "text-orientation", + "mixed upright sideways", + extra_gecko_aliases="sideways-right=sideways", + products="gecko", + animation_value_type="discrete", + spec="https://drafts.csswg.org/css-writing-modes/#propdef-text-orientation", +)} // CSS Color Module Level 4 // https://drafts.csswg.org/css-color/ -${helpers.single_keyword("color-adjust", - "economy exact", products="gecko", - gecko_pref="layout.css.color-adjust.enabled", - animation_value_type="discrete", - spec="https://drafts.csswg.org/css-color/#propdef-color-adjust")} +${helpers.single_keyword( + "color-adjust", + "economy exact", products="gecko", + gecko_pref="layout.css.color-adjust.enabled", + animation_value_type="discrete", + spec="https://drafts.csswg.org/css-color/#propdef-color-adjust", +)} <% image_rendering_custom_consts = { "crisp-edges": "CRISPEDGES", "-moz-crisp-edges": "CRISPEDGES" } %> // According to to CSS-IMAGES-3, `optimizespeed` and `optimizequality` are synonyms for `auto` // And, firefox doesn't support `pixelated` yet (https://bugzilla.mozilla.org/show_bug.cgi?id=856337) -${helpers.single_keyword("image-rendering", - "auto", - extra_gecko_values="optimizespeed optimizequality -moz-crisp-edges", - extra_servo_values="pixelated crisp-edges", - custom_consts=image_rendering_custom_consts, - animation_value_type="discrete", - spec="https://drafts.csswg.org/css-images/#propdef-image-rendering")} +${helpers.single_keyword( + "image-rendering", + "auto", + extra_gecko_values="optimizespeed optimizequality -moz-crisp-edges", + extra_servo_values="pixelated crisp-edges", + custom_consts=image_rendering_custom_consts, + animation_value_type="discrete", + spec="https://drafts.csswg.org/css-images/#propdef-image-rendering", +)} ${helpers.predefined_type("image-orientation", "ImageOrientation", From 9f8c80fb3ad9630b2db3fb1c2d40d52c7d69a266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 6 Jul 2018 03:44:28 +0200 Subject: [PATCH 7/9] style: Make writing-mode and direction non-animatable. Per https://github.com/w3c/csswg-drafts/issues/2751 Bug: 1473779 Reviewed-by: heycam --- .../style/properties/longhands/inherited_box.mako.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/style/properties/longhands/inherited_box.mako.rs b/components/style/properties/longhands/inherited_box.mako.rs index 1bbfeabba95..efb3ec19ccb 100644 --- a/components/style/properties/longhands/inherited_box.mako.rs +++ b/components/style/properties/longhands/inherited_box.mako.rs @@ -26,7 +26,7 @@ ${helpers.single_keyword( rl=horizontal-tb rl-tb=horizontal-tb \ tb=vertical-rl tb-rl=vertical-rl", servo_pref="layout.writing-mode.enabled", - animation_value_type="discrete", + animation_value_type="none", spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode", servo_restyle_damage="rebuild_and_reflow", )} @@ -34,12 +34,15 @@ ${helpers.single_keyword( ${helpers.single_keyword( "direction", "ltr rtl", - animation_value_type="discrete", + animation_value_type="none", spec="https://drafts.csswg.org/css-writing-modes/#propdef-direction", needs_conversion=True, servo_restyle_damage="rebuild_and_reflow", )} +// TODO(emilio): Should text-orientation be non-animatable? It affects the +// WritingMode value, but not the logical -> physical mapping of properties, +// which is the reason direction / writing-mode are non-animatable. ${helpers.single_keyword( "text-orientation", "mixed upright sideways", From d9d0186117965a4022cda6b2271b60c1e53c7821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 8 Jul 2018 01:27:12 +0200 Subject: [PATCH 8/9] style: Trivial indentation fix. MozReview-Commit-ID: JqBxF7i0HQZ --- components/style/properties/properties.mako.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 63e7cc87734..f7a81167155 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1490,7 +1490,7 @@ impl UnparsedValue { PropertyDeclaration::CSSWideKeyword(WideKeywordDeclaration { id: longhand_id, keyword, - }) + }) }) } } From 628ab7db01cf2a0de99730756e8abcd01b3c373c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 9 Jul 2018 03:22:52 +0200 Subject: [PATCH 9/9] style: Fix servo build. --- components/style/properties/properties.mako.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index f7a81167155..3e6676842c5 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -35,7 +35,7 @@ use logical_geometry::WritingMode; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use media_queries::Device; use parser::ParserContext; -#[cfg(feature = "gecko")] use properties::longhands::system_font::SystemFont; +use properties::longhands::system_font::SystemFont; use rule_cache::{RuleCache, RuleCacheConditions}; use selector_parser::PseudoElement; use selectors::parser::SelectorParseErrorKind;