mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update to cssparser 0.19, count line numbers during tokenization
This commit is contained in:
parent
32f835260c
commit
7382dad939
33 changed files with 145 additions and 196 deletions
|
@ -12,7 +12,7 @@ path = "lib.rs"
|
|||
[dependencies]
|
||||
azure = {git = "https://github.com/servo/rust-azure"}
|
||||
canvas_traits = {path = "../canvas_traits"}
|
||||
cssparser = "0.18"
|
||||
cssparser = "0.19"
|
||||
euclid = "0.15"
|
||||
gleam = "0.4"
|
||||
ipc-channel = "0.8"
|
||||
|
|
|
@ -10,7 +10,7 @@ name = "canvas_traits"
|
|||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
cssparser = "0.18"
|
||||
cssparser = "0.19"
|
||||
euclid = "0.15"
|
||||
heapsize = "0.4"
|
||||
heapsize_derive = "0.1"
|
||||
|
|
|
@ -34,7 +34,7 @@ byteorder = "1.0"
|
|||
canvas_traits = {path = "../canvas_traits"}
|
||||
caseless = "0.1.0"
|
||||
cookie = "0.6"
|
||||
cssparser = "0.18"
|
||||
cssparser = "0.19"
|
||||
deny_public_fields = {path = "../deny_public_fields"}
|
||||
devtools_traits = {path = "../devtools_traits"}
|
||||
dom_struct = {path = "../dom_struct"}
|
||||
|
|
|
@ -13,7 +13,7 @@ path = "lib.rs"
|
|||
app_units = "0.5"
|
||||
atomic_refcell = "0.1"
|
||||
canvas_traits = {path = "../canvas_traits"}
|
||||
cssparser = "0.18"
|
||||
cssparser = "0.19"
|
||||
euclid = "0.15"
|
||||
gfx_traits = {path = "../gfx_traits"}
|
||||
heapsize = "0.4"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::{Parser, SourcePosition};
|
||||
use cssparser::SourceLocation;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use log;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
|
@ -22,18 +22,14 @@ pub struct CSSErrorReporter {
|
|||
}
|
||||
|
||||
impl ParseErrorReporter for CSSErrorReporter {
|
||||
fn report_error<'a>(&self,
|
||||
input: &mut Parser,
|
||||
position: SourcePosition,
|
||||
error: ContextualParseError<'a>,
|
||||
url: &ServoUrl,
|
||||
line_number_offset: u64) {
|
||||
let location = input.source_location(position);
|
||||
let line_offset = location.line + line_number_offset as u32;
|
||||
fn report_error(&self,
|
||||
url: &ServoUrl,
|
||||
location: SourceLocation,
|
||||
error: ContextualParseError) {
|
||||
if log_enabled!(log::LogLevel::Info) {
|
||||
info!("Url:\t{}\n{}:{} {}",
|
||||
url.as_str(),
|
||||
line_offset,
|
||||
location.line,
|
||||
location.column,
|
||||
error.to_string())
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ unstable = []
|
|||
[dependencies]
|
||||
bitflags = "0.7"
|
||||
matches = "0.1"
|
||||
cssparser = "0.18"
|
||||
cssparser = "0.19"
|
||||
log = "0.3"
|
||||
fnv = "1.0"
|
||||
phf = "0.7.18"
|
||||
|
|
|
@ -1050,7 +1050,7 @@ fn parse_selector<'i, 't, P, E, Impl>(
|
|||
let combinator;
|
||||
let mut any_whitespace = false;
|
||||
loop {
|
||||
let position = input.position();
|
||||
let before_this_token = input.state();
|
||||
match input.next_including_whitespace() {
|
||||
Err(_e) => break 'outer_loop,
|
||||
Ok(&Token::WhiteSpace(_)) => any_whitespace = true,
|
||||
|
@ -1067,7 +1067,7 @@ fn parse_selector<'i, 't, P, E, Impl>(
|
|||
break
|
||||
}
|
||||
Ok(_) => {
|
||||
input.reset(position);
|
||||
input.reset(&before_this_token);
|
||||
if any_whitespace {
|
||||
combinator = Combinator::Descendant;
|
||||
break
|
||||
|
@ -1207,11 +1207,11 @@ fn parse_qualified_name<'i, 't, P, E, Impl>
|
|||
}
|
||||
};
|
||||
|
||||
let position = input.position();
|
||||
let start = input.state();
|
||||
// FIXME: remove clone() when lifetimes are non-lexical
|
||||
match input.next_including_whitespace().map(|t| t.clone()) {
|
||||
Ok(Token::Ident(value)) => {
|
||||
let position = input.position();
|
||||
let after_ident = input.state();
|
||||
match input.next_including_whitespace() {
|
||||
Ok(&Token::Delim('|')) => {
|
||||
let prefix = value.as_ref().into();
|
||||
|
@ -1221,7 +1221,7 @@ fn parse_qualified_name<'i, 't, P, E, Impl>
|
|||
explicit_namespace(input, QNamePrefix::ExplicitNamespace(prefix, url))
|
||||
},
|
||||
_ => {
|
||||
input.reset(position);
|
||||
input.reset(&after_ident);
|
||||
if in_attr_selector {
|
||||
Ok(Some((QNamePrefix::ImplicitNoNamespace, Some(value))))
|
||||
} else {
|
||||
|
@ -1231,14 +1231,14 @@ fn parse_qualified_name<'i, 't, P, E, Impl>
|
|||
}
|
||||
},
|
||||
Ok(Token::Delim('*')) => {
|
||||
let position = input.position();
|
||||
let after_star = input.state();
|
||||
// FIXME: remove clone() when lifetimes are non-lexical
|
||||
match input.next_including_whitespace().map(|t| t.clone()) {
|
||||
Ok(Token::Delim('|')) => {
|
||||
explicit_namespace(input, QNamePrefix::ExplicitAnyNamespace)
|
||||
}
|
||||
result => {
|
||||
input.reset(position);
|
||||
input.reset(&after_star);
|
||||
if in_attr_selector {
|
||||
match result {
|
||||
Ok(t) => Err(ParseError::Basic(BasicParseError::UnexpectedToken(t))),
|
||||
|
@ -1254,7 +1254,7 @@ fn parse_qualified_name<'i, 't, P, E, Impl>
|
|||
explicit_namespace(input, QNamePrefix::ExplicitNoNamespace)
|
||||
}
|
||||
_ => {
|
||||
input.reset(position);
|
||||
input.reset(&start);
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
@ -1427,9 +1427,9 @@ fn parse_negation<'i, 't, P, E, Impl>(parser: &P,
|
|||
|
||||
// Consume any leading whitespace.
|
||||
loop {
|
||||
let position = input.position();
|
||||
let before_this_token = input.state();
|
||||
if !matches!(input.next_including_whitespace(), Ok(&Token::WhiteSpace(_))) {
|
||||
input.reset(position);
|
||||
input.reset(&before_this_token);
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -1470,9 +1470,9 @@ fn parse_compound_selector<'i, 't, P, E, Impl>(
|
|||
{
|
||||
// Consume any leading whitespace.
|
||||
loop {
|
||||
let position = input.position();
|
||||
let before_this_token = input.state();
|
||||
if !matches!(input.next_including_whitespace(), Ok(&Token::WhiteSpace(_))) {
|
||||
input.reset(position);
|
||||
input.reset(&before_this_token);
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -1604,7 +1604,7 @@ fn parse_one_simple_selector<'i, 't, P, E, Impl>(parser: &P,
|
|||
ParseError<'i, SelectorParseError<'i, E>>>
|
||||
where P: Parser<'i, Impl=Impl, Error=E>, Impl: SelectorImpl
|
||||
{
|
||||
let start_position = input.position();
|
||||
let start = input.state();
|
||||
// FIXME: remove clone() when lifetimes are non-lexical
|
||||
match input.next_including_whitespace().map(|t| t.clone()) {
|
||||
Ok(Token::IDHash(id)) => {
|
||||
|
@ -1657,7 +1657,7 @@ fn parse_one_simple_selector<'i, 't, P, E, Impl>(parser: &P,
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
input.reset(start_position);
|
||||
input.reset(&start);
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ bitflags = "0.7"
|
|||
bit-vec = "0.4.3"
|
||||
byteorder = "1.0"
|
||||
cfg-if = "0.1.0"
|
||||
cssparser = "0.18"
|
||||
cssparser = "0.19"
|
||||
encoding = {version = "0.2", optional = true}
|
||||
euclid = "0.15"
|
||||
fnv = "1.0"
|
||||
|
|
|
@ -12,7 +12,7 @@ use cssparser::{Parser, Token, serialize_identifier, BasicParseError, CowRcStr};
|
|||
use error_reporting::ContextualParseError;
|
||||
#[cfg(feature = "gecko")] use gecko::rules::CounterStyleDescriptors;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSCounterDesc;
|
||||
use parser::{ParserContext, log_css_error, Parse};
|
||||
use parser::{ParserContext, Parse};
|
||||
use selectors::parser::SelectorParseError;
|
||||
use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use std::ascii::AsciiExt;
|
||||
|
@ -52,7 +52,7 @@ pub fn parse_counter_style_name<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Cu
|
|||
/// Parse the body (inside `{}`) of an @counter-style rule
|
||||
pub fn parse_counter_style_body<'i, 't>(name: CustomIdent, context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<CounterStyleRuleData, ParseError<'i>> {
|
||||
let start = input.position();
|
||||
let start = input.current_source_location();
|
||||
let mut rule = CounterStyleRuleData::empty(name);
|
||||
{
|
||||
let parser = CounterStyleRuleParser {
|
||||
|
@ -62,10 +62,8 @@ pub fn parse_counter_style_body<'i, 't>(name: CustomIdent, context: &ParserConte
|
|||
let mut iter = DeclarationListParser::new(input, parser);
|
||||
while let Some(declaration) = iter.next() {
|
||||
if let Err(err) = declaration {
|
||||
let pos = err.span.start;
|
||||
let error = ContextualParseError::UnsupportedCounterStyleDescriptorDeclaration(
|
||||
iter.input.slice(err.span), err.error);
|
||||
log_css_error(iter.input, pos, error, context);
|
||||
let error = ContextualParseError::UnsupportedCounterStyleDescriptorDeclaration(err.slice, err.error);
|
||||
context.log_css_error(err.location, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +95,7 @@ pub fn parse_counter_style_body<'i, 't>(name: CustomIdent, context: &ParserConte
|
|||
_ => None
|
||||
};
|
||||
if let Some(error) = error {
|
||||
log_css_error(input, start, error, context);
|
||||
context.log_css_error(start, error);
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
} else {
|
||||
Ok(rule)
|
||||
|
|
|
@ -234,9 +234,9 @@ fn parse_declaration_value<'i, 't>
|
|||
-> Result<(TokenSerializationType, TokenSerializationType), ParseError<'i>> {
|
||||
input.parse_until_before(Delimiter::Bang | Delimiter::Semicolon, |input| {
|
||||
// Need at least one token
|
||||
let start_position = input.position();
|
||||
let start = input.state();
|
||||
input.next_including_whitespace()?;
|
||||
input.reset(start_position);
|
||||
input.reset(&start);
|
||||
|
||||
parse_declaration_value_block(input, references, missing_closing_characters)
|
||||
})
|
||||
|
@ -293,11 +293,11 @@ fn parse_declaration_value_block<'i, 't>
|
|||
return Err(StyleParseError::UnbalancedCloseCurlyBracketInDeclarationValueBlock.into()),
|
||||
Token::Function(ref name) => {
|
||||
if name.eq_ignore_ascii_case("var") {
|
||||
let position = input.position();
|
||||
let args_start = input.state();
|
||||
input.parse_nested_block(|input| {
|
||||
parse_var_function(input, references)
|
||||
})?;
|
||||
input.reset(position);
|
||||
input.reset(&args_start);
|
||||
}
|
||||
nested!();
|
||||
check_closed!(")");
|
||||
|
@ -629,13 +629,13 @@ fn substitute_block<'i, 't, F>(input: &mut Parser<'i, 't>,
|
|||
while let Ok(_) = input.next() {}
|
||||
} else {
|
||||
input.expect_comma()?;
|
||||
let position = input.position();
|
||||
let after_comma = input.state();
|
||||
let first_token_type = input.next_including_whitespace_and_comments()
|
||||
// parse_var_function() ensures that .unwrap() will not fail.
|
||||
.unwrap()
|
||||
.serialization_type();
|
||||
input.reset(position);
|
||||
let mut position = (position, first_token_type);
|
||||
input.reset(&after_comma);
|
||||
let mut position = (after_comma.position(), first_token_type);
|
||||
last_token_type = substitute_block(
|
||||
input, &mut position, partial_computed_value, substitute_one)?;
|
||||
partial_computed_value.push_from(position, input, last_token_type);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#![deny(missing_docs)]
|
||||
|
||||
use cssparser::{Parser, SourcePosition, BasicParseError, Token};
|
||||
use cssparser::{BasicParseError, Token, SourceLocation};
|
||||
use cssparser::ParseError as CssParseError;
|
||||
use log;
|
||||
use style_traits::ParseError;
|
||||
|
@ -152,14 +152,12 @@ impl<'a> ContextualParseError<'a> {
|
|||
pub trait ParseErrorReporter {
|
||||
/// Called when the style engine detects an error.
|
||||
///
|
||||
/// Returns the current input being parsed, the source position it was
|
||||
/// Returns the current input being parsed, the source location it was
|
||||
/// reported from, and a message.
|
||||
fn report_error<'a>(&self,
|
||||
input: &mut Parser,
|
||||
position: SourcePosition,
|
||||
error: ContextualParseError<'a>,
|
||||
url: &UrlExtraData,
|
||||
line_number_offset: u64);
|
||||
fn report_error(&self,
|
||||
url: &UrlExtraData,
|
||||
location: SourceLocation,
|
||||
error: ContextualParseError);
|
||||
}
|
||||
|
||||
/// An error reporter that uses [the `log` crate](https://github.com/rust-lang-nursery/log)
|
||||
|
@ -171,16 +169,12 @@ pub trait ParseErrorReporter {
|
|||
pub struct RustLogReporter;
|
||||
|
||||
impl ParseErrorReporter for RustLogReporter {
|
||||
fn report_error<'a>(&self,
|
||||
input: &mut Parser,
|
||||
position: SourcePosition,
|
||||
error: ContextualParseError<'a>,
|
||||
url: &UrlExtraData,
|
||||
line_number_offset: u64) {
|
||||
fn report_error(&self,
|
||||
url: &UrlExtraData,
|
||||
location: SourceLocation,
|
||||
error: ContextualParseError) {
|
||||
if log_enabled!(log::LogLevel::Info) {
|
||||
let location = input.source_location(position);
|
||||
let line_offset = location.line + line_number_offset as u32;
|
||||
info!("Url:\t{}\n{}:{} {}", url.as_str(), line_offset, location.column, error.to_string())
|
||||
info!("Url:\t{}\n{}:{} {}", url.as_str(), location.line, location.column, error.to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,12 +183,10 @@ impl ParseErrorReporter for RustLogReporter {
|
|||
pub struct NullReporter;
|
||||
|
||||
impl ParseErrorReporter for NullReporter {
|
||||
fn report_error<'a>(&self,
|
||||
_: &mut Parser,
|
||||
_: SourcePosition,
|
||||
_: ContextualParseError<'a>,
|
||||
_: &UrlExtraData,
|
||||
_: u64) {
|
||||
fn report_error(&self,
|
||||
_url: &UrlExtraData,
|
||||
_location: SourceLocation,
|
||||
_error: ContextualParseError) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use cssparser::{SourceLocation, CowRcStr};
|
|||
use error_reporting::ContextualParseError;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::CSSFontFaceDescriptors;
|
||||
#[cfg(feature = "gecko")] use cssparser::UnicodeRange;
|
||||
use parser::{ParserContext, log_css_error, Parse};
|
||||
use parser::{ParserContext, Parse};
|
||||
#[cfg(feature = "gecko")]
|
||||
use properties::longhands::font_language_override;
|
||||
use selectors::parser::SelectorParseError;
|
||||
|
@ -119,10 +119,8 @@ pub fn parse_font_face_block(context: &ParserContext, input: &mut Parser, locati
|
|||
let mut iter = DeclarationListParser::new(input, parser);
|
||||
while let Some(declaration) = iter.next() {
|
||||
if let Err(err) = declaration {
|
||||
let pos = err.span.start;
|
||||
let error = ContextualParseError::UnsupportedFontFaceDescriptor(
|
||||
iter.input.slice(err.span), err.error);
|
||||
log_css_error(iter.input, pos, error, context);
|
||||
let error = ContextualParseError::UnsupportedFontFaceDescriptor(err.slice, err.error);
|
||||
context.log_css_error(err.location, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! The context within which CSS code is parsed.
|
||||
|
||||
use context::QuirksMode;
|
||||
use cssparser::{Parser, SourcePosition, UnicodeRange};
|
||||
use cssparser::{Parser, SourceLocation, UnicodeRange};
|
||||
use error_reporting::{ParseErrorReporter, ContextualParseError};
|
||||
use style_traits::{OneOrMoreSeparated, ParseError, ParsingMode, Separator};
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -133,20 +133,15 @@ impl<'a> ParserContext<'a> {
|
|||
pub fn rule_type(&self) -> CssRuleType {
|
||||
self.rule_type.expect("Rule type expected, but none was found.")
|
||||
}
|
||||
}
|
||||
|
||||
/// Defaults to a no-op.
|
||||
/// Set a `RUST_LOG=style::errors` environment variable
|
||||
/// to log CSS parse errors to stderr.
|
||||
pub fn log_css_error<'a>(input: &mut Parser,
|
||||
position: SourcePosition,
|
||||
error: ContextualParseError<'a>,
|
||||
parsercontext: &ParserContext) {
|
||||
let url_data = parsercontext.url_data;
|
||||
let line_number_offset = parsercontext.line_number_offset;
|
||||
parsercontext.error_reporter.report_error(input, position,
|
||||
error, url_data,
|
||||
line_number_offset);
|
||||
/// Record a CSS parse error with this context’s error reporting.
|
||||
pub fn log_css_error(&self, location: SourceLocation, error: ContextualParseError) {
|
||||
let location = SourceLocation {
|
||||
line: location.line + self.line_number_offset as u32,
|
||||
column: location.column,
|
||||
};
|
||||
self.error_reporter.report_error(self.url_data, location, error)
|
||||
}
|
||||
}
|
||||
|
||||
// XXXManishearth Replace all specified value parse impls with impls of this
|
||||
|
|
|
@ -10,7 +10,7 @@ use context::QuirksMode;
|
|||
use cssparser::{DeclarationListParser, parse_important, ParserInput, CowRcStr};
|
||||
use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter, ParseError as CssParseError};
|
||||
use error_reporting::{ParseErrorReporter, ContextualParseError};
|
||||
use parser::{ParserContext, log_css_error};
|
||||
use parser::ParserContext;
|
||||
use properties::animated_properties::AnimationValue;
|
||||
use selectors::parser::SelectorParseError;
|
||||
use shared_lock::Locked;
|
||||
|
@ -909,15 +909,15 @@ pub fn parse_one_declaration_into(declarations: &mut SourcePropertyDeclaration,
|
|||
quirks_mode);
|
||||
let mut input = ParserInput::new(input);
|
||||
let mut parser = Parser::new(&mut input);
|
||||
let start = parser.position();
|
||||
let start_position = parser.position();
|
||||
let start_location = parser.current_source_location();
|
||||
parser.parse_entirely(|parser| {
|
||||
PropertyDeclaration::parse_into(declarations, id, &context, parser)
|
||||
.map_err(|e| e.into())
|
||||
}).map_err(|err| {
|
||||
let end = parser.position();
|
||||
let error = ContextualParseError::UnsupportedPropertyDeclaration(
|
||||
parser.slice(start..end), err);
|
||||
log_css_error(&mut parser, start, error, &context);
|
||||
parser.slice_from(start_position), err);
|
||||
context.log_css_error(start_location, error);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1000,10 +1000,8 @@ pub fn parse_property_declaration_list(context: &ParserContext,
|
|||
continue;
|
||||
}
|
||||
|
||||
let pos = err.span.start;
|
||||
let error = ContextualParseError::UnsupportedPropertyDeclaration(
|
||||
iter.input.slice(err.span), err.error);
|
||||
log_css_error(iter.input, pos, error, &context);
|
||||
let error = ContextualParseError::UnsupportedPropertyDeclaration(err.slice, err.error);
|
||||
context.log_css_error(err.location, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1502,12 +1502,12 @@ impl PropertyDeclaration {
|
|||
PropertyDeclaration::CSSWideKeyword(id, keyword)
|
||||
}).or_else(|()| {
|
||||
input.look_for_var_functions();
|
||||
let start = input.position();
|
||||
let start = input.state();
|
||||
input.parse_entirely(|input| id.parse_value(context, input))
|
||||
.or_else(|err| {
|
||||
while let Ok(_) = input.next() {} // Look for var() after the error.
|
||||
if input.seen_var_functions() {
|
||||
input.reset(start);
|
||||
input.reset(&start);
|
||||
let (first_token_type, css) =
|
||||
::custom_properties::parse_non_custom_with_var(input).map_err(|e| {
|
||||
PropertyDeclarationParseError::InvalidValue(id.name().into(),
|
||||
|
@ -1540,13 +1540,13 @@ impl PropertyDeclaration {
|
|||
Ok(())
|
||||
} else {
|
||||
input.look_for_var_functions();
|
||||
let start = input.position();
|
||||
let start = input.state();
|
||||
// Not using parse_entirely here: each ${shorthand.ident}::parse_into function
|
||||
// needs to do so *before* pushing to `declarations`.
|
||||
id.parse_into(declarations, context, input).or_else(|err| {
|
||||
while let Ok(_) = input.next() {} // Look for var() after the error.
|
||||
if input.seen_var_functions() {
|
||||
input.reset(start);
|
||||
input.reset(&start);
|
||||
let (first_token_type, css) =
|
||||
::custom_properties::parse_non_custom_with_var(input).map_err(|e| {
|
||||
PropertyDeclarationParseError::InvalidValue(id.name().into(),
|
||||
|
|
|
@ -11,7 +11,7 @@ use computed_values::font_family::FamilyName;
|
|||
use cssparser::{AtRuleParser, AtRuleType, BasicParseError, DeclarationListParser, DeclarationParser, Parser};
|
||||
use cssparser::{CowRcStr, RuleListParser, SourceLocation, QualifiedRuleParser, Token, serialize_identifier};
|
||||
use error_reporting::ContextualParseError;
|
||||
use parser::{ParserContext, log_css_error, Parse};
|
||||
use parser::{ParserContext, Parse};
|
||||
use selectors::parser::SelectorParseError;
|
||||
use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use std::fmt;
|
||||
|
@ -222,10 +222,8 @@ macro_rules! font_feature_values_blocks {
|
|||
});
|
||||
while let Some(result) = iter.next() {
|
||||
if let Err(err) = result {
|
||||
let pos = err.span.start;
|
||||
let error = ContextualParseError::UnsupportedRule(
|
||||
iter.input.slice(err.span), err.error);
|
||||
log_css_error(iter.input, pos, error, context);
|
||||
let error = ContextualParseError::UnsupportedRule(err.slice, err.error);
|
||||
context.log_css_error(err.location, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -338,10 +336,9 @@ macro_rules! font_feature_values_blocks {
|
|||
let mut iter = DeclarationListParser::new(input, parser);
|
||||
while let Some(declaration) = iter.next() {
|
||||
if let Err(err) = declaration {
|
||||
let pos = err.span.start;
|
||||
let error = ContextualParseError::UnsupportedKeyframePropertyDeclaration(
|
||||
iter.input.slice(err.span), err.error);
|
||||
log_css_error(iter.input, pos, error, &context);
|
||||
err.slice, err.error);
|
||||
context.log_css_error(err.location, error);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
use cssparser::{AtRuleParser, Parser, QualifiedRuleParser, RuleListParser, ParserInput, CowRcStr};
|
||||
use cssparser::{DeclarationListParser, DeclarationParser, parse_one_rule, SourceLocation};
|
||||
use error_reporting::{NullReporter, ContextualParseError};
|
||||
use parser::{ParserContext, log_css_error};
|
||||
use parser::ParserContext;
|
||||
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, PropertyId};
|
||||
use properties::{PropertyDeclarationId, LonghandId, SourcePropertyDeclaration};
|
||||
use properties::LonghandIdSet;
|
||||
|
@ -473,12 +473,13 @@ impl<'a, 'i> QualifiedRuleParser<'i> for KeyframeListParser<'a> {
|
|||
type Error = SelectorParseError<'i, StyleParseError<'i>>;
|
||||
|
||||
fn parse_prelude<'t>(&mut self, input: &mut Parser<'i, 't>) -> Result<Self::Prelude, ParseError<'i>> {
|
||||
let start = input.position();
|
||||
let start_position = input.position();
|
||||
let start_location = input.current_source_location();
|
||||
match KeyframeSelector::parse(input) {
|
||||
Ok(sel) => Ok(sel),
|
||||
Err(e) => {
|
||||
let error = ContextualParseError::InvalidKeyframeRule(input.slice_from(start), e.clone());
|
||||
log_css_error(input, start, error, self.context);
|
||||
let error = ContextualParseError::InvalidKeyframeRule(input.slice_from(start_position), e.clone());
|
||||
self.context.log_css_error(start_location, error);
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
|
@ -500,10 +501,8 @@ impl<'a, 'i> QualifiedRuleParser<'i> for KeyframeListParser<'a> {
|
|||
}
|
||||
Err(err) => {
|
||||
iter.parser.declarations.clear();
|
||||
let pos = err.span.start;
|
||||
let error = ContextualParseError::UnsupportedKeyframePropertyDeclaration(
|
||||
iter.input.slice(err.span), err.error);
|
||||
log_css_error(iter.input, pos, error, &context);
|
||||
let error = ContextualParseError::UnsupportedKeyframePropertyDeclaration(err.slice, err.error);
|
||||
context.log_css_error(err.location, error);
|
||||
}
|
||||
}
|
||||
// `parse_important` is not called here, `!important` is not allowed in keyframe blocks.
|
||||
|
|
|
@ -12,7 +12,7 @@ use cssparser::{CowRcStr, SourceLocation, BasicParseError};
|
|||
use error_reporting::ContextualParseError;
|
||||
use font_face::parse_font_face_block;
|
||||
use media_queries::{parse_media_query_list, MediaList};
|
||||
use parser::{Parse, ParserContext, log_css_error};
|
||||
use parser::{Parse, ParserContext};
|
||||
use properties::parse_property_declaration_list;
|
||||
use selector_parser::{SelectorImpl, SelectorParser};
|
||||
use selectors::SelectorList;
|
||||
|
@ -318,10 +318,8 @@ impl<'a, 'b> NestedRuleParser<'a, 'b> {
|
|||
match result {
|
||||
Ok(rule) => rules.push(rule),
|
||||
Err(err) => {
|
||||
let pos = err.span.start;
|
||||
let error = ContextualParseError::UnsupportedRule(
|
||||
iter.input.slice(err.span), err.error);
|
||||
log_css_error(iter.input, pos, error, self.context);
|
||||
let error = ContextualParseError::UnsupportedRule(err.slice, err.error);
|
||||
self.context.log_css_error(err.location, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use error_reporting::{ParseErrorReporter, ContextualParseError};
|
|||
use fnv::FnvHashMap;
|
||||
use media_queries::{MediaList, Device};
|
||||
use parking_lot::RwLock;
|
||||
use parser::{ParserContext, log_css_error};
|
||||
use parser::ParserContext;
|
||||
use servo_arc::Arc;
|
||||
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard};
|
||||
use std::mem;
|
||||
|
@ -351,10 +351,8 @@ impl Stylesheet {
|
|||
match result {
|
||||
Ok(rule) => rules.push(rule),
|
||||
Err(err) => {
|
||||
let pos = err.span.start;
|
||||
let error = ContextualParseError::InvalidRule(
|
||||
iter.input.slice(err.span), err.error);
|
||||
log_css_error(iter.input, pos, error, iter.parser.context());
|
||||
let error = ContextualParseError::InvalidRule(err.slice, err.error);
|
||||
iter.parser.context().log_css_error(err.location, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use error_reporting::ContextualParseError;
|
|||
use euclid::TypedSize2D;
|
||||
use font_metrics::get_metrics_provider_for_product;
|
||||
use media_queries::Device;
|
||||
use parser::{Parse, ParserContext, log_css_error};
|
||||
use parser::{Parse, ParserContext};
|
||||
use properties::StyleBuilder;
|
||||
use selectors::parser::SelectorParseError;
|
||||
use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
|
||||
|
@ -360,10 +360,8 @@ impl Parse for ViewportRule {
|
|||
}
|
||||
}
|
||||
Err(err) => {
|
||||
let pos = err.span.start;
|
||||
let error = ContextualParseError::UnsupportedViewportDescriptorDeclaration(
|
||||
parser.input.slice(err.span), err.error);
|
||||
log_css_error(parser.input, pos, error, &context);
|
||||
let error = ContextualParseError::UnsupportedViewportDescriptorDeclaration(err.slice, err.error);
|
||||
context.log_css_error(err.location, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ impl CalcNode {
|
|||
let mut root = Self::parse_product(context, input, expected_unit)?;
|
||||
|
||||
loop {
|
||||
let position = input.position();
|
||||
let start = input.state();
|
||||
match input.next_including_whitespace() {
|
||||
Ok(&Token::WhiteSpace(_)) => {
|
||||
if input.is_exhausted() {
|
||||
|
@ -220,7 +220,7 @@ impl CalcNode {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
input.reset(position);
|
||||
input.reset(&start);
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ impl CalcNode {
|
|||
let mut root = Self::parse_one(context, input, expected_unit)?;
|
||||
|
||||
loop {
|
||||
let position = input.position();
|
||||
let start = input.state();
|
||||
match input.next() {
|
||||
Ok(&Token::Delim('*')) => {
|
||||
let rhs = Self::parse_one(context, input, expected_unit)?;
|
||||
|
@ -261,7 +261,7 @@ impl CalcNode {
|
|||
root = new_root;
|
||||
}
|
||||
_ => {
|
||||
input.reset(position);
|
||||
input.reset(&start);
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,12 +70,12 @@ impl Parse for Color {
|
|||
// Currently we only store authored value for color keywords,
|
||||
// because all browsers serialize those values as keywords for
|
||||
// specified value.
|
||||
let start_position = input.position();
|
||||
let start = input.state();
|
||||
let authored = match input.next() {
|
||||
Ok(&Token::Ident(ref s)) => Some(s.to_lowercase().into_boxed_str()),
|
||||
_ => None,
|
||||
};
|
||||
input.reset(start_position);
|
||||
input.reset(&start);
|
||||
match input.try(CSSParserColor::parse) {
|
||||
Ok(value) =>
|
||||
Ok(match value {
|
||||
|
|
|
@ -16,7 +16,7 @@ gecko = []
|
|||
[dependencies]
|
||||
app_units = "0.5"
|
||||
bitflags = "0.7"
|
||||
cssparser = "0.18"
|
||||
cssparser = "0.19"
|
||||
euclid = "0.15"
|
||||
heapsize = {version = "0.4", optional = true}
|
||||
heapsize_derive = {version = "0.1", optional = true}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue