style: Avoid cloning all over the error reporter.

This commit is contained in:
Emilio Cobos Álvarez 2017-03-14 00:12:38 +01:00
parent eaf27ccfa0
commit b4de69e3eb
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
36 changed files with 186 additions and 154 deletions

View file

@ -11,7 +11,7 @@ use servo_url::ServoUrl;
use std::sync::{Mutex, Arc};
use style::error_reporting::ParseErrorReporter;
#[derive(HeapSizeOf)]
#[derive(HeapSizeOf, Clone)]
pub struct CSSErrorReporter {
pub pipelineid: PipelineId,
// Arc+Mutex combo is necessary to make this struct Sync,
@ -22,11 +22,18 @@ pub struct CSSErrorReporter {
}
impl ParseErrorReporter for CSSErrorReporter {
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str,
url: &ServoUrl) {
fn report_error(&self,
input: &mut Parser,
position: SourcePosition,
message: &str,
url: &ServoUrl) {
let location = input.source_location(position);
if log_enabled!(log::LogLevel::Info) {
info!("Url:\t{}\n{}:{} {}", url.as_str(), location.line, location.column, message)
info!("Url:\t{}\n{}:{} {}",
url.as_str(),
location.line,
location.column,
message)
}
//TODO: report a real filename
@ -37,11 +44,4 @@ impl ParseErrorReporter for CSSErrorReporter {
location.column,
message.to_owned()));
}
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
box CSSErrorReporter {
pipelineid: self.pipelineid,
script_chan: self.script_chan.clone(),
}
}
}