style: Centralize a bit invalid value error reporting.

Also, buffer the errors, since we're going to want to look at the whole
declaration block to skip reporting them.

This shouldn't change behavior, just moves some work to the caller, and defers a
bit the work so that it happens only when error reporting is enabled.

Differential Revision: https://phabricator.services.mozilla.com/D30200
This commit is contained in:
Emilio Cobos Álvarez 2019-05-08 12:44:36 +00:00
parent 29cecf65b8
commit 02210264e7
3 changed files with 87 additions and 43 deletions

View file

@ -136,6 +136,12 @@ impl<'a> ParserContext<'a> {
.expect("Rule type expected, but none was found.")
}
/// Returns whether CSS error reporting is enabled.
#[inline]
pub fn error_reporting_enabled(&self) -> bool {
self.error_reporter.is_some()
}
/// Record a CSS parse error with this contexts error reporting.
pub fn log_css_error(&self, location: SourceLocation, error: ContextualParseError) {
let error_reporter = match self.error_reporter {