mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +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
|
@ -102,28 +102,28 @@ impl Position {
|
|||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
match input.r#try(|i| PositionComponent::parse_quirky(context, i, allow_quirks)) {
|
||||
match input.try(|i| PositionComponent::parse_quirky(context, i, allow_quirks)) {
|
||||
Ok(x_pos @ PositionComponent::Center) => {
|
||||
if let Ok(y_pos) =
|
||||
input.r#try(|i| PositionComponent::parse_quirky(context, i, allow_quirks))
|
||||
input.try(|i| PositionComponent::parse_quirky(context, i, allow_quirks))
|
||||
{
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
let x_pos = input
|
||||
.r#try(|i| PositionComponent::parse_quirky(context, i, allow_quirks))
|
||||
.try(|i| PositionComponent::parse_quirky(context, i, allow_quirks))
|
||||
.unwrap_or(x_pos);
|
||||
let y_pos = PositionComponent::Center;
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
},
|
||||
Ok(PositionComponent::Side(x_keyword, lop)) => {
|
||||
if input.r#try(|i| i.expect_ident_matching("center")).is_ok() {
|
||||
if input.try(|i| i.expect_ident_matching("center")).is_ok() {
|
||||
let x_pos = PositionComponent::Side(x_keyword, lop);
|
||||
let y_pos = PositionComponent::Center;
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
if let Ok(y_keyword) = input.r#try(Y::parse) {
|
||||
if let Ok(y_keyword) = input.try(Y::parse) {
|
||||
let y_lop = input
|
||||
.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.ok();
|
||||
let x_pos = PositionComponent::Side(x_keyword, lop);
|
||||
let y_pos = PositionComponent::Side(y_keyword, y_lop);
|
||||
|
@ -134,30 +134,30 @@ impl Position {
|
|||
return Ok(Self::new(x_pos, y_pos));
|
||||
},
|
||||
Ok(x_pos @ PositionComponent::Length(_)) => {
|
||||
if let Ok(y_keyword) = input.r#try(Y::parse) {
|
||||
if let Ok(y_keyword) = input.try(Y::parse) {
|
||||
let y_pos = PositionComponent::Side(y_keyword, None);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
if let Ok(y_lop) =
|
||||
input.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
input.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
{
|
||||
let y_pos = PositionComponent::Length(y_lop);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
let y_pos = PositionComponent::Center;
|
||||
let _ = input.r#try(|i| i.expect_ident_matching("center"));
|
||||
let _ = input.try(|i| i.expect_ident_matching("center"));
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
},
|
||||
Err(_) => {},
|
||||
}
|
||||
let y_keyword = Y::parse(input)?;
|
||||
let lop_and_x_pos: Result<_, ParseError> = input.r#try(|i| {
|
||||
let lop_and_x_pos: Result<_, ParseError> = input.try(|i| {
|
||||
let y_lop = i
|
||||
.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.ok();
|
||||
if let Ok(x_keyword) = i.r#try(X::parse) {
|
||||
if let Ok(x_keyword) = i.try(X::parse) {
|
||||
let x_lop = i
|
||||
.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.ok();
|
||||
let x_pos = PositionComponent::Side(x_keyword, x_lop);
|
||||
return Ok((y_lop, x_pos));
|
||||
|
@ -230,16 +230,15 @@ impl<S: Parse> PositionComponent<S> {
|
|||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input.r#try(|i| i.expect_ident_matching("center")).is_ok() {
|
||||
if input.try(|i| i.expect_ident_matching("center")).is_ok() {
|
||||
return Ok(PositionComponent::Center);
|
||||
}
|
||||
if let Ok(lop) = input.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
{
|
||||
if let Ok(lop) = input.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) {
|
||||
return Ok(PositionComponent::Length(lop));
|
||||
}
|
||||
let keyword = S::parse(context, input)?;
|
||||
let lop = input
|
||||
.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.ok();
|
||||
Ok(PositionComponent::Side(keyword, lop))
|
||||
}
|
||||
|
@ -360,51 +359,51 @@ impl LegacyPosition {
|
|||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
match input.r#try(|i| OriginComponent::parse(context, i)) {
|
||||
match input.try(|i| OriginComponent::parse(context, i)) {
|
||||
Ok(x_pos @ OriginComponent::Center) => {
|
||||
if let Ok(y_pos) = input.r#try(|i| OriginComponent::parse(context, i)) {
|
||||
if let Ok(y_pos) = input.try(|i| OriginComponent::parse(context, i)) {
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
let x_pos = input
|
||||
.r#try(|i| OriginComponent::parse(context, i))
|
||||
.try(|i| OriginComponent::parse(context, i))
|
||||
.unwrap_or(x_pos);
|
||||
let y_pos = OriginComponent::Center;
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
},
|
||||
Ok(OriginComponent::Side(x_keyword)) => {
|
||||
if let Ok(y_keyword) = input.r#try(Y::parse) {
|
||||
if let Ok(y_keyword) = input.try(Y::parse) {
|
||||
let x_pos = OriginComponent::Side(x_keyword);
|
||||
let y_pos = OriginComponent::Side(y_keyword);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
let x_pos = OriginComponent::Side(x_keyword);
|
||||
if let Ok(y_lop) =
|
||||
input.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
input.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
{
|
||||
return Ok(Self::new(x_pos, OriginComponent::Length(y_lop)));
|
||||
}
|
||||
let _ = input.r#try(|i| i.expect_ident_matching("center"));
|
||||
let _ = input.try(|i| i.expect_ident_matching("center"));
|
||||
return Ok(Self::new(x_pos, OriginComponent::Center));
|
||||
},
|
||||
Ok(x_pos @ OriginComponent::Length(_)) => {
|
||||
if let Ok(y_keyword) = input.r#try(Y::parse) {
|
||||
if let Ok(y_keyword) = input.try(Y::parse) {
|
||||
let y_pos = OriginComponent::Side(y_keyword);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
if let Ok(y_lop) =
|
||||
input.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
input.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks))
|
||||
{
|
||||
let y_pos = OriginComponent::Length(y_lop);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
let _ = input.r#try(|i| i.expect_ident_matching("center"));
|
||||
let _ = input.try(|i| i.expect_ident_matching("center"));
|
||||
return Ok(Self::new(x_pos, OriginComponent::Center));
|
||||
},
|
||||
Err(_) => {},
|
||||
}
|
||||
let y_keyword = Y::parse(input)?;
|
||||
let x_pos: Result<_, ParseError> = input.r#try(|i| {
|
||||
if let Ok(x_keyword) = i.r#try(X::parse) {
|
||||
let x_pos: Result<_, ParseError> = input.try(|i| {
|
||||
if let Ok(x_keyword) = i.try(X::parse) {
|
||||
let x_pos = OriginComponent::Side(x_keyword);
|
||||
return Ok(x_pos);
|
||||
}
|
||||
|
@ -649,7 +648,7 @@ impl Parse for TemplateAreas {
|
|||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let mut strings = vec![];
|
||||
while let Ok(string) = input.r#try(|i| i.expect_string().map(|s| s.as_ref().into())) {
|
||||
while let Ok(string) = input.try(|i| i.expect_string().map(|s| s.as_ref().into())) {
|
||||
strings.push(string);
|
||||
}
|
||||
|
||||
|
@ -743,7 +742,7 @@ impl Parse for ZIndex {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
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(GenericZIndex::Auto);
|
||||
}
|
||||
Ok(GenericZIndex::Integer(Integer::parse(context, input)?))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue