mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update to cssparser 0.22 (source location in error types)
This commit is contained in:
parent
056e599562
commit
c0f8f15f39
90 changed files with 974 additions and 790 deletions
|
@ -8,16 +8,16 @@
|
|||
//! [image]: https://drafts.csswg.org/css-images/#image-values
|
||||
|
||||
use Atom;
|
||||
use cssparser::{Parser, Token, BasicParseError};
|
||||
use cssparser::{Parser, Token};
|
||||
use custom_properties::SpecifiedValue;
|
||||
use parser::{Parse, ParserContext};
|
||||
use selectors::parser::SelectorParseError;
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
#[cfg(feature = "servo")]
|
||||
use servo_url::ServoUrl;
|
||||
use std::cmp::Ordering;
|
||||
use std::f32::consts::PI;
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, ParseError, StyleParseError};
|
||||
use style_traits::{ToCss, ParseError, StyleParseErrorKind};
|
||||
use values::{Either, None_};
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::computed::{Context, Position as ComputedPosition, ToComputedValue};
|
||||
|
@ -169,10 +169,11 @@ impl Image {
|
|||
/// Parses a `-moz-element(# <element-id>)`.
|
||||
fn parse_element<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Atom, ParseError<'i>> {
|
||||
input.try(|i| i.expect_function_matching("-moz-element"))?;
|
||||
let location = input.current_source_location();
|
||||
input.parse_nested_block(|i| {
|
||||
match *i.next()? {
|
||||
Token::IDHash(ref id) => Ok(Atom::from(id.as_ref())),
|
||||
ref t => Err(BasicParseError::UnexpectedToken(t.clone()).into()),
|
||||
ref t => Err(location.new_unexpected_token_error(t.clone())),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -236,7 +237,7 @@ impl Parse for Gradient {
|
|||
|
||||
let (shape, repeating, mut compat_mode) = match result {
|
||||
Some(result) => result,
|
||||
None => return Err(StyleParseError::UnexpectedFunction(func.clone()).into()),
|
||||
None => return Err(input.new_custom_error(StyleParseErrorKind::UnexpectedFunction(func.clone()))),
|
||||
};
|
||||
|
||||
let (kind, items) = input.parse_nested_block(|i| {
|
||||
|
@ -249,7 +250,7 @@ impl Parse for Gradient {
|
|||
})?;
|
||||
|
||||
if items.len() < 2 {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
Ok(Gradient {
|
||||
|
@ -435,7 +436,7 @@ impl Gradient {
|
|||
(kind, reverse_stops)
|
||||
}
|
||||
},
|
||||
_ => return Err(SelectorParseError::UnexpectedIdent(ident.clone()).into()),
|
||||
_ => return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone()))),
|
||||
};
|
||||
|
||||
let mut items = input.try(|i| {
|
||||
|
@ -454,11 +455,11 @@ impl Gradient {
|
|||
},
|
||||
"from" => Percentage::zero(),
|
||||
"to" => Percentage::hundred(),
|
||||
_ => return Err(StyleParseError::UnexpectedFunction(function.clone()).into()),
|
||||
_ => return Err(i.new_custom_error(StyleParseErrorKind::UnexpectedFunction(function.clone()))),
|
||||
};
|
||||
let color = Color::parse(context, i)?;
|
||||
if color == Color::CurrentColor {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(i.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
Ok((color.into(), p))
|
||||
})?;
|
||||
|
@ -728,7 +729,7 @@ impl LineDirection {
|
|||
// There is no `to` keyword in webkit prefixed syntax. If it's consumed,
|
||||
// parsing should throw an error.
|
||||
CompatMode::WebKit if to_ident.is_ok() => {
|
||||
return Err(SelectorParseError::UnexpectedIdent("to".into()).into())
|
||||
return Err(i.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("to".into())))
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
@ -743,7 +744,7 @@ impl LineDirection {
|
|||
};
|
||||
|
||||
if _angle.is_none() && position.is_none() {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(i.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
return Ok(LineDirection::MozPosition(position, _angle));
|
||||
}
|
||||
|
@ -867,7 +868,7 @@ impl ShapeExtent {
|
|||
-> Result<Self, ParseError<'i>> {
|
||||
match Self::parse(input)? {
|
||||
ShapeExtent::Contain | ShapeExtent::Cover if compat_mode == CompatMode::Modern => {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
},
|
||||
ShapeExtent::Contain => Ok(ShapeExtent::ClosestSide),
|
||||
ShapeExtent::Cover => Ok(ShapeExtent::FarthestCorner),
|
||||
|
@ -891,7 +892,7 @@ impl GradientItem {
|
|||
ColorStop::parse(context, input).map(GenericGradientItem::ColorStop)
|
||||
})?;
|
||||
if !seen_stop || items.len() < 2 {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
Ok(items)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue