style: Augment CSS errors with the CSS selector.

Differential Revision: https://phabricator.services.mozilla.com/D24894
This commit is contained in:
Julian Descottes 2019-03-27 12:12:55 +00:00 committed by Emilio Cobos Álvarez
parent 4fbbcdddbe
commit 5a55978478
3 changed files with 13 additions and 7 deletions

View file

@ -10,12 +10,14 @@ use crate::stylesheets::UrlExtraData;
use cssparser::{BasicParseErrorKind, ParseErrorKind, SourceLocation, Token};
use std::fmt;
use style_traits::ParseError;
use crate::selector_parser::{SelectorImpl};
use selectors::SelectorList;
/// Errors that can be encountered while parsing CSS.
#[derive(Debug)]
pub enum ContextualParseError<'a> {
/// A property declaration was not recognized.
UnsupportedPropertyDeclaration(&'a str, ParseError<'a>),
UnsupportedPropertyDeclaration(&'a str, ParseError<'a>, Option<&'a SelectorList<SelectorImpl>>),
/// A font face descriptor was not recognized.
UnsupportedFontFaceDescriptor(&'a str, ParseError<'a>),
/// A font feature values descriptor was not recognized.
@ -121,7 +123,7 @@ impl<'a> fmt::Display for ContextualParseError<'a> {
}
match *self {
ContextualParseError::UnsupportedPropertyDeclaration(decl, ref err) => {
ContextualParseError::UnsupportedPropertyDeclaration(decl, ref err, _selectors) => {
write!(f, "Unsupported property declaration: '{}', ", decl)?;
parse_error_to_str(err, f)
},