mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Hoist ParseErrorReporter into style and remove the dependency on msg.
The pipeline id stuff is currently unused. If someone needs it, they can add an additional trait bound on their css error reporter to get the pipeline id.
This commit is contained in:
parent
a03747e12b
commit
384cdfcfff
20 changed files with 39 additions and 79 deletions
25
components/style/error_reporting.rs
Normal file
25
components/style/error_reporting.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 log;
|
||||
|
||||
pub trait ParseErrorReporter {
|
||||
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str);
|
||||
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync>;
|
||||
}
|
||||
|
||||
pub struct StdoutErrorReporter;
|
||||
impl ParseErrorReporter for StdoutErrorReporter {
|
||||
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) {
|
||||
if log_enabled!(log::LogLevel::Info) {
|
||||
let location = input.source_location(position);
|
||||
info!("{}:{} {}", location.line, location.column, message)
|
||||
}
|
||||
}
|
||||
|
||||
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
|
||||
box StdoutErrorReporter
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue