mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +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,19 +8,19 @@
|
|||
|
||||
use context::QuirksMode;
|
||||
use cssparser::{DeclarationListParser, parse_important, ParserInput, CowRcStr};
|
||||
use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter, ParseError as CssParseError};
|
||||
use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter, ParseErrorKind};
|
||||
use custom_properties::CustomPropertiesBuilder;
|
||||
use error_reporting::{ParseErrorReporter, ContextualParseError};
|
||||
use parser::{ParserContext, ParserErrorContext};
|
||||
use properties::animated_properties::AnimationValue;
|
||||
use selectors::parser::SelectorParseError;
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use shared_lock::Locked;
|
||||
use smallbitvec::{self, SmallBitVec};
|
||||
use smallvec::SmallVec;
|
||||
use std::fmt;
|
||||
use std::iter::{DoubleEndedIterator, Zip};
|
||||
use std::slice::Iter;
|
||||
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError, ParsingMode, StyleParseError};
|
||||
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError, ParsingMode, StyleParseErrorKind};
|
||||
use stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||
use super::*;
|
||||
use values::computed::Context;
|
||||
|
@ -1059,7 +1059,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for PropertyDeclarationParser<'a, 'b> {
|
|||
type PreludeNoBlock = ();
|
||||
type PreludeBlock = ();
|
||||
type AtRule = Importance;
|
||||
type Error = SelectorParseError<'i, StyleParseError<'i>>;
|
||||
type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
|
||||
}
|
||||
|
||||
/// Based on NonMozillaVendorIdentifier from Gecko's CSS parser.
|
||||
|
@ -1070,7 +1070,7 @@ fn is_non_mozilla_vendor_identifier(name: &str) -> bool {
|
|||
|
||||
impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyDeclarationParser<'a, 'b> {
|
||||
type Declaration = Importance;
|
||||
type Error = SelectorParseError<'i, StyleParseError<'i>>;
|
||||
type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
|
||||
|
||||
fn parse_value<'t>(&mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>)
|
||||
-> Result<Importance, ParseError<'i>> {
|
||||
|
@ -1078,11 +1078,11 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyDeclarationParser<'a, 'b> {
|
|||
let id = match PropertyId::parse(&name, Some(&prop_context)) {
|
||||
Ok(id) => id,
|
||||
Err(()) => {
|
||||
return Err(if is_non_mozilla_vendor_identifier(&name) {
|
||||
PropertyDeclarationParseError::UnknownVendorProperty
|
||||
return Err(input.new_custom_error(if is_non_mozilla_vendor_identifier(&name) {
|
||||
PropertyDeclarationParseErrorKind::UnknownVendorProperty
|
||||
} else {
|
||||
PropertyDeclarationParseError::UnknownProperty(name)
|
||||
}.into());
|
||||
PropertyDeclarationParseErrorKind::UnknownProperty(name)
|
||||
}));
|
||||
}
|
||||
};
|
||||
input.parse_until_before(Delimiter::Bang, |input| {
|
||||
|
@ -1120,18 +1120,18 @@ pub fn parse_property_declaration_list<R>(context: &ParserContext,
|
|||
Ok(importance) => {
|
||||
block.extend(iter.parser.declarations.drain(), importance);
|
||||
}
|
||||
Err(err) => {
|
||||
Err((error, slice)) => {
|
||||
iter.parser.declarations.clear();
|
||||
|
||||
// If the unrecognized property looks like a vendor-specific property,
|
||||
// silently ignore it instead of polluting the error output.
|
||||
if let CssParseError::Custom(SelectorParseError::Custom(
|
||||
StyleParseError::PropertyDeclaration(
|
||||
PropertyDeclarationParseError::UnknownVendorProperty))) = err.error {
|
||||
if let ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
|
||||
StyleParseErrorKind::PropertyDeclaration(
|
||||
PropertyDeclarationParseErrorKind::UnknownVendorProperty))) = error.kind {
|
||||
continue;
|
||||
}
|
||||
|
||||
let error = ContextualParseError::UnsupportedPropertyDeclaration(err.slice, err.error);
|
||||
let error = ContextualParseError::UnsupportedPropertyDeclaration(slice, error);
|
||||
let location = iter.input.current_source_location();
|
||||
context.log_css_error(error_context, location, error);
|
||||
}
|
||||
|
|
|
@ -93,9 +93,9 @@
|
|||
#[allow(unused_imports)]
|
||||
use properties::ShorthandId;
|
||||
#[allow(unused_imports)]
|
||||
use selectors::parser::SelectorParseError;
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
#[allow(unused_imports)]
|
||||
use style_traits::{ParseError, StyleParseError};
|
||||
use style_traits::{ParseError, StyleParseErrorKind};
|
||||
#[allow(unused_imports)]
|
||||
use values::computed::{Context, ToComputedValue};
|
||||
#[allow(unused_imports)]
|
||||
|
@ -285,11 +285,11 @@
|
|||
#[allow(unused_imports)]
|
||||
use properties::style_structs;
|
||||
#[allow(unused_imports)]
|
||||
use selectors::parser::SelectorParseError;
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
#[allow(unused_imports)]
|
||||
use servo_arc::Arc;
|
||||
#[allow(unused_imports)]
|
||||
use style_traits::{ParseError, StyleParseError};
|
||||
use style_traits::{ParseError, StyleParseErrorKind};
|
||||
#[allow(unused_imports)]
|
||||
use values::computed::{Context, ToComputedValue};
|
||||
#[allow(unused_imports)]
|
||||
|
@ -699,11 +699,11 @@
|
|||
use parser::ParserContext;
|
||||
use properties::{PropertyDeclaration, SourcePropertyDeclaration, MaybeBoxed, longhands};
|
||||
#[allow(unused_imports)]
|
||||
use selectors::parser::SelectorParseError;
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
#[allow(unused_imports)]
|
||||
use std::fmt;
|
||||
#[allow(unused_imports)]
|
||||
use style_traits::{ParseError, StyleParseError};
|
||||
use style_traits::{ParseError, StyleParseErrorKind};
|
||||
#[allow(unused_imports)]
|
||||
use style_traits::ToCss;
|
||||
|
||||
|
@ -992,7 +992,7 @@
|
|||
// Keyword values don't make sense in the block direction; don't parse them
|
||||
% if "block" in name:
|
||||
if let Ok(${length_type}::ExtremumLength(..)) = ret {
|
||||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
% endif
|
||||
ret.map(SpecifiedValue)
|
||||
|
|
|
@ -25,7 +25,7 @@ use properties::longhands::visibility::computed_value::T as Visibility;
|
|||
#[cfg(feature = "gecko")]
|
||||
use properties::PropertyId;
|
||||
use properties::{LonghandId, ShorthandId};
|
||||
use selectors::parser::SelectorParseError;
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use servo_arc::Arc;
|
||||
use smallvec::SmallVec;
|
||||
use std::borrow::Cow;
|
||||
|
@ -134,6 +134,7 @@ impl TransitionProperty {
|
|||
|
||||
/// Parse a transition-property value.
|
||||
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
let location = input.current_source_location();
|
||||
let ident = input.expect_ident()?;
|
||||
match_ignore_ascii_case! { &ident,
|
||||
"all" => Ok(TransitionProperty::All),
|
||||
|
@ -143,8 +144,8 @@ impl TransitionProperty {
|
|||
% for prop in data.longhands:
|
||||
"${prop.name}" => Ok(TransitionProperty::Longhand(LonghandId::${prop.camel_case})),
|
||||
% endfor
|
||||
"none" => Err(SelectorParseError::UnexpectedIdent(ident.clone()).into()),
|
||||
_ => CustomIdent::from_ident(ident, &[]).map(TransitionProperty::Unsupported),
|
||||
"none" => Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone()))),
|
||||
_ => CustomIdent::from_ident(location, ident, &[]).map(TransitionProperty::Unsupported),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ ${helpers.predefined_type("background-image", "ImageLayer",
|
|||
_ => Err(()),
|
||||
}).or_else(|()| {
|
||||
let horizontal: Result<_, ParseError> = RepeatKeyword::from_ident(&ident)
|
||||
.map_err(|()| SelectorParseError::UnexpectedIdent(ident.clone()).into());
|
||||
.map_err(|()| input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone())));
|
||||
let horizontal = horizontal?;
|
||||
let vertical = input.try(RepeatKeyword::parse).ok();
|
||||
Ok(SpecifiedValue::Other(horizontal, vertical))
|
||||
|
|
|
@ -187,7 +187,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
|
|||
if !result.is_empty() {
|
||||
Ok(SpecifiedValue::Colors(result))
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
/// Parse a display value.
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
try_match_ident_ignore_ascii_case! { input.expect_ident()?,
|
||||
try_match_ident_ignore_ascii_case! { input,
|
||||
% for value in values:
|
||||
"${value}" => {
|
||||
Ok(computed_value::T::${to_rust_ident(value)})
|
||||
|
@ -545,7 +545,7 @@ ${helpers.predefined_type("animation-timing-function",
|
|||
|
||||
let number = input.expect_number()?;
|
||||
if number < 0.0 {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
Ok(SpecifiedValue::Number(number))
|
||||
|
@ -1177,7 +1177,7 @@ ${helpers.predefined_type(
|
|||
_ => Err(()),
|
||||
};
|
||||
result
|
||||
.map_err(|()| StyleParseError::UnexpectedFunction(function.clone()).into())
|
||||
.map_err(|()| input.new_custom_error(StyleParseErrorKind::UnexpectedFunction(function.clone())))
|
||||
})
|
||||
})?))
|
||||
}
|
||||
|
@ -1730,7 +1730,7 @@ ${helpers.predefined_type("transform-origin",
|
|||
};
|
||||
let flag = match flag {
|
||||
Some(flag) if !result.contains(flag) => flag,
|
||||
_ => return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
_ => return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
};
|
||||
result.insert(flag);
|
||||
}
|
||||
|
@ -1738,7 +1738,7 @@ ${helpers.predefined_type("transform-origin",
|
|||
if !result.is_empty() {
|
||||
Ok(result)
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
@ -1839,7 +1839,8 @@ ${helpers.single_keyword("-moz-orient",
|
|||
Ok(computed_value::T::Auto)
|
||||
} else {
|
||||
input.parse_comma_separated(|i| {
|
||||
CustomIdent::from_ident(i.expect_ident()?, &[
|
||||
let location = i.current_source_location();
|
||||
CustomIdent::from_ident(location, i.expect_ident()?, &[
|
||||
"will-change",
|
||||
"none",
|
||||
"all",
|
||||
|
@ -1914,7 +1915,7 @@ ${helpers.predefined_type(
|
|||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
// FIXME: remove clone() when lifetimes are non-lexical
|
||||
try_match_ident_ignore_ascii_case! { input.expect_ident()?.clone(),
|
||||
try_match_ident_ignore_ascii_case! { input,
|
||||
"auto" => Ok(TOUCH_ACTION_AUTO),
|
||||
"none" => Ok(TOUCH_ACTION_NONE),
|
||||
"manipulation" => Ok(TOUCH_ACTION_MANIPULATION),
|
||||
|
|
|
@ -205,7 +205,9 @@
|
|||
};
|
||||
match result {
|
||||
Some(result) => content.push(result?),
|
||||
None => return Err(StyleParseError::UnexpectedFunction(name.clone()).into())
|
||||
None => return Err(input.new_custom_error(
|
||||
StyleParseErrorKind::UnexpectedFunction(name.clone())
|
||||
))
|
||||
}
|
||||
}
|
||||
Ok(Token::Ident(ref ident)) => {
|
||||
|
@ -218,15 +220,15 @@
|
|||
_ => false,
|
||||
};
|
||||
if !valid {
|
||||
return Err(SelectorParseError::UnexpectedIdent(ident.clone()).into())
|
||||
return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone())))
|
||||
}
|
||||
}
|
||||
Err(_) => break,
|
||||
Ok(t) => return Err(BasicParseError::UnexpectedToken(t).into())
|
||||
Ok(t) => return Err(input.new_unexpected_token_error(t))
|
||||
}
|
||||
}
|
||||
if content.is_empty() {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
Ok(SpecifiedValue::Items(content))
|
||||
}
|
||||
|
@ -332,9 +334,10 @@
|
|||
|
||||
let mut counters = Vec::new();
|
||||
loop {
|
||||
let location = input.current_source_location();
|
||||
let counter_name = match input.next() {
|
||||
Ok(&Token::Ident(ref ident)) => CustomIdent::from_ident(ident, &["none"])?,
|
||||
Ok(t) => return Err(BasicParseError::UnexpectedToken(t.clone()).into()),
|
||||
Ok(&Token::Ident(ref ident)) => CustomIdent::from_ident(location, ident, &["none"])?,
|
||||
Ok(t) => return Err(location.new_unexpected_token_error(t.clone())),
|
||||
Err(_) => break,
|
||||
};
|
||||
let counter_delta = input.try(|input| specified::parse_integer(context, input))
|
||||
|
@ -345,7 +348,7 @@
|
|||
if !counters.is_empty() {
|
||||
Ok(SpecifiedValue(counters))
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
|
|
@ -587,7 +587,7 @@ macro_rules! impl_gecko_keyword_conversions {
|
|||
fn parse<'i, 't>(_: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
match FontFamily::parse(input) {
|
||||
Ok(FontFamily::FamilyName(name)) => Ok(name),
|
||||
Ok(FontFamily::Generic(_)) => Err(StyleParseError::UnspecifiedError.into()),
|
||||
Ok(FontFamily::Generic(_)) => Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
Err(e) => Err(e)
|
||||
}
|
||||
}
|
||||
|
@ -744,7 +744,7 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
fn parse<'i, 't>(_: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
Self::from_int(input.expect_integer()?)
|
||||
.map_err(|_| StyleParseError::UnspecifiedError.into())
|
||||
.map_err(|_| input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -837,7 +837,7 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
return Ok(SpecifiedValue::Keyword(kw.into()))
|
||||
}
|
||||
|
||||
try_match_ident_ignore_ascii_case! { input.expect_ident()?,
|
||||
try_match_ident_ignore_ascii_case! { input,
|
||||
"smaller" => Ok(SpecifiedValue::Smaller),
|
||||
"larger" => Ok(SpecifiedValue::Larger),
|
||||
}
|
||||
|
@ -1082,7 +1082,7 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
let mut result = SpecifiedValue { weight: false, style: false };
|
||||
// FIXME: remove clone() when lifetimes are non-lexical
|
||||
try_match_ident_ignore_ascii_case! { input.expect_ident()?.clone(),
|
||||
try_match_ident_ignore_ascii_case! { input,
|
||||
"none" => Ok(result),
|
||||
"weight" => {
|
||||
result.weight = true;
|
||||
|
@ -1298,9 +1298,9 @@ ${helpers.single_keyword_system("font-kerning",
|
|||
|
||||
let mut parsed_alternates = ParsingFlags::empty();
|
||||
macro_rules! check_if_parsed(
|
||||
($flag:ident) => (
|
||||
($input:expr, $flag:ident) => (
|
||||
if parsed_alternates.contains($flag) {
|
||||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
return Err($input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
parsed_alternates |= $flag;
|
||||
)
|
||||
|
@ -1310,11 +1310,11 @@ ${helpers.single_keyword_system("font-kerning",
|
|||
match input.next()?.clone() {
|
||||
Token::Ident(ref ident) => {
|
||||
if *ident == "historical-forms" {
|
||||
check_if_parsed!(HISTORICAL_FORMS);
|
||||
check_if_parsed!(input, HISTORICAL_FORMS);
|
||||
alternates.push(VariantAlternates::HistoricalForms);
|
||||
Ok(())
|
||||
} else {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
},
|
||||
Token::Function(ref name) => {
|
||||
|
@ -1322,31 +1322,34 @@ ${helpers.single_keyword_system("font-kerning",
|
|||
match_ignore_ascii_case! { &name,
|
||||
% for value in "swash stylistic ornaments annotation".split():
|
||||
"${value}" => {
|
||||
check_if_parsed!(${value.upper()});
|
||||
let ident = CustomIdent::from_ident(i.expect_ident()?, &[])?;
|
||||
check_if_parsed!(i, ${value.upper()});
|
||||
let location = i.current_source_location();
|
||||
let ident = CustomIdent::from_ident(location, i.expect_ident()?, &[])?;
|
||||
alternates.push(VariantAlternates::${to_camel_case(value)}(ident));
|
||||
Ok(())
|
||||
},
|
||||
% endfor
|
||||
% for value in "styleset character-variant".split():
|
||||
"${value}" => {
|
||||
check_if_parsed!(${to_rust_ident(value).upper()});
|
||||
let idents = i.parse_comma_separated(|i|
|
||||
CustomIdent::from_ident(i.expect_ident()?, &[]))?;
|
||||
check_if_parsed!(i, ${to_rust_ident(value).upper()});
|
||||
let idents = i.parse_comma_separated(|i| {
|
||||
let location = i.current_source_location();
|
||||
CustomIdent::from_ident(location, i.expect_ident()?, &[])
|
||||
})?;
|
||||
alternates.push(VariantAlternates::${to_camel_case(value)}(idents.into_boxed_slice()));
|
||||
Ok(())
|
||||
},
|
||||
% endfor
|
||||
_ => return Err(StyleParseError::UnspecifiedError.into()),
|
||||
_ => return Err(i.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
}
|
||||
})
|
||||
},
|
||||
_ => Err(StyleParseError::UnspecifiedError.into()),
|
||||
_ => Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
}
|
||||
}) { }
|
||||
|
||||
if parsed_alternates.is_empty() {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
Ok(SpecifiedValue::Value(VariantAlternatesList(alternates.into_boxed_slice())))
|
||||
}
|
||||
|
@ -1501,7 +1504,7 @@ macro_rules! exclusive_value {
|
|||
if !result.is_empty() {
|
||||
Ok(SpecifiedValue::Value(result))
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1661,7 +1664,7 @@ macro_rules! exclusive_value {
|
|||
if !result.is_empty() {
|
||||
Ok(SpecifiedValue::Value(result))
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1809,7 +1812,7 @@ macro_rules! exclusive_value {
|
|||
if !result.is_empty() {
|
||||
Ok(SpecifiedValue::Value(result))
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2082,10 +2085,10 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
|
|||
computed_value::T(atom!(""))
|
||||
}
|
||||
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, _input: &mut Parser<'i, 't>)
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
debug_assert!(false, "Should be set directly by presentation attributes only.");
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
|
@ -2105,10 +2108,10 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
|
|||
::gecko_bindings::structs::NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER as f32
|
||||
}
|
||||
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, _input: &mut Parser<'i, 't>)
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
debug_assert!(false, "Should be set directly by presentation attributes only.");
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
|
@ -2254,10 +2257,10 @@ ${helpers.single_keyword("-moz-math-variant",
|
|||
Length::new(NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT as f32 * (AU_PER_PT / AU_PER_PX))
|
||||
}
|
||||
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, _input: &mut Parser<'i, 't>)
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
debug_assert!(false, "Should be set directly by presentation attributes only.");
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
|
@ -2287,10 +2290,10 @@ ${helpers.single_keyword("-moz-math-variant",
|
|||
computed_value::T(true)
|
||||
}
|
||||
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, _input: &mut Parser<'i, 't>)
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
debug_assert!(false, "Should be set directly by presentation attributes only.");
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
|
@ -2445,7 +2448,7 @@ ${helpers.single_keyword("-moz-math-variant",
|
|||
|
||||
impl SystemFont {
|
||||
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
try_match_ident_ignore_ascii_case! { input.expect_ident()?,
|
||||
try_match_ident_ignore_ascii_case! { input,
|
||||
% for font in system_fonts:
|
||||
"${font}" => Ok(SystemFont::${to_camel_case(font)}),
|
||||
% endfor
|
||||
|
|
|
@ -241,7 +241,7 @@ ${helpers.single_keyword("image-rendering",
|
|||
// Handle <angle> | <angle> flip
|
||||
let angle = input.try(|input| Angle::parse(context, input)).ok();
|
||||
if angle.is_none() {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
let flipped = input.try(|input| input.expect_ident_matching("flip")).is_ok();
|
||||
|
|
|
@ -207,8 +207,8 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
|
|||
let mut pos = 0;
|
||||
|
||||
loop {
|
||||
let result: Result<_, ParseError> = input.try(|i| {
|
||||
try_match_ident_ignore_ascii_case! { i.expect_ident()?,
|
||||
let result: Result<_, ParseError> = input.try(|input| {
|
||||
try_match_ident_ignore_ascii_case! { input,
|
||||
"fill" => Ok(PaintOrder::Fill),
|
||||
"stroke" => Ok(PaintOrder::Stroke),
|
||||
"markers" => Ok(PaintOrder::Markers),
|
||||
|
@ -219,7 +219,7 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
|
|||
Ok(val) => {
|
||||
if (seen & (1 << val as u8)) != 0 {
|
||||
// don't parse the same ident twice
|
||||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
|
||||
value |= (val as u8) << (pos * SHIFT);
|
||||
|
@ -232,7 +232,7 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
|
|||
|
||||
if value == 0 {
|
||||
// Couldn't find any keyword
|
||||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
|
||||
// fill in rest
|
||||
|
@ -293,7 +293,8 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
|
|||
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
let location = input.current_source_location();
|
||||
let i = input.expect_ident()?;
|
||||
CustomIdent::from_ident(i, &["all", "none", "auto"])
|
||||
CustomIdent::from_ident(location, i, &["all", "none", "auto"])
|
||||
}
|
||||
</%helpers:vector_longhand>
|
||||
|
|
|
@ -585,7 +585,7 @@ ${helpers.predefined_type(
|
|||
(Some(fill), Ok(shape)) => KeywordValue::FillAndShape(fill,shape),
|
||||
(Some(fill), Err(_)) => KeywordValue::Fill(fill),
|
||||
(None, Ok(shape)) => KeywordValue::Shape(shape),
|
||||
_ => return Err(StyleParseError::UnspecifiedError.into()),
|
||||
_ => return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
};
|
||||
Ok(SpecifiedValue::Keyword(keyword_value))
|
||||
}
|
||||
|
|
|
@ -188,14 +188,16 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
|
|||
|
||||
let mut quotes = Vec::new();
|
||||
loop {
|
||||
let location = input.current_source_location();
|
||||
let first = match input.next() {
|
||||
Ok(&Token::QuotedString(ref value)) => value.as_ref().to_owned(),
|
||||
Ok(t) => return Err(BasicParseError::UnexpectedToken(t.clone()).into()),
|
||||
Ok(t) => return Err(location.new_unexpected_token_error(t.clone())),
|
||||
Err(_) => break,
|
||||
};
|
||||
let location = input.current_source_location();
|
||||
let second = match input.next() {
|
||||
Ok(&Token::QuotedString(ref value)) => value.as_ref().to_owned(),
|
||||
Ok(t) => return Err(BasicParseError::UnexpectedToken(t.clone()).into()),
|
||||
Ok(t) => return Err(location.new_unexpected_token_error(t.clone())),
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
quotes.push((first, second))
|
||||
|
@ -203,7 +205,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
|
|||
if !quotes.is_empty() {
|
||||
Ok(SpecifiedValue(quotes))
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
|
|
@ -58,7 +58,7 @@ ${helpers.predefined_type(
|
|||
// The outline-style property accepts the same values as
|
||||
// border-style, except that 'hidden' is not a legal outline
|
||||
// style.
|
||||
Err(SelectorParseError::UnexpectedIdent("hidden".into()).into())
|
||||
Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("hidden".into())))
|
||||
} else {
|
||||
Ok(result)
|
||||
}
|
||||
|
|
|
@ -92,13 +92,14 @@
|
|||
-> Result<computed_value::Keyword, ParseError<'i>> {
|
||||
use std::ascii::AsciiExt;
|
||||
use style_traits::cursor::Cursor;
|
||||
let location = input.current_source_location();
|
||||
let ident = input.expect_ident()?;
|
||||
if ident.eq_ignore_ascii_case("auto") {
|
||||
Ok(computed_value::Keyword::Auto)
|
||||
} else {
|
||||
Cursor::from_css_keyword(&ident)
|
||||
.map(computed_value::Keyword::Cursor)
|
||||
.map_err(|()| SelectorParseError::UnexpectedIdent(ident.clone()).into())
|
||||
.map_err(|()| location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone())))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -340,6 +340,7 @@ ${helpers.predefined_type("object-position",
|
|||
let mut dense = false;
|
||||
|
||||
while !input.is_exhausted() {
|
||||
let location = input.current_source_location();
|
||||
let ident = input.expect_ident()?;
|
||||
let success = match_ignore_ascii_case! { &ident,
|
||||
"row" if value.is_none() => {
|
||||
|
@ -357,7 +358,7 @@ ${helpers.predefined_type("object-position",
|
|||
_ => false
|
||||
};
|
||||
if !success {
|
||||
return Err(SelectorParseError::UnexpectedIdent(ident.clone()).into());
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,7 +368,7 @@ ${helpers.predefined_type("object-position",
|
|||
dense: dense,
|
||||
})
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,7 +466,7 @@ ${helpers.predefined_type("object-position",
|
|||
}
|
||||
|
||||
TemplateAreas::from_vec(strings)
|
||||
.map_err(|()| StyleParseError::UnspecifiedError.into())
|
||||
.map_err(|()| input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ ${helpers.single_keyword("table-layout", "auto fixed",
|
|||
// never parse it, only set via presentation attribute
|
||||
fn parse<'i, 't>(
|
||||
_: &ParserContext,
|
||||
_: &mut Parser<'i, 't>,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<SpecifiedValue, ParseError<'i>> {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
|
|
@ -119,17 +119,21 @@
|
|||
impl Parse for Side {
|
||||
fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Side, ParseError<'i>> {
|
||||
let location = input.current_source_location();
|
||||
match *input.next()? {
|
||||
Token::Ident(ref ident) => {
|
||||
try_match_ident_ignore_ascii_case! { ident,
|
||||
match_ignore_ascii_case! { ident,
|
||||
"clip" => Ok(Side::Clip),
|
||||
"ellipsis" => Ok(Side::Ellipsis),
|
||||
_ => Err(location.new_custom_error(
|
||||
SelectorParseErrorKind::UnexpectedIdent(ident.clone())
|
||||
))
|
||||
}
|
||||
}
|
||||
Token::QuotedString(ref v) => {
|
||||
Ok(Side::String(v.as_ref().to_owned().into_boxed_str()))
|
||||
}
|
||||
ref t => Err(BasicParseError::UnexpectedToken(t.clone()).into()),
|
||||
ref t => Err(location.new_unexpected_token_error(t.clone())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -222,6 +226,7 @@ ${helpers.single_keyword("unicode-bidi",
|
|||
|
||||
loop {
|
||||
let result: Result<_, ParseError> = input.try(|input| {
|
||||
let location = input.current_source_location();
|
||||
match input.expect_ident() {
|
||||
Ok(ident) => {
|
||||
(match_ignore_ascii_case! { &ident,
|
||||
|
@ -234,7 +239,9 @@ ${helpers.single_keyword("unicode-bidi",
|
|||
"blink" => if result.contains(BLINK) { Err(()) }
|
||||
else { empty = false; result.insert(BLINK); Ok(()) },
|
||||
_ => Err(())
|
||||
}).map_err(|()| SelectorParseError::UnexpectedIdent(ident.clone()).into())
|
||||
}).map_err(|()| {
|
||||
location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone()))
|
||||
})
|
||||
}
|
||||
Err(e) => return Err(e.into())
|
||||
}
|
||||
|
@ -244,7 +251,7 @@ ${helpers.single_keyword("unicode-bidi",
|
|||
}
|
||||
}
|
||||
|
||||
if !empty { Ok(result) } else { Err(StyleParseError::UnspecifiedError.into()) }
|
||||
if !empty { Ok(result) } else { Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) }
|
||||
}
|
||||
|
||||
% if product == "servo":
|
||||
|
|
|
@ -77,7 +77,7 @@ ${helpers.single_keyword("-moz-window-shadow", "none default menu tooltip sheet"
|
|||
match input.expect_integer()? {
|
||||
0 => Ok(computed_value::T(false)),
|
||||
1 => Ok(computed_value::T(true)),
|
||||
_ => Err(StyleParseError::UnspecifiedError.into()),
|
||||
_ => Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,11 +35,11 @@ use parser::ParserContext;
|
|||
#[cfg(feature = "gecko")] use properties::longhands::system_font::SystemFont;
|
||||
use rule_cache::{RuleCache, RuleCacheConditions};
|
||||
use selector_parser::PseudoElement;
|
||||
use selectors::parser::SelectorParseError;
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
|
||||
use shared_lock::StylesheetGuards;
|
||||
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError};
|
||||
use style_traits::{PropertyDeclarationParseError, StyleParseError, ValueParseError};
|
||||
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError, PropertyDeclarationParseError};
|
||||
use style_traits::{PropertyDeclarationParseErrorKind, StyleParseErrorKind};
|
||||
use stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||
#[cfg(feature = "servo")] use values::Either;
|
||||
use values::generics::text::LineHeight;
|
||||
|
@ -153,7 +153,7 @@ macro_rules! unwrap_or_initial {
|
|||
pub mod shorthands {
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use style_traits::{ParseError, StyleParseError};
|
||||
use style_traits::{ParseError, StyleParseErrorKind};
|
||||
use values::specified;
|
||||
|
||||
<%include file="/shorthand/serialize.mako.rs" />
|
||||
|
@ -553,7 +553,9 @@ impl LonghandId {
|
|||
% if not property.derived_from:
|
||||
longhands::${property.ident}::parse_declared(context, input)
|
||||
% else:
|
||||
Err(PropertyDeclarationParseError::UnknownProperty("${property.ident}".into()).into())
|
||||
Err(input.new_custom_error(
|
||||
PropertyDeclarationParseErrorKind::UnknownProperty("${property.ident}".into())
|
||||
))
|
||||
% endif
|
||||
}
|
||||
% endfor
|
||||
|
@ -878,7 +880,7 @@ impl ShorthandId {
|
|||
}
|
||||
% endfor
|
||||
// 'all' accepts no value other than CSS-wide keywords
|
||||
ShorthandId::All => Err(StyleParseError::UnspecifiedError.into())
|
||||
ShorthandId::All => Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -962,7 +964,7 @@ impl UnparsedValue {
|
|||
Some(ShorthandId::All) => {
|
||||
// No need to parse the 'all' shorthand as anything other than a CSS-wide
|
||||
// keyword, after variable substitution.
|
||||
Err(SelectorParseError::UnexpectedIdent("all".into()).into())
|
||||
Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("all".into())))
|
||||
}
|
||||
% for shorthand in data.shorthands_except_all():
|
||||
Some(ShorthandId::${shorthand.camel_case}) => {
|
||||
|
@ -1642,8 +1644,7 @@ impl PropertyDeclaration {
|
|||
Ok(keyword) => DeclaredValueOwned::CSSWideKeyword(keyword),
|
||||
Err(()) => match ::custom_properties::SpecifiedValue::parse(input) {
|
||||
Ok(value) => DeclaredValueOwned::Value(value),
|
||||
Err(e) => return Err(PropertyDeclarationParseError::InvalidValue(name.to_string().into(),
|
||||
ValueParseError::from_parse_error(e))),
|
||||
Err(e) => return Err(PropertyDeclarationParseErrorKind::new_invalid(name, e)),
|
||||
}
|
||||
};
|
||||
declarations.push(PropertyDeclaration::Custom(property_name, value));
|
||||
|
@ -1662,8 +1663,7 @@ impl PropertyDeclaration {
|
|||
input.reset(&start);
|
||||
let (first_token_type, css) =
|
||||
::custom_properties::parse_non_custom_with_var(input).map_err(|e| {
|
||||
PropertyDeclarationParseError::InvalidValue(name,
|
||||
ValueParseError::from_parse_error(e))
|
||||
PropertyDeclarationParseErrorKind::new_invalid(name, e)
|
||||
})?;
|
||||
Ok(PropertyDeclaration::WithVariables(id, Arc::new(UnparsedValue {
|
||||
css: css.into_owned(),
|
||||
|
@ -1672,8 +1672,7 @@ impl PropertyDeclaration {
|
|||
from_shorthand: None,
|
||||
})))
|
||||
} else {
|
||||
Err(PropertyDeclarationParseError::InvalidValue(name,
|
||||
ValueParseError::from_parse_error(err)))
|
||||
Err(PropertyDeclarationParseErrorKind::new_invalid(name, err))
|
||||
}
|
||||
})
|
||||
}).map(|declaration| {
|
||||
|
@ -1701,8 +1700,7 @@ impl PropertyDeclaration {
|
|||
input.reset(&start);
|
||||
let (first_token_type, css) =
|
||||
::custom_properties::parse_non_custom_with_var(input).map_err(|e| {
|
||||
PropertyDeclarationParseError::InvalidValue(name,
|
||||
ValueParseError::from_parse_error(e))
|
||||
PropertyDeclarationParseErrorKind::new_invalid(name, e)
|
||||
})?;
|
||||
let unparsed = Arc::new(UnparsedValue {
|
||||
css: css.into_owned(),
|
||||
|
@ -1721,8 +1719,7 @@ impl PropertyDeclaration {
|
|||
}
|
||||
Ok(())
|
||||
} else {
|
||||
Err(PropertyDeclarationParseError::InvalidValue(name,
|
||||
ValueParseError::from_parse_error(err)))
|
||||
Err(PropertyDeclarationParseErrorKind::new_invalid(name, err))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
// background-color can only be in the last element, so if it
|
||||
// is parsed anywhere before, the value is invalid.
|
||||
if background_color.is_some() {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
% for name in "image position repeat size attachment origin clip".split():
|
||||
|
@ -112,7 +112,7 @@
|
|||
% endfor
|
||||
Ok(())
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
})?;
|
||||
|
||||
|
@ -217,7 +217,7 @@
|
|||
Ok(())
|
||||
})?;
|
||||
if !any {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
Ok(expanded! {
|
||||
|
|
|
@ -83,7 +83,7 @@ pub fn parse_border<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
|||
style.unwrap_or(BorderStyle::none),
|
||||
width.unwrap_or(BorderSideWidth::Medium)))
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ pub fn parse_border<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
|||
border_image_outset::parse(context, input)
|
||||
}).ok();
|
||||
if w.is_none() && o.is_none() {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
else {
|
||||
Ok((w, o))
|
||||
|
@ -312,7 +312,7 @@ pub fn parse_border<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
|||
% endfor
|
||||
Ok(())
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
});
|
||||
result?;
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
% if product == "gecko":
|
||||
let moz_kw_found = input.try(|i| {
|
||||
try_match_ident_ignore_ascii_case! { i.expect_ident()?,
|
||||
let moz_kw_found = input.try(|input| {
|
||||
try_match_ident_ignore_ascii_case! { input,
|
||||
"-moz-scrollbars-horizontal" => {
|
||||
Ok(expanded! {
|
||||
overflow_x: SpecifiedValue::scroll,
|
||||
|
@ -141,7 +141,7 @@ macro_rules! try_parse_one {
|
|||
Some(transition_property::single_value::get_initial_specified_value())),
|
||||
})
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ macro_rules! try_parse_one {
|
|||
// If there is more than one item, and any of transitions has 'none',
|
||||
// then it's invalid. Othersize, leave propertys to be empty (which
|
||||
// means "transition-property: none");
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
% for prop in "duration timing_function delay".split():
|
||||
|
@ -269,7 +269,7 @@ macro_rules! try_parse_one {
|
|||
|
||||
// If nothing is parsed, this is an invalid entry.
|
||||
if parsed == 0 {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
} else {
|
||||
Ok(SingleAnimation {
|
||||
% for prop in props:
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
let values = autos + column_count.iter().len() + column_width.iter().len();
|
||||
if values == 0 || values > 2 {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
} else {
|
||||
Ok(expanded! {
|
||||
column_count: unwrap_or_initial!(column_count),
|
||||
|
@ -89,7 +89,7 @@
|
|||
column_rule_color: unwrap_or_initial!(column_rule_color),
|
||||
})
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
}
|
||||
if size.is_none() ||
|
||||
(count(&style) + count(&weight) + count(&variant_caps) + count(&stretch) + nb_normals) > 4 {
|
||||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
let line_height = if input.try(|input| input.expect_delim('/')).is_ok() {
|
||||
Some(LineHeight::parse(context, input)?)
|
||||
|
@ -262,7 +262,7 @@
|
|||
loop {
|
||||
if input.try(|input| input.expect_ident_matching("normal")).is_ok() ||
|
||||
input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
% for prop in sub_properties:
|
||||
if ${prop}.is_none() {
|
||||
|
@ -278,7 +278,7 @@
|
|||
}
|
||||
|
||||
if !has_custom_value {
|
||||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
text_emphasis_style: unwrap_or_initial!(text_emphasis_style, style),
|
||||
})
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
@ -78,7 +78,7 @@
|
|||
_webkit_text_stroke_width: unwrap_or_initial!(_webkit_text_stroke_width, width),
|
||||
})
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
nones = nones + 1;
|
||||
if nones > 2 {
|
||||
return Err(SelectorParseError::UnexpectedIdent("none".into()).into())
|
||||
return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("none".into())))
|
||||
}
|
||||
any = true;
|
||||
continue
|
||||
|
@ -106,7 +106,7 @@
|
|||
list_style_type: unwrap_or_initial!(list_style_type),
|
||||
})
|
||||
}
|
||||
_ => Err(StyleParseError::UnspecifiedError.into()),
|
||||
_ => Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
% endfor
|
||||
Ok(())
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
})?;
|
||||
|
||||
|
@ -203,7 +203,7 @@
|
|||
Ok(())
|
||||
})?;
|
||||
if any == false {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
Ok(expanded! {
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
outline_width: unwrap_or_initial!(outline_width, width),
|
||||
})
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
}
|
||||
|
||||
if direction.is_none() && wrap.is_none() {
|
||||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
Ok(expanded! {
|
||||
flex_direction: unwrap_or_initial!(flex_direction, direction),
|
||||
|
@ -87,7 +87,7 @@
|
|||
}
|
||||
|
||||
if grow.is_none() && basis.is_none() {
|
||||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
Ok(expanded! {
|
||||
flex_grow: grow.unwrap_or(NonNegativeNumber::new(1.0)),
|
||||
|
@ -309,7 +309,7 @@
|
|||
}
|
||||
|
||||
let template_areas = TemplateAreas::from_vec(strings)
|
||||
.map_err(|()| StyleParseError::UnspecifiedError)?;
|
||||
.map_err(|()| input.new_custom_error(StyleParseErrorKind::UnspecifiedError))?;
|
||||
let template_rows = TrackList {
|
||||
list_type: TrackListType::Normal,
|
||||
values: values,
|
||||
|
@ -321,7 +321,7 @@
|
|||
let value = GridTemplateComponent::parse_without_none(context, input)?;
|
||||
if let GenericGridTemplateComponent::TrackList(ref list) = value {
|
||||
if list.list_type != TrackListType::Explicit {
|
||||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,7 +340,7 @@
|
|||
if list.line_names[0].is_empty() {
|
||||
list.line_names[0] = first_line_names; // won't panic
|
||||
} else {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,7 @@
|
|||
autoflow: flow,
|
||||
dense: dense,
|
||||
}
|
||||
}).ok_or(StyleParseError::UnspecifiedError.into())
|
||||
}).ok_or(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
|
||||
if let Ok((rows, cols, areas)) = input.try(|i| super::grid_template::parse_grid_template(context, i)) {
|
||||
|
@ -617,12 +617,12 @@
|
|||
-> Result<Longhands, ParseError<'i>> {
|
||||
let align = align_content::parse(context, input)?;
|
||||
if align.has_extra_flags() {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
let justify = input.try(|input| justify_content::parse(context, input))
|
||||
.unwrap_or(justify_content::SpecifiedValue::from(align));
|
||||
if justify.has_extra_flags() {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
Ok(expanded! {
|
||||
|
@ -653,11 +653,11 @@
|
|||
-> Result<Longhands, ParseError<'i>> {
|
||||
let align = AlignJustifySelf::parse(context, input)?;
|
||||
if align.has_extra_flags() {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
let justify = input.try(|input| AlignJustifySelf::parse(context, input)).unwrap_or(align.clone());
|
||||
if justify.has_extra_flags() {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
Ok(expanded! {
|
||||
|
@ -695,12 +695,12 @@
|
|||
-> Result<Longhands, ParseError<'i>> {
|
||||
let align = AlignItems::parse(context, input)?;
|
||||
if align.has_extra_flags() {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
let justify = input.try(|input| JustifyItems::parse(context, input))
|
||||
.unwrap_or(JustifyItems::from(align));
|
||||
if justify.has_extra_flags() {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
Ok(expanded! {
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
}
|
||||
|
||||
if !any {
|
||||
return Err(StyleParseError::UnspecifiedError.into());
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
Ok(expanded! {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue