mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
b11ee5a0ec
This is on top of https://github.com/servo/servo/pull/15928. Now that cascade() gets a Device ref, we can use the default computed values from there to avoid propagating that state all over the place. Source-Repo: https://github.com/servo/servo Source-Revision: 8c8edb8731dc01d254839d0922590fba72f278c6 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 4da0b4a162f5987954a443b93f411e461ef0187d
42 lines
1.4 KiB
Rust
42 lines
1.4 KiB
Rust
/* 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/. */
|
|
|
|
//! Types used to report parsing errors.
|
|
|
|
#![deny(missing_docs)]
|
|
|
|
use cssparser::{Parser, SourcePosition};
|
|
use log;
|
|
use servo_url::ServoUrl;
|
|
|
|
/// A generic trait for an error reporter.
|
|
pub trait ParseErrorReporter : Sync + Send {
|
|
/// Called the style engine detects an error.
|
|
///
|
|
/// Returns the current input being parsed, the source position it was
|
|
/// reported from, and a message.
|
|
fn report_error(&self,
|
|
input: &mut Parser,
|
|
position: SourcePosition,
|
|
message: &str,
|
|
url: &ServoUrl);
|
|
}
|
|
|
|
/// An error reporter that reports the errors to the `info` log channel.
|
|
///
|
|
/// TODO(emilio): The name of this reporter is a lie, and should be renamed!
|
|
pub struct StdoutErrorReporter;
|
|
impl ParseErrorReporter for StdoutErrorReporter {
|
|
fn report_error(&self,
|
|
input: &mut Parser,
|
|
position: SourcePosition,
|
|
message: &str,
|
|
url: &ServoUrl) {
|
|
if log_enabled!(log::LogLevel::Info) {
|
|
let location = input.source_location(position);
|
|
info!("Url:\t{}\n{}:{} {}", url.as_str(), location.line, location.column, message)
|
|
}
|
|
}
|
|
}
|