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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -83,7 +83,6 @@ ${helpers.predefined_type(
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text/#propdef-overflow-wrap",
alias="word-wrap",
needs_context=False,
servo_restyle_damage="rebuild_and_reflow",
)}
@ -95,7 +94,6 @@ ${helpers.predefined_type(
servo_2020_pref="layout.2020.unimplemented",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text/#propdef-word-break",
needs_context=False,
servo_restyle_damage="rebuild_and_reflow",
)}
@ -143,7 +141,6 @@ ${helpers.predefined_type(
"text-align-last",
"TextAlignLast",
"computed::text::TextAlignLast::Auto",
needs_context=False,
engines="gecko",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text/#propdef-text-align-last",
@ -286,7 +283,6 @@ ${helpers.predefined_type(
engines="gecko",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text-3/#line-break-property",
needs_context=False,
)}
// CSS Compatibility
@ -402,7 +398,6 @@ ${helpers.predefined_type(
"TextDecorationSkipInk",
"computed::TextDecorationSkipInk::Auto",
engines="gecko",
needs_context=False,
animation_value_type="discrete",
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",
animation_value_type="discrete",
enabled_in="ua",
needs_context=False,
spec="Internal implementation detail for <ol reversed>",
servo_restyle_damage="rebuild_and_reflow",
)}

View file

@ -37,7 +37,6 @@ ${helpers.predefined_type(
engines="gecko",
extra_prefixes="moz webkit",
animation_value_type="discrete",
needs_context=False,
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(
"border-style",
"border-%s-style",
"specified::BorderStyle::parse",
engines="gecko servo-2013 servo-2020",
needs_context=False,
spec="https://drafts.csswg.org/css-backgrounds/#border-style",
)}

View file

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