aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-10-09 17:20:52 +0200
committerSimon Sapin <simon.sapin@exyr.org>2017-10-10 13:28:30 +0200
commit46ea99d54b0c7c2ece0aec961756e9f01d050cfc (patch)
treefa3d71dc3a1552f5fd00b68b00d3b0a16bcc26fb
parentc64374bc5832a41c1c60316fc25ff19c963ae8b8 (diff)
downloadservo-46ea99d54b0c7c2ece0aec961756e9f01d050cfc.tar.gz
servo-46ea99d54b0c7c2ece0aec961756e9f01d050cfc.zip
CSS parsing error types: flatten nested enums somewhat
-rw-r--r--components/selectors/parser.rs188
-rw-r--r--components/style/counter_style/mod.rs4
-rw-r--r--components/style/font_face.rs4
-rw-r--r--components/style/properties/declaration_block.rs9
-rw-r--r--components/style/stylesheets/font_feature_values_rule.rs9
-rw-r--r--components/style/stylesheets/keyframes_rule.rs9
-rw-r--r--components/style/stylesheets/rule_parser.rs9
-rw-r--r--components/style/stylesheets/viewport_rule.rs4
-rw-r--r--components/style_traits/lib.rs27
-rw-r--r--ports/geckolib/error_reporter.rs198
-rw-r--r--tests/unit/style/size_of.rs9
11 files changed, 242 insertions, 228 deletions
diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs
index 8dae09b81a9..6b87ed96720 100644
--- a/components/selectors/parser.rs
+++ b/components/selectors/parser.rs
@@ -47,10 +47,10 @@ fn to_ascii_lowercase(s: &str) -> Cow<str> {
}
}
-pub type SelectorParseError<'i, E> = ParseError<'i, SelectorParseErrorKind<'i, E>>;
+pub type SelectorParseError<'i> = ParseError<'i, SelectorParseErrorKind<'i>>;
#[derive(Clone, Debug, PartialEq)]
-pub enum SelectorParseErrorKind<'i, E> {
+pub enum SelectorParseErrorKind<'i> {
PseudoElementInComplexSelector,
NoQualifiedNameInAttributeSelector(Token<'i>),
EmptySelector,
@@ -69,13 +69,6 @@ pub enum SelectorParseErrorKind<'i, E> {
ExplicitNamespaceUnexpectedToken(Token<'i>),
ClassNeedsIdent(Token<'i>),
EmptyNegation,
- Custom(E),
-}
-
-impl<'i, E> From<E> for SelectorParseErrorKind<'i, E> {
- fn from(custom: E) -> Self {
- SelectorParseErrorKind::Custom(custom)
- }
}
macro_rules! with_all_bounds {
@@ -131,7 +124,7 @@ with_bounds! {
pub trait Parser<'i> {
type Impl: SelectorImpl;
- type Error: 'i;
+ type Error: 'i + From<SelectorParseErrorKind<'i>>;
/// Whether the name is a pseudo-element that can be specified with
/// the single colon syntax in addition to the double-colon syntax.
@@ -143,28 +136,29 @@ pub trait Parser<'i> {
/// pseudo-elements.
fn parse_non_ts_pseudo_class(&self, location: SourceLocation, name: CowRcStr<'i>)
-> Result<<Self::Impl as SelectorImpl>::NonTSPseudoClass,
- SelectorParseError<'i, Self::Error>> {
+ ParseError<'i, Self::Error>>
+ {
Err(location.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)))
}
fn parse_non_ts_functional_pseudo_class<'t>
(&self, name: CowRcStr<'i>, arguments: &mut CssParser<'i, 't>)
- -> Result<<Self::Impl as SelectorImpl>::NonTSPseudoClass,
- SelectorParseError<'i, Self::Error>>
+ -> Result<<Self::Impl as SelectorImpl>::NonTSPseudoClass, ParseError<'i, Self::Error>>
{
Err(arguments.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)))
}
fn parse_pseudo_element(&self, location: SourceLocation, name: CowRcStr<'i>)
-> Result<<Self::Impl as SelectorImpl>::PseudoElement,
- SelectorParseError<'i, Self::Error>> {
+ ParseError<'i, Self::Error>>
+ {
Err(location.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)))
}
fn parse_functional_pseudo_element<'t>
(&self, name: CowRcStr<'i>, arguments: &mut CssParser<'i, 't>)
- -> Result<<Self::Impl as SelectorImpl>::PseudoElement,
- SelectorParseError<'i, Self::Error>> {
+ -> Result<<Self::Impl as SelectorImpl>::PseudoElement, ParseError<'i, Self::Error>>
+ {
Err(arguments.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)))
}
@@ -186,9 +180,9 @@ impl<Impl: SelectorImpl> SelectorList<Impl> {
/// https://drafts.csswg.org/selectors/#grouping
///
/// Return the Selectors or Err if there is an invalid selector.
- pub fn parse<'i, 't, P, E>(parser: &P, input: &mut CssParser<'i, 't>)
- -> Result<Self, SelectorParseError<'i, E>>
- where P: Parser<'i, Impl=Impl, Error=E> {
+ pub fn parse<'i, 't, P>(parser: &P, input: &mut CssParser<'i, 't>)
+ -> Result<Self, ParseError<'i, P::Error>>
+ where P: Parser<'i, Impl=Impl> {
let mut values = SmallVec::new();
loop {
values.push(input.parse_until_before(Delimiter::Comma, |input| parse_selector(parser, input))?);
@@ -1055,25 +1049,28 @@ fn display_to_css_identifier<T: Display, W: fmt::Write>(x: &T, dest: &mut W) ->
/// selector : simple_selector_sequence [ combinator simple_selector_sequence ]* ;
///
/// `Err` means invalid selector.
-fn parse_selector<'i, 't, P, E, Impl>(
+fn parse_selector<'i, 't, P, Impl>(
parser: &P,
input: &mut CssParser<'i, 't>)
- -> Result<Selector<Impl>, SelectorParseError<'i, E>>
- where P: Parser<'i, Impl=Impl, Error=E>, Impl: SelectorImpl
+ -> Result<Selector<Impl>, ParseError<'i, P::Error>>
+ where P: Parser<'i, Impl=Impl>, Impl: SelectorImpl
{
let mut builder = SelectorBuilder::default();
- let mut parsed_pseudo_element;
+ let mut has_pseudo_element;
'outer_loop: loop {
// Parse a sequence of simple selectors.
- parsed_pseudo_element = match parse_compound_selector(parser, input, &mut builder) {
- Ok(result) => result,
- Err(ParseError { kind: ParseErrorKind::Custom(SelectorParseErrorKind::EmptySelector), .. })
- if builder.has_combinators() =>
- return Err(input.new_custom_error(SelectorParseErrorKind::DanglingCombinator)),
- Err(e) => return Err(e),
+ has_pseudo_element = match parse_compound_selector(parser, input, &mut builder)? {
+ Some(has_pseudo_element) => has_pseudo_element,
+ None => {
+ return Err(input.new_custom_error(if builder.has_combinators() {
+ SelectorParseErrorKind::DanglingCombinator
+ } else {
+ SelectorParseErrorKind::EmptySelector
+ }))
+ }
};
- if parsed_pseudo_element {
+ if has_pseudo_element {
break;
}
@@ -1111,14 +1108,14 @@ fn parse_selector<'i, 't, P, E, Impl>(
builder.push_combinator(combinator);
}
- Ok(Selector(builder.build(parsed_pseudo_element)))
+ Ok(Selector(builder.build(has_pseudo_element)))
}
impl<Impl: SelectorImpl> Selector<Impl> {
/// Parse a selector, without any pseudo-element.
- pub fn parse<'i, 't, P, E>(parser: &P, input: &mut CssParser<'i, 't>)
- -> Result<Self, SelectorParseError<'i, E>>
- where P: Parser<'i, Impl=Impl, Error=E>
+ pub fn parse<'i, 't, P>(parser: &P, input: &mut CssParser<'i, 't>)
+ -> Result<Self, ParseError<'i, P::Error>>
+ where P: Parser<'i, Impl=Impl>
{
let selector = parse_selector(parser, input)?;
if selector.has_pseudo_element() {
@@ -1131,9 +1128,9 @@ impl<Impl: SelectorImpl> Selector<Impl> {
/// * `Err(())`: Invalid selector, abort
/// * `Ok(false)`: Not a type selector, could be something else. `input` was not consumed.
/// * `Ok(true)`: Length 0 (`*|*`), 1 (`*|E` or `ns|*`) or 2 (`|E` or `ns|E`)
-fn parse_type_selector<'i, 't, P, E, Impl, S>(parser: &P, input: &mut CssParser<'i, 't>, sink: &mut S)
- -> Result<bool, SelectorParseError<'i, E>>
- where P: Parser<'i, Impl=Impl, Error=E>,
+fn parse_type_selector<'i, 't, P, Impl, S>(parser: &P, input: &mut CssParser<'i, 't>, sink: &mut S)
+ -> Result<bool, ParseError<'i, P::Error>>
+ where P: Parser<'i, Impl=Impl>,
Impl: SelectorImpl,
S: Push<Component<Impl>>,
{
@@ -1218,11 +1215,11 @@ enum OptionalQName<'i, Impl: SelectorImpl> {
/// * `Ok(None(token))`: Not a simple selector, could be something else. `input` was not consumed,
/// but the token is still returned.
/// * `Ok(Some(namespace, local_name))`: `None` for the local name means a `*` universal selector
-fn parse_qualified_name<'i, 't, P, E, Impl>
+fn parse_qualified_name<'i, 't, P, Impl>
(parser: &P, input: &mut CssParser<'i, 't>,
in_attr_selector: bool)
- -> Result<OptionalQName<'i, Impl>, SelectorParseError<'i, E>>
- where P: Parser<'i, Impl=Impl, Error=E>, Impl: SelectorImpl
+ -> Result<OptionalQName<'i, Impl>, ParseError<'i, P::Error>>
+ where P: Parser<'i, Impl=Impl>, Impl: SelectorImpl
{
let default_namespace = |local_name| {
let namespace = match parser.default_namespace() {
@@ -1315,9 +1312,9 @@ fn parse_qualified_name<'i, 't, P, E, Impl>
}
-fn parse_attribute_selector<'i, 't, P, E, Impl>(parser: &P, input: &mut CssParser<'i, 't>)
- -> Result<Component<Impl>, SelectorParseError<'i, E>>
- where P: Parser<'i, Impl=Impl, Error=E>, Impl: SelectorImpl
+fn parse_attribute_selector<'i, 't, P, Impl>(parser: &P, input: &mut CssParser<'i, 't>)
+ -> Result<Component<Impl>, ParseError<'i, P::Error>>
+ where P: Parser<'i, Impl=Impl>, Impl: SelectorImpl
{
let namespace;
let local_name;
@@ -1451,8 +1448,9 @@ fn parse_attribute_selector<'i, 't, P, E, Impl>(parser: &P, input: &mut CssParse
}
-fn parse_attribute_flags<'i, 't, E>(input: &mut CssParser<'i, 't>)
- -> Result<ParsedCaseSensitivity, SelectorParseError<'i, E>> {
+fn parse_attribute_flags<'i, 't>(input: &mut CssParser<'i, 't>)
+ -> Result<ParsedCaseSensitivity, BasicParseError<'i>>
+{
let location = input.current_source_location();
match input.next() {
Err(_) => {
@@ -1462,17 +1460,17 @@ fn parse_attribute_flags<'i, 't, E>(input: &mut CssParser<'i, 't>)
Ok(&Token::Ident(ref value)) if value.eq_ignore_ascii_case("i") => {
Ok(ParsedCaseSensitivity::AsciiCaseInsensitive)
}
- Ok(t) => Err(location.new_unexpected_token_error(t.clone()))
+ Ok(t) => Err(location.new_basic_unexpected_token_error(t.clone()))
}
}
/// Level 3: Parse **one** simple_selector. (Though we might insert a second
/// implied "<defaultns>|*" type selector.)
-fn parse_negation<'i, 't, P, E, Impl>(parser: &P,
- input: &mut CssParser<'i, 't>)
- -> Result<Component<Impl>, SelectorParseError<'i, E>>
- where P: Parser<'i, Impl=Impl, Error=E>, Impl: SelectorImpl
+fn parse_negation<'i, 't, P, Impl>(parser: &P,
+ input: &mut CssParser<'i, 't>)
+ -> Result<Component<Impl>, ParseError<'i, P::Error>>
+ where P: Parser<'i, Impl=Impl>, Impl: SelectorImpl
{
// We use a sequence because a type selector may be represented as two Components.
let mut sequence = SmallVec::<[Component<Impl>; 2]>::new();
@@ -1511,14 +1509,15 @@ fn parse_negation<'i, 't, P, E, Impl>(parser: &P,
/// | [ HASH | class | attrib | pseudo | negation ]+
///
/// `Err(())` means invalid selector.
+/// `Ok(None)` is an empty selector
///
/// The boolean represent whether a pseudo-element has been parsed.
-fn parse_compound_selector<'i, 't, P, E, Impl>(
+fn parse_compound_selector<'i, 't, P, Impl>(
parser: &P,
input: &mut CssParser<'i, 't>,
builder: &mut SelectorBuilder<Impl>)
- -> Result<bool, SelectorParseError<'i, E>>
- where P: Parser<'i, Impl=Impl, Error=E>, Impl: SelectorImpl
+ -> Result<Option<bool>, ParseError<'i, P::Error>>
+ where P: Parser<'i, Impl=Impl>, Impl: SelectorImpl
{
input.skip_whitespace();
@@ -1595,24 +1594,24 @@ fn parse_compound_selector<'i, 't, P, E, Impl>(
}
if empty {
// An empty selector is invalid.
- Err(input.new_custom_error(SelectorParseErrorKind::EmptySelector))
+ Ok(None)
} else {
- Ok(pseudo)
+ Ok(Some(pseudo))
}
}
-fn parse_functional_pseudo_class<'i, 't, P, E, Impl>(parser: &P,
- input: &mut CssParser<'i, 't>,
- name: CowRcStr<'i>,
- inside_negation: bool)
- -> Result<Component<Impl>, SelectorParseError<'i, E>>
- where P: Parser<'i, Impl=Impl, Error=E>, Impl: SelectorImpl
+fn parse_functional_pseudo_class<'i, 't, P, Impl>(parser: &P,
+ input: &mut CssParser<'i, 't>,
+ name: CowRcStr<'i>,
+ inside_negation: bool)
+ -> Result<Component<Impl>, ParseError<'i, P::Error>>
+ where P: Parser<'i, Impl=Impl>, Impl: SelectorImpl
{
match_ignore_ascii_case! { &name,
- "nth-child" => return parse_nth_pseudo_class(input, Component::NthChild),
- "nth-of-type" => return parse_nth_pseudo_class(input, Component::NthOfType),
- "nth-last-child" => return parse_nth_pseudo_class(input, Component::NthLastChild),
- "nth-last-of-type" => return parse_nth_pseudo_class(input, Component::NthLastOfType),
+ "nth-child" => return Ok(parse_nth_pseudo_class(input, Component::NthChild)?),
+ "nth-of-type" => return Ok(parse_nth_pseudo_class(input, Component::NthOfType)?),
+ "nth-last-child" => return Ok(parse_nth_pseudo_class(input, Component::NthLastChild)?),
+ "nth-last-of-type" => return Ok(parse_nth_pseudo_class(input, Component::NthLastOfType)?),
"not" => {
if inside_negation {
return Err(input.new_custom_error(
@@ -1628,8 +1627,8 @@ fn parse_functional_pseudo_class<'i, 't, P, E, Impl>(parser: &P,
}
-fn parse_nth_pseudo_class<'i, 't, Impl, F, E>(input: &mut CssParser<'i, 't>, selector: F)
- -> Result<Component<Impl>, SelectorParseError<'i, E>>
+fn parse_nth_pseudo_class<'i, 't, Impl, F>(input: &mut CssParser<'i, 't>, selector: F)
+ -> Result<Component<Impl>, BasicParseError<'i>>
where Impl: SelectorImpl, F: FnOnce(i32, i32) -> Component<Impl> {
let (a, b) = parse_nth(input)?;
Ok(selector(a, b))
@@ -1652,12 +1651,12 @@ pub fn is_css2_pseudo_element<'i>(name: &CowRcStr<'i>) -> bool {
/// * `Err(())`: Invalid selector, abort
/// * `Ok(None)`: Not a simple selector, could be something else. `input` was not consumed.
/// * `Ok(Some(_))`: Parsed a simple selector or pseudo-element
-fn parse_one_simple_selector<'i, 't, P, E, Impl>(parser: &P,
- input: &mut CssParser<'i, 't>,
- inside_negation: bool)
- -> Result<Option<SimpleSelectorParseResult<Impl>>,
- SelectorParseError<'i, E>>
- where P: Parser<'i, Impl=Impl, Error=E>, Impl: SelectorImpl
+fn parse_one_simple_selector<'i, 't, P, Impl>(parser: &P,
+ input: &mut CssParser<'i, 't>,
+ inside_negation: bool)
+ -> Result<Option<SimpleSelectorParseResult<Impl>>,
+ ParseError<'i, P::Error>>
+ where P: Parser<'i, Impl=Impl>, Impl: SelectorImpl
{
let start = input.state();
// FIXME: remove clone() when lifetimes are non-lexical
@@ -1724,10 +1723,10 @@ fn parse_one_simple_selector<'i, 't, P, E, Impl>(parser: &P,
}
}
-fn parse_simple_pseudo_class<'i, P, E, Impl>(parser: &P, location: SourceLocation,
- name: CowRcStr<'i>)
- -> Result<Component<Impl>, SelectorParseError<'i, E>>
- where P: Parser<'i, Impl=Impl, Error=E>, Impl: SelectorImpl
+fn parse_simple_pseudo_class<'i, P, Impl>(parser: &P, location: SourceLocation,
+ name: CowRcStr<'i>)
+ -> Result<Component<Impl>, ParseError<'i, P::Error>>
+ where P: Parser<'i, Impl=Impl>, Impl: SelectorImpl
{
(match_ignore_ascii_case! { &name,
"first-child" => Ok(Component::FirstChild),
@@ -1877,34 +1876,37 @@ pub mod tests {
impl<'i> Parser<'i> for DummyParser {
type Impl = DummySelectorImpl;
- type Error = ();
+ type Error = SelectorParseErrorKind<'i>;
fn parse_non_ts_pseudo_class(&self, location: SourceLocation, name: CowRcStr<'i>)
- -> Result<PseudoClass, SelectorParseError<'i, ()>> {
+ -> Result<PseudoClass, SelectorParseError<'i>> {
match_ignore_ascii_case! { &name,
- "hover" => Ok(PseudoClass::Hover),
- "active" => Ok(PseudoClass::Active),
- _ => Err(location.new_custom_error(SelectorParseErrorKind::Custom(())))
+ "hover" => return Ok(PseudoClass::Hover),
+ "active" => return Ok(PseudoClass::Active),
+ _ => {}
}
+ Err(location.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)))
}
fn parse_non_ts_functional_pseudo_class<'t>(&self, name: CowRcStr<'i>,
parser: &mut CssParser<'i, 't>)
- -> Result<PseudoClass, SelectorParseError<'i, ()>> {
+ -> Result<PseudoClass, SelectorParseError<'i>> {
match_ignore_ascii_case! { &name,
- "lang" => Ok(PseudoClass::Lang(parser.expect_ident_or_string()?.as_ref().to_owned())),
- _ => Err(parser.new_custom_error(SelectorParseErrorKind::Custom(())))
+ "lang" => return Ok(PseudoClass::Lang(parser.expect_ident_or_string()?.as_ref().to_owned())),
+ _ => {}
}
+ Err(parser.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)))
}
fn parse_pseudo_element(&self, location: SourceLocation, name: CowRcStr<'i>)
-> Result<PseudoElement,
- SelectorParseError<'i, ()>> {
+ SelectorParseError<'i>> {
match_ignore_ascii_case! { &name,
- "before" => Ok(PseudoElement::Before),
- "after" => Ok(PseudoElement::After),
- _ => Err(location.new_custom_error(SelectorParseErrorKind::Custom(())))
+ "before" => return Ok(PseudoElement::Before),
+ "after" => return Ok(PseudoElement::After),
+ _ => {}
}
+ Err(location.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)))
}
fn default_namespace(&self) -> Option<DummyAtom> {
@@ -1917,17 +1919,17 @@ pub mod tests {
}
fn parse<'i>(input: &'i str)
- -> Result<SelectorList<DummySelectorImpl>, SelectorParseError<'i, ()>> {
+ -> Result<SelectorList<DummySelectorImpl>, SelectorParseError<'i>> {
parse_ns(input, &DummyParser::default())
}
fn parse_expected<'i, 'a>(input: &'i str, expected: Option<&'a str>)
- -> Result<SelectorList<DummySelectorImpl>, SelectorParseError<'i, ()>> {
+ -> Result<SelectorList<DummySelectorImpl>, SelectorParseError<'i>> {
parse_ns_expected(input, &DummyParser::default(), expected)
}
fn parse_ns<'i>(input: &'i str, parser: &DummyParser)
- -> Result<SelectorList<DummySelectorImpl>, SelectorParseError<'i, ()>> {
+ -> Result<SelectorList<DummySelectorImpl>, SelectorParseError<'i>> {
parse_ns_expected(input, parser, None)
}
@@ -1935,7 +1937,7 @@ pub mod tests {
input: &'i str,
parser: &DummyParser,
expected: Option<&'a str>
- ) -> Result<SelectorList<DummySelectorImpl>, SelectorParseError<'i, ()>> {
+ ) -> Result<SelectorList<DummySelectorImpl>, SelectorParseError<'i>> {
let mut parser_input = ParserInput::new(input);
let result = SelectorList::parse(parser, &mut CssParser::new(&mut parser_input));
if let Ok(ref selectors) = result {
diff --git a/components/style/counter_style/mod.rs b/components/style/counter_style/mod.rs
index cb89e707197..60e865f7ea8 100644
--- a/components/style/counter_style/mod.rs
+++ b/components/style/counter_style/mod.rs
@@ -119,7 +119,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for CounterStyleRuleParser<'a, 'b> {
type PreludeNoBlock = ();
type PreludeBlock = ();
type AtRule = ();
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
}
macro_rules! accessor {
@@ -188,7 +188,7 @@ macro_rules! counter_style_descriptors {
impl<'a, 'b, 'i> DeclarationParser<'i> for CounterStyleRuleParser<'a, 'b> {
type Declaration = ();
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
fn parse_value<'t>(&mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>)
-> Result<(), ParseError<'i>> {
diff --git a/components/style/font_face.rs b/components/style/font_face.rs
index 15814274a7c..fec122d344c 100644
--- a/components/style/font_face.rs
+++ b/components/style/font_face.rs
@@ -187,7 +187,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for FontFaceRuleParser<'a, 'b> {
type PreludeNoBlock = ();
type PreludeBlock = ();
type AtRule = ();
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
}
impl Parse for Source {
@@ -288,7 +288,7 @@ macro_rules! font_face_descriptors_common {
impl<'a, 'b, 'i> DeclarationParser<'i> for FontFaceRuleParser<'a, 'b> {
type Declaration = ();
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
fn parse_value<'t>(&mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>)
-> Result<(), ParseError<'i>> {
diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs
index 47018122857..788b426154d 100644
--- a/components/style/properties/declaration_block.rs
+++ b/components/style/properties/declaration_block.rs
@@ -13,7 +13,6 @@ use custom_properties::CustomPropertiesBuilder;
use error_reporting::{ParseErrorReporter, ContextualParseError};
use parser::{ParserContext, ParserErrorContext};
use properties::animated_properties::AnimationValue;
-use selectors::parser::SelectorParseErrorKind;
use shared_lock::Locked;
use smallbitvec::{self, SmallBitVec};
use smallvec::SmallVec;
@@ -1060,7 +1059,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for PropertyDeclarationParser<'a, 'b> {
type PreludeNoBlock = ();
type PreludeBlock = ();
type AtRule = Importance;
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
}
/// Based on NonMozillaVendorIdentifier from Gecko's CSS parser.
@@ -1071,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 = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
fn parse_value<'t>(&mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>)
-> Result<Importance, ParseError<'i>> {
@@ -1126,9 +1125,9 @@ pub fn parse_property_declaration_list<R>(context: &ParserContext,
// If the unrecognized property looks like a vendor-specific property,
// silently ignore it instead of polluting the error output.
- if let ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
+ if let ParseErrorKind::Custom(
StyleParseErrorKind::PropertyDeclaration(
- PropertyDeclarationParseErrorKind::UnknownVendorProperty))) = error.kind {
+ PropertyDeclarationParseErrorKind::UnknownVendorProperty)) = error.kind {
continue;
}
diff --git a/components/style/stylesheets/font_feature_values_rule.rs b/components/style/stylesheets/font_feature_values_rule.rs
index cbb11515bce..932ac08e9b3 100644
--- a/components/style/stylesheets/font_feature_values_rule.rs
+++ b/components/style/stylesheets/font_feature_values_rule.rs
@@ -16,7 +16,6 @@ use gecko_bindings::bindings::Gecko_AppendFeatureValueHashEntry;
#[cfg(feature = "gecko")]
use gecko_bindings::structs::{self, gfxFontFeatureValueSet, nsTArray};
use parser::{ParserContext, ParserErrorContext, Parse};
-use selectors::parser::SelectorParseErrorKind;
use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use std::fmt;
use style_traits::{ParseError, StyleParseErrorKind, ToCss};
@@ -201,14 +200,14 @@ impl<'a, 'b, 'i, T> AtRuleParser<'i> for FFVDeclarationsParser<'a, 'b, T> {
type PreludeNoBlock = ();
type PreludeBlock = ();
type AtRule = ();
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
}
impl<'a, 'b, 'i, T> DeclarationParser<'i> for FFVDeclarationsParser<'a, 'b, T>
where T: Parse
{
type Declaration = ();
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
fn parse_value<'t>(&mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>)
-> Result<(), ParseError<'i>> {
@@ -392,14 +391,14 @@ macro_rules! font_feature_values_blocks {
impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for FontFeatureValuesRuleParser<'a, R> {
type Prelude = ();
type QualifiedRule = ();
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
}
impl<'a, 'i, R: ParseErrorReporter> AtRuleParser<'i> for FontFeatureValuesRuleParser<'a, R> {
type PreludeNoBlock = ();
type PreludeBlock = BlockType;
type AtRule = ();
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
fn parse_prelude<'t>(&mut self,
name: CowRcStr<'i>,
diff --git a/components/style/stylesheets/keyframes_rule.rs b/components/style/stylesheets/keyframes_rule.rs
index 8d6d7d4a319..19da2677110 100644
--- a/components/style/stylesheets/keyframes_rule.rs
+++ b/components/style/stylesheets/keyframes_rule.rs
@@ -12,7 +12,6 @@ use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, Prop
use properties::{PropertyDeclarationId, LonghandId, SourcePropertyDeclaration};
use properties::LonghandIdSet;
use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction;
-use selectors::parser::SelectorParseErrorKind;
use servo_arc::Arc;
use shared_lock::{DeepCloneParams, DeepCloneWithLock, SharedRwLock, SharedRwLockReadGuard, Locked, ToCssWithGuard};
use std::fmt;
@@ -500,7 +499,7 @@ impl<'a, 'i, R> AtRuleParser<'i> for KeyframeListParser<'a, R> {
type PreludeNoBlock = ();
type PreludeBlock = ();
type AtRule = Arc<Locked<Keyframe>>;
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
}
/// A wrapper to wraps the KeyframeSelector with its source location
@@ -512,7 +511,7 @@ struct KeyframeSelectorParserPrelude {
impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for KeyframeListParser<'a, R> {
type Prelude = KeyframeSelectorParserPrelude;
type QualifiedRule = Arc<Locked<Keyframe>>;
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
fn parse_prelude<'t>(&mut self, input: &mut Parser<'i, 't>) -> Result<Self::Prelude, ParseError<'i>> {
let start_position = input.position();
@@ -580,12 +579,12 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for KeyframeDeclarationParser<'a, 'b> {
type PreludeNoBlock = ();
type PreludeBlock = ();
type AtRule = ();
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
}
impl<'a, 'b, 'i> DeclarationParser<'i> for KeyframeDeclarationParser<'a, 'b> {
type Declaration = ();
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
fn parse_value<'t>(&mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>)
-> Result<(), ParseError<'i>> {
diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs
index 2368e670557..2c25d64e8c8 100644
--- a/components/style/stylesheets/rule_parser.rs
+++ b/components/style/stylesheets/rule_parser.rs
@@ -16,7 +16,6 @@ use parser::{Parse, ParserContext, ParserErrorContext};
use properties::parse_property_declaration_list;
use selector_parser::{SelectorImpl, SelectorParser};
use selectors::SelectorList;
-use selectors::parser::SelectorParseErrorKind;
use servo_arc::Arc;
use shared_lock::{Locked, SharedRwLock};
use str::starts_with_ignore_ascii_case;
@@ -160,7 +159,7 @@ impl<'a, 'i, R: ParseErrorReporter> AtRuleParser<'i> for TopLevelRuleParser<'a,
type PreludeNoBlock = AtRuleNonBlockPrelude;
type PreludeBlock = AtRuleBlockPrelude;
type AtRule = CssRule;
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
fn parse_prelude<'t>(
&mut self,
@@ -280,7 +279,7 @@ pub struct QualifiedRuleParserPrelude {
impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for TopLevelRuleParser<'a, R> {
type Prelude = QualifiedRuleParserPrelude;
type QualifiedRule = CssRule;
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
#[inline]
fn parse_prelude<'t>(
@@ -347,7 +346,7 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
type PreludeNoBlock = AtRuleNonBlockPrelude;
type PreludeBlock = AtRuleBlockPrelude;
type AtRule = CssRule;
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
fn parse_prelude<'t>(
&mut self,
@@ -550,7 +549,7 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
impl<'a, 'b, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b, R> {
type Prelude = QualifiedRuleParserPrelude;
type QualifiedRule = CssRule;
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
fn parse_prelude<'t>(
&mut self,
diff --git a/components/style/stylesheets/viewport_rule.rs b/components/style/stylesheets/viewport_rule.rs
index b150cdf6128..635fe9ca82c 100644
--- a/components/style/stylesheets/viewport_rule.rs
+++ b/components/style/stylesheets/viewport_rule.rs
@@ -276,12 +276,12 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for ViewportRuleParser<'a, 'b> {
type PreludeNoBlock = ();
type PreludeBlock = ();
type AtRule = Vec<ViewportDescriptorDeclaration>;
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
}
impl<'a, 'b, 'i> DeclarationParser<'i> for ViewportRuleParser<'a, 'b> {
type Declaration = Vec<ViewportDescriptorDeclaration>;
- type Error = SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>;
+ type Error = StyleParseErrorKind<'i>;
fn parse_value<'t>(&mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>)
-> Result<Vec<ViewportDescriptorDeclaration>, ParseError<'i>> {
diff --git a/components/style_traits/lib.rs b/components/style_traits/lib.rs
index ad652011034..a87a7031e92 100644
--- a/components/style_traits/lib.rs
+++ b/components/style_traits/lib.rs
@@ -85,10 +85,7 @@ pub mod viewport;
pub use values::{Comma, CommaWithSpace, OneOrMoreSeparated, Separator, Space, ToCss};
/// The error type for all CSS parsing routines.
-pub type ParseError<'i> = cssparser::ParseError<'i, SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>>;
-
-/// Error emitted by the style crate
-pub type StyleParseError<'i> = cssparser::ParseError<'i, StyleParseErrorKind<'i>>;
+pub type ParseError<'i> = cssparser::ParseError<'i, StyleParseErrorKind<'i>>;
/// Error in property value parsing
pub type ValueParseError<'i> = cssparser::ParseError<'i, ValueParseErrorKind<'i>>;
@@ -139,17 +136,25 @@ pub enum StyleParseErrorKind<'i> {
UnexpectedTokenWithinNamespace(Token<'i>),
/// An error was encountered while parsing a property value.
ValueError(ValueParseErrorKind<'i>),
+ /// An error was encountered while parsing a selector
+ SelectorError(SelectorParseErrorKind<'i>),
}
-impl<'i> From<ValueParseErrorKind<'i>> for SelectorParseErrorKind<'i, StyleParseErrorKind<'i>> {
+impl<'i> From<ValueParseErrorKind<'i>> for StyleParseErrorKind<'i> {
fn from(this: ValueParseErrorKind<'i>) -> Self {
- StyleParseErrorKind::ValueError(this).into()
+ StyleParseErrorKind::ValueError(this)
+ }
+}
+
+impl<'i> From<SelectorParseErrorKind<'i>> for StyleParseErrorKind<'i> {
+ fn from(this: SelectorParseErrorKind<'i>) -> Self {
+ StyleParseErrorKind::SelectorError(this)
}
}
-impl<'i> From<PropertyDeclarationParseErrorKind<'i>> for SelectorParseErrorKind<'i, StyleParseErrorKind<'i>> {
+impl<'i> From<PropertyDeclarationParseErrorKind<'i>> for StyleParseErrorKind<'i> {
fn from(this: PropertyDeclarationParseErrorKind<'i>) -> Self {
- StyleParseErrorKind::PropertyDeclaration(this).into()
+ StyleParseErrorKind::PropertyDeclaration(this)
}
}
@@ -189,11 +194,7 @@ impl<'i> PropertyDeclarationParseErrorKind<'i> {
kind: cssparser::ParseErrorKind::Custom(PropertyDeclarationParseErrorKind::InvalidValue(
name,
match value_error.kind {
- cssparser::ParseErrorKind::Custom(
- SelectorParseErrorKind::Custom(
- StyleParseErrorKind::ValueError(e)
- )
- ) => Some(e),
+ cssparser::ParseErrorKind::Custom(StyleParseErrorKind::ValueError(e)) => Some(e),
_ => None,
}
)),
diff --git a/ports/geckolib/error_reporter.rs b/ports/geckolib/error_reporter.rs
index 331862fbed8..c35cece1a89 100644
--- a/ports/geckolib/error_reporter.rs
+++ b/ports/geckolib/error_reporter.rs
@@ -20,7 +20,7 @@ use style::gecko_bindings::sugar::refptr::RefPtr;
use style::stylesheets::UrlExtraData;
use style_traits::{StyleParseErrorKind, PropertyDeclarationParseErrorKind, ValueParseErrorKind};
-pub type ErrorKind<'i> = ParseErrorKind<'i, SelectorParseErrorKind<'i, StyleParseErrorKind<'i>>>;
+pub type ErrorKind<'i> = ParseErrorKind<'i, StyleParseErrorKind<'i>>;
/// Wrapper around an instance of Gecko's CSS error reporter.
pub struct ErrorReporter(*mut GeckoErrorReporter);
@@ -84,37 +84,39 @@ fn extract_error_param<'a>(err: ErrorKind<'a>) -> Option<ErrorString<'a>> {
}
ParseErrorKind::Basic(BasicParseErrorKind::AtRuleInvalid(i)) |
- ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
- StyleParseErrorKind::UnsupportedAtRule(i)
- )) => {
+ ParseErrorKind::Custom(StyleParseErrorKind::UnsupportedAtRule(i)) => {
let mut s = String::from("@");
serialize_identifier(&i, &mut s).unwrap();
ErrorString::Snippet(s.into())
}
- ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
+ ParseErrorKind::Custom(
StyleParseErrorKind::PropertyDeclaration(
PropertyDeclarationParseErrorKind::InvalidValue(property, None)
)
- )) => {
+ ) => {
ErrorString::Snippet(property)
}
- ParseErrorKind::Custom(SelectorParseErrorKind::UnexpectedIdent(ident)) => {
+ ParseErrorKind::Custom(
+ StyleParseErrorKind::SelectorError(
+ SelectorParseErrorKind::UnexpectedIdent(ident)
+ )
+ ) => {
ErrorString::Ident(ident)
}
- ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
+ ParseErrorKind::Custom(
StyleParseErrorKind::PropertyDeclaration(
PropertyDeclarationParseErrorKind::UnknownProperty(property)
)
- )) => {
+ ) => {
ErrorString::Ident(property)
}
- ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
+ ParseErrorKind::Custom(
StyleParseErrorKind::UnexpectedTokenWithinNamespace(token)
- )) => {
+ ) => {
ErrorString::UnexpectedToken(token)
}
@@ -138,51 +140,57 @@ struct ErrorParams<'a> {
/// a second parameter if it exists, for use in the prefix for the eventual error message.
fn extract_error_params<'a>(err: ErrorKind<'a>) -> Option<ErrorParams<'a>> {
let (main, prefix) = match err {
- ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
+ ParseErrorKind::Custom(
StyleParseErrorKind::PropertyDeclaration(
PropertyDeclarationParseErrorKind::InvalidValue(property, Some(e))
)
- )) => {
+ ) => {
(Some(ErrorString::Snippet(property.into())), Some(extract_value_error_param(e)))
}
- ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
+ ParseErrorKind::Custom(
StyleParseErrorKind::MediaQueryExpectedFeatureName(ident)
- )) => {
+ ) => {
(Some(ErrorString::Ident(ident)), None)
}
- ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
+ ParseErrorKind::Custom(
StyleParseErrorKind::ExpectedIdentifier(token)
- )) => {
+ ) => {
(Some(ErrorString::UnexpectedToken(token)), None)
}
- ParseErrorKind::Custom(SelectorParseErrorKind::UnexpectedTokenInAttributeSelector(t)) |
- ParseErrorKind::Custom(SelectorParseErrorKind::BadValueInAttr(t)) |
- ParseErrorKind::Custom(SelectorParseErrorKind::ExpectedBarInAttr(t)) |
- ParseErrorKind::Custom(SelectorParseErrorKind::NoQualifiedNameInAttributeSelector(t)) |
- ParseErrorKind::Custom(SelectorParseErrorKind::InvalidQualNameInAttr(t)) |
- ParseErrorKind::Custom(SelectorParseErrorKind::ExplicitNamespaceUnexpectedToken(t)) |
- ParseErrorKind::Custom(SelectorParseErrorKind::PseudoElementExpectedIdent(t)) |
- ParseErrorKind::Custom(SelectorParseErrorKind::NoIdentForPseudo(t)) |
- ParseErrorKind::Custom(SelectorParseErrorKind::ClassNeedsIdent(t)) |
- ParseErrorKind::Custom(SelectorParseErrorKind::PseudoElementExpectedColon(t)) => {
- (None, Some(ErrorString::UnexpectedToken(t)))
- }
- ParseErrorKind::Custom(SelectorParseErrorKind::ExpectedNamespace(namespace)) => {
- (None, Some(ErrorString::Ident(namespace)))
- }
- ParseErrorKind::Custom(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(p)) => {
- (None, Some(ErrorString::Ident(p)))
- }
- ParseErrorKind::Custom(SelectorParseErrorKind::EmptySelector) |
- ParseErrorKind::Custom(SelectorParseErrorKind::DanglingCombinator) => {
- (None, None)
- }
- ParseErrorKind::Custom(SelectorParseErrorKind::EmptyNegation) => {
- (None, Some(ErrorString::Snippet(")".into())))
- }
+ ParseErrorKind::Custom(StyleParseErrorKind::SelectorError(err)) => match err {
+ SelectorParseErrorKind::UnexpectedTokenInAttributeSelector(t) |
+ SelectorParseErrorKind::BadValueInAttr(t) |
+ SelectorParseErrorKind::ExpectedBarInAttr(t) |
+ SelectorParseErrorKind::NoQualifiedNameInAttributeSelector(t) |
+ SelectorParseErrorKind::InvalidQualNameInAttr(t) |
+ SelectorParseErrorKind::ExplicitNamespaceUnexpectedToken(t) |
+ SelectorParseErrorKind::PseudoElementExpectedIdent(t) |
+ SelectorParseErrorKind::NoIdentForPseudo(t) |
+ SelectorParseErrorKind::ClassNeedsIdent(t) |
+ SelectorParseErrorKind::PseudoElementExpectedColon(t) => {
+ (None, Some(ErrorString::UnexpectedToken(t)))
+ }
+ SelectorParseErrorKind::ExpectedNamespace(namespace) => {
+ (None, Some(ErrorString::Ident(namespace)))
+ }
+ SelectorParseErrorKind::UnsupportedPseudoClassOrElement(p) => {
+ (None, Some(ErrorString::Ident(p)))
+ }
+ SelectorParseErrorKind::EmptySelector |
+ SelectorParseErrorKind::DanglingCombinator => {
+ (None, None)
+ }
+ SelectorParseErrorKind::EmptyNegation => {
+ (None, Some(ErrorString::Snippet(")".into())))
+ }
+ err => match extract_error_param(ParseErrorKind::Custom(StyleParseErrorKind::SelectorError(err))) {
+ Some(e) => (Some(e), None),
+ None => return None,
+ }
+ },
err => match extract_error_param(err) {
Some(e) => (Some(e), None),
None => return None,
@@ -241,10 +249,10 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
(b"PEParseDeclarationDeclExpected\0", Action::Skip)
}
ContextualParseError::UnsupportedPropertyDeclaration(
- _, ParseError { kind: ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
+ _, ParseError { kind: ParseErrorKind::Custom(
StyleParseErrorKind::PropertyDeclaration(
PropertyDeclarationParseErrorKind::InvalidValue(_, ref err)
- ))
+ )
), .. }
) => {
let prefix = match *err {
@@ -263,9 +271,9 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
ContextualParseError::UnsupportedKeyframePropertyDeclaration(..) =>
(b"PEBadSelectorKeyframeRuleIgnored\0", Action::Nothing),
ContextualParseError::InvalidRule(
- _, ParseError { kind: ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
+ _, ParseError { kind: ParseErrorKind::Custom(
StyleParseErrorKind::UnexpectedTokenWithinNamespace(_)
- )), .. }
+ ), .. }
) => {
(b"PEAtNSUnexpected\0", Action::Nothing)
}
@@ -273,68 +281,78 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
_, ParseError { kind: ParseErrorKind::Basic(BasicParseErrorKind::AtRuleInvalid(_)), .. }
) |
ContextualParseError::InvalidRule(
- _, ParseError { kind: ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
+ _, ParseError { kind: ParseErrorKind::Custom(
StyleParseErrorKind::UnsupportedAtRule(_)
- )), .. }
+ ), .. }
) => {
(b"PEUnknownAtRule\0", Action::Nothing)
}
ContextualParseError::InvalidRule(_, ref err) => {
let prefix = match err.kind {
- ParseErrorKind::Custom(SelectorParseErrorKind::UnexpectedTokenInAttributeSelector(_)) =>
- Some(&b"PEAttSelUnexpected\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::ExpectedBarInAttr(_)) =>
- Some(&b"PEAttSelNoBar\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::BadValueInAttr(_)) =>
- Some(&b"PEAttSelBadValue\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::NoQualifiedNameInAttributeSelector(_)) =>
- Some(&b"PEAttributeNameOrNamespaceExpected\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::InvalidQualNameInAttr(_)) =>
- Some(&b"PEAttributeNameExpected\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::ExplicitNamespaceUnexpectedToken(_)) =>
- Some(&b"PETypeSelNotType\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::ExpectedNamespace(_)) =>
- Some(&b"PEUnknownNamespacePrefix\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::EmptySelector) =>
- Some(&b"PESelectorGroupNoSelector\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::DanglingCombinator) =>
- Some(&b"PESelectorGroupExtraCombinator\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(_)) =>
- Some(&b"PEPseudoSelUnknown\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::PseudoElementExpectedColon(_)) =>
- Some(&b"PEPseudoSelEndOrUserActionPC\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::NoIdentForPseudo(_)) =>
- Some(&b"PEPseudoClassArgNotIdent\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::PseudoElementExpectedIdent(_)) =>
- Some(&b"PEPseudoSelBadName\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::ClassNeedsIdent(_)) =>
- Some(&b"PEClassSelNotIdent\0"[..]),
- ParseErrorKind::Custom(SelectorParseErrorKind::EmptyNegation) =>
- Some(&b"PENegationBadArg\0"[..]),
+ ParseErrorKind::Custom(StyleParseErrorKind::SelectorError(ref err)) => match *err {
+ SelectorParseErrorKind::UnexpectedTokenInAttributeSelector(_) => {
+ Some(&b"PEAttSelUnexpected\0"[..])
+ }
+ SelectorParseErrorKind::ExpectedBarInAttr(_) => {
+ Some(&b"PEAttSelNoBar\0"[..])
+ }
+ SelectorParseErrorKind::BadValueInAttr(_) => {
+ Some(&b"PEAttSelBadValue\0"[..])
+ }
+ SelectorParseErrorKind::NoQualifiedNameInAttributeSelector(_) => {
+ Some(&b"PEAttributeNameOrNamespaceExpected\0"[..])
+ }
+ SelectorParseErrorKind::InvalidQualNameInAttr(_) => {
+ Some(&b"PEAttributeNameExpected\0"[..])
+ }
+ SelectorParseErrorKind::ExplicitNamespaceUnexpectedToken(_) => {
+ Some(&b"PETypeSelNotType\0"[..])
+ }
+ SelectorParseErrorKind::ExpectedNamespace(_) => {
+ Some(&b"PEUnknownNamespacePrefix\0"[..])
+ }
+ SelectorParseErrorKind::EmptySelector => {
+ Some(&b"PESelectorGroupNoSelector\0"[..])
+ }
+ SelectorParseErrorKind::DanglingCombinator => {
+ Some(&b"PESelectorGroupExtraCombinator\0"[..])
+ }
+ SelectorParseErrorKind::UnsupportedPseudoClassOrElement(_) => {
+ Some(&b"PEPseudoSelUnknown\0"[..])
+ }
+ SelectorParseErrorKind::PseudoElementExpectedColon(_) => {
+ Some(&b"PEPseudoSelEndOrUserActionPC\0"[..])
+ }
+ SelectorParseErrorKind::NoIdentForPseudo(_) => {
+ Some(&b"PEPseudoClassArgNotIdent\0"[..])
+ }
+ SelectorParseErrorKind::PseudoElementExpectedIdent(_) => {
+ Some(&b"PEPseudoSelBadName\0"[..])
+ }
+ SelectorParseErrorKind::ClassNeedsIdent(_) => {
+ Some(&b"PEClassSelNotIdent\0"[..])
+ }
+ SelectorParseErrorKind::EmptyNegation => {
+ Some(&b"PENegationBadArg\0"[..])
+ }
+ _ => None,
+ },
_ => None,
};
return (prefix, b"PEBadSelectorRSIgnored\0", Action::Nothing);
}
ContextualParseError::InvalidMediaRule(_, ref err) => {
let err: &[u8] = match err.kind {
- ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
- StyleParseErrorKind::ExpectedIdentifier(..)
- )) => {
+ ParseErrorKind::Custom(StyleParseErrorKind::ExpectedIdentifier(..)) => {
b"PEGatherMediaNotIdent\0"
},
- ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
- StyleParseErrorKind::MediaQueryExpectedFeatureName(..)
- )) => {
+ ParseErrorKind::Custom(StyleParseErrorKind::MediaQueryExpectedFeatureName(..)) => {
b"PEMQExpectedFeatureName\0"
},
- ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
- StyleParseErrorKind::MediaQueryExpectedFeatureValue
- )) => {
+ ParseErrorKind::Custom(StyleParseErrorKind::MediaQueryExpectedFeatureValue) => {
b"PEMQExpectedFeatureValue\0"
},
- ParseErrorKind::Custom(SelectorParseErrorKind::Custom(
- StyleParseErrorKind::RangedExpressionWithNoValue
- )) => {
+ ParseErrorKind::Custom(StyleParseErrorKind::RangedExpressionWithNoValue) => {
b"PEMQNoMinMaxWithoutValue\0"
},
_ => {
diff --git a/tests/unit/style/size_of.rs b/tests/unit/style/size_of.rs
index 4f8a45559b9..79568b29301 100644
--- a/tests/unit/style/size_of.rs
+++ b/tests/unit/style/size_of.rs
@@ -14,15 +14,12 @@ size_of_test!(test_size_of_property_declaration, properties::PropertyDeclaration
// we only pass `&mut SourcePropertyDeclaration` references around.
size_of_test!(test_size_of_parsed_declaration, properties::SourcePropertyDeclaration, 576);
-size_of_test!(test_size_of_selector_parse_error_kind_with_unit, SelectorParseErrorKind<()>, 40);
+size_of_test!(test_size_of_selector_parse_error_kind, SelectorParseErrorKind, 40);
size_of_test!(test_size_of_style_parse_error_kind, ::style_traits::StyleParseErrorKind, 80);
size_of_test!(test_size_of_value_parse_error_kind, ::style_traits::ValueParseErrorKind, 40);
size_of_test!(test_size_of_declaration_parse_error_kind, ::style_traits::PropertyDeclarationParseErrorKind, 72);
-size_of_test!(test_size_of_style_traits_parse_error_kind,
- SelectorParseErrorKind<::style_traits::StyleParseErrorKind>, 88);
-size_of_test!(test_size_of_selector_parse_error_with_unit, SelectorParseError<()>, 56);
-size_of_test!(test_size_of_style_parse_error, ::style_traits::StyleParseError, 96);
+size_of_test!(test_size_of_selector_parse_error, SelectorParseError, 56);
+size_of_test!(test_size_of_style_traits_parse_error, ::style_traits::ParseError, 96);
size_of_test!(test_size_of_value_parse_error, ::style_traits::ValueParseError, 56);
size_of_test!(test_size_of_declaration_parse_error, ::style_traits::PropertyDeclarationParseError, 88);
-size_of_test!(test_size_of_style_traits_parse_error, ::style_traits::ParseError, 104);