diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2017-08-09 18:14:02 +0200 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2017-08-09 22:37:16 +0200 |
commit | 7382dad9399ae2bdabaf25ffc885ae2bb17dc2ee (patch) | |
tree | 1f04e036ee3f484ce8ad8acb51b2387d8b67fda3 /components/style/parser.rs | |
parent | 32f835260cd3ea03a881f7a344a01f401c4db621 (diff) | |
download | servo-7382dad9399ae2bdabaf25ffc885ae2bb17dc2ee.tar.gz servo-7382dad9399ae2bdabaf25ffc885ae2bb17dc2ee.zip |
Update to cssparser 0.19, count line numbers during tokenization
Diffstat (limited to 'components/style/parser.rs')
-rw-r--r-- | components/style/parser.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/components/style/parser.rs b/components/style/parser.rs index 5df3fb25ec6..d59488017c0 100644 --- a/components/style/parser.rs +++ b/components/style/parser.rs @@ -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 |