style: Remove the need for needs_context in the mako glue.

It's only used to disambiguate between the one-argument and the trait
version of Keyword::parse. Instead, just explicitly use the trait
version, so that we don't need to specify it.

Differential Revision: https://phabricator.services.mozilla.com/D104328
This commit is contained in:
Emilio Cobos Álvarez 2021-02-09 00:35:51 +00:00
parent 5fe702fa2b
commit 20f5e14bf8
11 changed files with 14 additions and 49 deletions

View file

@ -9,7 +9,7 @@
%> %>
<%def name="predefined_type(name, type, initial_value, parse_method='parse', <%def name="predefined_type(name, type, initial_value, parse_method='parse',
needs_context=True, vector=False, vector=False,
computed_type=None, initial_specified_value=None, computed_type=None, initial_specified_value=None,
allow_quirks='No', allow_empty=False, **kwargs)"> allow_quirks='No', allow_empty=False, **kwargs)">
<%def name="predefined_type_inner(name, type, initial_value, parse_method)"> <%def name="predefined_type_inner(name, type, initial_value, parse_method)">
@ -45,10 +45,10 @@
) -> Result<SpecifiedValue, ParseError<'i>> { ) -> Result<SpecifiedValue, ParseError<'i>> {
% if allow_quirks != "No": % if allow_quirks != "No":
specified::${type}::${parse_method}_quirky(context, input, AllowQuirks::${allow_quirks}) specified::${type}::${parse_method}_quirky(context, input, AllowQuirks::${allow_quirks})
% elif needs_context: % elif parse_method != "parse":
specified::${type}::${parse_method}(context, input) specified::${type}::${parse_method}(context, input)
% else: % else:
specified::${type}::${parse_method}(input) <specified::${type} as crate::parser::Parse>::parse(context, input)
% endif % endif
} }
</%def> </%def>
@ -971,25 +971,21 @@
name, name,
first_property, first_property,
second_property, second_property,
parser_function, parser_function='crate::parser::Parse::parse',
needs_context=True,
**kwargs **kwargs
)"> )">
<%call expr="self.shorthand(name, sub_properties=' '.join([first_property, second_property]), **kwargs)"> <%call expr="self.shorthand(name, sub_properties=' '.join([first_property, second_property]), **kwargs)">
#[allow(unused_imports)] #[allow(unused_imports)]
use crate::parser::Parse; use crate::parser::Parse;
#[allow(unused_imports)]
use crate::values::specified; use crate::values::specified;
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> { ) -> Result<Longhands, ParseError<'i>> {
let parse_one = |_c: &ParserContext, input: &mut Parser<'i, 't>| { let parse_one = |c: &ParserContext, input: &mut Parser<'i, 't>| -> Result<crate::properties::longhands::${to_rust_ident(first_property)}::SpecifiedValue, ParseError<'i>> {
% if needs_context: ${parser_function}(c, input)
${parser_function}(_c, input)
% else:
${parser_function}(input)
% endif
}; };
let first = parse_one(context, input)?; let first = parse_one(context, input)?;
@ -1017,26 +1013,26 @@
</%call> </%call>
</%def> </%def>
<%def name="four_sides_shorthand(name, sub_property_pattern, parser_function, <%def name="four_sides_shorthand(name, sub_property_pattern,
needs_context=True, allow_quirks='No', **kwargs)"> parser_function='crate::parser::Parse::parse',
allow_quirks='No', **kwargs)">
<% sub_properties=' '.join(sub_property_pattern % side for side in PHYSICAL_SIDES) %> <% sub_properties=' '.join(sub_property_pattern % side for side in PHYSICAL_SIDES) %>
<%call expr="self.shorthand(name, sub_properties=sub_properties, **kwargs)"> <%call expr="self.shorthand(name, sub_properties=sub_properties, **kwargs)">
#[allow(unused_imports)] #[allow(unused_imports)]
use crate::parser::Parse; use crate::parser::Parse;
use crate::values::generics::rect::Rect; use crate::values::generics::rect::Rect;
#[allow(unused_imports)]
use crate::values::specified; use crate::values::specified;
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> { ) -> Result<Longhands, ParseError<'i>> {
let rect = Rect::parse_with(context, input, |_c, i| { let rect = Rect::parse_with(context, input, |c, i| -> Result<crate::properties::longhands::${to_rust_ident(sub_property_pattern % "top")}::SpecifiedValue, ParseError<'i>> {
% if allow_quirks != "No": % if allow_quirks != "No":
${parser_function}_quirky(_c, i, specified::AllowQuirks::${allow_quirks}) ${parser_function}_quirky(c, i, specified::AllowQuirks::${allow_quirks})
% elif needs_context:
${parser_function}(_c, i)
% else: % else:
${parser_function}(i) ${parser_function}(c, i)
% endif % endif
})?; })?;
Ok(expanded! { Ok(expanded! {

View file

@ -42,7 +42,6 @@
animation_value_type="discrete" if not is_logical else "none", animation_value_type="discrete" if not is_logical else "none",
logical=is_logical, logical=is_logical,
logical_group="border-style", logical_group="border-style",
needs_context=False,
)} )}
${helpers.predefined_type( ${helpers.predefined_type(

View file

@ -71,7 +71,6 @@ ${helpers.predefined_type(
initial_specified_value="specified::Float::None", initial_specified_value="specified::Float::None",
spec="https://drafts.csswg.org/css-box/#propdef-float", spec="https://drafts.csswg.org/css-box/#propdef-float",
animation_value_type="discrete", animation_value_type="discrete",
needs_context=False,
servo_restyle_damage="rebuild_and_reflow", servo_restyle_damage="rebuild_and_reflow",
gecko_ffi_name="mFloat", gecko_ffi_name="mFloat",
)} )}
@ -82,7 +81,6 @@ ${helpers.predefined_type(
"computed::Clear::None", "computed::Clear::None",
engines="gecko servo-2013", engines="gecko servo-2013",
animation_value_type="discrete", animation_value_type="discrete",
needs_context=False,
gecko_ffi_name="mBreakType", gecko_ffi_name="mBreakType",
spec="https://drafts.csswg.org/css-box/#propdef-clear", spec="https://drafts.csswg.org/css-box/#propdef-clear",
servo_restyle_damage="rebuild_and_reflow", servo_restyle_damage="rebuild_and_reflow",
@ -117,7 +115,6 @@ ${helpers.single_keyword(
"computed::OverflowClipBox::PaddingBox", "computed::OverflowClipBox::PaddingBox",
engines="gecko", engines="gecko",
enabled_in="ua", enabled_in="ua",
needs_context=False,
gecko_pref="layout.css.overflow-clip-box.enabled", gecko_pref="layout.css.overflow-clip-box.enabled",
animation_value_type="discrete", animation_value_type="discrete",
spec="Internal, may be standardized in the future: \ spec="Internal, may be standardized in the future: \
@ -136,7 +133,6 @@ ${helpers.single_keyword(
logical=logical, logical=logical,
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-overflow-3/#propdef-{}".format(full_name), spec="https://drafts.csswg.org/css-overflow-3/#propdef-{}".format(full_name),
needs_context=False,
servo_restyle_damage = "reflow", servo_restyle_damage = "reflow",
gecko_pref="layout.css.overflow-logical.enabled" if logical else None, gecko_pref="layout.css.overflow-logical.enabled" if logical else None,
)} )}
@ -148,7 +144,6 @@ ${helpers.predefined_type(
"computed::OverflowAnchor::Auto", "computed::OverflowAnchor::Auto",
engines="gecko", engines="gecko",
initial_specified_value="specified::OverflowAnchor::Auto", initial_specified_value="specified::OverflowAnchor::Auto",
needs_context=False,
gecko_pref="layout.css.scroll-anchoring.enabled", gecko_pref="layout.css.scroll-anchoring.enabled",
spec="https://drafts.csswg.org/css-scroll-anchoring/#exclusion-api", spec="https://drafts.csswg.org/css-scroll-anchoring/#exclusion-api",
animation_value_type="discrete", animation_value_type="discrete",
@ -468,7 +463,6 @@ ${helpers.predefined_type(
"OverscrollBehavior", "OverscrollBehavior",
"computed::OverscrollBehavior::Auto", "computed::OverscrollBehavior::Auto",
engines="gecko", engines="gecko",
needs_context=False,
logical_group="overscroll-behavior", logical_group="overscroll-behavior",
logical=logical, logical=logical,
gecko_pref="layout.css.overscroll-behavior.enabled", gecko_pref="layout.css.overscroll-behavior.enabled",
@ -494,7 +488,6 @@ ${helpers.predefined_type(
"BreakBetween", "BreakBetween",
"computed::BreakBetween::Auto", "computed::BreakBetween::Auto",
engines="gecko", engines="gecko",
needs_context=False,
spec="https://drafts.csswg.org/css-break/#propdef-break-after", spec="https://drafts.csswg.org/css-break/#propdef-break-after",
animation_value_type="discrete", animation_value_type="discrete",
)} )}
@ -504,7 +497,6 @@ ${helpers.predefined_type(
"BreakBetween", "BreakBetween",
"computed::BreakBetween::Auto", "computed::BreakBetween::Auto",
engines="gecko", engines="gecko",
needs_context=False,
spec="https://drafts.csswg.org/css-break/#propdef-break-before", spec="https://drafts.csswg.org/css-break/#propdef-break-before",
animation_value_type="discrete", animation_value_type="discrete",
)} )}
@ -514,7 +506,6 @@ ${helpers.predefined_type(
"BreakWithin", "BreakWithin",
"computed::BreakWithin::Auto", "computed::BreakWithin::Auto",
engines="gecko", engines="gecko",
needs_context=False,
alias="page-break-inside", alias="page-break-inside",
spec="https://drafts.csswg.org/css-break/#propdef-break-inside", spec="https://drafts.csswg.org/css-break/#propdef-break-inside",
animation_value_type="discrete", animation_value_type="discrete",
@ -528,7 +519,6 @@ ${helpers.predefined_type(
"computed::Resize::None", "computed::Resize::None",
engines="gecko", engines="gecko",
animation_value_type="discrete", animation_value_type="discrete",
needs_context=False,
gecko_ffi_name="mResize", gecko_ffi_name="mResize",
spec="https://drafts.csswg.org/css-ui/#propdef-resize", spec="https://drafts.csswg.org/css-ui/#propdef-resize",
)} )}
@ -584,7 +574,6 @@ ${helpers.predefined_type(
"computed::TransformStyle::Flat", "computed::TransformStyle::Flat",
engines="gecko servo-2013 servo-2020", engines="gecko servo-2013 servo-2020",
spec="https://drafts.csswg.org/css-transforms-2/#transform-style-property", spec="https://drafts.csswg.org/css-transforms-2/#transform-style-property",
needs_context=False,
extra_prefixes=transform_extra_prefixes, extra_prefixes=transform_extra_prefixes,
flags="CREATES_STACKING_CONTEXT FIXPOS_CB", flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
animation_value_type="discrete", animation_value_type="discrete",

View file

@ -84,7 +84,6 @@ ${helpers.predefined_type(
"BorderStyle", "BorderStyle",
"computed::BorderStyle::None", "computed::BorderStyle::None",
engines="gecko", engines="gecko",
needs_context=False,
initial_specified_value="specified::BorderStyle::None", initial_specified_value="specified::BorderStyle::None",
extra_prefixes="moz:layout.css.prefixes.columns", extra_prefixes="moz:layout.css.prefixes.columns",
animation_value_type="discrete", animation_value_type="discrete",

View file

@ -72,7 +72,6 @@ ${helpers.predefined_type(
"FillRule", "FillRule",
"Default::default()", "Default::default()",
engines="gecko", engines="gecko",
needs_context=False,
animation_value_type="discrete", animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG11/painting.html#FillRuleProperty", spec="https://www.w3.org/TR/SVG11/painting.html#FillRuleProperty",
)} )}
@ -165,7 +164,6 @@ ${helpers.predefined_type(
"FillRule", "FillRule",
"Default::default()", "Default::default()",
engines="gecko", engines="gecko",
needs_context=False,
animation_value_type="discrete", animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG11/masking.html#ClipRuleProperty", spec="https://www.w3.org/TR/SVG11/masking.html#ClipRuleProperty",
)} )}

View file

@ -30,7 +30,6 @@ ${helpers.predefined_type(
"caption-side", "caption-side",
"table::CaptionSide", "table::CaptionSide",
"computed::table::CaptionSide::Top", "computed::table::CaptionSide::Top",
needs_context=False,
engines="gecko servo-2013", engines="gecko servo-2013",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-tables/#propdef-caption-side", spec="https://drafts.csswg.org/css-tables/#propdef-caption-side",

View file

@ -83,7 +83,6 @@ ${helpers.predefined_type(
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text/#propdef-overflow-wrap", spec="https://drafts.csswg.org/css-text/#propdef-overflow-wrap",
alias="word-wrap", alias="word-wrap",
needs_context=False,
servo_restyle_damage="rebuild_and_reflow", servo_restyle_damage="rebuild_and_reflow",
)} )}
@ -95,7 +94,6 @@ ${helpers.predefined_type(
servo_2020_pref="layout.2020.unimplemented", servo_2020_pref="layout.2020.unimplemented",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text/#propdef-word-break", spec="https://drafts.csswg.org/css-text/#propdef-word-break",
needs_context=False,
servo_restyle_damage="rebuild_and_reflow", servo_restyle_damage="rebuild_and_reflow",
)} )}
@ -143,7 +141,6 @@ ${helpers.predefined_type(
"text-align-last", "text-align-last",
"TextAlignLast", "TextAlignLast",
"computed::text::TextAlignLast::Auto", "computed::text::TextAlignLast::Auto",
needs_context=False,
engines="gecko", engines="gecko",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text/#propdef-text-align-last", spec="https://drafts.csswg.org/css-text/#propdef-text-align-last",
@ -286,7 +283,6 @@ ${helpers.predefined_type(
engines="gecko", engines="gecko",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text-3/#line-break-property", spec="https://drafts.csswg.org/css-text-3/#line-break-property",
needs_context=False,
)} )}
// CSS Compatibility // CSS Compatibility
@ -402,7 +398,6 @@ ${helpers.predefined_type(
"TextDecorationSkipInk", "TextDecorationSkipInk",
"computed::TextDecorationSkipInk::Auto", "computed::TextDecorationSkipInk::Auto",
engines="gecko", engines="gecko",
needs_context=False,
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text-decor-4/#text-decoration-skip-ink-property", spec="https://drafts.csswg.org/css-text-decor-4/#text-decoration-skip-ink-property",
)} )}

View file

@ -91,7 +91,6 @@ ${helpers.predefined_type(
engines="gecko", engines="gecko",
animation_value_type="discrete", animation_value_type="discrete",
enabled_in="ua", enabled_in="ua",
needs_context=False,
spec="Internal implementation detail for <ol reversed>", spec="Internal implementation detail for <ol reversed>",
servo_restyle_damage="rebuild_and_reflow", servo_restyle_damage="rebuild_and_reflow",
)} )}

View file

@ -37,7 +37,6 @@ ${helpers.predefined_type(
engines="gecko", engines="gecko",
extra_prefixes="moz webkit", extra_prefixes="moz webkit",
animation_value_type="discrete", animation_value_type="discrete",
needs_context=False,
spec="https://drafts.csswg.org/css-ui-4/#propdef-user-select", spec="https://drafts.csswg.org/css-ui-4/#propdef-user-select",
)} )}

View file

@ -17,9 +17,7 @@ ${helpers.four_sides_shorthand(
${helpers.four_sides_shorthand( ${helpers.four_sides_shorthand(
"border-style", "border-style",
"border-%s-style", "border-%s-style",
"specified::BorderStyle::parse",
engines="gecko servo-2013 servo-2020", engines="gecko servo-2013 servo-2020",
needs_context=False,
spec="https://drafts.csswg.org/css-backgrounds/#border-style", spec="https://drafts.csswg.org/css-backgrounds/#border-style",
)} )}

View file

@ -8,10 +8,8 @@ ${helpers.two_properties_shorthand(
"overflow", "overflow",
"overflow-x", "overflow-x",
"overflow-y", "overflow-y",
"specified::Overflow::parse",
engines="gecko servo-2013 servo-2020", engines="gecko servo-2013 servo-2020",
flags="SHORTHAND_IN_GETCS", flags="SHORTHAND_IN_GETCS",
needs_context=False,
spec="https://drafts.csswg.org/css-overflow/#propdef-overflow", spec="https://drafts.csswg.org/css-overflow/#propdef-overflow",
)} )}
@ -19,10 +17,8 @@ ${helpers.two_properties_shorthand(
"overflow-clip-box", "overflow-clip-box",
"overflow-clip-box-block", "overflow-clip-box-block",
"overflow-clip-box-inline", "overflow-clip-box-inline",
"specified::OverflowClipBox::parse",
engines="gecko", engines="gecko",
enabled_in="ua", enabled_in="ua",
needs_context=False,
gecko_pref="layout.css.overflow-clip-box.enabled", gecko_pref="layout.css.overflow-clip-box.enabled",
spec="Internal, may be standardized in the future " spec="Internal, may be standardized in the future "
"(https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)", "(https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)",
@ -310,9 +306,7 @@ ${helpers.two_properties_shorthand(
"overscroll-behavior", "overscroll-behavior",
"overscroll-behavior-x", "overscroll-behavior-x",
"overscroll-behavior-y", "overscroll-behavior-y",
"specified::OverscrollBehavior::parse",
engines="gecko", engines="gecko",
needs_context=False,
gecko_pref="layout.css.overscroll-behavior.enabled", gecko_pref="layout.css.overscroll-behavior.enabled",
spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties", spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties",
)} )}