mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Move the error reporter into ParserContext.
Summary: This should make it easier to report errors, and also reduce codesize. The reason this was so generic is that error reporting was unconditionally enabled and was super-hot, but now that's no longer the case after bug 1452143, so we can afford the virtual call in the "error reporting enabled" case. This opens the possibility of simplifying a lot the error setup as well, though this patch doesn't do it. Test Plan: No behavior change, so no new tests. Reviewers: xidorn Bug #: 1469957 Differential Revision: https://phabricator.services.mozilla.com/D1734 MozReview-Commit-ID: F3wTdhX9MB5
This commit is contained in:
parent
bab7be63b2
commit
3a0c3224b9
13 changed files with 128 additions and 194 deletions
|
@ -9,8 +9,8 @@
|
|||
use context::QuirksMode;
|
||||
use cssparser::{Delimiter, Parser};
|
||||
use cssparser::{ParserInput, Token};
|
||||
use error_reporting::{ContextualParseError, ParseErrorReporter};
|
||||
use parser::{ParserContext, ParserErrorContext};
|
||||
use error_reporting::ContextualParseError;
|
||||
use parser::ParserContext;
|
||||
use super::{Device, MediaQuery, Qualifier};
|
||||
|
||||
/// A type that encapsulates a media query list.
|
||||
|
@ -30,14 +30,10 @@ impl MediaList {
|
|||
/// "not all", see:
|
||||
///
|
||||
/// <https://drafts.csswg.org/mediaqueries/#error-handling>
|
||||
pub fn parse<R>(
|
||||
pub fn parse(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser,
|
||||
error_reporter: &R,
|
||||
) -> MediaList
|
||||
where
|
||||
R: ParseErrorReporter,
|
||||
{
|
||||
) -> Self {
|
||||
if input.is_exhausted() {
|
||||
return Self::empty();
|
||||
}
|
||||
|
@ -54,8 +50,7 @@ impl MediaList {
|
|||
let location = err.location;
|
||||
let error =
|
||||
ContextualParseError::InvalidMediaRule(input.slice_from(start_position), err);
|
||||
let error_context = ParserErrorContext { error_reporter };
|
||||
context.log_css_error(&error_context, location, error);
|
||||
context.log_css_error(location, error);
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue