mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Revert try -> r#try change.
Since we're in an inconsistent state because mako files weren't updated, and it's really really ugly.
This commit is contained in:
parent
155caba595
commit
212b3e1311
47 changed files with 326 additions and 336 deletions
|
@ -85,7 +85,7 @@ impl<T: Parse> Parse for FontSettings<T> {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input.r#try(|i| i.expect_ident_matching("normal")).is_ok() {
|
||||
if input.try(|i| i.expect_ident_matching("normal")).is_ok() {
|
||||
return Ok(Self::normal());
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ impl Parse for GridLine<specified::Integer> {
|
|||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let mut grid_line = Self::auto();
|
||||
if input.r#try(|i| i.expect_ident_matching("auto")).is_ok() {
|
||||
if input.try(|i| i.expect_ident_matching("auto")).is_ok() {
|
||||
return Ok(grid_line);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ impl Parse for GridLine<specified::Integer> {
|
|||
for _ in 0..3 {
|
||||
// Maximum possible entities for <grid-line>
|
||||
let location = input.current_source_location();
|
||||
if input.r#try(|i| i.expect_ident_matching("span")).is_ok() {
|
||||
if input.try(|i| i.expect_ident_matching("span")).is_ok() {
|
||||
if grid_line.is_span {
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
@ -109,14 +109,14 @@ impl Parse for GridLine<specified::Integer> {
|
|||
}
|
||||
|
||||
grid_line.is_span = true;
|
||||
} else if let Ok(i) = input.r#try(|i| specified::Integer::parse(context, i)) {
|
||||
} else if let Ok(i) = input.try(|i| specified::Integer::parse(context, i)) {
|
||||
// FIXME(emilio): Probably shouldn't reject if it's calc()...
|
||||
if i.value() == 0 || val_before_span || grid_line.line_num.is_some() {
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
grid_line.line_num = Some(i);
|
||||
} else if let Ok(name) = input.r#try(|i| i.expect_ident_cloned()) {
|
||||
} else if let Ok(name) = input.try(|i| i.expect_ident_cloned()) {
|
||||
if val_before_span || grid_line.ident.is_some() {
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ impl Parse for RepeatCount<specified::Integer> {
|
|||
) -> Result<Self, ParseError<'i>> {
|
||||
// Maximum number of repeat is 10000. The greater numbers should be clamped.
|
||||
const MAX_LINE: i32 = 10000;
|
||||
if let Ok(mut i) = input.r#try(|i| specified::Integer::parse_positive(context, i)) {
|
||||
if let Ok(mut i) = input.try(|i| specified::Integer::parse_positive(context, i)) {
|
||||
if i.value() > MAX_LINE {
|
||||
i = specified::Integer::new(MAX_LINE);
|
||||
}
|
||||
|
@ -605,14 +605,14 @@ impl Parse for LineNameList {
|
|||
let mut fill_idx = None;
|
||||
|
||||
loop {
|
||||
let repeat_parse_result = input.r#try(|input| {
|
||||
let repeat_parse_result = input.try(|input| {
|
||||
input.expect_function_matching("repeat")?;
|
||||
input.parse_nested_block(|input| {
|
||||
let count = RepeatCount::parse(context, input)?;
|
||||
input.expect_comma()?;
|
||||
let mut names_list = vec![];
|
||||
names_list.push(parse_line_names(input)?); // there should be at least one
|
||||
while let Ok(names) = input.r#try(parse_line_names) {
|
||||
while let Ok(names) = input.try(parse_line_names) {
|
||||
names_list.push(names);
|
||||
}
|
||||
|
||||
|
@ -643,7 +643,7 @@ impl Parse for LineNameList {
|
|||
},
|
||||
_ => return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
}
|
||||
} else if let Ok(names) = input.r#try(parse_line_names) {
|
||||
} else if let Ok(names) = input.try(parse_line_names) {
|
||||
line_names.push(names);
|
||||
} else {
|
||||
break;
|
||||
|
|
|
@ -111,19 +111,16 @@ impl Parse for CounterStyleOrNone {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(name) = input.r#try(|i| parse_counter_style_name(i)) {
|
||||
if let Ok(name) = input.try(|i| parse_counter_style_name(i)) {
|
||||
return Ok(CounterStyleOrNone::Name(name));
|
||||
}
|
||||
if input.r#try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(CounterStyleOrNone::None);
|
||||
}
|
||||
if input
|
||||
.r#try(|i| i.expect_function_matching("symbols"))
|
||||
.is_ok()
|
||||
{
|
||||
if input.try(|i| i.expect_function_matching("symbols")).is_ok() {
|
||||
return input.parse_nested_block(|input| {
|
||||
let symbols_type = input
|
||||
.r#try(|i| SymbolsType::parse(i))
|
||||
.try(|i| SymbolsType::parse(i))
|
||||
.unwrap_or(SymbolsType::Symbolic);
|
||||
let symbols = Symbols::parse(context, input)?;
|
||||
// There must be at least two symbols for alphabetic or
|
||||
|
|
|
@ -50,7 +50,7 @@ where
|
|||
Parse: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<T, ParseError<'i>>,
|
||||
{
|
||||
let first = parse(context, input)?;
|
||||
let second = if let Ok(second) = input.r#try(|i| parse(context, i)) {
|
||||
let second = if let Ok(second) = input.try(|i| parse(context, i)) {
|
||||
second
|
||||
} else {
|
||||
// <first>
|
||||
|
@ -61,13 +61,13 @@ where
|
|||
first,
|
||||
));
|
||||
};
|
||||
let third = if let Ok(third) = input.r#try(|i| parse(context, i)) {
|
||||
let third = if let Ok(third) = input.try(|i| parse(context, i)) {
|
||||
third
|
||||
} else {
|
||||
// <first> <second>
|
||||
return Ok(Self::new(first.clone(), second.clone(), first, second));
|
||||
};
|
||||
let fourth = if let Ok(fourth) = input.r#try(|i| parse(context, i)) {
|
||||
let fourth = if let Ok(fourth) = input.try(|i| parse(context, i)) {
|
||||
fourth
|
||||
} else {
|
||||
// <first> <second> <third>
|
||||
|
|
|
@ -55,7 +55,7 @@ impl<L> Size<L> {
|
|||
{
|
||||
let first = parse_one(context, input)?;
|
||||
let second = input
|
||||
.r#try(|i| parse_one(context, i))
|
||||
.try(|i| parse_one(context, i))
|
||||
.unwrap_or_else(|_| first.clone());
|
||||
Ok(Self::new(first, second))
|
||||
}
|
||||
|
|
|
@ -84,10 +84,10 @@ fn parse_fallback<'i, 't, ColorType: Parse>(
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Option<Either<ColorType, None_>> {
|
||||
if input.r#try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
Some(Either::Second(None_))
|
||||
} else {
|
||||
if let Ok(color) = input.r#try(|i| ColorType::parse(context, i)) {
|
||||
if let Ok(color) = input.try(|i| ColorType::parse(context, i)) {
|
||||
Some(Either::First(color))
|
||||
} else {
|
||||
None
|
||||
|
@ -100,12 +100,12 @@ impl<ColorType: Parse, UrlPaintServer: Parse> Parse for SVGPaint<ColorType, UrlP
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(url) = input.r#try(|i| UrlPaintServer::parse(context, i)) {
|
||||
if let Ok(url) = input.try(|i| UrlPaintServer::parse(context, i)) {
|
||||
Ok(SVGPaint {
|
||||
kind: SVGPaintKind::PaintServer(url),
|
||||
fallback: parse_fallback(context, input),
|
||||
})
|
||||
} else if let Ok(kind) = input.r#try(SVGPaintKind::parse_ident) {
|
||||
} else if let Ok(kind) = input.try(SVGPaintKind::parse_ident) {
|
||||
if let SVGPaintKind::None = kind {
|
||||
Ok(SVGPaint {
|
||||
kind: kind,
|
||||
|
@ -117,7 +117,7 @@ impl<ColorType: Parse, UrlPaintServer: Parse> Parse for SVGPaint<ColorType, UrlP
|
|||
fallback: parse_fallback(context, input),
|
||||
})
|
||||
}
|
||||
} else if let Ok(color) = input.r#try(|i| ColorType::parse(context, i)) {
|
||||
} else if let Ok(color) = input.try(|i| ColorType::parse(context, i)) {
|
||||
Ok(SVGPaint {
|
||||
kind: SVGPaintKind::Color(color),
|
||||
fallback: None,
|
||||
|
@ -158,7 +158,7 @@ impl<LengthOrPercentageType: Parse, NumberType: Parse> Parse
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(num) = input.r#try(|i| NumberType::parse(context, i)) {
|
||||
if let Ok(num) = input.try(|i| NumberType::parse(context, i)) {
|
||||
return Ok(SvgLengthOrPercentageOrNumber::Number(num));
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ impl<Value> Spacing<Value> {
|
|||
where
|
||||
F: FnOnce(&ParserContext, &mut Parser<'i, 't>) -> Result<Value, ParseError<'i>>,
|
||||
{
|
||||
if input.r#try(|i| i.expect_ident_matching("normal")).is_ok() {
|
||||
if input.try(|i| i.expect_ident_matching("normal")).is_ok() {
|
||||
return Ok(Spacing::Normal);
|
||||
}
|
||||
parse(context, input).map(Spacing::Value)
|
||||
|
|
|
@ -44,7 +44,7 @@ where
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<UrlOrNone<Url>, ParseError<'i>> {
|
||||
if let Ok(url) = input.r#try(|input| Url::parse(context, input)) {
|
||||
if let Ok(url) = input.try(|input| Url::parse(context, input)) {
|
||||
return Ok(UrlOrNone::Url(url));
|
||||
}
|
||||
input.expect_ident_matching("none")?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue