Skip to content

Commit

Permalink
style: Fix a few initial values in Rust property definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
heycam authored and emilio committed Apr 16, 2020
1 parent 846996a commit fa733ec
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion components/style/properties/longhands/background.mako.rs
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/longhands/font.mako.rs
Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions components/style/properties/longhands/inherited_text.mako.rs
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/longhands/position.mako.rs
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/longhands/svg.mako.rs
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/longhands/ui.mako.rs
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion components/style/properties/longhands/xul.mako.rs
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions components/style/values/computed/length_percentage.rs
Expand Up @@ -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<CalcNode> {
match self.unpack() {
Unpacked::Length(l) => Cow::Owned(CalcNode::Leaf(CalcLengthPercentageLeaf::Length(l))),
Expand Down

0 comments on commit fa733ec

Please sign in to comment.