From fa733ecb7227e9d08633cc5b8c4fdb9db00d25fa Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Wed, 8 Apr 2020 05:31:19 +0000 Subject: [PATCH] style: Fix a few initial values in Rust property definitions. Differential Revision: https://phabricator.services.mozilla.com/D67929 --- components/style/properties/longhands/background.mako.rs | 2 +- components/style/properties/longhands/font.mako.rs | 2 +- .../style/properties/longhands/inherited_text.mako.rs | 5 ++--- components/style/properties/longhands/position.mako.rs | 2 +- components/style/properties/longhands/svg.mako.rs | 2 +- components/style/properties/longhands/ui.mako.rs | 2 +- components/style/properties/longhands/xul.mako.rs | 4 +++- components/style/values/computed/length_percentage.rs | 6 ++++++ 8 files changed, 16 insertions(+), 9 deletions(-) diff --git a/components/style/properties/longhands/background.mako.rs b/components/style/properties/longhands/background.mako.rs index a0b026c592e..08bfd0bdc55 100644 --- a/components/style/properties/longhands/background.mako.rs +++ b/components/style/properties/longhands/background.mako.rs @@ -35,8 +35,8 @@ ${helpers.predefined_type( ${helpers.predefined_type( "background-position-" + axis, "position::" + direction + "Position", + "computed::LengthPercentage::zero_percent()", engines="gecko servo-2013 servo-2020", - initial_value="computed::LengthPercentage::zero()", initial_specified_value="SpecifiedValue::initial_specified_value()", spec="https://drafts.csswg.org/css-backgrounds-4/#propdef-background-position-" + axis, animation_value_type="ComputedValue", diff --git a/components/style/properties/longhands/font.mako.rs b/components/style/properties/longhands/font.mako.rs index 7e0bff6fbbe..98ed7fb7f9e 100644 --- a/components/style/properties/longhands/font.mako.rs +++ b/components/style/properties/longhands/font.mako.rs @@ -230,7 +230,7 @@ ${helpers.predefined_type( ${helpers.predefined_type( "-moz-script-level", "MozScriptLevel", - 0, + "0", engines="gecko", animation_value_type="none", enabled_in="ua", diff --git a/components/style/properties/longhands/inherited_text.mako.rs b/components/style/properties/longhands/inherited_text.mako.rs index 0d910448185..41614a04d92 100644 --- a/components/style/properties/longhands/inherited_text.mako.rs +++ b/components/style/properties/longhands/inherited_text.mako.rs @@ -245,7 +245,7 @@ ${helpers.predefined_type( ${helpers.predefined_type( "text-emphasis-style", "TextEmphasisStyle", - None, + "computed::TextEmphasisStyle::None", engines="gecko", initial_specified_value="SpecifiedValue::None", animation_value_type="discrete", @@ -368,13 +368,12 @@ ${helpers.single_keyword( servo_restyle_damage="rebuild_and_reflow", )} -// FIXME Firefox expects the initial value of this property to change depending -// on the value of the layout.css.control-characters.visible pref. ${helpers.single_keyword( "-moz-control-character-visibility", "hidden visible", engines="gecko", gecko_enum_prefix="StyleControlCharacterVisibility", + gecko_pref_controlled_initial_value="layout.css.control-characters.visible=visible", animation_value_type="none", gecko_ffi_name="mControlCharacterVisibility", spec="Nonstandard", diff --git a/components/style/properties/longhands/position.mako.rs b/components/style/properties/longhands/position.mako.rs index f43c2c56aa3..d9403be5864 100644 --- a/components/style/properties/longhands/position.mako.rs +++ b/components/style/properties/longhands/position.mako.rs @@ -333,7 +333,7 @@ ${helpers.single_keyword( ${helpers.predefined_type( "object-position", "Position", - "computed::Position::zero()", + "computed::Position::center()", engines="gecko", boxed=True, spec="https://drafts.csswg.org/css-images-3/#the-object-position", diff --git a/components/style/properties/longhands/svg.mako.rs b/components/style/properties/longhands/svg.mako.rs index 69e9ccaf229..a09f3e7b656 100644 --- a/components/style/properties/longhands/svg.mako.rs +++ b/components/style/properties/longhands/svg.mako.rs @@ -111,7 +111,7 @@ ${helpers.predefined_type( ${helpers.predefined_type( "mask-position-" + axis, "position::" + direction + "Position", - "computed::LengthPercentage::zero()", + "computed::LengthPercentage::zero_percent()", engines="gecko", extra_prefixes="webkit", initial_specified_value="specified::PositionComponent::Center", diff --git a/components/style/properties/longhands/ui.mako.rs b/components/style/properties/longhands/ui.mako.rs index 05d22abd9e9..8aaee392662 100644 --- a/components/style/properties/longhands/ui.mako.rs +++ b/components/style/properties/longhands/ui.mako.rs @@ -56,7 +56,7 @@ ${helpers.single_keyword( ${helpers.single_keyword( "-moz-window-shadow", - "none default menu tooltip sheet", + "default none menu tooltip sheet", engines="gecko", gecko_ffi_name="mWindowShadow", gecko_enum_prefix="StyleWindowShadow", diff --git a/components/style/properties/longhands/xul.mako.rs b/components/style/properties/longhands/xul.mako.rs index d5c4011eaf6..a981f5ba795 100644 --- a/components/style/properties/longhands/xul.mako.rs +++ b/components/style/properties/longhands/xul.mako.rs @@ -64,10 +64,12 @@ ${helpers.single_keyword( spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/box-pack)", )} +// NOTE(heycam): Odd that the initial value is 1 yet 0 is a valid value. There +// are uses of `-moz-box-ordinal-group: 0` in the tree, too. ${helpers.predefined_type( "-moz-box-ordinal-group", "Integer", - "0", + "1", engines="gecko", parse_method="parse_non_negative", alias="-webkit-box-ordinal-group", diff --git a/components/style/values/computed/length_percentage.rs b/components/style/values/computed/length_percentage.rs index 7c87fdef229..906f002ec3a 100644 --- a/components/style/values/computed/length_percentage.rs +++ b/components/style/values/computed/length_percentage.rs @@ -193,6 +193,12 @@ impl LengthPercentage { Self::new_length(Length::new(1.)) } + /// 0% + #[inline] + pub fn zero_percent() -> Self { + Self::new_percent(Percentage::zero()) + } + fn to_calc_node(&self) -> Cow { match self.unpack() { Unpacked::Length(l) => Cow::Owned(CalcNode::Leaf(CalcLengthPercentageLeaf::Length(l))),