mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update to cssparser 0.22 (source location in error types)
This commit is contained in:
parent
056e599562
commit
c0f8f15f39
90 changed files with 974 additions and 790 deletions
|
@ -14,7 +14,7 @@ use parser::ParserContext;
|
|||
use properties::{ComputedValues, StyleBuilder};
|
||||
use properties::longhands::font_size;
|
||||
use rule_cache::RuleCacheConditions;
|
||||
use selectors::parser::SelectorParseError;
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use std::cell::RefCell;
|
||||
use std::fmt;
|
||||
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering};
|
||||
|
@ -198,7 +198,7 @@ impl Expression {
|
|||
"width" => {
|
||||
ExpressionKind::Width(Range::Eq(specified::Length::parse_non_negative(context, input)?))
|
||||
},
|
||||
_ => return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
_ => return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
use {Atom, Prefix, Namespace, LocalName, CaseSensitivityExt};
|
||||
use attr::{AttrIdentifier, AttrValue};
|
||||
use cssparser::{Parser as CssParser, ToCss, serialize_identifier, CowRcStr};
|
||||
use cssparser::{Parser as CssParser, ToCss, serialize_identifier, CowRcStr, SourceLocation};
|
||||
use dom::{OpaqueNode, TElement, TNode};
|
||||
use element_state::ElementState;
|
||||
use fnv::FnvHashMap;
|
||||
|
@ -19,14 +19,14 @@ use properties::longhands::display::computed_value as display;
|
|||
use selector_parser::{AttrValue as SelectorAttrValue, ElementExt, PseudoElementCascadeType, SelectorParser};
|
||||
use selectors::Element;
|
||||
use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity};
|
||||
use selectors::parser::{SelectorMethods, SelectorParseError};
|
||||
use selectors::parser::{SelectorMethods, SelectorParseErrorKind};
|
||||
use selectors::visitor::SelectorVisitor;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use std::fmt::Debug;
|
||||
use std::mem;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use style_traits::{ParseError, StyleParseError};
|
||||
use style_traits::{ParseError, StyleParseErrorKind};
|
||||
|
||||
/// A pseudo-element, both public and private.
|
||||
///
|
||||
|
@ -395,9 +395,9 @@ impl ::selectors::SelectorImpl for SelectorImpl {
|
|||
|
||||
impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
|
||||
type Impl = SelectorImpl;
|
||||
type Error = StyleParseError<'i>;
|
||||
type Error = StyleParseErrorKind<'i>;
|
||||
|
||||
fn parse_non_ts_pseudo_class(&self, name: CowRcStr<'i>)
|
||||
fn parse_non_ts_pseudo_class(&self, location: SourceLocation, name: CowRcStr<'i>)
|
||||
-> Result<NonTSPseudoClass, ParseError<'i>> {
|
||||
use self::NonTSPseudoClass::*;
|
||||
let pseudo_class = match_ignore_ascii_case! { &name,
|
||||
|
@ -418,12 +418,13 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
|
|||
"visited" => Visited,
|
||||
"-servo-nonzero-border" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(
|
||||
"-servo-nonzero-border".into()).into());
|
||||
return Err(location.new_custom_error(
|
||||
SelectorParseErrorKind::UnexpectedIdent("-servo-nonzero-border".into())
|
||||
))
|
||||
}
|
||||
ServoNonZeroBorder
|
||||
},
|
||||
_ => return Err(SelectorParseError::UnexpectedIdent(name.clone()).into()),
|
||||
_ => return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone()))),
|
||||
};
|
||||
|
||||
Ok(pseudo_class)
|
||||
|
@ -440,17 +441,18 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
|
|||
}
|
||||
"-servo-case-sensitive-type-attr" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into());
|
||||
return Err(parser.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())));
|
||||
}
|
||||
ServoCaseSensitiveTypeAttr(Atom::from(parser.expect_ident()?.as_ref()))
|
||||
}
|
||||
_ => return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
_ => return Err(parser.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
};
|
||||
|
||||
Ok(pseudo_class)
|
||||
}
|
||||
|
||||
fn parse_pseudo_element(&self, name: CowRcStr<'i>) -> Result<PseudoElement, ParseError<'i>> {
|
||||
fn parse_pseudo_element(&self, location: SourceLocation, name: CowRcStr<'i>)
|
||||
-> Result<PseudoElement, ParseError<'i>> {
|
||||
use self::PseudoElement::*;
|
||||
let pseudo_element = match_ignore_ascii_case! { &name,
|
||||
"before" => Before,
|
||||
|
@ -458,77 +460,77 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
|
|||
"selection" => Selection,
|
||||
"-servo-details-summary" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
DetailsSummary
|
||||
},
|
||||
"-servo-details-content" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
DetailsContent
|
||||
},
|
||||
"-servo-text" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
ServoText
|
||||
},
|
||||
"-servo-input-text" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
ServoInputText
|
||||
},
|
||||
"-servo-table-wrapper" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
ServoTableWrapper
|
||||
},
|
||||
"-servo-anonymous-table-wrapper" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
ServoAnonymousTableWrapper
|
||||
},
|
||||
"-servo-anonymous-table" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
ServoAnonymousTable
|
||||
},
|
||||
"-servo-anonymous-table-row" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
ServoAnonymousTableRow
|
||||
},
|
||||
"-servo-anonymous-table-cell" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
ServoAnonymousTableCell
|
||||
},
|
||||
"-servo-anonymous-block" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
ServoAnonymousBlock
|
||||
},
|
||||
"-servo-inline-block-wrapper" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
ServoInlineBlockWrapper
|
||||
},
|
||||
"-servo-input-absolute" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
}
|
||||
ServoInlineAbsolute
|
||||
},
|
||||
_ => return Err(SelectorParseError::UnexpectedIdent(name.clone()).into())
|
||||
_ => return Err(location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())))
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue