CSS parsing error types: flatten nested enums somewhat

This commit is contained in:
Simon Sapin 2017-10-09 17:20:52 +02:00
parent c64374bc58
commit 46ea99d54b
11 changed files with 242 additions and 228 deletions

View file

@ -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>,

View file

@ -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>> {

View file

@ -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,

View file

@ -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>> {