mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
style: Switch all callsites of try() to try_parse() in the style crate.
Fully automated via: $ rg -l '\.try\(' | xargs sed -i 's/\.try(/.try_parse(/g' $ cd servo/components/style && cargo +nightly fmt Differential Revision: https://phabricator.services.mozilla.com/D80099
This commit is contained in:
parent
5af0d7ca7c
commit
685e749cfc
56 changed files with 469 additions and 403 deletions
|
@ -59,19 +59,19 @@
|
|||
% endfor
|
||||
loop {
|
||||
if background_color.is_none() {
|
||||
if let Ok(value) = input.try(|i| Color::parse(context, i)) {
|
||||
if let Ok(value) = input.try_parse(|i| Color::parse(context, i)) {
|
||||
background_color = Some(value);
|
||||
continue
|
||||
}
|
||||
}
|
||||
if position.is_none() {
|
||||
if let Ok(value) = input.try(|input| {
|
||||
if let Ok(value) = input.try_parse(|input| {
|
||||
Position::parse_three_value_quirky(context, input, AllowQuirks::No)
|
||||
}) {
|
||||
position = Some(value);
|
||||
|
||||
// Parse background size, if applicable.
|
||||
size = input.try(|input| {
|
||||
size = input.try_parse(|input| {
|
||||
input.expect_delim('/')?;
|
||||
background_size::single_value::parse(context, input)
|
||||
}).ok();
|
||||
|
@ -81,7 +81,7 @@
|
|||
}
|
||||
% for name in "image repeat attachment origin clip".split():
|
||||
if ${name}.is_none() {
|
||||
if let Ok(value) = input.try(|input| background_${name}::single_value
|
||||
if let Ok(value) = input.try_parse(|input| background_${name}::single_value
|
||||
::parse(context, input)) {
|
||||
${name} = Some(value);
|
||||
continue
|
||||
|
|
|
@ -71,20 +71,20 @@ pub fn parse_border<'i, 't>(
|
|||
let mut any = false;
|
||||
loop {
|
||||
if width.is_none() {
|
||||
if let Ok(value) = input.try(|i| BorderSideWidth::parse(context, i)) {
|
||||
if let Ok(value) = input.try_parse(|i| BorderSideWidth::parse(context, i)) {
|
||||
width = Some(value);
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
if style.is_none() {
|
||||
if let Ok(value) = input.try(BorderStyle::parse) {
|
||||
if let Ok(value) = input.try_parse(BorderStyle::parse) {
|
||||
style = Some(value);
|
||||
any = true;
|
||||
continue
|
||||
}
|
||||
}
|
||||
if color.is_none() {
|
||||
if let Ok(value) = input.try(|i| Color::parse(context, i)) {
|
||||
if let Ok(value) = input.try_parse(|i| Color::parse(context, i)) {
|
||||
color = Some(value);
|
||||
any = true;
|
||||
continue
|
||||
|
@ -301,24 +301,24 @@ pub fn parse_border<'i, 't>(
|
|||
let mut border_image_${name} = border_image_${name}::get_initial_specified_value();
|
||||
% endfor
|
||||
|
||||
let result: Result<_, ParseError> = input.try(|input| {
|
||||
let result: Result<_, ParseError> = input.try_parse(|input| {
|
||||
% for name in "outset repeat slice source width".split():
|
||||
let mut ${name} = None;
|
||||
% endfor
|
||||
loop {
|
||||
if slice.is_none() {
|
||||
if let Ok(value) = input.try(|input| border_image_slice::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| border_image_slice::parse(context, input)) {
|
||||
slice = Some(value);
|
||||
// Parse border image width and outset, if applicable.
|
||||
let maybe_width_outset: Result<_, ParseError> = input.try(|input| {
|
||||
let maybe_width_outset: Result<_, ParseError> = input.try_parse(|input| {
|
||||
input.expect_delim('/')?;
|
||||
|
||||
// Parse border image width, if applicable.
|
||||
let w = input.try(|input|
|
||||
let w = input.try_parse(|input|
|
||||
border_image_width::parse(context, input)).ok();
|
||||
|
||||
// Parse border image outset if applicable.
|
||||
let o = input.try(|input| {
|
||||
let o = input.try_parse(|input| {
|
||||
input.expect_delim('/')?;
|
||||
border_image_outset::parse(context, input)
|
||||
}).ok();
|
||||
|
@ -339,7 +339,7 @@ pub fn parse_border<'i, 't>(
|
|||
}
|
||||
% for name in "source repeat".split():
|
||||
if ${name}.is_none() {
|
||||
if let Ok(value) = input.try(|input| border_image_${name}::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| border_image_${name}::parse(context, input)) {
|
||||
${name} = Some(value);
|
||||
continue
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ pub fn parse_border<'i, 't>(
|
|||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let start_value = border_${axis}_start_${prop}::parse(context, input)?;
|
||||
let end_value =
|
||||
input.try(|input| border_${axis}_start_${prop}::parse(context, input))
|
||||
input.try_parse(|input| border_${axis}_start_${prop}::parse(context, input))
|
||||
.unwrap_or_else(|_| start_value.clone());
|
||||
|
||||
Ok(expanded! {
|
||||
|
|
|
@ -31,7 +31,7 @@ ${helpers.two_properties_shorthand(
|
|||
macro_rules! try_parse_one {
|
||||
($context: expr, $input: expr, $var: ident, $prop_module: ident) => {
|
||||
if $var.is_none() {
|
||||
if let Ok(value) = $input.try(|i| {
|
||||
if let Ok(value) = $input.try_parse(|i| {
|
||||
$prop_module::single_value::parse($context, i)
|
||||
}) {
|
||||
$var = Some(value);
|
||||
|
@ -85,12 +85,12 @@ macro_rules! try_parse_one {
|
|||
// Must check 'transition-property' after 'transition-timing-function' since
|
||||
// 'transition-property' accepts any keyword.
|
||||
if property.is_none() {
|
||||
if let Ok(value) = input.try(|i| TransitionProperty::parse(context, i)) {
|
||||
if let Ok(value) = input.try_parse(|i| TransitionProperty::parse(context, i)) {
|
||||
property = Some(Some(value));
|
||||
continue;
|
||||
}
|
||||
|
||||
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
if input.try_parse(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
// 'none' is not a valid value for <single-transition-property>,
|
||||
// so it's not acceptable in the function above.
|
||||
property = Some(None);
|
||||
|
@ -389,13 +389,13 @@ ${helpers.two_properties_shorthand(
|
|||
let mut offset_rotate = None;
|
||||
loop {
|
||||
if offset_distance.is_none() {
|
||||
if let Ok(value) = input.try(|i| LengthPercentage::parse(context, i)) {
|
||||
if let Ok(value) = input.try_parse(|i| LengthPercentage::parse(context, i)) {
|
||||
offset_distance = Some(value);
|
||||
}
|
||||
}
|
||||
|
||||
if offset_rotate.is_none() {
|
||||
if let Ok(value) = input.try(|i| OffsetRotate::parse(context, i)) {
|
||||
if let Ok(value) = input.try_parse(|i| OffsetRotate::parse(context, i)) {
|
||||
offset_rotate = Some(value);
|
||||
continue;
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ ${helpers.two_properties_shorthand(
|
|||
break;
|
||||
}
|
||||
|
||||
let offset_anchor = input.try(|i| {
|
||||
let offset_anchor = input.try_parse(|i| {
|
||||
i.expect_delim('/')?;
|
||||
PositionOrAuto::parse(context, i)
|
||||
}).ok();
|
||||
|
@ -454,7 +454,7 @@ ${helpers.two_properties_shorthand(
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let zoom = match input.try(|input| NumberOrPercentage::parse(context, input)) {
|
||||
let zoom = match input.try_parse(|input| NumberOrPercentage::parse(context, input)) {
|
||||
Ok(number_or_percent) => number_or_percent.to_number(),
|
||||
Err(..) => {
|
||||
input.expect_ident_matching("normal")?;
|
||||
|
|
|
@ -22,21 +22,21 @@
|
|||
let mut autos = 0;
|
||||
|
||||
loop {
|
||||
if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
|
||||
if input.try_parse(|input| input.expect_ident_matching("auto")).is_ok() {
|
||||
// Leave the options to None, 'auto' is the initial value.
|
||||
autos += 1;
|
||||
continue
|
||||
}
|
||||
|
||||
if column_count.is_none() {
|
||||
if let Ok(value) = input.try(|input| column_count::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| column_count::parse(context, input)) {
|
||||
column_count = Some(value);
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if column_width.is_none() {
|
||||
if let Ok(value) = input.try(|input| column_width::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| column_width::parse(context, input)) {
|
||||
column_width = Some(value);
|
||||
continue
|
||||
}
|
||||
|
@ -80,7 +80,7 @@
|
|||
loop {
|
||||
% for name in "width style color".split():
|
||||
if column_rule_${name}.is_none() {
|
||||
if let Ok(value) = input.try(|input|
|
||||
if let Ok(value) = input.try_parse(|input|
|
||||
column_rule_${name}::parse(context, input)) {
|
||||
column_rule_${name} = Some(value);
|
||||
any = true;
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
let mut stretch = None;
|
||||
let size;
|
||||
% if engine == "gecko":
|
||||
if let Ok(sys) = input.try(SystemFont::parse) {
|
||||
if let Ok(sys) = input.try_parse(SystemFont::parse) {
|
||||
return Ok(expanded! {
|
||||
% for name in SYSTEM_FONT_LONGHANDS:
|
||||
% if name == "font_size":
|
||||
|
@ -83,30 +83,30 @@
|
|||
// Special-case 'normal' because it is valid in each of
|
||||
// font-style, font-weight, font-variant and font-stretch.
|
||||
// Leaves the values to None, 'normal' is the initial value for each of them.
|
||||
if input.try(|input| input.expect_ident_matching("normal")).is_ok() {
|
||||
if input.try_parse(|input| input.expect_ident_matching("normal")).is_ok() {
|
||||
nb_normals += 1;
|
||||
continue;
|
||||
}
|
||||
if style.is_none() {
|
||||
if let Ok(value) = input.try(|input| font_style::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| font_style::parse(context, input)) {
|
||||
style = Some(value);
|
||||
continue
|
||||
}
|
||||
}
|
||||
if weight.is_none() {
|
||||
if let Ok(value) = input.try(|input| font_weight::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| font_weight::parse(context, input)) {
|
||||
weight = Some(value);
|
||||
continue
|
||||
}
|
||||
}
|
||||
if variant_caps.is_none() {
|
||||
if let Ok(value) = input.try(|input| font_variant_caps::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| font_variant_caps::parse(context, input)) {
|
||||
variant_caps = Some(value);
|
||||
continue
|
||||
}
|
||||
}
|
||||
if stretch.is_none() {
|
||||
if let Ok(value) = input.try(FontStretchKeyword::parse) {
|
||||
if let Ok(value) = input.try_parse(FontStretchKeyword::parse) {
|
||||
stretch = Some(FontStretch::Keyword(value));
|
||||
continue
|
||||
}
|
||||
|
@ -122,7 +122,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
let line_height = if input.try(|input| input.expect_delim('/')).is_ok() {
|
||||
let line_height = if input.try_parse(|input| input.expect_delim('/')).is_ok() {
|
||||
Some(LineHeight::parse(context, input)?)
|
||||
} else {
|
||||
None
|
||||
|
@ -325,9 +325,9 @@
|
|||
let mut ${prop} = None;
|
||||
% endfor
|
||||
|
||||
if input.try(|input| input.expect_ident_matching("normal")).is_ok() {
|
||||
if input.try_parse(|input| input.expect_ident_matching("normal")).is_ok() {
|
||||
// Leave the values to None, 'normal' is the initial value for all the sub properties.
|
||||
} else if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
} else if input.try_parse(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
// The 'none' value sets 'font-variant-ligatures' to 'none' and resets all other sub properties
|
||||
// to their initial value.
|
||||
% if engine == "gecko":
|
||||
|
@ -336,13 +336,13 @@
|
|||
} else {
|
||||
let mut has_custom_value: bool = false;
|
||||
loop {
|
||||
if input.try(|input| input.expect_ident_matching("normal")).is_ok() ||
|
||||
input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
if input.try_parse(|input| input.expect_ident_matching("normal")).is_ok() ||
|
||||
input.try_parse(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
% for prop in sub_properties:
|
||||
if ${prop}.is_none() {
|
||||
if let Ok(value) = input.try(|i| font_variant_${prop}::parse(context, i)) {
|
||||
if let Ok(value) = input.try_parse(|i| font_variant_${prop}::parse(context, i)) {
|
||||
has_custom_value = true;
|
||||
${prop} = Some(value);
|
||||
continue
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
|
||||
loop {
|
||||
if color.is_none() {
|
||||
if let Ok(value) = input.try(|input| text_emphasis_color::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| text_emphasis_color::parse(context, input)) {
|
||||
color = Some(value);
|
||||
continue
|
||||
}
|
||||
}
|
||||
if style.is_none() {
|
||||
if let Ok(value) = input.try(|input| text_emphasis_style::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| text_emphasis_style::parse(context, input)) {
|
||||
style = Some(value);
|
||||
continue
|
||||
}
|
||||
|
@ -64,14 +64,14 @@
|
|||
let mut width = None;
|
||||
loop {
|
||||
if color.is_none() {
|
||||
if let Ok(value) = input.try(|input| _webkit_text_stroke_color::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| _webkit_text_stroke_color::parse(context, input)) {
|
||||
color = Some(value);
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if width.is_none() {
|
||||
if let Ok(value) = input.try(|input| _webkit_text_stroke_width::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| _webkit_text_stroke_width::parse(context, input)) {
|
||||
width = Some(value);
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
let mut nones = 0u8;
|
||||
let (mut image, mut position, mut list_style_type, mut any) = (None, None, None, false);
|
||||
loop {
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
if input.try_parse(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
nones = nones + 1;
|
||||
if nones > 2 {
|
||||
return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("none".into())))
|
||||
|
@ -31,7 +31,7 @@
|
|||
}
|
||||
|
||||
if image.is_none() {
|
||||
if let Ok(value) = input.try(|input| list_style_image::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| list_style_image::parse(context, input)) {
|
||||
image = Some(value);
|
||||
any = true;
|
||||
continue
|
||||
|
@ -39,7 +39,7 @@
|
|||
}
|
||||
|
||||
if position.is_none() {
|
||||
if let Ok(value) = input.try(|input| list_style_position::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| list_style_position::parse(context, input)) {
|
||||
position = Some(value);
|
||||
any = true;
|
||||
continue
|
||||
|
@ -50,7 +50,7 @@
|
|||
// arbitrary identifier for custom counter style, and thus may
|
||||
// affect values of list-style-position.
|
||||
if list_style_type.is_none() {
|
||||
if let Ok(value) = input.try(|input| list_style_type::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| list_style_type::parse(context, input)) {
|
||||
list_style_type = Some(value);
|
||||
any = true;
|
||||
continue
|
||||
|
|
|
@ -24,21 +24,21 @@
|
|||
let mut any = false;
|
||||
loop {
|
||||
if color.is_none() {
|
||||
if let Ok(value) = input.try(|i| specified::Color::parse(context, i)) {
|
||||
if let Ok(value) = input.try_parse(|i| specified::Color::parse(context, i)) {
|
||||
color = Some(value);
|
||||
any = true;
|
||||
continue
|
||||
}
|
||||
}
|
||||
if style.is_none() {
|
||||
if let Ok(value) = input.try(|input| outline_style::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| outline_style::parse(context, input)) {
|
||||
style = Some(value);
|
||||
any = true;
|
||||
continue
|
||||
}
|
||||
}
|
||||
if width.is_none() {
|
||||
if let Ok(value) = input.try(|input| outline_width::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| outline_width::parse(context, input)) {
|
||||
width = Some(value);
|
||||
any = true;
|
||||
continue
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
let mut wrap = None;
|
||||
loop {
|
||||
if direction.is_none() {
|
||||
if let Ok(value) = input.try(|input| flex_direction::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| flex_direction::parse(context, input)) {
|
||||
direction = Some(value);
|
||||
continue
|
||||
}
|
||||
}
|
||||
if wrap.is_none() {
|
||||
if let Ok(value) = input.try(|input| flex_wrap::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| flex_wrap::parse(context, input)) {
|
||||
wrap = Some(value);
|
||||
continue
|
||||
}
|
||||
|
@ -61,7 +61,7 @@
|
|||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<(NonNegativeNumber, Option<NonNegativeNumber>),ParseError<'i>> {
|
||||
let grow = NonNegativeNumber::parse(context, input)?;
|
||||
let shrink = input.try(|i| NonNegativeNumber::parse(context, i)).ok();
|
||||
let shrink = input.try_parse(|i| NonNegativeNumber::parse(context, i)).ok();
|
||||
Ok((grow, shrink))
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@
|
|||
let mut shrink = None;
|
||||
let mut basis = None;
|
||||
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
if input.try_parse(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(expanded! {
|
||||
flex_grow: NonNegativeNumber::new(0.0),
|
||||
flex_shrink: NonNegativeNumber::new(0.0),
|
||||
|
@ -82,14 +82,14 @@
|
|||
}
|
||||
loop {
|
||||
if grow.is_none() {
|
||||
if let Ok((flex_grow, flex_shrink)) = input.try(|i| parse_flexibility(context, i)) {
|
||||
if let Ok((flex_grow, flex_shrink)) = input.try_parse(|i| parse_flexibility(context, i)) {
|
||||
grow = Some(flex_grow);
|
||||
shrink = flex_shrink;
|
||||
continue
|
||||
}
|
||||
}
|
||||
if basis.is_none() {
|
||||
if let Ok(value) = input.try(|input| FlexBasis::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| FlexBasis::parse(context, input)) {
|
||||
basis = Some(value);
|
||||
continue
|
||||
}
|
||||
|
@ -124,7 +124,7 @@
|
|||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
let r_gap = row_gap::parse(context, input)?;
|
||||
let c_gap = input.try(|input| column_gap::parse(context, input)).unwrap_or(r_gap.clone());
|
||||
let c_gap = input.try_parse(|input| column_gap::parse(context, input)).unwrap_or(r_gap.clone());
|
||||
|
||||
Ok(expanded! {
|
||||
row_gap: r_gap,
|
||||
|
@ -164,8 +164,8 @@
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let start = input.try(|i| GridLine::parse(context, i))?;
|
||||
let end = if input.try(|i| i.expect_delim('/')).is_ok() {
|
||||
let start = input.try_parse(|i| GridLine::parse(context, i))?;
|
||||
let end = if input.try_parse(|i| i.expect_delim('/')).is_ok() {
|
||||
GridLine::parse(context, input)?
|
||||
} else {
|
||||
let mut line = GridLine::auto();
|
||||
|
@ -226,12 +226,12 @@
|
|||
this
|
||||
}
|
||||
|
||||
let row_start = input.try(|i| GridLine::parse(context, i))?;
|
||||
let (column_start, row_end, column_end) = if input.try(|i| i.expect_delim('/')).is_ok() {
|
||||
let row_start = input.try_parse(|i| GridLine::parse(context, i))?;
|
||||
let (column_start, row_end, column_end) = if input.try_parse(|i| i.expect_delim('/')).is_ok() {
|
||||
let column_start = GridLine::parse(context, input)?;
|
||||
let (row_end, column_end) = if input.try(|i| i.expect_delim('/')).is_ok() {
|
||||
let (row_end, column_end) = if input.try_parse(|i| i.expect_delim('/')).is_ok() {
|
||||
let row_end = GridLine::parse(context, input)?;
|
||||
let column_end = if input.try(|i| i.expect_delim('/')).is_ok() {
|
||||
let column_end = if input.try_parse(|i| i.expect_delim('/')).is_ok() {
|
||||
GridLine::parse(context, input)?
|
||||
} else { // grid-column-end has not been given
|
||||
line_with_ident_from(&column_start)
|
||||
|
@ -324,8 +324,8 @@
|
|||
}
|
||||
%>
|
||||
% for keyword, rust_type in keywords.items():
|
||||
if let Ok(x) = input.try(|i| {
|
||||
if i.try(|i| i.expect_ident_matching("${keyword}")).is_ok() {
|
||||
if let Ok(x) = input.try_parse(|i| {
|
||||
if i.try_parse(|i| i.expect_ident_matching("${keyword}")).is_ok() {
|
||||
if !i.is_exhausted() {
|
||||
return Err(());
|
||||
}
|
||||
|
@ -337,20 +337,20 @@
|
|||
}
|
||||
% endfor
|
||||
|
||||
let first_line_names = input.try(parse_line_names).unwrap_or_default();
|
||||
if let Ok(string) = input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned().into())) {
|
||||
let first_line_names = input.try_parse(parse_line_names).unwrap_or_default();
|
||||
if let Ok(string) = input.try_parse(|i| i.expect_string().map(|s| s.as_ref().to_owned().into())) {
|
||||
let mut strings = vec![];
|
||||
let mut values = vec![];
|
||||
let mut line_names = vec![];
|
||||
line_names.push(first_line_names);
|
||||
strings.push(string);
|
||||
loop {
|
||||
let size = input.try(|i| TrackSize::parse(context, i)).unwrap_or_default();
|
||||
let size = input.try_parse(|i| TrackSize::parse(context, i)).unwrap_or_default();
|
||||
values.push(TrackListValue::TrackSize(size));
|
||||
let mut names = input.try(parse_line_names).unwrap_or_default();
|
||||
let more_names = input.try(parse_line_names);
|
||||
let mut names = input.try_parse(parse_line_names).unwrap_or_default();
|
||||
let more_names = input.try_parse(parse_line_names);
|
||||
|
||||
match input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned().into())) {
|
||||
match input.try_parse(|i| i.expect_string().map(|s| s.as_ref().to_owned().into())) {
|
||||
Ok(string) => {
|
||||
strings.push(string);
|
||||
if let Ok(v) = more_names {
|
||||
|
@ -387,7 +387,7 @@
|
|||
auto_repeat_index: std::usize::MAX,
|
||||
};
|
||||
|
||||
let template_cols = if input.try(|i| i.expect_delim('/')).is_ok() {
|
||||
let template_cols = if input.try_parse(|i| i.expect_delim('/')).is_ok() {
|
||||
let value = GridTemplateComponent::parse_without_none(context, input)?;
|
||||
if let GenericGridTemplateComponent::TrackList(ref list) = value {
|
||||
if !list.is_explicit() {
|
||||
|
@ -572,13 +572,13 @@
|
|||
let mut dense = GridAutoFlow::empty();
|
||||
|
||||
for _ in 0..2 {
|
||||
if input.try(|i| i.expect_ident_matching("auto-flow")).is_ok() {
|
||||
if input.try_parse(|i| i.expect_ident_matching("auto-flow")).is_ok() {
|
||||
track = if is_row {
|
||||
Some(GridAutoFlow::ROW)
|
||||
} else {
|
||||
Some(GridAutoFlow::COLUMN)
|
||||
};
|
||||
} else if input.try(|i| i.expect_ident_matching("dense")).is_ok() {
|
||||
} else if input.try_parse(|i| i.expect_ident_matching("dense")).is_ok() {
|
||||
dense = GridAutoFlow::DENSE
|
||||
} else {
|
||||
break
|
||||
|
@ -592,18 +592,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
if let Ok((rows, cols, areas)) = input.try(|i| super::grid_template::parse_grid_template(context, i)) {
|
||||
if let Ok((rows, cols, areas)) = input.try_parse(|i| super::grid_template::parse_grid_template(context, i)) {
|
||||
temp_rows = rows;
|
||||
temp_cols = cols;
|
||||
temp_areas = areas;
|
||||
} else if let Ok(rows) = input.try(|i| GridTemplateComponent::parse(context, i)) {
|
||||
} else if let Ok(rows) = input.try_parse(|i| GridTemplateComponent::parse(context, i)) {
|
||||
temp_rows = rows;
|
||||
input.expect_delim('/')?;
|
||||
flow = parse_auto_flow(input, false)?;
|
||||
auto_cols = grid_auto_columns::parse(context, input).unwrap_or_default();
|
||||
} else {
|
||||
flow = parse_auto_flow(input, true)?;
|
||||
auto_rows = input.try(|i| grid_auto_rows::parse(context, i)).unwrap_or_default();
|
||||
auto_rows = input.try_parse(|i| grid_auto_rows::parse(context, i)).unwrap_or_default();
|
||||
input.expect_delim('/')?;
|
||||
temp_cols = GridTemplateComponent::parse(context, input)?;
|
||||
}
|
||||
|
@ -710,7 +710,7 @@
|
|||
let align_content =
|
||||
ContentDistribution::parse(input, AxisDirection::Block)?;
|
||||
|
||||
let justify_content = input.try(|input| {
|
||||
let justify_content = input.try_parse(|input| {
|
||||
ContentDistribution::parse(input, AxisDirection::Inline)
|
||||
});
|
||||
|
||||
|
@ -763,7 +763,7 @@
|
|||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let align = SelfAlignment::parse(input, AxisDirection::Block)?;
|
||||
let justify = input.try(|input| SelfAlignment::parse(input, AxisDirection::Inline));
|
||||
let justify = input.try_parse(|input| SelfAlignment::parse(input, AxisDirection::Inline));
|
||||
|
||||
let justify = match justify {
|
||||
Ok(v) => v,
|
||||
|
@ -812,7 +812,7 @@
|
|||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let align = AlignItems::parse(context, input)?;
|
||||
let justify =
|
||||
input.try(|input| JustifyItems::parse(context, input))
|
||||
input.try_parse(|input| JustifyItems::parse(context, input))
|
||||
.unwrap_or_else(|_| JustifyItems::from(align));
|
||||
|
||||
Ok(expanded! {
|
||||
|
|
|
@ -55,18 +55,18 @@
|
|||
% endfor
|
||||
loop {
|
||||
if image.is_none() {
|
||||
if let Ok(value) = input.try(|input| mask_image::single_value
|
||||
if let Ok(value) = input.try_parse(|input| mask_image::single_value
|
||||
::parse(context, input)) {
|
||||
image = Some(value);
|
||||
continue
|
||||
}
|
||||
}
|
||||
if position.is_none() {
|
||||
if let Ok(value) = input.try(|input| Position::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| Position::parse(context, input)) {
|
||||
position = Some(value);
|
||||
|
||||
// Parse mask size, if applicable.
|
||||
size = input.try(|input| {
|
||||
size = input.try_parse(|input| {
|
||||
input.expect_delim('/')?;
|
||||
mask_size::single_value::parse(context, input)
|
||||
}).ok();
|
||||
|
@ -76,7 +76,7 @@
|
|||
}
|
||||
% for name in "repeat origin clip composite mode".split():
|
||||
if ${name}.is_none() {
|
||||
if let Ok(value) = input.try(|input| mask_${name}::single_value
|
||||
if let Ok(value) = input.try_parse(|input| mask_${name}::single_value
|
||||
::parse(context, input)) {
|
||||
${name} = Some(value);
|
||||
continue
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
macro_rules! parse_component {
|
||||
($value:ident, $module:ident) => (
|
||||
if $value.is_none() {
|
||||
if let Ok(value) = input.try(|input| $module::parse(context, input)) {
|
||||
if let Ok(value) = input.try_parse(|input| $module::parse(context, input)) {
|
||||
$value = Some(value);
|
||||
any = true;
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue