mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
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:
parent
5fe702fa2b
commit
20f5e14bf8
11 changed files with 14 additions and 49 deletions
|
@ -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! {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue